This commit is contained in:
zhangsheng 2025-05-30 18:35:58 +08:00
parent f406bd903a
commit 48eb60ed26
3 changed files with 21 additions and 7 deletions

View File

@ -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) {

View File

@ -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;

View File

@ -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;