From 48eb60ed264b6cb447adfdc89a42993e91bd439a Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Fri, 30 May 2025 18:35:58 +0800 Subject: [PATCH] fix bugs --- scheduler/schedule.cpp | 6 +++--- uart/uart.cpp | 4 ++-- uart/uart_feature_parse.cpp | 18 ++++++++++++++++-- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/scheduler/schedule.cpp b/scheduler/schedule.cpp index fe03a95..465d8ab 100644 --- a/scheduler/schedule.cpp +++ b/scheduler/schedule.cpp @@ -421,16 +421,16 @@ int SensorScheduler::WaveError(uint16_t short_addr) { if (iter == failure_map_.end()) { failure_map_[short_addr] = 3; // 重试次数 zlog_warn(zct, "[WaveError][%x] will try 3 times", short_addr); - return 0; + return 1; } if (iter->second == 0) { zlog_warn(zct, "[WaveError][%x] no try times", short_addr); failure_map_.erase(short_addr); - return -1; + return 3; } iter->second = iter->second - 1; zlog_warn(zct, "[WaveError][%x] remain try %d times", short_addr, iter->second); - return 0; + return 3 - iter->second; } bool SensorScheduler::RetransferWave(uint16_t short_addr) { diff --git a/uart/uart.cpp b/uart/uart.cpp index 8148eda..f7c5a17 100644 --- a/uart/uart.cpp +++ b/uart/uart.cpp @@ -1245,7 +1245,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { } zlog_error(zct, "WaveError error ShortAddr :%s", strShortAddr.c_str()); - sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strChannelID.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg.c_str()); + sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s','' ", strChannelID.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg.c_str()); sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql); @@ -1287,7 +1287,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { } zlog_error(zct, "WaveError error ShortAddr :%s", strShortAddr.c_str()); - sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s' ", strChannelID.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg.c_str()); + sprintf(insertSql, "'%s','%s','%s',%d,'%d','%s','' ", strChannelID.c_str(),strShortAddr.c_str(),localtimestamp,bytesRead,0,error_msg.c_str()); sqlite_db_ctrl::instance().InsertData(" receive_wave_status ", insertSql); JsonData jd; diff --git a/uart/uart_feature_parse.cpp b/uart/uart_feature_parse.cpp index a64e7c3..b47ec58 100644 --- a/uart/uart_feature_parse.cpp +++ b/uart/uart_feature_parse.cpp @@ -862,7 +862,14 @@ void Uart::DealWave() { (vecDataY.size() <= 0 && g_mapCompress[strShortAddr].CountY > 0) || (vecDataZ.size() <= 0 && g_mapCompress[strShortAddr].CountZ > 0)) { - scheduler::instance().WaveError(wave_shortAddr); + int iRet = scheduler::instance().WaveError(wave_shortAddr); + if (iRet != 0) { + memset(whereCon, 0x00, sizeof(whereCon)); + char updateSql[1024] = { 0 }; + sprintf(updateSql, "resend = '%d'", iRet); + sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp); + sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon); + } }else if ((vecDataX.size() > 0 && g_mapCompress[strShortAddr].CountX > 0) || (vecDataY.size() > 0 && g_mapCompress[strShortAddr].CountY > 0) || (vecDataZ.size() > 0 && g_mapCompress[strShortAddr].CountZ > 0)) @@ -879,7 +886,14 @@ void Uart::DealWave() { if (g_mapCompress[strShortAddr].CountX <= 0 && g_mapCompress[strShortAddr].CountY <= 0 && g_mapCompress[strShortAddr].CountZ <= 0) { - scheduler::instance().WaveError(wave_shortAddr); + int iRet = scheduler::instance().WaveError(wave_shortAddr); + if (iRet != 0) { + memset(whereCon, 0x00, sizeof(whereCon)); + char updateSql[1024] = { 0 }; + sprintf(updateSql, "resend = '%d'", iRet); + sprintf(whereCon, "short_addr='%02x%02x' and timestamp = '%s'", (wave_shortAddr >> 8) & 0xFF,wave_shortAddr & 0xFF,localtimestamp); + sqlite_db_ctrl::instance().UpdateTableData(" receive_wave_status ", updateSql, whereCon); + } } g_mapCompress[strShortAddr].CountX = 0;