2026-07-13 14:30:13 +08:00
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
|
|
#include "UartDebug.h"
|
|
|
|
|
#include "main.h"
|
|
|
|
|
#include "bsp.h"
|
|
|
|
|
#include "sx127x.h"
|
|
|
|
|
#include "SGCP.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if (USE_DEBUG != 0)
|
|
|
|
|
#define DEBUG_CMD_CNT 16
|
|
|
|
|
const DBGFunType DebugFun[DEBUG_CMD_CNT];
|
|
|
|
|
|
|
|
|
|
volatile DebugChannel_e gDebugChannel = DBG_CH_UART0;
|
|
|
|
|
|
|
|
|
|
static char buff[DEBUG_BUFSIZE];
|
|
|
|
|
volatile uint16_t iw=0; /* buffer write index*/
|
|
|
|
|
static uint16_t ir=0; /* buffer read index*/
|
|
|
|
|
static uint8_t RxRevTimeOutCnt = 0;
|
|
|
|
|
static char RxBuff[128];
|
|
|
|
|
static uint8_t RxLen = 0;
|
|
|
|
|
|
|
|
|
|
void vcom_Print(uint8_t sLen);
|
|
|
|
|
|
|
|
|
|
void vcom_Send( char *format, ... )
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, format);
|
|
|
|
|
uint8_t len;
|
|
|
|
|
uint8_t offset = 0;
|
|
|
|
|
char tempBuff[DEBUG_BUFF_SIZE_MAX];
|
|
|
|
|
//uint32_t primask_bit;
|
|
|
|
|
|
|
|
|
|
//primask_bit = __get_PRIMASK();
|
|
|
|
|
//__disable_irq();
|
|
|
|
|
|
|
|
|
|
/*convert into string at buff[0] of length iw*/
|
|
|
|
|
len = vsprintf(&tempBuff[0], format, args);
|
|
|
|
|
|
|
|
|
|
while(offset < len) {
|
|
|
|
|
if((len - offset) < DEBUG_BUFSIZE) {
|
|
|
|
|
memcpy(&buff[0], &tempBuff[offset], len - offset);
|
|
|
|
|
vcom_Print(len - offset);
|
|
|
|
|
offset = len;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
memcpy(&buff[0], &tempBuff[offset], DEBUG_BUFSIZE);
|
|
|
|
|
offset += DEBUG_BUFSIZE;
|
|
|
|
|
vcom_Print(DEBUG_BUFSIZE);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//__set_PRIMASK(primask_bit);
|
|
|
|
|
//__enable_irq();
|
|
|
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void vcom_Print(uint8_t sLen)
|
|
|
|
|
{
|
|
|
|
|
// 定义一个字符指针CurChar
|
|
|
|
|
char* CurChar;
|
|
|
|
|
// 初始化ir
|
|
|
|
|
ir = 0;
|
|
|
|
|
// 当ir小于sLen时,循环执行
|
|
|
|
|
while(ir < sLen)
|
|
|
|
|
{
|
|
|
|
|
// 获取字符指针CurChar
|
|
|
|
|
CurChar = &buff[ir++];
|
|
|
|
|
// 调用DebugUartSend函数,发送CurChar指向的字符,次数为1
|
|
|
|
|
DBGUartSend((uint8_t*)CurChar, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 定义一个函数vcom_Send2,用于发送字符串
|
|
|
|
|
void vcom_Send2(uint8_t *sData, uint16_t len)
|
|
|
|
|
{
|
|
|
|
|
// 遍历sData,将每个元素发送到DebugUartSend
|
|
|
|
|
for(int i = 0; i < len; i++) {
|
|
|
|
|
DBGUartSendByte(sData[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DebugLoopHandler(void)
|
|
|
|
|
{
|
|
|
|
|
int argc = 0;
|
|
|
|
|
char *argv[10], *argp;
|
|
|
|
|
|
|
|
|
|
if(RxRevTimeOutCnt > 0 || RxLen == 0)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
//for(argv[argc] = strtok(RxBuff, " '\r'"); argv[argc] != NULL; argv[++argc] = strtok(NULL, " '\r'"));
|
|
|
|
|
// 解析字符串,将参数放入argv数组中
|
|
|
|
|
argp = strtok(RxBuff, " ");
|
|
|
|
|
for(int i = 0; i < 10; i++) {
|
|
|
|
|
if(argp != NULL) {
|
|
|
|
|
argv[argc++] = argp;
|
|
|
|
|
argp = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
else if(argc > 0){
|
|
|
|
|
argc--;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取第一个参数,并将其赋值给argp
|
|
|
|
|
argp = strtok(argv[argc], "'\r'");
|
|
|
|
|
// 如果argp不为空,则将argp的值赋值给argv[argc],并将argc加1
|
|
|
|
|
if(argp != NULL) {
|
|
|
|
|
argv[argc++] = argp;
|
|
|
|
|
}
|
|
|
|
|
// 否则,将RxLen设置为0,并返回
|
|
|
|
|
else {
|
|
|
|
|
RxLen = 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 遍历DebugFun数组,查找argv[0]是否与DBGCmd匹配,若匹配则调用DBGExec函数
|
|
|
|
|
for(int i = 0; i < DEBUG_CMD_CNT; i++) {
|
|
|
|
|
if(strcmp(argv[0], DebugFun[i].DBGCmd) == 0)
|
|
|
|
|
DebugFun[i].DBGExec(argc, argv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(RxBuff, 0x00, 128);
|
|
|
|
|
RxLen = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 函数:Debug1mSRoutine
|
|
|
|
|
// 功能:1ms调试时钟routine
|
|
|
|
|
void Debug1mSRoutine(void)
|
|
|
|
|
{
|
|
|
|
|
// 如果1ms调试时钟计数器大于0
|
|
|
|
|
if(RxRevTimeOutCnt > 0)
|
|
|
|
|
// 1ms调试时钟计数器减1
|
|
|
|
|
RxRevTimeOutCnt--;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 定义函数DebugUartIRQ,用于处理串口接收中断
|
|
|
|
|
void DebugUartIRQ(uint8_t Data)
|
|
|
|
|
{
|
|
|
|
|
// 如果1分钟超时计数器为0,则清空RxLen
|
|
|
|
|
if(RxRevTimeOutCnt == 0)
|
|
|
|
|
RxLen = 0;
|
|
|
|
|
|
|
|
|
|
// 重置1分钟超时计数器
|
|
|
|
|
RxRevTimeOutCnt = 3;
|
|
|
|
|
// 如果RxLen小于128,则将数据添加到RxBuff中
|
|
|
|
|
if(RxLen < 128) {
|
|
|
|
|
RxBuff[RxLen++] = Data;
|
|
|
|
|
}
|
|
|
|
|
// DBG_LOG("RxBuff = %s\n", RxBuff);
|
|
|
|
|
// RS485_Flag=1;//接收标志为置1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
extern uint8_t LocalMAC[6]; //本机MAC地址
|
|
|
|
|
extern uint8_t GatewayMAC[6]; //网关MAC地址,注册时全为0
|
|
|
|
|
extern uint32_t LocalType;
|
|
|
|
|
extern uint32_t CommWay;
|
|
|
|
|
extern uint32_t DeviceSign;
|
|
|
|
|
extern uint32_t AddNumber;
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdGetPara
|
|
|
|
|
* 功能描述: 查看参数
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdGetPara(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc > 1) {
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: para\r\n");
|
|
|
|
|
DBG_LOG(" brief --> View gateway parameters.\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
DBG_LOG("\r\n**********************************************************\r\n");
|
|
|
|
|
DBG_LOG("SoftWare V:%d.%d, HardWare V:%d.%d\r\n", SOFTWARE_VERSION / 10, SOFTWARE_VERSION % 10, HARDWARE_VERSION / 10, HARDWARE_VERSION % 10);
|
|
|
|
|
DBG_LOG("Local MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
|
|
|
|
LocalMAC[0], LocalMAC[1], LocalMAC[2], LocalMAC[3], LocalMAC[4], LocalMAC[5]);
|
|
|
|
|
DBG_LOG("Battery: %d%\r\n", VBAT_Percentage);
|
|
|
|
|
DBG_LOG("LocalType: %04X\r\n", LocalType);
|
|
|
|
|
DBG_LOG("CommInf: %s\r\n",
|
|
|
|
|
(CommWay == LORA) ? "Lora" :
|
|
|
|
|
(CommWay == RS485) ? "RS485" :
|
|
|
|
|
(CommWay == RS232) ? "RS232" :
|
|
|
|
|
(CommWay == CAN) ? "CAN" :
|
|
|
|
|
(CommWay == CATONE) ? "CATONE" :
|
|
|
|
|
(CommWay == BLE) ? "BLE" :
|
|
|
|
|
(CommWay == WIFI) ? "WIFI" :
|
|
|
|
|
(CommWay == UART) ? "UART" :
|
|
|
|
|
"NULL");
|
|
|
|
|
DBG_LOG("DeviceSign: %s\r\n",
|
|
|
|
|
(DeviceSign == MASTER) ? "MASTER" :
|
|
|
|
|
(DeviceSign == SUBSET) ? "SUBSET" :
|
|
|
|
|
"NULL");
|
|
|
|
|
|
|
|
|
|
DBG_LOG("GateWay MAC: %02X-%02X-%02X-%02X-%02X-%02X\r\n",
|
|
|
|
|
GatewayMAC[0], GatewayMAC[1], GatewayMAC[2], GatewayMAC[3], GatewayMAC[4], GatewayMAC[5]);
|
|
|
|
|
DBG_LOG("Register Status: %d\r\n", SGCP.LoginOk);
|
|
|
|
|
|
|
|
|
|
DBG_LOG("RS485h1: %s, ",(App.Para.Rs485Ch1.Enable == true) ? "Enable" : "Disable");
|
|
|
|
|
DBG_LOG("Upgrade %s, ",(App.Para.Rs485Ch1.UpgradeEnable == true) ? "Enable" : "Disable");
|
|
|
|
|
DBG_LOG("Addr %02X, Baudrate %d\r\n",App.Para.Rs485Ch1.Addr, App.Para.Rs485Ch1.BaudRate);
|
|
|
|
|
DBG_LOG("RS485h2: %s, ",(App.Para.Rs485Ch2.Enable == true) ? "Enable" : "Disable");
|
|
|
|
|
DBG_LOG("Upgrade %s, ",(App.Para.Rs485Ch2.UpgradeEnable == true) ? "Enable" : "Disable");
|
|
|
|
|
DBG_LOG("Addr %02X, Baudrate %d\r\n",App.Para.Rs485Ch2.Addr, App.Para.Rs485Ch2.BaudRate);
|
|
|
|
|
|
|
|
|
|
DBG_LOG("Lora: ch %d, rp %d, fc %d\r\n", App.Para.Lora.ucChannel, App.Para.Lora.RegPreamble, App.Para.Lora.FreqCent);
|
|
|
|
|
DBG_LOG("LpCfg: CI:%dsec, RI:%dmin, EI:%dmin, ET:%dmin\r\n",
|
|
|
|
|
App.Para.Layout.CollectTime*30, App.Para.Layout.ReportInterval/2, App.Para.Layout.ERInterval/2, App.Para.Layout.ERTime/2);
|
|
|
|
|
struct tm *stime;
|
|
|
|
|
uint32_t dwStamp = TimeTs();
|
|
|
|
|
stime = localtime(&dwStamp);
|
|
|
|
|
DBG_LOG("%d/",stime->tm_year + 1900);
|
|
|
|
|
DBG_LOG("%d/",stime->tm_mon + 1);
|
|
|
|
|
DBG_LOG("%d-",stime->tm_mday);
|
|
|
|
|
DBG_LOG("%d:",stime->tm_hour);
|
|
|
|
|
DBG_LOG("%d:",stime->tm_min);
|
|
|
|
|
DBG_LOG("%d\r\n",stime->tm_sec);
|
|
|
|
|
DBG_LOG("**********************************************************\r\n");
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdMainOnOff
|
|
|
|
|
* 功能描述: 主调试信息开关
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdMainOnOff(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: main arg1\r\n");
|
|
|
|
|
DBG_LOG(" brief --> Turn the Main_DBG on or off.\r\n");
|
|
|
|
|
DBG_LOG(" arg1 --> on/off\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "on") == 0) {
|
|
|
|
|
MainDBGOnOff(true);
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[1], "off") == 0) {
|
|
|
|
|
MainDBGOnOff(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdDataOnOff
|
|
|
|
|
* 功能描述: 数据调试信息开关
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdDataOnOff(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: data arg1\r\n");
|
|
|
|
|
DBG_LOG(" brief --> Turn the Data_DBG on or off.\r\n");
|
|
|
|
|
DBG_LOG(" arg1 --> on/off\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "on") == 0) {
|
|
|
|
|
DataDBGOnOff(true);
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[1], "off") == 0) {
|
|
|
|
|
DataDBGOnOff(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdSetMac
|
|
|
|
|
* 功能描述: 设置MAC地址
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdSetMac(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
uint8_t mac[6];
|
|
|
|
|
|
|
|
|
|
if(argc < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
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 --> password\r\n");
|
|
|
|
|
DBG_LOG(" arg2 --> mac(xx-xx-xx-xx-xx-xx)\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "gxjt") != 0) {
|
|
|
|
|
DBG_LOG("Password Error\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int ret = sscanf(argv[2], "%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)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
memcpy(LocalMAC, mac, 6);
|
|
|
|
|
SAVE_APP_PARA((uint32_t *)&App.Para);
|
|
|
|
|
DBG_LOG("Set gateway mac Address completed.\r\n");
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdDevReg
|
|
|
|
|
* 功能描述: 设备申请注册
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdDevReg(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc > 1)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: reg\r\n");
|
|
|
|
|
DBG_LOG(" brief --> Initiate a registration request to the gateway.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG_LOG("In the registration request.\r\n");
|
|
|
|
|
SGCP.LoginOk = false;
|
|
|
|
|
App.LoginFlag = true;
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdDataUpload
|
|
|
|
|
* 功能描述: 设备数据上传
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdDataUpload(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc > 1)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: up\r\n");
|
|
|
|
|
DBG_LOG(" brief --> Upload the current data to the gateway.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(SGCP.LoginOk == false)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("The device is not registered.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(App.UpdateOk == false)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("Device data is not ready.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
DBG_LOG("Uploading data to the gateway.\r\n");
|
|
|
|
|
App.UploadFlag = true;
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdDataColl
|
|
|
|
|
* 功能描述: 设备数据采集
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdDataColl(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc > 1)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: coll\r\n");
|
|
|
|
|
DBG_LOG(" brief --> Collect the current device data.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG_LOG("Data collection of device.\r\n");
|
|
|
|
|
SGCP.TimingAcquisition = true;
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdCat1OnOff
|
|
|
|
|
* 功能描述: CAT1调试信息开关
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
void DebugCmdRS485Ctrl(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: rs485 arg1 arg2 arg3\r\n");
|
|
|
|
|
DBG_LOG(" brief --> RS485 control command.\r\n");
|
|
|
|
|
DBG_LOG(" arg1 --> idx: (1, 2) RS485 channel selection.\r\n");
|
|
|
|
|
DBG_LOG(" arg2 --> scmd:(o, a, b, u)Rs485 subcommand.\r\n");
|
|
|
|
|
DBG_LOG(" scmd = o, arg3 = (on, off) RS485 Channel On-OFF.\r\n");
|
|
|
|
|
DBG_LOG(" scmd = a, arg3 = (1~16) Set 485 address.\r\n");
|
|
|
|
|
DBG_LOG(" scmd = b, arg3 = (2400~9600) Set baud rate.\r\n");
|
|
|
|
|
DBG_LOG(" scmd = u, arg3 = (on, off) Set Upgrade symbol.\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int idx = atoi(argv[1]);
|
|
|
|
|
if(idx < 1 || idx > 2) {
|
|
|
|
|
DBG_LOG("RS485 Cmd Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char scmd = argv[2][0];
|
|
|
|
|
switch(scmd) {
|
|
|
|
|
case 'o':
|
|
|
|
|
if(strstr(argv[3], "on") != NULL) {
|
|
|
|
|
if(idx == 1)
|
|
|
|
|
App.Para.Rs485Ch1.Enable = true;
|
|
|
|
|
else if(idx == 2)
|
|
|
|
|
App.Para.Rs485Ch2.Enable = true;
|
|
|
|
|
DBG_LOG("RS485Ch%d Enable!\r\n", idx);
|
|
|
|
|
}
|
|
|
|
|
else if(strstr(argv[3], "off") != NULL){
|
|
|
|
|
if(idx == 1)
|
2026-07-14 18:16:53 +08:00
|
|
|
App.Para.Rs485Ch1.Enable = false;
|
2026-07-13 14:30:13 +08:00
|
|
|
else if(idx == 2)
|
|
|
|
|
App.Para.Rs485Ch2.Enable = false;
|
|
|
|
|
DBG_LOG("RS485Ch%d Disable!\r\n", idx);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'a':{
|
|
|
|
|
int Addr = atoi(argv[3]);
|
|
|
|
|
if(idx == 1) {
|
|
|
|
|
if(Addr > 16 || Addr < 1)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("RS485Ch%d set addr is %d err!\r\n",idx, Addr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
App.Para.Rs485Ch1.Addr = Addr;
|
|
|
|
|
DBG_LOG("RS485Ch%d set addr %d ok!\r\n", idx, App.Para.Rs485Ch1.Addr);
|
|
|
|
|
}
|
|
|
|
|
else if(idx == 2) {
|
|
|
|
|
if(Addr > 16 || Addr < 1)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("RS485Ch%d set addr is %d err!\r\n",idx, Addr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
App.Para.Rs485Ch2.Addr = Addr;
|
|
|
|
|
DBG_LOG("RS485Ch%d set addr %d ok!\r\n", idx, App.Para.Rs485Ch2.Addr);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'b': {
|
|
|
|
|
int BaudRate = atoi(argv[3]);
|
|
|
|
|
if(idx == 1) {
|
|
|
|
|
if(App.Para.Rs485Ch1.UpgradeEnable == true)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("Upgrade the serial port to prohibit modification of the baud rate!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(BaudRate > 9600 || BaudRate < 2400)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("RS485Ch%d BaudRate is %d err!\r\n",idx, BaudRate);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
App.Para.Rs485Ch1.BaudRate = BaudRate;
|
|
|
|
|
LpUart0Init(App.Para.Rs485Ch1.BaudRate);
|
|
|
|
|
DBG_LOG("RS485Ch%d Set BaudRate %d!\r\n", idx, App.Para.Rs485Ch1.BaudRate);
|
|
|
|
|
}
|
|
|
|
|
else if(idx == 2) {
|
|
|
|
|
if(App.Para.Rs485Ch2.UpgradeEnable == true)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("Upgrade the serial port to prohibit modification of the baud rate!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if(BaudRate > 500000 || BaudRate < 2400)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("RS485Ch%d BaudRate is %d err!\r\n",idx, BaudRate);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
App.Para.Rs485Ch2.BaudRate = BaudRate;
|
|
|
|
|
//Uart0Init(App.Para.Rs485Ch2.BaudRate);
|
|
|
|
|
DBG_LOG("RS485Ch%d Set BaudRate %d!\r\n", idx, App.Para.Rs485Ch2.BaudRate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'u':
|
|
|
|
|
if(strstr(argv[3], "on") != NULL) {
|
|
|
|
|
if(idx == 1) {
|
|
|
|
|
App.Para.Rs485Ch1.UpgradeEnable = true;
|
|
|
|
|
DBG_LOG("RS485Ch%d Upgrade On!\r\n", idx);
|
|
|
|
|
}
|
|
|
|
|
else if(idx == 2) {
|
|
|
|
|
App.Para.Rs485Ch2.UpgradeEnable = true;
|
|
|
|
|
DBG_LOG("RS485Ch%d Upgrade On!\r\n", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(strstr(argv[3], "off") != NULL){
|
|
|
|
|
if(idx == 1) {
|
|
|
|
|
if(App.Para.Rs485Ch2.UpgradeEnable == false)
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("At least keep one upgraded serial port!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-07-14 18:16:53 +08:00
|
|
|
App.Para.Rs485Ch1.UpgradeEnable = false;
|
2026-07-13 14:30:13 +08:00
|
|
|
DBG_LOG("RS485Ch%d Upgrade Off!\r\n", idx);
|
|
|
|
|
}
|
|
|
|
|
else if(idx == 2) {
|
2026-07-14 18:16:53 +08:00
|
|
|
if(App.Para.Rs485Ch1.UpgradeEnable == false)
|
2026-07-13 14:30:13 +08:00
|
|
|
{
|
|
|
|
|
DBG_LOG("At least keep one upgraded serial port!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
App.Para.Rs485Ch2.UpgradeEnable = false;
|
|
|
|
|
DBG_LOG("RS485Ch%d Upgrade Off!\r\n", idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
DBG_LOG("RS485 Cmd Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SAVE_APP_PARA((uint32_t *)&App.Para);
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugLoraConfig
|
|
|
|
|
* 功能描述: Lora参数配置
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugLoraConfig(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
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");
|
|
|
|
|
DBG_LOG(" bw: SignalBw--para=(0~9)\r\n");
|
|
|
|
|
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");
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "o") == 0) {
|
|
|
|
|
if(strcmp(argv[2], "on") == 0) {
|
|
|
|
|
App.Para.Lora.OnOff = true;
|
|
|
|
|
//LORA_POW_ON();
|
|
|
|
|
DBG_LOG(" Lora Power On!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[2], "off") == 0) {
|
|
|
|
|
App.Para.Lora.OnOff = false;
|
|
|
|
|
//LORA_POW_OFF();
|
|
|
|
|
DBG_LOG(" Lora Power Off!\r\n");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "ch") == 0) {
|
|
|
|
|
int ch = atoi(argv[2]);
|
|
|
|
|
if(LoraSetChannel(ch)) {
|
|
|
|
|
App.Para.Lora.ucChannel = ch;
|
|
|
|
|
DBG_LOG(" Lora Channel is configured successfully!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DBG_LOG("Lora Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "pw") == 0) {
|
|
|
|
|
int pow = atoi(argv[2]);
|
|
|
|
|
if(LoraSetPower(pow)) {
|
|
|
|
|
App.Para.Lora.ucPower = pow;
|
|
|
|
|
DBG_LOG(" Lora Power is configured successfully!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DBG_LOG("Lora Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "bw") == 0) {
|
|
|
|
|
int bw = atoi(argv[2]);
|
|
|
|
|
if(LoraSetSignalBw(bw)) {
|
|
|
|
|
App.Para.Lora.SignalBw = bw;
|
|
|
|
|
DBG_LOG(" Lora SignalBw is configured successfully!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DBG_LOG("Lora Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "sf") == 0) {
|
|
|
|
|
int sf = atoi(argv[2]);
|
|
|
|
|
if(LoraSetSpreadFactor(sf)) {
|
|
|
|
|
App.Para.Lora.SpreadFactor = sf;
|
|
|
|
|
DBG_LOG(" Lora SpreadFactor is configured successfully!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DBG_LOG("Lora Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "ec") == 0) {
|
|
|
|
|
int ec = atoi(argv[2]);
|
|
|
|
|
if(LoraSetErrorCoding(ec)) {
|
|
|
|
|
App.Para.Lora.ErrorCoding = ec;
|
|
|
|
|
DBG_LOG(" Lora ErrorCoding is configured successfully!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DBG_LOG("Lora Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "rp") == 0) {
|
|
|
|
|
int rp = atoi(argv[2]);
|
|
|
|
|
if(LoraSetRegPreamble(rp)) {
|
|
|
|
|
App.Para.Lora.RegPreamble = rp;
|
|
|
|
|
DBG_LOG(" Lora RegPreamble is configured successfully!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DBG_LOG("Lora Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(strcmp(argv[1], "fc") == 0){
|
|
|
|
|
uint32_t fc = atoi(argv[2]);
|
|
|
|
|
if(LoraSetFreqCent(fc)) {
|
|
|
|
|
App.Para.BLPara.LoraFreq = fc;
|
|
|
|
|
App.Para.Lora.FreqCent = fc;
|
|
|
|
|
DBG_LOG(" Lora FreqCent is configured successfully!\r\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
DBG_LOG("Lora Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(App.Para.Lora.OnOff == true)
|
|
|
|
|
{
|
|
|
|
|
LoraInit();
|
|
|
|
|
SGCP.LoginOk = false;
|
|
|
|
|
App.LoginFlag = true;
|
|
|
|
|
}
|
|
|
|
|
SAVE_APP_PARA((uint32_t *)&App.Para);
|
|
|
|
|
DBG_LOG("Lora reinitializes.\r\n");
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdLPConfig
|
|
|
|
|
* 功能描述: 低功耗参数配置
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdLPConfig(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
uint16_t CollectInterval; //采集时间间隔
|
|
|
|
|
uint16_t ReportInterval; //上报时间间隔
|
|
|
|
|
uint8_t ERInterval; //紧急上报时间间隔
|
|
|
|
|
uint8_t ERTime; //紧急上报时长
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: lpcfg arg1 arg2 arg3 arg4\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");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(argc < 5)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CollectInterval = atoi(argv[1]);
|
|
|
|
|
if(CollectInterval < 30 || CollectInterval > 7200) {
|
|
|
|
|
DBG_LOG("CollectInterval Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ReportInterval = atoi(argv[2]);
|
|
|
|
|
if(ReportInterval < 5 || ReportInterval > 720) {
|
|
|
|
|
DBG_LOG("ReportInterval Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERInterval = atoi(argv[3]);
|
|
|
|
|
if(ERInterval < 1 || ERInterval > 5) {
|
|
|
|
|
DBG_LOG("ERInterval Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERTime = atoi(argv[4]);
|
|
|
|
|
if(ERTime < 10 || ERTime > 120) {
|
|
|
|
|
DBG_LOG("ERTime Para Error!\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
App.Para.Layout.CollectTime = CollectInterval/30;
|
|
|
|
|
App.Para.Layout.ReportInterval = ReportInterval * 2;
|
|
|
|
|
App.Para.Layout.ERInterval = ERInterval * 2;
|
|
|
|
|
App.Para.Layout.ERTime = ERTime * 2;
|
|
|
|
|
|
|
|
|
|
SAVE_APP_PARA((uint32_t *)&App.Para);
|
|
|
|
|
DBG_LOG("The low-power device is configured.\r\n");
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugLaserConfig
|
|
|
|
|
* 功能描述: 激光控制
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugLaserConfig(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc < 2)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: laser arg1\r\n");
|
|
|
|
|
DBG_LOG(" brief --> Control laser on or off.\r\n");
|
|
|
|
|
DBG_LOG(" arg1 --> on/off\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "on") == 0) {
|
|
|
|
|
DBG_LOG("The laser has been activated.\r\n");
|
|
|
|
|
SGCP.LaserOnOff = true;
|
|
|
|
|
SGCP.GWStatus = GW_STATUS_LASER_STARES;
|
|
|
|
|
}
|
|
|
|
|
else if(strcmp(argv[1], "off") == 0) {
|
|
|
|
|
DBG_LOG("The laser has been turned off.\r\n");
|
|
|
|
|
SGCP.LaserOnOff = false;
|
|
|
|
|
SGCP.GWStatus = GW_STATUS_LASER_STARES;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdRestoreFactory
|
|
|
|
|
* 功能描述: 恢复出厂设置
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
void DebugCmdRestoreFactory(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: res arg1\r\n\
|
|
|
|
|
brief --> Restore to factory.\r\n");
|
|
|
|
|
DBG_LOG(" arg1 --> password\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "gxjt") != 0) {
|
|
|
|
|
DBG_LOG("Password Error\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG_LOG("Restore factory settings, Device Restart...\r\n");
|
|
|
|
|
App.Para.FactoryFlag = 0xFF;
|
|
|
|
|
SAVE_APP_PARA((uint32_t *)&App.Para);
|
|
|
|
|
delay_ms(1000);
|
|
|
|
|
SystemReset();
|
|
|
|
|
while(1);
|
|
|
|
|
}
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* 函数名称: DebugCmdReboot
|
|
|
|
|
* 功能描述: 设备重启
|
|
|
|
|
* 参 数: argc, 输入参数数量
|
|
|
|
|
argv, 输入参数
|
|
|
|
|
* 返 回 值: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdChannel(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc < 2 || strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: dch\r\n\
|
|
|
|
|
brief --> Switch debug output channel.\r\n\
|
|
|
|
|
dch dbg --> Debug output via UART0 (default)\r\n\
|
|
|
|
|
dch ch1 --> Debug output via RS485_1 (LPUART0)\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(strcmp(argv[1], "dbg") == 0) {
|
|
|
|
|
gDebugChannel = DBG_CH_UART0;
|
|
|
|
|
DBG_LOG("Debug channel switched to UART0\r\n");
|
|
|
|
|
} else if(strcmp(argv[1], "ch1") == 0) {
|
|
|
|
|
gDebugChannel = DBG_CH_RS485_1;
|
|
|
|
|
DBG_LOG("Debug channel switched to RS485_1\r\n");
|
|
|
|
|
} else {
|
|
|
|
|
DBG_LOG("Unknown channel: %s\r\nUse 'dch ?' for help\r\n", argv[1]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void DebugCmdReboot(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: reboot\r\n\
|
|
|
|
|
brief --> System Reboot.\r\n\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DBG_LOG("Device Reboot...\r\n");
|
|
|
|
|
delay_ms(1000);
|
|
|
|
|
SystemReset();
|
|
|
|
|
while(1);
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-14 10:13:17 +08:00
|
|
|
|
|
|
|
|
/*****************************************************************************************
|
|
|
|
|
* Function: DebugCmdSignal
|
|
|
|
|
* Description: 信号质量查询
|
|
|
|
|
* Input: argc, 参数个数
|
|
|
|
|
argv, 参数列表
|
|
|
|
|
* Output: 无
|
|
|
|
|
*****************************************************************************************/
|
|
|
|
|
static void DebugCmdSignal(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
if(argc > 1)
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(argv[1], "?") == 0) {
|
|
|
|
|
DBG_LOG("Debug Cmd: sig\r\n");
|
|
|
|
|
DBG_LOG(" brief --> Query signal quality with gateway.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(SGCP.GWStatus != GW_STATUS_IDLE) {
|
|
|
|
|
DBG_LOG("Device is busy, please try again later.\r\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
SGCP.GWStatus = GW_STATUS_SIGNAL;
|
|
|
|
|
}
|
2026-07-13 14:30:13 +08:00
|
|
|
void DebugCmdHelp(int argc, char *argv[])
|
|
|
|
|
{
|
|
|
|
|
DBG_LOG("\r\n");
|
|
|
|
|
char Data[10];
|
|
|
|
|
uint8_t len = 0;
|
|
|
|
|
char *argv1[10]; // 最多10个参数,按需调整
|
|
|
|
|
int argc1 = 0;
|
|
|
|
|
char *token;
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("para ?\0");
|
|
|
|
|
memcpy(Data, "para ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdGetPara(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("main ?\0");
|
|
|
|
|
memcpy(Data, "main ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdMainOnOff(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("data ?\0");
|
|
|
|
|
memcpy(Data, "data ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdDataOnOff(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("mac ?\0");
|
|
|
|
|
memcpy(Data, "mac ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdSetMac(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("reg ?\0");
|
|
|
|
|
memcpy(Data, "reg ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdDevReg(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("up ?\0");
|
|
|
|
|
memcpy(Data, "up ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdDataUpload(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("coll ?\0");
|
|
|
|
|
memcpy(Data, "coll ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdDataColl(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("rs485 ?\0");
|
|
|
|
|
memcpy(Data, "rs485 ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++){
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdRS485Ctrl(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("lora ?\0");
|
|
|
|
|
memcpy(Data, "lora ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugLoraConfig(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("lpcfg ?\0");
|
|
|
|
|
memcpy(Data, "lpcfg ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdLPConfig(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("laser ?\0");
|
|
|
|
|
memcpy(Data, "laser ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugLaserConfig(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("res ?\0");
|
|
|
|
|
memcpy(Data, "res ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdRestoreFactory(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("dch ?\0");
|
|
|
|
|
memcpy(Data, "dch ?\0", len);
|
|
|
|
|
token = strtok(Data, " ");
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdChannel(argc1, argv1);
|
|
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("reboot ?\0");
|
|
|
|
|
memcpy(Data, "reboot ?\0", len);
|
|
|
|
|
token = strtok(Data, " "); // 假设分隔符是空格
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdReboot(argc1, argv1);
|
2026-07-14 10:13:17 +08:00
|
|
|
|
|
|
|
|
memset(Data, 0x00, 10);
|
|
|
|
|
len = strlen("sig ?\0");
|
|
|
|
|
memcpy(Data, "sig ?\0", len);
|
|
|
|
|
token = strtok(Data, " ");
|
|
|
|
|
for(argc1 = 0; (token != NULL && argc1 < 10); argc1++) {
|
|
|
|
|
argv1[argc1] = token;
|
|
|
|
|
token = strtok(NULL, " ");
|
|
|
|
|
}
|
|
|
|
|
DebugCmdSignal(argc1, argv1);
|
2026-07-13 14:30:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
|
|
|
|
|
"help", DebugCmdHelp,
|
|
|
|
|
"para", DebugCmdGetPara,
|
|
|
|
|
"main", DebugCmdMainOnOff,
|
|
|
|
|
"data", DebugCmdDataOnOff,
|
|
|
|
|
"mac", DebugCmdSetMac,
|
|
|
|
|
"reg", DebugCmdDevReg,
|
|
|
|
|
"up", DebugCmdDataUpload,
|
|
|
|
|
"coll", DebugCmdDataColl,
|
|
|
|
|
"rs485", DebugCmdRS485Ctrl,
|
|
|
|
|
"lora", DebugLoraConfig,
|
|
|
|
|
"lpcfg", DebugCmdLPConfig,
|
|
|
|
|
"laser", DebugLaserConfig,
|
|
|
|
|
"res", DebugCmdRestoreFactory,
|
|
|
|
|
"dch", DebugCmdChannel,
|
|
|
|
|
"reboot", DebugCmdReboot,
|
2026-07-14 10:13:17 +08:00
|
|
|
"sig", DebugCmdSignal,
|
2026-07-13 14:30:13 +08:00
|
|
|
};
|
|
|
|
|
#endif
|
|
|
|
|
|