From 93cc7f69e73612641e7b6bc13c7e947613894e34 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Tue, 6 May 2025 10:07:30 +0800 Subject: [PATCH] fix bugs --- uart/uart.cpp | 42 +++++++++++++++++----------------- uart/uart_parameter_config.cpp | 8 +++---- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/uart/uart.cpp b/uart/uart.cpp index 8e6ca6c..759a6c5 100644 --- a/uart/uart.cpp +++ b/uart/uart.cpp @@ -75,7 +75,7 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) { maxSize = 0; tcflush(fd, TCIOFLUSH); } - zlog_info(zct, "0x8888 ===str_recv===,offSize = %d,ret = %d", offSize,ret); + //zlog_info(zct, "0x9999 ===str_recv===,offSize = %d,ret = %d", offSize,ret); } } else { @@ -351,8 +351,6 @@ int Uart::DealAskTask(uint16_t ushortAdd){ mssleep(50000); UpdateConfig(ushortAdd); } - next_task_id = UPGRADE; - next_duration = 20; if(next_task_id == kScheduleWaveForm){ scheduleTask.cmd = REVIVE_DURATION; scheduleTask.shortAddr = ushortAdd; @@ -363,13 +361,13 @@ int Uart::DealAskTask(uint16_t ushortAdd){ scheduleTask.cmd = REVIVE_DURATION; scheduleTask.shortAddr = ushortAdd; scheduleTask.duration = next_duration; - scheduleTask.next_taskID = next_task_id; + scheduleTask.next_taskID = MEAS_EVAL; TaskResp(scheduleTask); - }else if(next_task_id == UPGRADE){ + }else if(next_task_id == kScheduleUpgrade){ scheduleTask.cmd = REVIVE_DURATION; scheduleTask.shortAddr = ushortAdd; scheduleTask.duration = next_duration; - scheduleTask.next_taskID = next_task_id; + scheduleTask.next_taskID = UPGRADE; TaskResp(scheduleTask); } @@ -434,6 +432,8 @@ int Uart::DealConfig(uint16_t ushortAdd){ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){ zlog_info(zct, "DealWaveCompress "); + ModifyDistAddr(ushortAdd); + mssleep(50000); now_task = WAVE_CMD; WaveResp(ushortAdd); char buf[20] = {0x00}; @@ -874,19 +874,7 @@ void Uart::DealDataNodeInfo(const char *pData) { } } int upgrade = GET_BIT(chTemp, 7); - zlog_info(zct, "upgrade = %d", upgrade); - if (upgrade == 1) - { - sprintf(whereCon, "dataNodeNo='%s'", dataNodeInfo.ZigbeeLongAddr.c_str()); - std::string soft_version = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " softVersion ", whereCon); - if (dataNodeInfo.SoftVersion != soft_version) { - DealUpgrade(ushortAdd,0); - scheduler::instance().UpgradeResult(ushortAdd,0); - }else{ - DealUpgrade(ushortAdd,3); - scheduler::instance().UpgradeResult(ushortAdd,3); - } - } + // 54=》序号25 ACC采样时间 memset(buf, 0, 32); @@ -948,7 +936,8 @@ void Uart::DealDataNodeInfo(const char *pData) { memset(buf, 0, 32); sprintf(buf, "%d", chTemp); dataNodeInfo.VIntegralFilterFrequency = atoi(buf); - + sprintf(whereCon, "dataNodeNo='%s'", dataNodeInfo.ZigbeeLongAddr.c_str()); + std::string soft_version = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " softVersion ", whereCon); sprintf(whereCon, "dataNodeNo='%s'", dataNodeInfo.ZigbeeLongAddr.c_str()); if (sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), whereCon) > 0) { @@ -987,7 +976,18 @@ void Uart::DealDataNodeInfo(const char *pData) { zlog_error(zct, "res = %d", res); } } - + zlog_info(zct, "upgrade = %d", upgrade); + if (upgrade == 1) + { + zlog_info(zct, "soft_version = %s,dataNodeInfo.SoftVersion = %s", soft_version.c_str(),dataNodeInfo.SoftVersion.c_str()); + if (dataNodeInfo.SoftVersion != soft_version) { + DealUpgrade(ushortAdd,2); + scheduler::instance().UpgradeResult(ushortAdd,0); + }else{ + DealUpgrade(ushortAdd,3); + scheduler::instance().UpgradeResult(ushortAdd,3); + } + } Json::Value jsonVal; jsonVal.clear(); jsonVal["cmd"] = "26"; diff --git a/uart/uart_parameter_config.cpp b/uart/uart_parameter_config.cpp index 576072e..f7acdf1 100644 --- a/uart/uart_parameter_config.cpp +++ b/uart/uart_parameter_config.cpp @@ -460,9 +460,9 @@ int Uart::UpdateConfig(uint16_t ushortAdd) { WriteToUart((const char*)UpdateData, 100); int iRet = CheckZigbeeACK(); if (iRet == 0) { - zlog_info(zct, "updataconfig ACK send success,shortAddr = %02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); + zlog_info(zct, "updateconfig ACK send success,shortAddr = %02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); } else { - zlog_warn(zct, "updataconfig ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); + zlog_warn(zct, "updateconfig ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); } mssleep(50000); @@ -643,9 +643,9 @@ int Uart::WaveResp(uint16_t shortAddr){ WriteToUart((const char*)sendData, 8); int iRet = CheckZigbeeACK(); if (iRet == 0) { - zlog_info(zct, "SendReviveDuration ACK send success,shortAddr = %d", shortAddr); + zlog_info(zct, "WaveResp ACK send success,shortAddr = %x", shortAddr); } else { - zlog_warn(zct, "SendReviveDuration ACK send failed,shortAddr = %d", shortAddr); + zlog_warn(zct, "WaveResp ACK send failed,shortAddr = %x", shortAddr); } return iRet; }