This commit is contained in:
zhangsheng 2025-03-19 17:27:36 +08:00
parent f4a6f79f73
commit 072cd7fd7c
2 changed files with 64 additions and 58 deletions

View File

@ -516,69 +516,67 @@ void Uart::DealRecvData(const char *pData) {
zlog_info(zct, "whereCon = %s", whereCon); zlog_info(zct, "whereCon = %s", whereCon);
array_t vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(T_SENSOR_INFO(TNAME), " dataNodeNo, MeasurementID,hardVersion,softVersion", whereCon); array_t vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(T_SENSOR_INFO(TNAME), " dataNodeNo, MeasurementID,hardVersion,softVersion", whereCon);
zlog_info(zct, "vecRes = %d", vecRes.size()); zlog_info(zct, "vecRes = %d", vecRes.size());
if(vecRes.size() == 0){
zlog_warn(zct, "device info not found %02x%02x ", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
return;
}
std::string hardVersion = vecRes[0][2]; std::string hardVersion = vecRes[0][2];
std::string softVersion = vecRes[0][3]; std::string softVersion = vecRes[0][3];
zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command); zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command);
if ((hardVersion == "3.0" && compareVersions(softVersion, "5.0") == -1) || (hardVersion == "4.0" && compareVersions(softVersion, "5.0") == -1)|| (hardVersion == "1.0" && compareVersions(softVersion,"1.2") == -1)) { zlog_info(zct, "hardVersion1 = %s,softVersion2 = %s ",hardVersion.c_str(),softVersion.c_str());
switch (command) {
case DEVICE_INF: switch (command) {
DealDataNodeFeature(pData,0); case DEVICE_INF:
break; DealDataNodeInfo(pData);
default: break; break;
} case DEVICE_INF2:
}else{ DealDataNodeName(pData);
switch (command) { break;
case DEVICE_INF: case ASK_TASK:
DealDataNodeInfo(pData); DealAskTask(ushortAdd);
break; break;
case DEVICE_INF2: case DEVICE_EXCEPTION:
DealDataNodeName(pData); DealException(pData);
break; break;
case ASK_TASK: case MEAS_EVAL:
DealAskTask(ushortAdd); DealDataNodeFeature(pData, 0);
break; DealReviveDuration(ushortAdd);
case DEVICE_EXCEPTION: break;
DealException(pData); case UPGRADE:
break; if (recvcode == 0){
case MEAS_EVAL: DealUpgrade(ushortAdd,2);
DealDataNodeFeature(pData, 0); scheduler::instance().UpgradeResult(ushortAdd,0);
zlog_info(zbt, "[UPGRADE SUCCESS] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
}else if (recvcode == 5)
{
DealUpgrade(ushortAdd,2);
scheduler::instance().UpgradeResult(ushortAdd,0);
zlog_warn(zbt, "[UPGRADE ALREADY] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
}else
{
DealUpgrade(ushortAdd,3);
scheduler::instance().UpgradeResult(ushortAdd,recvcode);
zlog_warn(zbt, "[UPGRADE FAILED] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
}
break;
case CONFIG:
if (recvcode == 0){
DealReviveDuration(ushortAdd); DealReviveDuration(ushortAdd);
break; DealConfig(ushortAdd);
case UPGRADE: }else{
if (recvcode == 0){ scheduler::instance().UpdateConfigResult(ushortAdd,recvcode);
DealUpgrade(ushortAdd,2); zlog_warn(zbt, "[CONFIG] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
scheduler::instance().UpgradeResult(ushortAdd,0); }
zlog_info(zbt, "[UPGRADE SUCCESS] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode); break;
}else if (recvcode == 5) case WAVE_COMPRESS:
{ DealWaveCompress(pData,ushortAdd);
DealUpgrade(ushortAdd,2); break;
scheduler::instance().UpgradeResult(ushortAdd,0); case SIGNAL_STRENGTH:
zlog_warn(zbt, "[UPGRADE ALREADY] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode); DealSensorRSSI(pData,ushortAdd);
}else break;
{ default: break;
DealUpgrade(ushortAdd,3);
scheduler::instance().UpgradeResult(ushortAdd,recvcode);
zlog_warn(zbt, "[UPGRADE FAILED] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
}
break;
case CONFIG:
if (recvcode == 0){
DealReviveDuration(ushortAdd);
DealConfig(ushortAdd);
}else{
scheduler::instance().UpdateConfigResult(ushortAdd,recvcode);
zlog_warn(zbt, "[CONFIG] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
}
break;
case WAVE_COMPRESS:
DealWaveCompress(pData,ushortAdd);
break;
case SIGNAL_STRENGTH:
DealSensorRSSI(pData,ushortAdd);
break;
default: break;
}
} }
} }
void Uart::DealDataNodeName(const char *pData) { void Uart::DealDataNodeName(const char *pData) {
@ -697,6 +695,13 @@ void Uart::DealDataNodeInfo(const char *pData) {
memset(buf, 0, 32); memset(buf, 0, 32);
sprintf(buf, "%.1f", 0.1 * chTemp); sprintf(buf, "%.1f", 0.1 * chTemp);
dataNodeInfo.HardVersion = std::string(buf); dataNodeInfo.HardVersion = std::string(buf);
zlog_info(zct, "dataNodeInfo.HardVersion = %s", dataNodeInfo.HardVersion.c_str());
if (dataNodeInfo.HardVersion != "3.0" && dataNodeInfo.HardVersion != "4.0" && dataNodeInfo.HardVersion != "1.0") {
DealDataNodeFeatureTransition(pData,0);
zlog_info(zct, "DealDataNodeFeatureTransition");
return;
}
chTemp = pRecvData->Data[10]; //软件版本 1 byte chTemp = pRecvData->Data[10]; //软件版本 1 byte
memset(buf, 0, 32); memset(buf, 0, 32);

View File

@ -1530,6 +1530,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
fTemp = (((~iTemp) & 0xffff) + 1) * (-1); fTemp = (((~iTemp) & 0xffff) + 1) * (-1);
} }
dataStatic.TemBot = fTemp * 0.0625; //设备温度 dataStatic.TemBot = fTemp * 0.0625; //设备温度
fTemp = 0; fTemp = 0;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));