1、增加ExclCommUint_t结构体,用于排除指定通讯单元的MAC

2、修复了复位后重复定义各项参数的bug。只有从flash读取到的出厂标志位错误时,才会进入配置默认参数判断,否则会以从flash读取到的数据为配置参数
3、增加CheckCommUnitExcl函数,用于查询mac是否被排除

GateWay_Debug:
1、rs485配置函数增加了boot升级使能功能
2、增加了excu、exdel、exls命令,用于配置排除设备的增、删、查
3、para命令增加显示LpCfg参数

sx127x:
1、lora通道选择取消,通过修改频率来修改通道
This commit is contained in:
2026-05-21 17:30:35 +08:00
parent 37d8152227
commit 7103c8ddfb
9 changed files with 95 additions and 143 deletions
+5 -86
View File
@@ -410,7 +410,7 @@
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
<Key>JL2CM3</Key> <Key>JL2CM3</Key>
<Name>-U12345678 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO8 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_otp.FLM -FS03000C00 -FL03FC -FP0($$Device:HC32F460KETA$FlashARM\HC32F460_otp.FLM) -FF1HC32F460_512K.FLM -FS10 -FL180000 -FP1($$Device:HC32F460KETA$FlashARM\HC32F460_512K.FLM)</Name> <Name>-U12345678 -O78 -S4 -ZTIFSpeedSel2000 -A0 -C0 -JU1 -JI127.0.0.1 -JP0 -RST0 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO18 -TC10000000 -TP21 -TDS8027 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -TB1 -TFE0 -FO11 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_otp.FLM -FS03000C00 -FL03FC -FP0($$Device:HC32F460KETA$FlashARM\HC32F460_otp.FLM) -FF1HC32F460_512K.FLM -FS10 -FL180000 -FP1($$Device:HC32F460KETA$FlashARM\HC32F460_512K.FLM)</Name>
</SetRegEntry> </SetRegEntry>
<SetRegEntry> <SetRegEntry>
<Number>0</Number> <Number>0</Number>
@@ -428,93 +428,12 @@
<Name></Name> <Name></Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint> <Breakpoint/>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>1598</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>83604</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\source\Module\DebugCmd\DebugCmd.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\GateWay\../source/Module/DebugCmd/DebugCmd.c\1598</Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>460</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>59254</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\source\User\Src\Public.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\GateWay\../source/User/Src/Public.c\460</Expression>
</Bp>
<Bp>
<Number>2</Number>
<Type>0</Type>
<LineNumber>466</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>59314</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\source\User\Src\Public.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\GateWay\../source/User/Src/Public.c\466</Expression>
</Bp>
<Bp>
<Number>3</Number>
<Type>0</Type>
<LineNumber>416</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>109936</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\source\Module\SX127x\sx127x.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\GateWay\../source/Module/SX127x/sx127x.c\416</Expression>
</Bp>
<Bp>
<Number>4</Number>
<Type>0</Type>
<LineNumber>415</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>109924</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>1</BreakIfRCount>
<Filename>..\source\Module\SX127x\sx127x.c</Filename>
<ExecCommand></ExecCommand>
<Expression>\\GateWay\../source/Module/SX127x/sx127x.c\415</Expression>
</Bp>
</Breakpoint>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>GateWay,0x0A</ItemText> <ItemText>GateWay,0x10</ItemText>
</Ww> </Ww>
</WatchWindow1> </WatchWindow1>
<WatchWindow2> <WatchWindow2>
@@ -977,7 +896,7 @@
</Group> </Group>
<Group> <Group>
<GroupName>DebugCmd</GroupName> <GroupName>GateWay_Debug</GroupName>
<tvExp>1</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
@@ -989,7 +908,7 @@
<tvExp>0</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>..\source\Module\DebugCmd\DebugCmd.c</PathWithFileName> <PathWithFileName>..\source\Module\GateWay_Debug\DebugCmd.c</PathWithFileName>
<FilenameWithoutPath>DebugCmd.c</FilenameWithoutPath> <FilenameWithoutPath>DebugCmd.c</FilenameWithoutPath>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
<bShared>0</bShared> <bShared>0</bShared>
+6 -6
View File
@@ -341,7 +341,7 @@
<MiscControls>--diag_suppress=186,66</MiscControls> <MiscControls>--diag_suppress=186,66</MiscControls>
<Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA</Define> <Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\SX127x</IncludePath> <IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\GateWay_Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\SX127x</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@@ -586,12 +586,12 @@
</Files> </Files>
</Group> </Group>
<Group> <Group>
<GroupName>DebugCmd</GroupName> <GroupName>GateWay_Debug</GroupName>
<Files> <Files>
<File> <File>
<FileName>DebugCmd.c</FileName> <FileName>DebugCmd.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\source\Module\DebugCmd\DebugCmd.c</FilePath> <FilePath>..\source\Module\GateWay_Debug\DebugCmd.c</FilePath>
</File> </File>
</Files> </Files>
</Group> </Group>
@@ -1267,7 +1267,7 @@
<MiscControls>--diag_suppress=186,66</MiscControls> <MiscControls>--diag_suppress=186,66</MiscControls>
<Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA,BOOT_ENABLE</Define> <Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA,BOOT_ENABLE</Define>
<Undefine></Undefine> <Undefine></Undefine>
<IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\sx127x;..\source\Module\DebugCmd</IncludePath> <IncludePath>..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\sx127x;..\source\Module\GateWay_Debug</IncludePath>
</VariousControls> </VariousControls>
</Cads> </Cads>
<Aads> <Aads>
@@ -1512,12 +1512,12 @@
</Files> </Files>
</Group> </Group>
<Group> <Group>
<GroupName>DebugCmd</GroupName> <GroupName>GateWay_Debug</GroupName>
<Files> <Files>
<File> <File>
<FileName>DebugCmd.c</FileName> <FileName>DebugCmd.c</FileName>
<FileType>1</FileType> <FileType>1</FileType>
<FilePath>..\source\Module\DebugCmd\DebugCmd.c</FilePath> <FilePath>..\source\Module\GateWay_Debug\DebugCmd.c</FilePath>
</File> </File>
</Files> </Files>
</Group> </Group>
@@ -0,0 +1,21 @@
/*
* Auto generated Run-Time-Environment Configuration File
* *** Do not modify ! ***
*
* Project: 'GateWay'
* Target: 'app_app'
*/
#ifndef RTE_COMPONENTS_H
#define RTE_COMPONENTS_H
/*
* Define the Device Header File:
*/
#define CMSIS_device_header "HC32F460KETA.h"
#endif /* RTE_COMPONENTS_H */
+7
View File
@@ -191,6 +191,11 @@ typedef struct {
uint8_t ERTime; //紧急上报时长 uint8_t ERTime; //紧急上报时长
}__attribute__((packed))CommUnitPara_t, *CommUnitPara; }__attribute__((packed))CommUnitPara_t, *CommUnitPara;
typedef struct {
bool ExclFlag;
uint8_t ExclMac[6];//需要排除的通讯单元MAC
}__attribute__((packed))ExclCommUnit_t, *ExclCommUnit;
typedef struct { typedef struct {
uint8_t Data[SENSOR_NUM_MAX][SENSOR_DATA_LEN_MAX]; uint8_t Data[SENSOR_NUM_MAX][SENSOR_DATA_LEN_MAX];
}__attribute__((packed))CommUnitData_t, *CommUnitData; }__attribute__((packed))CommUnitData_t, *CommUnitData;
@@ -251,6 +256,7 @@ typedef struct {
uint32_t SvrPort; //服务器端口 uint32_t SvrPort; //服务器端口
uint32_t CommUnitReadInterval; //通讯单元读取时间间隔,单位S uint32_t CommUnitReadInterval; //通讯单元读取时间间隔,单位S
CommUnitPara_t CommUnitArray[COMMUNIT_NUM_MAX]; //注册的通讯单元信息 CommUnitPara_t CommUnitArray[COMMUNIT_NUM_MAX]; //注册的通讯单元信息
ExclCommUnit_t ExclCommUnit[COMMUNIT_NUM_MAX]; //排除的通讯单元信息
RS485Para_t Rs485Ch1; //RS485通道1配置 RS485Para_t Rs485Ch1; //RS485通道1配置
RS485Para_t Rs485Ch2; //RS485通道2配置 RS485Para_t Rs485Ch2; //RS485通道2配置
uint8_t DebugChannel; //调试通道 uint8_t DebugChannel; //调试通道
@@ -286,6 +292,7 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen); void DebugAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen);
void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cmd, uint8_t *Payload, uint16_t PayloadLen, SendData Send); void CommUnitCmdSend(GateWayPara GateWay, uint8_t *CommUnitMac, CommUnitCmd_m Cmd, uint8_t *Payload, uint16_t PayloadLen, SendData Send);
int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac); int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac);
int CheckCommUnitExcl(GateWayPara GateWay, uint8_t *CommUnitMac);
int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUData, uint8_t *sData); int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUData, uint8_t *sData);
void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorData); void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorData);
#endif #endif
+1 -1
View File
@@ -66,7 +66,7 @@ void LoraIRQ_Thread_Entry(void *parameter)
static void LoRaSendBuffer(uint8_t* pucBuff, uint16_t ucLen) static void LoRaSendBuffer(uint8_t* pucBuff, uint16_t ucLen)
{ {
if(GateWay->ConfigPara.Lora.OnOff) if(GateWay->ConfigPara.Lora.OnOff == true)
Sx1276LoRaSendBuffer(pucBuff, ucLen); Sx1276LoRaSendBuffer(pucBuff, ucLen);
} }
+26 -6
View File
@@ -184,7 +184,7 @@ int NetCommOrgData(GateWayPara GateWay, uint8_t *MegData, uint8_t *OutData)
* 功能描述: 检查设备是否注册 * 功能描述: 检查设备是否注册
* 参 数: GateWay,网关句柄 * 参 数: GateWay,网关句柄
CommUnitMac, 待检查的设备MAC CommUnitMac, 待检查的设备MAC
* 返 回 值: 已注册返回true,没注册返回false * 返 回 值: 已注册返回非0,没注册返回-1
*****************************************************************************************/ *****************************************************************************************/
int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac) int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac)
{ {
@@ -196,8 +196,23 @@ int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac)
} }
return -1; return -1;
} }
/*****************************************************************************************
* 函数名称: CheckCommUnitExcl
* 功能描述: 检查设备是否排除
* 参 数: GateWay,网关句柄
CommUnitMac, 待检查的设备MAC
* 返 回 值: 已排除返回非0,没排除返回-1
*****************************************************************************************/
int CheckCommUnitExcl(GateWayPara GateWay, uint8_t *CommUnitMac)
{
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {//判断是否被排除
if(memcmp(GateWay->ConfigPara.ExclCommUnit[i].ExclMac, CommUnitMac, 6) == 0) {
if(GateWay->ConfigPara.ExclCommUnit[i].ExclFlag == true)
return i;
}
}
return -1;
}
/***************************************************************************************** /*****************************************************************************************
* 函数名称: CommUnitSendCmd * 函数名称: CommUnitSendCmd
* 功能描述: 网关下发通讯单元指令函数 * 功能描述: 网关下发通讯单元指令函数
@@ -445,7 +460,7 @@ void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorD
int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData Response) int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData Response)
{ {
uint16_t check, crc16; uint16_t check, crc16;
int CommUnitIdx; int CommUnitIdx, ExclCommUnit;
uint16_t PayLoadLen; uint16_t PayLoadLen;
uint8_t *PayLoad; uint8_t *PayLoad;
uint8_t *MegData; uint8_t *MegData;
@@ -468,11 +483,16 @@ int CommUnitAnalyze(GateWayPara GateWay, uint8_t *rData, uint16_t rLen, SendData
if((CUHeader->Cmd != COMM_UNIT_CMD_REG) && (memcmp(GateWay->ConfigPara.GwMac, CUHeader->GWMac, 6) != 0)) if((CUHeader->Cmd != COMM_UNIT_CMD_REG) && (memcmp(GateWay->ConfigPara.GwMac, CUHeader->GWMac, 6) != 0))
return -1; return -1;
CommUnitIdx = CheckCommUnitReg(GateWay, CUHeader->DevMac); CommUnitIdx = CheckCommUnitReg(GateWay, CUHeader->DevMac);//判断是否是已注册的设备
if(CommUnitIdx < 0) { if(CommUnitIdx < 0) {
if(CUHeader->Cmd != COMM_UNIT_CMD_REG) if(CUHeader->Cmd != COMM_UNIT_CMD_REG){//判断是否是注册请求
return -1; return -1;
} }
ExclCommUnit = CheckCommUnitExcl(GateWay, CUHeader->DevMac);//判断是否是被排除的设备
if(ExclCommUnit > -1) {
return -1;
}
}
switch(CUHeader->Cmd) { switch(CUHeader->Cmd) {
case COMM_UNIT_CMD_REG:{ case COMM_UNIT_CMD_REG:{
+22 -37
View File
@@ -134,12 +134,11 @@ void GateWayInit(void)
memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t)); memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t));
GateWay.ConfigPara.SavFlag = LOG_SAV_FLAG; GateWay.ConfigPara.SavFlag = LOG_SAV_FLAG;
GateWay.ConfigPara.Comm = CATONE_COMM; GateWay.ConfigPara.Comm = CATONE_COMM;
// memcpy(GateWay.ConfigPara.GwMac, GateWayMac, 6); GateWay.ConfigPara.SvrAddr[0] = 103;
GateWay.ConfigPara.SvrAddr[0] = 8; GateWay.ConfigPara.SvrAddr[1] = 217;
GateWay.ConfigPara.SvrAddr[1] = 137; GateWay.ConfigPara.SvrAddr[2] = 192;
GateWay.ConfigPara.SvrAddr[2] = 104; GateWay.ConfigPara.SvrAddr[3] = 248;
GateWay.ConfigPara.SvrAddr[3] = 4; GateWay.ConfigPara.SvrPort = 12111;
GateWay.ConfigPara.SvrPort = 8007;
GateWay.ConfigPara.CommUnitReadInterval = COMMUNIT_READ_SENSOR_INTERVAL_MAX;//非低功耗设备 GateWay.ConfigPara.CommUnitReadInterval = COMMUNIT_READ_SENSOR_INTERVAL_MAX;//非低功耗设备
memset(GateWay.ConfigPara.CommUnitArray, 0x00, sizeof(CommUnitData_t) * COMMUNIT_NUM_MAX); memset(GateWay.ConfigPara.CommUnitArray, 0x00, sizeof(CommUnitData_t) * COMMUNIT_NUM_MAX);
GateWay.ConfigPara.Rs485Ch1.Enable = true; GateWay.ConfigPara.Rs485Ch1.Enable = true;
@@ -151,39 +150,10 @@ void GateWayInit(void)
GateWay.ConfigPara.Rs485Ch2.BaudRate = 500000; GateWay.ConfigPara.Rs485Ch2.BaudRate = 500000;
GateWay.ConfigPara.Rs485Ch2.UpgradeEnable = false; GateWay.ConfigPara.Rs485Ch2.UpgradeEnable = false;
GateWay.ConfigPara.Rs485Ch2.CommUnitEnable = false; GateWay.ConfigPara.Rs485Ch2.CommUnitEnable = false;
GateWay.ConfigPara.Rs485Ch2.Power = true; GateWay.ConfigPara.Rs485Ch2.Power = false;
GateWay.ConfigPara.Lora.OnOff = true;
GateWay.ConfigPara.Lora.ucChannel = 8;
GateWay.ConfigPara.Lora.ucPower = 20;
GateWay.ConfigPara.Lora.SignalBw = 8;
GateWay.ConfigPara.Lora.SpreadFactor = 9;
GateWay.ConfigPara.Lora.ErrorCoding = 2;
GateWay.ConfigPara.Lora.RegPreamble = 10;
GateWay.ConfigPara.Lora.FreqCent = FREQ_CENT;
GateWay.ConfigPara.OutageFlag = false;
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
}
if(GateWay.ConfigPara.OutageFlag != true && GateWay.ConfigPara.OutageFlag != false)
GateWay.ConfigPara.OutageFlag = false;
GateWay.SvrRegFlag = false;
memset(GateWay.SvrMac, 0x00, 6);
GateWay.ConfigPara.Rs485Ch1.RS485Send = RS485Ch1UartSend; GateWay.ConfigPara.Rs485Ch1.RS485Send = RS485Ch1UartSend;
GateWay.ConfigPara.Rs485Ch2.RS485Send = RS485Ch2UartSend; GateWay.ConfigPara.Rs485Ch2.RS485Send = RS485Ch2UartSend;
GateWay.ConfigPara.Rs485Ch1.Enable = true;
GateWay.ConfigPara.Rs485Ch1.CommUnitEnable = false;
GateWay.ConfigPara.Rs485Ch1.UpgradeEnable = true;
GateWay.ConfigPara.Rs485Ch1.BaudRate = 500000;
GateWay.ConfigPara.Rs485Ch1.Power = false;
GateWay.ConfigPara.Rs485Ch2.Enable = true;
GateWay.ConfigPara.Rs485Ch2.BaudRate = 500000;
GateWay.ConfigPara.Rs485Ch2.CommUnitEnable = false;
GateWay.ConfigPara.Rs485Ch2.UpgradeEnable = false;
GateWay.ConfigPara.Rs485Ch2.Power = false;
GateWay.ConfigPara.Lora.OnOff = true; GateWay.ConfigPara.Lora.OnOff = true;
GateWay.ConfigPara.Lora.ucChannel = 8; GateWay.ConfigPara.Lora.ucChannel = 8;
GateWay.ConfigPara.Lora.ucPower = 20; GateWay.ConfigPara.Lora.ucPower = 20;
@@ -193,6 +163,9 @@ void GateWayInit(void)
GateWay.ConfigPara.Lora.RegPreamble = 10; GateWay.ConfigPara.Lora.RegPreamble = 10;
GateWay.ConfigPara.Lora.FreqCent = FREQ_CENT; GateWay.ConfigPara.Lora.FreqCent = FREQ_CENT;
GateWay.ConfigPara.OutageFlag = false;
GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1;
#if MAC_ADDR_TYPE == 0 #if MAC_ADDR_TYPE == 0
memcpy(GateWay.ConfigPara.GwMac, GateWayMac_Test, 6); memcpy(GateWay.ConfigPara.GwMac, GateWayMac_Test, 6);
GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG; GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG;
@@ -248,6 +221,13 @@ void GateWayInit(void)
GateWay.ConfigPara.SvrAddr[3] = 248; GateWay.ConfigPara.SvrAddr[3] = 248;
GateWay.ConfigPara.SvrPort = 12111; GateWay.ConfigPara.SvrPort = 12111;
#endif #endif
}
if(GateWay.ConfigPara.OutageFlag != true && GateWay.ConfigPara.OutageFlag != false)
GateWay.ConfigPara.OutageFlag = false;
GateWay.SvrRegFlag = false;
memset(GateWay.SvrMac, 0x00, 6);
if(GateWay.ConfigPara.DebugChannel == DEBUG_CH_RS485_1) { if(GateWay.ConfigPara.DebugChannel == DEBUG_CH_RS485_1) {
GateWay.ConfigPara.Rs485Ch1.Enable = true; GateWay.ConfigPara.Rs485Ch1.Enable = true;
@@ -289,6 +269,11 @@ void GateWayInit(void)
LoraSetChannel(GateWay.ConfigPara.Lora.ucChannel); LoraSetChannel(GateWay.ConfigPara.Lora.ucChannel);
//WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); //WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t));
} }
if(LoraSetFreqCent(GateWay.ConfigPara.Lora.FreqCent) == false)
{
GateWay.ConfigPara.Lora.FreqCent = 433100000;
LoraSetFreqCent(GateWay.ConfigPara.Lora.ucChannel);
}
if(LoraSetPower(GateWay.ConfigPara.Lora.ucPower) == false) { if(LoraSetPower(GateWay.ConfigPara.Lora.ucPower) == false) {
GateWay.ConfigPara.Lora.ucPower = 20; GateWay.ConfigPara.Lora.ucPower = 20;
LoraSetPower(GateWay.ConfigPara.Lora.ucPower); LoraSetPower(GateWay.ConfigPara.Lora.ucPower);
@@ -311,9 +296,9 @@ void GateWayInit(void)
} }
if(GateWay.ConfigPara.Lora.RegPreamble > 0xFE) { if(GateWay.ConfigPara.Lora.RegPreamble > 0xFE) {
GateWay.ConfigPara.Lora.RegPreamble = 10; GateWay.ConfigPara.Lora.RegPreamble = 10;
LoraSetRegPreamble(GateWay.ConfigPara.Lora.RegPreamble);
//WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); //WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t));
} }
LoraSetRegPreamble(GateWay.ConfigPara.Lora.RegPreamble);
WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t));