This commit is contained in:
zhangsheng 2025-05-30 18:31:15 +08:00
parent 8bc249ba03
commit f50c3e35de
5 changed files with 33 additions and 11 deletions

View File

@ -21,7 +21,7 @@ enum enumZigBeeTransmitStatus {
//#define Q4G_MODULE
//#define WIFI_MODULE
//#define NR5G_MEIGE
//#define BLUETEETH_MODULE
#define BLUETEETH_MODULE
class GlobalConfig

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

@ -865,7 +865,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))
@ -881,7 +888,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;
g_mapCompress[strShortAddr].CountY = 0;

View File

@ -176,11 +176,19 @@ void ScanBlueteeth::ParseData(unsigned char *data, int len,int8_t rssi){
//printf("time %s Bluetooth temp :%f ℃ , NST 1001 temp: %f ℃\n",GetCurrentTime().c_str(),(float)temp*0.01, ((float)temp1*0.0625) - 50.0625);
//printf(" volt : %f v\n", (double)volt * 0.03125 );
char insertSql[512] = {0};
char insertSql[512] = {0},whereCon[128] = {0};
char localtimestamp[32] = {0};
memset(whereCon,0,sizeof(whereCon));
sprintf(whereCon, "mac='%s' order by timeStamp desc limit 1", mac);
std::string timestamp_last = sqlite_db_ctrl::instance().GetData(" blueteeth_info ", " timeStamp ", whereCon);
GetTimeNet(localtimestamp, 1);
if (atol(localtimestamp) - atol(timestamp_last.c_str()) < 10) {
zlog_info(zct, "blueteeth_info already exist, mac = %s, timeStamp = %s", mac, timestamp_last.c_str());
return;
} else {
sprintf(insertSql,"'%s','%s','%d',%d,'%.1f','%.1f','%.1f','%.1f','%s'",device_id,mac,rssi,count,volt_,blueteeth_temp,chip_temp,env_temp,localtimestamp);
sqlite_db_ctrl::instance().InsertData(" blueteeth_info ", insertSql);
}
return;
}
}