diff --git a/DebugCmd.c b/DebugCmd.c index 39da31c..e96f36c 100644 --- a/DebugCmd.c +++ b/DebugCmd.c @@ -8,7 +8,7 @@ #define DBG_RX_LEN_MAX 128 //#define DBG_LOG(...) rt_kprintf(__VA_ARGS__) -#define DEBUG_CMD_CNT 22 +#define DEBUG_CMD_CNT 23 #define DEBUG_BUFF_SIZE_MAX 512 #define DEBUG_BUFSIZE 200 @@ -747,13 +747,19 @@ void DebugCmdRestoreFactory(int argc, char *argv[]) DBG_LOG("\r\n"); if(strcmp(argv[1], "?") == 0) { DBG_LOG("Debug Cmd: res\r\n\ - brief --> Restore to factory.\r\n\r\n"); + brief --> Restore to factory.\r\n"); + DBG_LOG(" arg1 --> password\r\n\r\n"); return; } - memset((uint8_t *)&GateWay->ConfigPara, 0x00, sizeof(GWConfigPara_t)); - WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); + if(strcmp(argv[1], "gxjt") != 0) { + DBG_LOG("Password Error\r\n"); + return; + } + DBG_LOG("Restore factory settings, GateWay Restart...\r\n"); + memset((uint8_t *)&GateWay->ConfigPara, 0xFF, sizeof(GWConfigPara_t)); + WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); rt_thread_delay(1000); NVIC_SystemReset(); while(1); @@ -997,22 +1003,27 @@ static void DebugCmdSetSvr(int argc, char *argv[]) return; if(strcmp(argv[1], "?") == 0) { - DBG_LOG("Debug Cmd: arg1 arg2\r\n"); + DBG_LOG("Debug Cmd: arg1 arg2 arg3\r\n"); DBG_LOG(" brief --> Set the server IP address and port for 4G communication.\r\n"); - DBG_LOG(" arg1 --> (xx.xx.xx.xx) ip\r\n"); - DBG_LOG(" arg2 --> port\r\n\r\n"); + DBG_LOG(" arg1 --> password\r\n"); + DBG_LOG(" arg2 --> (xx.xx.xx.xx) ip\r\n"); + DBG_LOG(" arg3 --> port\r\n\r\n"); return; } - char *IpStr = argv[1]; - + if(strcmp(argv[1], "gxjt") != 0) { + DBG_LOG("Password Error\r\n"); + return; + } + + char *IpStr = argv[2]; int ret = sscanf(IpStr, "%d.%d.%d.%d", &IP[0], &IP[1], &IP[2], &IP[3]); if(ret != 4) return; if(IP[0] > 0xff || IP[1] > 0xff || IP[2] > 0xff || IP[3] > 0xff) return; - port = atoi(argv[2]); + port = atoi(argv[3]); if(port > 0xffff) return; @@ -1044,7 +1055,7 @@ static void DebugCmdSetMac(int argc, char *argv[]) if(strcmp(argv[1], "?") == 0) { DBG_LOG("Debug Cmd: mac arg1 arg2\r\n"); DBG_LOG(" brief --> Set the server IP address and port for 4G communication.\r\n"); - DBG_LOG(" arg1 --> psw\r\n"); + DBG_LOG(" arg1 --> password\r\n"); DBG_LOG(" arg2 --> mac(xx-xx-xx-xx-xx-xx)\r\n\r\n"); return; } @@ -1286,7 +1297,7 @@ static void DebugLaserConfig(int argc, char *argv[]) if(argc > 1) { if(strcmp(argv[1], "?") == 0) { DBG_LOG("Debug Cmd: laser\r\n"); - DBG_LOG(" brief --> Control laser cutting.\r\n\r\n"); + DBG_LOG(" brief --> Control laser cutting.\r\n"); DBG_LOG(" arg1 --> mac: communication unit Mac address.\r\n"); DBG_LOG(" mac = (XX-XX-XX-XX-XX-XX), Control specified MAC communication unit.\r\n"); DBG_LOG(" arg2 --> state: on/off, Turn on or off the laser.\r\n\r\n"); @@ -1460,7 +1471,7 @@ static void DebugCmdLPConfig(int argc, char *argv[]) /***************************************************************************************** * 函数名称: DebugCmdLPConfig -* 功能描述: 低功耗参数配置 +* 功能描述: Lora参数配置 * 参 数: argc, 输入参数数量 argv, 输入参数 * 返 回 值: 无 @@ -1472,7 +1483,7 @@ static void DebugLoraConfig(int argc, char *argv[]) return; if(strcmp(argv[1], "?") == 0) { - DBG_LOG("Debug Cmd: Lora arg1 arg2\r\n"); + DBG_LOG("Debug Cmd: lora arg1 arg2\r\n"); DBG_LOG(" brief --> Configure Lora parameters.\r\n"); DBG_LOG(" arg1 --> ch: Channel--para=(0~16)\r\n"); DBG_LOG(" pw: Power--para=(0~20)\r\n"); @@ -1480,6 +1491,7 @@ static void DebugLoraConfig(int argc, char *argv[]) DBG_LOG(" sf: SpreadFactor--para=(6~12)\r\n"); DBG_LOG(" ec: ErrorCoding--para=(1~4)\r\n"); DBG_LOG(" rp: RegPreamble--para=(1~32)\r\n"); + DBG_LOG(" fc: FreqCent--para=(410000000~525000000)\r\n"); DBG_LOG(" o: on/off\r\n"); DBG_LOG(" arg2 --> para\r\n"); @@ -1570,6 +1582,17 @@ static void DebugLoraConfig(int argc, char *argv[]) return; } } + if(strcmp(argv[1], "fc") == 0){ + uint32_t fc = atoi(argv[2]); + if(LoraSetFreqCent(fc)) { + GateWay->ConfigPara.Lora.FreqCent = fc; + DBG_LOG(" Lora FreqCent is configured successfully!\r\n"); + } + else { + DBG_LOG("Lora Para Error!\r\n"); + return; + } + } if(GateWay->ConfigPara.Lora.OnOff) LoraInit(); WritePara((uint8_t *)&GateWay->ConfigPara, sizeof(GWConfigPara_t)); @@ -1630,22 +1653,14 @@ void DebugCmdHelp(int argc, char *argv[]) memcpy(Data, "hinf ?\r\n", len); DebugAnalyze(GateWay, Data, len); -// len = strlen("res ?\r\n"); -// memcpy(Data, "res ?\r\n", len); -// DebugAnalyze(GateWay, Data, len); - - len = strlen("sct ?\r\n"); - memcpy(Data, "sct ?\r\n", len); + len = strlen("res ?\r\n"); + memcpy(Data, "res ?\r\n", len); DebugAnalyze(GateWay, Data, len); - + len = strlen("time ?\r\n"); memcpy(Data, "time ?\r\n", len); DebugAnalyze(GateWay, Data, len); - len = strlen("svr ?\r\n"); - memcpy(Data, "svr ?\r\n", len); - DebugAnalyze(GateWay, Data, len); - len = strlen("qs ?\r\n"); memcpy(Data, "qs ?\r\n", len); DebugAnalyze(GateWay, Data, len); @@ -1654,9 +1669,37 @@ void DebugCmdHelp(int argc, char *argv[]) memcpy(Data, "dch ?\r\n", len); DebugAnalyze(GateWay, Data, len); + len = strlen("svr ?\r\n"); + memcpy(Data, "svr ?\r\n", len); + DebugAnalyze(GateWay, Data, len); + + len = strlen("mac ?\r\n"); + memcpy(Data, "mac ?\r\n", len); + DebugAnalyze(GateWay, Data, len); + len = strlen("para ?\r\n"); memcpy(Data, "para ?\r\n", len); DebugAnalyze(GateWay, Data, len); + + len = strlen("cali ?\r\n"); + memcpy(Data, "cali ?\r\n", len); + DebugAnalyze(GateWay, Data, len); + + len = strlen("laser ?\r\n"); + memcpy(Data, "laser ?\r\n", len); + DebugAnalyze(GateWay, Data, len); + + len = strlen("lpcfg ?\r\n"); + memcpy(Data, "lpcfg ?\r\n", len); + DebugAnalyze(GateWay, Data, len); + + len = strlen("lora ?\r\n"); + memcpy(Data, "lora ?\r\n", len); + DebugAnalyze(GateWay, Data, len); + + len = strlen("reboot ?\r\n"); + memcpy(Data, "reboot ?\r\n", len); + DebugAnalyze(GateWay, Data, len); } const DBGFunType DebugFun[DEBUG_CMD_CNT] = { @@ -1668,10 +1711,10 @@ const DBGFunType DebugFun[DEBUG_CMD_CNT] = { "culs", DebugCmdLsCommUnit, "comm", DebugCmdSetComm, "sct", DebugCmdSetCollectTime, -// "his", DebugCmdReadHisData, + "his", DebugCmdReadHisData, "fmt", DebugCmdDelHisData, "hinf", DebugCmdGetHisInfo, -// "res", DebugCmdRestoreFactory, + "res", DebugCmdRestoreFactory, "time", DebugCmdTimeSync, "qs", DebugCmdQuerySensor, "dch", DebugCmdSelDebugChannel,