feat(debug): 优化culs显示+lpcfg支持MAC参数指定设备
1. culs命令优化: - 新增LpCfg参数显示(CI/RI/EI/ET) - FPO状态基于CurFPOTime判断(Pending/FullPower/LowPower) - 移除para命令中的LpCfg打印(原为常量默认值) 2. lpcfg命令新增MAC参数支持: - lpcfg <Mac|all> <CI> <RI> <EI> <ET> - 支持指定单个设备或all配置全部设备 - 与fpocfg命令风格统一
This commit is contained in:
@@ -545,6 +545,8 @@ void DebugCmdLsCommUnit(int argc, char *argv[])
|
||||
(CU->FPOTimeStart + CU->FPOTime) % 24,
|
||||
FPOStatus);
|
||||
}
|
||||
DBG_LOG(" LpCfg: CI:%dsec, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
|
||||
CU->CollectInterval, CU->ReportInterval, CU->ERInterval, CU->ERTime);
|
||||
DBG_LOG(" Online:%s\r\n\r\n", CU->CommStatus ? "Yes" : "No");
|
||||
}
|
||||
}
|
||||
@@ -1486,8 +1488,6 @@ static void DebugCmdGetPara(int argc, char *argv[])
|
||||
DBG_LOG("Baudrate %d\r\n", GateWay->ConfigPara.Rs485Ch2.BaudRate);
|
||||
|
||||
DBG_LOG("Lora: ch %d, rp %d, fc %d\r\n", GateWay->ConfigPara.Lora.ucChannel, GateWay->ConfigPara.Lora.RegPreamble, GateWay->ConfigPara.Lora.FreqCent);
|
||||
DBG_LOG("LpCfg: CI:%dsec, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
|
||||
LW_DEV_COLLECT_INTERVAL_MAX, LW_DEV_REPORT_INTERVAL_MAX, LW_DEV_ER_INTERVAL_MAX, LW_DEV_ER_TIME_MAX);
|
||||
struct tm *stime;
|
||||
uint32_t dwStamp = TimeTs();
|
||||
stime = localtime(&dwStamp);
|
||||
@@ -1775,57 +1775,84 @@ static void DebugCmdLPConfig(int argc, char *argv[])
|
||||
uint16_t ReportInterval; //上报时间间隔
|
||||
uint8_t ERInterval; //紧急上报时间间隔
|
||||
uint8_t ERTime; //紧急上报时间
|
||||
uint8_t Mac[6];
|
||||
bool ConfigAll = false;
|
||||
|
||||
if(strcmp(argv[1], "?") == 0) {
|
||||
DBG_LOG("Debug Cmd: lpcfg arg1 arg2 arg3 arg4\r\n");
|
||||
DBG_LOG("Debug Cmd: lpcfg arg1 arg2 arg3 arg4 arg5\r\n");
|
||||
DBG_LOG(" brief --> Configure low-power device parameters.\r\n");
|
||||
DBG_LOG(" arg1 --> Collect interval(30~7200 second)\r\n");
|
||||
DBG_LOG(" arg2 --> Report interval(5~720 minute)\r\n");
|
||||
DBG_LOG(" arg3 --> Emergency reporting interval(1~5 minute)\r\n");
|
||||
DBG_LOG(" arg4 --> Emergency reporting time(10~120 minute)\r\n\r\n");
|
||||
DBG_LOG(" arg1 --> Mac(xx-xx-xx-xx-xx-xx) or \"all\"\r\n");
|
||||
DBG_LOG(" arg2 --> Collect interval(30~7200 second)\r\n");
|
||||
DBG_LOG(" arg3 --> Report interval(5~720 minute)\r\n");
|
||||
DBG_LOG(" arg4 --> Emergency reporting interval(1~5 minute)\r\n");
|
||||
DBG_LOG(" arg5 --> Emergency reporting time(10~120 minute)\r\n\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(argc < 5)
|
||||
if(argc < 6)
|
||||
return;
|
||||
|
||||
if(strcmp(argv[1], "all") == 0) {
|
||||
ConfigAll = true;
|
||||
}
|
||||
else {
|
||||
int ret = sscanf(argv[1], "%02X-%02X-%02X-%02X-%02X-%02X",
|
||||
(int *)&Mac[0], (int *)&Mac[1], (int *)&Mac[2], (int *)&Mac[3], (int *)&Mac[4], (int *)&Mac[5]);
|
||||
if(ret != 6) {
|
||||
DBG_LOG("Mac Para Error! (xx-xx-xx-xx-xx-xx or all)\r\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
CollectInterval = atoi(argv[1]);
|
||||
CollectInterval = atoi(argv[2]);
|
||||
if(CollectInterval < 30 || CollectInterval > 7200) {
|
||||
DBG_LOG("CollectInterval Para Error!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ReportInterval = atoi(argv[2]);
|
||||
ReportInterval = atoi(argv[3]);
|
||||
if(ReportInterval < 5 || ReportInterval > 720) {
|
||||
DBG_LOG("ReportInterval Para Error!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ERInterval = atoi(argv[3]);
|
||||
ERInterval = atoi(argv[4]);
|
||||
if(ERInterval < 1 || ERInterval > 5) {
|
||||
DBG_LOG("ERInterval Para Error!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ERTime = atoi(argv[4]);
|
||||
ERTime = atoi(argv[5]);
|
||||
if(ERTime < 10 || ERTime > 120) {
|
||||
DBG_LOG("ERTime Para Error!\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
bool Found = false;
|
||||
for(int i = 0; i < COMMUNIT_NUM_MAX; i++) {
|
||||
if(GateWay->ConfigPara.CommUnitArray[i].RegFlag) {
|
||||
if(ConfigAll || memcmp(GateWay->ConfigPara.CommUnitArray[i].Mac[0], Mac, 6) == 0) {
|
||||
GateWay->ConfigPara.CommUnitArray[i].CollectInterval = CollectInterval;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ReportInterval = ReportInterval;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERInterval = ERInterval;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ERTime = ERTime;
|
||||
GateWay->ConfigPara.CommUnitArray[i].ConfigFlag = true;
|
||||
Found = true;
|
||||
DBG_LOG("Mac:%02X-%02X-%02X-%02X-%02X-%02X LpCfg set.\r\n",
|
||||
GateWay->ConfigPara.CommUnitArray[i].Mac[0][0], GateWay->ConfigPara.CommUnitArray[i].Mac[0][1],
|
||||
GateWay->ConfigPara.CommUnitArray[i].Mac[0][2], GateWay->ConfigPara.CommUnitArray[i].Mac[0][3],
|
||||
GateWay->ConfigPara.CommUnitArray[i].Mac[0][4], GateWay->ConfigPara.CommUnitArray[i].Mac[0][5]);
|
||||
TrySendFullPowerCmd(GateWay, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!Found) {
|
||||
DBG_LOG("Device not found.\r\n");
|
||||
return;
|
||||
}
|
||||
WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t));
|
||||
DBG_LOG("The low-power device is configured.\r\n");
|
||||
DBG_LOG("LpCfg configured. CI:%dsec, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
|
||||
CollectInterval, ReportInterval, ERInterval, ERTime);
|
||||
}
|
||||
|
||||
/*****************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user