fix sensor online bugs

This commit is contained in:
zhangsheng 2024-11-16 18:05:12 +08:00
parent 424cad8755
commit 5b3ada1974
2 changed files with 7 additions and 3 deletions

View File

@ -601,7 +601,6 @@ void Uart::DealDataNodeName(const char *pData) {
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), vecRes[i][1].c_str());
sqlite_db_ctrl::instance().DeleteTableData(T_DATA_INFO(TNAME), whereCon);
sqlite_db_ctrl::instance().DeleteTableData(T_DATASTATIC_INFO(TNAME), whereCon);
sqlite_db_ctrl::instance().DeleteTableData(T_DATANODE_TIME(TNAME), whereCon);
sqlite_db_ctrl::instance().DeleteTableData(T_BATTERY_INFO(TNAME), whereCon);
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
memset(whereCon,0,sizeof(whereCon));
@ -613,7 +612,10 @@ void Uart::DealDataNodeName(const char *pData) {
memset(szTableName, 0x00, sizeof(szTableName));
sprintf(szTableName, "DROP TABLE t_dataStatic_%s", vecRes[i][1].c_str());
sqlite_db_ctrl::instance().CreateTable(szTableName);
scheduler::instance().ClearScheduleCfg(atoi(szShortAdd));
uint16_t short_addr;
char *end_ptr = NULL;
short_addr = strtol(szShortAdd, &end_ptr, 16);
scheduler::instance().ClearScheduleCfg(short_addr);
}
}
@ -623,6 +625,8 @@ void Uart::DealDataNodeName(const char *pData) {
if ((hardVersion == "3.0" && compareVersions(softVersion, "3.6") == -1) || (hardVersion == "4.0" && compareVersions(softVersion, "4.6") == -1)|| (hardVersion == "1.0" && compareVersions(softVersion,"1.2") == -1)) {
memcpy(MeasurementID, vecRes[0][0].c_str(), sizeof(MeasurementID));
}
memset(whereCon,0,sizeof(whereCon));
sprintf(whereCon, "zigbeeShortAddr='%s'", szShortAdd);
std::string strNodeName(NodeName);
zlog_info(zct, "strNodeName = %s", strNodeName.c_str());
solve(gbkNodeName, NodeName);

View File

@ -50,7 +50,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
GetTimeNet(localtimestamp, 1);
char insertSql[100] = {0};
char wherecon[50] = {0};
sprintf(wherecon," short_Addr = '%02x%02x' order by start_timestamp DESC",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
sprintf(wherecon," short_Addr = '%02x%02x' and status = 3 order by start_timestamp DESC",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
std::string spend_count = sqlite_db_ctrl::instance().GetData(" firmware_upgrade ","spend_count",wherecon);
if (atoi(spend_count.c_str()) >= 10){
zlog_warn(zbt, "UpdateWirelessNode spend_count %d,shortAddr = %02x%02x", atoi(spend_count.c_str()), UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));