dg101 transition

This commit is contained in:
zhangsheng 2025-03-15 12:00:13 +08:00
parent e59d824ce8
commit f4a6f79f73
3 changed files with 1485 additions and 49 deletions

View File

@ -511,57 +511,73 @@ void Uart::DealRecvData(const char *pData) {
uint8_t command = pData[5] & 0xFF; uint8_t command = pData[5] & 0xFF;
uint8_t recvcode = pData[7] & 0xFF; uint8_t recvcode = pData[7] & 0xFF;
char whereCon[100] = {0};
sprintf(whereCon, "zigbeeShortAddr='%02x%02x'", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
zlog_info(zct, "whereCon = %s", 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());
std::string hardVersion = vecRes[0][2];
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);
switch (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)) {
case DEVICE_INF: switch (command) {
DealDataNodeInfo(pData); case DEVICE_INF:
break; DealDataNodeFeature(pData,0);
case DEVICE_INF2: break;
DealDataNodeName(pData); default: break;
break; }
case ASK_TASK: }else{
DealAskTask(ushortAdd); switch (command) {
break; case DEVICE_INF:
case DEVICE_EXCEPTION: DealDataNodeInfo(pData);
DealException(pData); break;
break; case DEVICE_INF2:
case MEAS_EVAL: DealDataNodeName(pData);
DealDataNodeFeature(pData, 0); break;
DealReviveDuration(ushortAdd); case ASK_TASK:
break; DealAskTask(ushortAdd);
case UPGRADE: break;
if (recvcode == 0){ case DEVICE_EXCEPTION:
DealUpgrade(ushortAdd,2); DealException(pData);
scheduler::instance().UpgradeResult(ushortAdd,0); break;
zlog_info(zbt, "[UPGRADE SUCCESS] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode); case MEAS_EVAL:
}else if (recvcode == 5) DealDataNodeFeature(pData, 0);
{
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);
DealConfig(ushortAdd); break;
}else{ case UPGRADE:
scheduler::instance().UpdateConfigResult(ushortAdd,recvcode); if (recvcode == 0){
zlog_warn(zbt, "[CONFIG] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode); DealUpgrade(ushortAdd,2);
} scheduler::instance().UpgradeResult(ushortAdd,0);
break; zlog_info(zbt, "[UPGRADE SUCCESS] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
case WAVE_COMPRESS: }else if (recvcode == 5)
DealWaveCompress(pData,ushortAdd); {
break; DealUpgrade(ushortAdd,2);
case SIGNAL_STRENGTH: scheduler::instance().UpgradeResult(ushortAdd,0);
DealSensorRSSI(pData,ushortAdd); zlog_warn(zbt, "[UPGRADE ALREADY] shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
break; }else
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;
}
} }
} }

View File

@ -177,6 +177,7 @@ public:
// feature parse // feature parse
void DealDataNodeFeature(const char* pData, int flag); void DealDataNodeFeature(const char* pData, int flag);
void DealDataNodeFeatureTransition(const char* pData,int flag = 0);
void RecordBattery(std::string& strLongAddr, DataRecvStatic& dataStatic, std::string& nowTimetamp); void RecordBattery(std::string& strLongAddr, DataRecvStatic& dataStatic, std::string& nowTimetamp);
void DealDataNodeWave(const char* pData, int comand); void DealDataNodeWave(const char* pData, int comand);
void DealWaveThread(); void DealWaveThread();

File diff suppressed because it is too large Load Diff