From 7103c8ddfbee1a1355560073b07edede1deb59d8 Mon Sep 17 00:00:00 2001 From: YuanHongbin <975559679@qq.com> Date: Thu, 21 May 2026 17:30:35 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E5=A2=9E=E5=8A=A0ExclCommUint=5Ft?= =?UTF-8?q?=E7=BB=93=E6=9E=84=E4=BD=93=EF=BC=8C=E7=94=A8=E4=BA=8E=E6=8E=92?= =?UTF-8?q?=E9=99=A4=E6=8C=87=E5=AE=9A=E9=80=9A=E8=AE=AF=E5=8D=95=E5=85=83?= =?UTF-8?q?=E7=9A=84MAC=202=E3=80=81=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=A4=8D?= =?UTF-8?q?=E4=BD=8D=E5=90=8E=E9=87=8D=E5=A4=8D=E5=AE=9A=E4=B9=89=E5=90=84?= =?UTF-8?q?=E9=A1=B9=E5=8F=82=E6=95=B0=E7=9A=84bug=E3=80=82=E5=8F=AA?= =?UTF-8?q?=E6=9C=89=E4=BB=8Eflash=E8=AF=BB=E5=8F=96=E5=88=B0=E7=9A=84?= =?UTF-8?q?=E5=87=BA=E5=8E=82=E6=A0=87=E5=BF=97=E4=BD=8D=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E6=89=8D=E4=BC=9A=E8=BF=9B=E5=85=A5=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0=E5=88=A4=E6=96=AD?= =?UTF-8?q?=EF=BC=8C=E5=90=A6=E5=88=99=E4=BC=9A=E4=BB=A5=E4=BB=8Eflash?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E5=88=B0=E7=9A=84=E6=95=B0=E6=8D=AE=E4=B8=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=8F=82=E6=95=B0=203=E3=80=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0CheckCommUnitExcl=E5=87=BD=E6=95=B0=EF=BC=8C=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E6=9F=A5=E8=AF=A2mac=E6=98=AF=E5=90=A6=E8=A2=AB?= =?UTF-8?q?=E6=8E=92=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GateWay_Debug: 1、rs485配置函数增加了boot升级使能功能 2、增加了excu、exdel、exls命令,用于配置排除设备的增、删、查 3、para命令增加显示LpCfg参数 sx127x: 1、lora通道选择取消,通过修改频率来修改通道 --- Project/GateWay/MDK/GateWay.uvoptx | 91 +------------------ Project/GateWay/MDK/GateWay.uvprojx | 12 +-- .../GateWay/MDK/RTE/_app_app/RTE_Components.h | 21 +++++ Project/GateWay/source/Module/GateWay_Debug | 2 +- Project/GateWay/source/Module/sx127x | 2 +- Project/GateWay/source/User/Inc/Public.h | 7 ++ Project/GateWay/source/User/Src/LoraTask.c | 2 +- Project/GateWay/source/User/Src/Public.c | 34 +++++-- Project/GateWay/source/User/Src/main.c | 67 ++++++-------- 9 files changed, 95 insertions(+), 143 deletions(-) create mode 100644 Project/GateWay/MDK/RTE/_app_app/RTE_Components.h diff --git a/Project/GateWay/MDK/GateWay.uvoptx b/Project/GateWay/MDK/GateWay.uvoptx index 3727ed7..8d9ab6e 100644 --- a/Project/GateWay/MDK/GateWay.uvoptx +++ b/Project/GateWay/MDK/GateWay.uvoptx @@ -410,7 +410,7 @@ 0 JL2CM3 - -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) + -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) 0 @@ -428,93 +428,12 @@ - - - 0 - 0 - 1598 - 1 -
83604
- 0 - 0 - 0 - 0 - 0 - 1 - ..\source\Module\DebugCmd\DebugCmd.c - - \\GateWay\../source/Module/DebugCmd/DebugCmd.c\1598 -
- - 1 - 0 - 460 - 1 -
59254
- 0 - 0 - 0 - 0 - 0 - 1 - ..\source\User\Src\Public.c - - \\GateWay\../source/User/Src/Public.c\460 -
- - 2 - 0 - 466 - 1 -
59314
- 0 - 0 - 0 - 0 - 0 - 1 - ..\source\User\Src\Public.c - - \\GateWay\../source/User/Src/Public.c\466 -
- - 3 - 0 - 416 - 1 -
109936
- 0 - 0 - 0 - 0 - 0 - 1 - ..\source\Module\SX127x\sx127x.c - - \\GateWay\../source/Module/SX127x/sx127x.c\416 -
- - 4 - 0 - 415 - 1 -
109924
- 0 - 0 - 0 - 0 - 0 - 1 - ..\source\Module\SX127x\sx127x.c - - \\GateWay\../source/Module/SX127x/sx127x.c\415 -
-
+ 0 1 - GateWay,0x0A + GateWay,0x10 @@ -977,7 +896,7 @@ - DebugCmd + GateWay_Debug 1 0 0 @@ -989,7 +908,7 @@ 0 0 0 - ..\source\Module\DebugCmd\DebugCmd.c + ..\source\Module\GateWay_Debug\DebugCmd.c DebugCmd.c 0 0 diff --git a/Project/GateWay/MDK/GateWay.uvprojx b/Project/GateWay/MDK/GateWay.uvprojx index e18a2db..e88e94b 100644 --- a/Project/GateWay/MDK/GateWay.uvprojx +++ b/Project/GateWay/MDK/GateWay.uvprojx @@ -341,7 +341,7 @@ --diag_suppress=186,66 __DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA - ..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\SX127x + ..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\GateWay_Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\SX127x @@ -586,12 +586,12 @@ - DebugCmd + GateWay_Debug DebugCmd.c 1 - ..\source\Module\DebugCmd\DebugCmd.c + ..\source\Module\GateWay_Debug\DebugCmd.c @@ -1267,7 +1267,7 @@ --diag_suppress=186,66 __DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA,BOOT_ENABLE - ..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\sx127x;..\source\Module\DebugCmd + ..\..\..\driver\inc;..\..\..\mcu\common;..\source\User\Inc;..\source\Module\Debug;..\source\Module\SDCard;..\source\Module\FatFS\source;..\source\Module\sx127x;..\source\Module\GateWay_Debug @@ -1512,12 +1512,12 @@ - DebugCmd + GateWay_Debug DebugCmd.c 1 - ..\source\Module\DebugCmd\DebugCmd.c + ..\source\Module\GateWay_Debug\DebugCmd.c diff --git a/Project/GateWay/MDK/RTE/_app_app/RTE_Components.h b/Project/GateWay/MDK/RTE/_app_app/RTE_Components.h new file mode 100644 index 0000000..9a32dcf --- /dev/null +++ b/Project/GateWay/MDK/RTE/_app_app/RTE_Components.h @@ -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 */ diff --git a/Project/GateWay/source/Module/GateWay_Debug b/Project/GateWay/source/Module/GateWay_Debug index 7b80a04..28b612d 160000 --- a/Project/GateWay/source/Module/GateWay_Debug +++ b/Project/GateWay/source/Module/GateWay_Debug @@ -1 +1 @@ -Subproject commit 7b80a04f4f8fbf08d4910b89022fe08550e289e5 +Subproject commit 28b612dd2894afbe832ac901c143f010ea413e14 diff --git a/Project/GateWay/source/Module/sx127x b/Project/GateWay/source/Module/sx127x index e7f30c7..149f38b 160000 --- a/Project/GateWay/source/Module/sx127x +++ b/Project/GateWay/source/Module/sx127x @@ -1 +1 @@ -Subproject commit e7f30c751f76f3624276acf76997cd0dcaf49586 +Subproject commit 149f38bf3f387772f547f709aeb57dbcbd152245 diff --git a/Project/GateWay/source/User/Inc/Public.h b/Project/GateWay/source/User/Inc/Public.h index c4025e5..4a85ffb 100644 --- a/Project/GateWay/source/User/Inc/Public.h +++ b/Project/GateWay/source/User/Inc/Public.h @@ -191,6 +191,11 @@ typedef struct { uint8_t ERTime; //ϱʱ }__attribute__((packed))CommUnitPara_t, *CommUnitPara; +typedef struct { + bool ExclFlag; + uint8_t ExclMac[6];//ҪųͨѶԪMAC +}__attribute__((packed))ExclCommUnit_t, *ExclCommUnit; + typedef struct { uint8_t Data[SENSOR_NUM_MAX][SENSOR_DATA_LEN_MAX]; }__attribute__((packed))CommUnitData_t, *CommUnitData; @@ -251,6 +256,7 @@ typedef struct { uint32_t SvrPort; //˿ uint32_t CommUnitReadInterval; //ͨѶԪȡʱ,λS CommUnitPara_t CommUnitArray[COMMUNIT_NUM_MAX]; //עͨѶԪϢ + ExclCommUnit_t ExclCommUnit[COMMUNIT_NUM_MAX]; //ųͨѶԪϢ RS485Para_t Rs485Ch1; //RS485ͨ1 RS485Para_t Rs485Ch2; //RS485ͨ2 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 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 CheckCommUnitExcl(GateWayPara GateWay, uint8_t *CommUnitMac); int CommUintOrgData(GateWayPara GateWay, CommUnitPara CUPara, CommUnitData CUData, uint8_t *sData); void DebugDisplaySensorData(int SensorIdx, uint16_t SensorType, uint8_t *SensorData); #endif diff --git a/Project/GateWay/source/User/Src/LoraTask.c b/Project/GateWay/source/User/Src/LoraTask.c index 9a6ae81..134a091 100644 --- a/Project/GateWay/source/User/Src/LoraTask.c +++ b/Project/GateWay/source/User/Src/LoraTask.c @@ -66,7 +66,7 @@ void LoraIRQ_Thread_Entry(void *parameter) static void LoRaSendBuffer(uint8_t* pucBuff, uint16_t ucLen) { - if(GateWay->ConfigPara.Lora.OnOff) + if(GateWay->ConfigPara.Lora.OnOff == true) Sx1276LoRaSendBuffer(pucBuff, ucLen); } diff --git a/Project/GateWay/source/User/Src/Public.c b/Project/GateWay/source/User/Src/Public.c index 421b5c3..048ef70 100644 --- a/Project/GateWay/source/User/Src/Public.c +++ b/Project/GateWay/source/User/Src/Public.c @@ -184,7 +184,7 @@ int NetCommOrgData(GateWayPara GateWay, uint8_t *MegData, uint8_t *OutData) * : 豸Ƿע * : GateWay,ؾ CommUnitMac, 豸MAC -* ֵ: ע᷵true,ûע᷵false +* ֵ: ע᷵ط0,ûע᷵-1 *****************************************************************************************/ int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac) { @@ -196,8 +196,23 @@ int CheckCommUnitReg(GateWayPara GateWay, uint8_t *CommUnitMac) } 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 * : ·ͨѶԪָ @@ -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) { uint16_t check, crc16; - int CommUnitIdx; + int CommUnitIdx, ExclCommUnit; uint16_t PayLoadLen; uint8_t *PayLoad; uint8_t *MegData; @@ -468,12 +483,17 @@ 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)) return -1; - CommUnitIdx = CheckCommUnitReg(GateWay, CUHeader->DevMac); + CommUnitIdx = CheckCommUnitReg(GateWay, CUHeader->DevMac);//жǷע豸 if(CommUnitIdx < 0) { - if(CUHeader->Cmd != COMM_UNIT_CMD_REG) + if(CUHeader->Cmd != COMM_UNIT_CMD_REG){//жǷע return -1; + } + ExclCommUnit = CheckCommUnitExcl(GateWay, CUHeader->DevMac);//жǷDZų豸 + if(ExclCommUnit > -1) { + return -1; + } } - + switch(CUHeader->Cmd) { case COMM_UNIT_CMD_REG:{ if(PayLoad[0] > SENSOR_NUM_MAX) { diff --git a/Project/GateWay/source/User/Src/main.c b/Project/GateWay/source/User/Src/main.c index ffbc81b..964e254 100644 --- a/Project/GateWay/source/User/Src/main.c +++ b/Project/GateWay/source/User/Src/main.c @@ -134,12 +134,11 @@ void GateWayInit(void) memset((uint8_t *)&GateWay.ConfigPara, 0x00, sizeof(GWConfigPara_t)); GateWay.ConfigPara.SavFlag = LOG_SAV_FLAG; GateWay.ConfigPara.Comm = CATONE_COMM; -// memcpy(GateWay.ConfigPara.GwMac, GateWayMac, 6); - GateWay.ConfigPara.SvrAddr[0] = 8; - GateWay.ConfigPara.SvrAddr[1] = 137; - GateWay.ConfigPara.SvrAddr[2] = 104; - GateWay.ConfigPara.SvrAddr[3] = 4; - GateWay.ConfigPara.SvrPort = 8007; + GateWay.ConfigPara.SvrAddr[0] = 103; + GateWay.ConfigPara.SvrAddr[1] = 217; + GateWay.ConfigPara.SvrAddr[2] = 192; + GateWay.ConfigPara.SvrAddr[3] = 248; + GateWay.ConfigPara.SvrPort = 12111; GateWay.ConfigPara.CommUnitReadInterval = COMMUNIT_READ_SENSOR_INTERVAL_MAX;//ǵ͹豸 memset(GateWay.ConfigPara.CommUnitArray, 0x00, sizeof(CommUnitData_t) * COMMUNIT_NUM_MAX); GateWay.ConfigPara.Rs485Ch1.Enable = true; @@ -151,7 +150,9 @@ void GateWayInit(void) GateWay.ConfigPara.Rs485Ch2.BaudRate = 500000; GateWay.ConfigPara.Rs485Ch2.UpgradeEnable = false; GateWay.ConfigPara.Rs485Ch2.CommUnitEnable = false; - GateWay.ConfigPara.Rs485Ch2.Power = true; + GateWay.ConfigPara.Rs485Ch2.Power = false; + GateWay.ConfigPara.Rs485Ch1.RS485Send = RS485Ch1UartSend; + GateWay.ConfigPara.Rs485Ch2.RS485Send = RS485Ch2UartSend; GateWay.ConfigPara.Lora.OnOff = true; GateWay.ConfigPara.Lora.ucChannel = 8; @@ -161,38 +162,10 @@ void GateWayInit(void) 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.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.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; - + #if MAC_ADDR_TYPE == 0 memcpy(GateWay.ConfigPara.GwMac, GateWayMac_Test, 6); GateWay.ConfigPara.DebugChannel = DEBUG_CH_DBG; @@ -229,7 +202,7 @@ void GateWayInit(void) memcpy(GateWay.ConfigPara.GwMac, GateWayMac_BL10, 6); GateWay.ConfigPara.DebugChannel = DEBUG_CH_RS485_1; #endif - + #if MAC_ADDR_TYPE == 0//Է GateWay.ConfigPara.SvrAddr[0] = 39; GateWay.ConfigPara.SvrAddr[1] = 106; @@ -248,7 +221,14 @@ void GateWayInit(void) GateWay.ConfigPara.SvrAddr[3] = 248; GateWay.ConfigPara.SvrPort = 12111; #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) { GateWay.ConfigPara.Rs485Ch1.Enable = true; GateWay.ConfigPara.Rs485Ch1.BaudRate = 500000; @@ -289,6 +269,11 @@ void GateWayInit(void) LoraSetChannel(GateWay.ConfigPara.Lora.ucChannel); //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) { GateWay.ConfigPara.Lora.ucPower = 20; LoraSetPower(GateWay.ConfigPara.Lora.ucPower); @@ -311,9 +296,9 @@ void GateWayInit(void) } if(GateWay.ConfigPara.Lora.RegPreamble > 0xFE) { GateWay.ConfigPara.Lora.RegPreamble = 10; + LoraSetRegPreamble(GateWay.ConfigPara.Lora.RegPreamble); //WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); } - LoraSetRegPreamble(GateWay.ConfigPara.Lora.RegPreamble); WritePara((uint8_t *)&GateWay.ConfigPara, sizeof(GWConfigPara_t)); @@ -373,7 +358,7 @@ int main(void) uint8_t AlarmType = 0; GateWayInit(); - + rt_kprintf("\r\n\r\n"); rt_kprintf("****************************************************\r\n"); rt_kprintf("** **\r\n");