From a31550c604d5d6234671c8771c032254414d181e Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Tue, 10 Mar 2026 09:27:50 +0800 Subject: [PATCH] fix debug mode bugs --- jsonparse/web_cmd_parse3.cpp | 4 +-- uart/uart.cpp | 50 +++++------------------------------- uart/uart.hpp | 1 - uart/uart_feature_parse.cpp | 11 ++++++++ 4 files changed, 20 insertions(+), 46 deletions(-) diff --git a/jsonparse/web_cmd_parse3.cpp b/jsonparse/web_cmd_parse3.cpp index 3f0c53c..96a083e 100644 --- a/jsonparse/web_cmd_parse3.cpp +++ b/jsonparse/web_cmd_parse3.cpp @@ -1481,7 +1481,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){ char whereCon[512] = {0}; char updateSql[256] = {0}; sprintf(whereCon, " MeasurementID = '%s' ", param.measurementID[i].c_str()); - sprintf(updateSql, " status = '%d' ", 1);// 0 未调试,1 调试中,2 调试完成 + sprintf(updateSql, " status = '%d' ", 1);// 0 未调试,1 调试中,2 调试完成,3停止调试 sqlite_db_ctrl::instance().UpdateTableData("t_debug_info", updateSql, whereCon); uint16_t short_addr; char *end_ptr = NULL; @@ -1495,7 +1495,7 @@ std::string JsonData::JsonCmd_Cgi_67(Param_67 ¶m){ char whereCon[512] = {0}; char updateSql[256] = {0}; sprintf(whereCon, " status = '1' "); - sprintf(updateSql, " status = '%d' ", 0);// 0 未调试,1 调试中,2 调试完成 + sprintf(updateSql, " status = '%d' ", 3);// 0 未调试,1 调试中,2 调试完成,3停止调试 sqlite_db_ctrl::instance().UpdateTableData("t_debug_info", updateSql, whereCon); scheduler::instance().CloseDebugMode(); } diff --git a/uart/uart.cpp b/uart/uart.cpp index d2a8e59..1545df2 100644 --- a/uart/uart.cpp +++ b/uart/uart.cpp @@ -591,49 +591,6 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){ memset(whereCon,0,sizeof(whereCon)); sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str()); sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon); - - } - zlog_warn(zct, "count X = %d,Y = %d,Z = %d,vol X = %d,vol Y = %d,vol Z = %d short_add = %s", tempchannel.CountX, tempchannel.CountY, tempchannel.CountZ,tempchannel.CountVolX,tempchannel.CountVolY,tempchannel.CountVolZ,strShortAddr.c_str()); - zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ); - zlog_info(zct, "compress vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.compressChannelVolX, tempchannel.compressChannelVolY, tempchannel.compressChannelVolZ); - zlog_info(zct, "samplerate X = %d,Y = %d,Z = %d ", tempchannel.samplerateX, tempchannel.samplerateY, tempchannel.samplerateZ); - zlog_info(zct, "samplerate vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.samplerateVolX, tempchannel.samplerateVolY, tempchannel.samplerateVolZ); - return 0; -} -int Uart::DealSensorRSSI(const char *pData,uint16_t ushortAdd){ - - //传感器获取网关信号强度 - zlog_info(zct, "DealSensorRSSI ushortAdd = %02x%02x",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); - mssleep(200000); - ScheduleTask scheduleTask; - now_task = WAVE_CMD; - scheduleTask.cmd = WAVE_CMD; - scheduleTask.shortAddr = ushortAdd; - - TaskResp(scheduleTask); - - char localtimestamp[32] = {0}; - GetTimeNet(localtimestamp, 1); - char sensor_rssi[10] = {0x00}; - sprintf(sensor_rssi, "%02d", pData[7] & 0xFF); - if (!strcmp(sensor_rssi, "00") || !strcmp(sensor_rssi, "0")) { - char errorInfo[100] = {0x00}; - sprintf(errorInfo, "No RSSI %s", sensor_rssi); - zlog_error(zct, errorInfo); - } else { - char tableName[100] = {0x00}; - char whereCon[100] = {0}; - char updateSql[100] = {0}; - sprintf(whereCon, "zigbeeShortAddr='%02x%02x'", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); - vec_t vecDataNodeNo = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " MeasurementID,RSSI ", whereCon); - sprintf(tableName, "t_dataStatic_%s", (char *)vecDataNodeNo[0].c_str()); - memset(whereCon,0,sizeof(whereCon)); - sprintf(whereCon, "dataNodeNo='%s' order by timeStamp desc limit 1", vecDataNodeNo[0].c_str()); - std::string timestamp_last = sqlite_db_ctrl::instance().GetData(tableName, " timeStamp ", whereCon); - sprintf(updateSql, "zigbeeSignalNode = '%02d' ",atoi(sensor_rssi)); - memset(whereCon,0,sizeof(whereCon)); - sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),timestamp_last.c_str()); - sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon); if(schedule_status == kScheduleStatusDebug){ memset(whereCon,0,sizeof(whereCon)); memset(updateSql,0,sizeof(updateSql)); @@ -643,9 +600,16 @@ int Uart::DealSensorRSSI(const char *pData,uint16_t ushortAdd){ sprintf(whereCon, "shortAddr = '%02x%02x' ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon); } + } + zlog_warn(zct, "count X = %d,Y = %d,Z = %d,vol X = %d,vol Y = %d,vol Z = %d short_add = %s", tempchannel.CountX, tempchannel.CountY, tempchannel.CountZ,tempchannel.CountVolX,tempchannel.CountVolY,tempchannel.CountVolZ,strShortAddr.c_str()); + zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ); + zlog_info(zct, "compress vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.compressChannelVolX, tempchannel.compressChannelVolY, tempchannel.compressChannelVolZ); + zlog_info(zct, "samplerate X = %d,Y = %d,Z = %d ", tempchannel.samplerateX, tempchannel.samplerateY, tempchannel.samplerateZ); + zlog_info(zct, "samplerate vol X = %d,vol Y = %d,vol Z = %d ", tempchannel.samplerateVolX, tempchannel.samplerateVolY, tempchannel.samplerateVolZ); return 0; } + int Uart::DealUpgrade(uint16_t ushortAdd,int status){ char updateSql[100] = {0}; diff --git a/uart/uart.hpp b/uart/uart.hpp index 68756cc..cff68f7 100644 --- a/uart/uart.hpp +++ b/uart/uart.hpp @@ -188,7 +188,6 @@ public: int DealReviveDuration(uint16_t ushortAdd); int DealConfig(uint16_t ushortAdd); int DealWaveCompress(const char *pData,uint16_t ushortAdd); - int DealSensorRSSI(const char *pData,uint16_t ushortAdd); int DealUpgrade(uint16_t ushortAdd,int status); void GetLocalZigbeeRSSI(uint16_t ushortAdd); int WaveSendCondition(char* shortAddr); diff --git a/uart/uart_feature_parse.cpp b/uart/uart_feature_parse.cpp index faad0f8..96bd7a3 100644 --- a/uart/uart_feature_parse.cpp +++ b/uart/uart_feature_parse.cpp @@ -87,6 +87,17 @@ void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, s sprintf(updateSql,"RSSI = '%f'", comprehensiveRSSI); sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); zlog_info(zct, "dataNodeNo='%s',zigbeeSignal=%d,zigbeeSignalNode=%d,actualRate=%f,comprehensiveRSSI=%f", strLongAddr.c_str(), zigbeeSignal, zigbeeSignalNode, actualRate, comprehensiveRSSI); + if (schedule_status == kScheduleStatusDebug) + { + char localtimestamp[32] = { 0 }; + GetTimeNet(localtimestamp, 1); + memset(updateSql,0,sizeof(updateSql)); + memset(tableName,0,sizeof(tableName)); + sprintf(tableName, "t_debug_info"); + sprintf(updateSql, " comprehensiveRSSI = '%f',minnumVoltage = '%d',status = '2',timeStamp = '%s' ", comprehensiveRSSI,dataStatic.instantaneousBatteryVoltage,localtimestamp); + sqlite_db_ctrl::instance().UpdateTableData(tableName, updateSql, whereCon); + } + } } void Uart::DealTriger(uint16_t ushortAdd,std::string & measurementID){