Merge branch 'refactor' of http://192.168.0.10:3000/pandx/WLG into refactor

This commit is contained in:
pandx 2024-11-05 17:24:22 +08:00
commit 3894997c4f
4 changed files with 46 additions and 10 deletions

View File

@ -903,7 +903,6 @@ std::string GetGwIp_(const char *eth_name) {
if (host) { if (host) {
strcpy(gwip_, inet_ntoa(host->sin_addr)); strcpy(gwip_, inet_ntoa(host->sin_addr));
} }
zlog_info(zbt, "eth_name :%s, local ip:%s", eth_name, gwip_);
return std::string(gwip_); return std::string(gwip_);
} }

View File

@ -374,7 +374,9 @@ int Uart::DealAskTask(uint16_t ushortAdd){
int next_duration = 0; int next_duration = 0;
int taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration); int taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration);
ScheduleTask scheduleTask; ScheduleTask scheduleTask;
if (taskID == kScheduleEigenValue) //1.特征值 zlog_info(zct, "taskID = %d ", taskID);
// if (taskID == kScheduleEigenValue) //1.特征值
if (taskID == 6)
{ {
char localtimestamp[32] = {0x00}; char localtimestamp[32] = {0x00};
int millisecond = 0; int millisecond = 0;
@ -383,6 +385,7 @@ int Uart::DealAskTask(uint16_t ushortAdd){
scheduleTask.shortAddr = ushortAdd; scheduleTask.shortAddr = ushortAdd;
scheduleTask.timeStamp = atoi(localtimestamp); scheduleTask.timeStamp = atoi(localtimestamp);
TaskResp(scheduleTask); TaskResp(scheduleTask);
return 0;
} }
else if (taskID == kScheduleWaveForm) //2.波形 else if (taskID == kScheduleWaveForm) //2.波形
{ {
@ -407,6 +410,7 @@ int Uart::DealAskTask(uint16_t ushortAdd){
scheduleTask.cmd = REVIVE_DURATION; scheduleTask.cmd = REVIVE_DURATION;
scheduleTask.shortAddr = ushortAdd; scheduleTask.shortAddr = ushortAdd;
scheduleTask.duration = next_duration; scheduleTask.duration = next_duration;
zlog_info(zct, "next_duration = %d ", next_duration);
TaskResp(scheduleTask); TaskResp(scheduleTask);
}else if (taskID == kScheduleConfigSensor) //6.更新配置 }else if (taskID == kScheduleConfigSensor) //6.更新配置
{ {
@ -430,6 +434,7 @@ int Uart::DealReviveDuration(uint16_t ushortAdd){
scheduleTask.cmd = REVIVE_DURATION; scheduleTask.cmd = REVIVE_DURATION;
scheduleTask.shortAddr = ushortAdd; scheduleTask.shortAddr = ushortAdd;
scheduleTask.duration = next_duration; scheduleTask.duration = next_duration;
zlog_info(zct, "next_duration = %d ", next_duration);
TaskResp(scheduleTask); TaskResp(scheduleTask);
return 0; return 0;
} }
@ -1028,11 +1033,41 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
DealDataNodeWave(RecvBuf, command); DealDataNodeWave(RecvBuf, command);
} else if (now_task != WAVE_CMD && (command == ASK_TASK || command == DEVICE_INF || command == MEAS_EVAL || command == CONFIG || command == UPGRADE || command == DEVICE_INF2 || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS)) { } else if (now_task != WAVE_CMD && (command == ASK_TASK || command == DEVICE_INF || command == MEAS_EVAL || command == CONFIG || command == UPGRADE || command == DEVICE_INF2 || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS)) {
char RecvBuf[100] = {0x00}; char RecvBuf[100] = {0x00};
if (command == ASK_TASK )
{
memcpy(RecvBuf, &UartRecvBuf[i], 8);
if (!CheckCrc(RecvBuf, 7)) {
zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
break;
}
}
if (command == WAVE_COMPRESS )
{
memcpy(RecvBuf, &UartRecvBuf[i], 23);
if (!CheckCrc(RecvBuf, 22)) {
zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
break;
}
}
if (command == CONFIG || command == CONFIG_INF2 || command == UPGRADE || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS)
{
memcpy(RecvBuf, &UartRecvBuf[i], 9);
if (!CheckCrc(RecvBuf, 8)) {
zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
break;
}
}
if (command == DEVICE_INF || command == MEAS_EVAL || command == DEVICE_INF2)
{
memcpy(RecvBuf, &UartRecvBuf[i], 100); memcpy(RecvBuf, &UartRecvBuf[i], 100);
if (!CheckCrc(RecvBuf, 99)) { if (!CheckCrc(RecvBuf, 99)) {
zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command); zlog_info(zct, "CheckCrc error ShortAddr :%s command = %d ", strShortAddr.c_str(), command);
break; break;
} }
}
DealRecvData(RecvBuf); DealRecvData(RecvBuf);
} else if (command == 35) { } else if (command == 35) {

View File

@ -23,11 +23,12 @@ enum InteractiveCommand {
WAVE_Z = 7, // 只从传感器发出 WAVE_Z = 7, // 只从传感器发出
REVIVE_DURATION = 8, // 复活时长 REVIVE_DURATION = 8, // 复活时长
CONFIG = 9, // 配置 只从无线网关发出 CONFIG = 9, // 配置 只从无线网关发出
UPGRADE = 10, // 升级, 升级给这条信息 CONFIG_INF2 = 10, // 配置 只从无线网关发出
DEVICE_INF2 = 11, // 测点名称,测点编号 DEVICE_INF2 = 11, // 测点名称,测点编号
SIGNAL_STRENGTH = 12, // 信号强度 UPGRADE = 12, // 升级, 升级给这条信息
DEVICE_EXCEPTION = 13, // 异常: 外设 SIGNAL_STRENGTH = 13, // 信号强度
WAVE_COMPRESS = 14, // 波形数据压缩 DEVICE_EXCEPTION = 14, // 异常: 外设
WAVE_COMPRESS = 15, // 波形数据压缩
}; };
// 无线传感器请求任务 // 无线传感器请求任务
typedef struct { typedef struct {

View File

@ -543,6 +543,7 @@ int Uart::TaskResp(ScheduleTask scheduleTask){
tmp += UpdateData[k]; tmp += UpdateData[k];
} }
UpdateData[99] = tmp; UpdateData[99] = tmp;
mssleep(10000);
WriteToUart((const char*)UpdateData, 100); WriteToUart((const char*)UpdateData, 100);
int iRet = CheckZigbeeACK(); int iRet = CheckZigbeeACK();
if (iRet == 0) { if (iRet == 0) {