add upgrade code

This commit is contained in:
zhangsheng 2025-12-16 23:00:40 +08:00
parent 57a54c8de8
commit 8baccebd76
4 changed files with 41 additions and 6 deletions

View File

@ -18,7 +18,7 @@ enum enumZigBeeTransmitStatus {
//#define NR5G_MODULE
//#define Q4G_MODULE
#define Q4G_MODULE
//#define WIFI_MODULE
//#define NR5G_MEIGE
//#define BLUETEETH_MODULE

View File

@ -605,6 +605,32 @@ int Uart::DealFeatureValue(const char *pData,uint16_t ushortAdd){
last_time = atol(nowTimetamp.c_str());
return 0;
}
int Uart::DealAskTaskOld(uint16_t ushortAdd){
char wherecon[50]={0};
sprintf(wherecon, "zigbeeShortAddr='%02x%02x'", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
int sensor_count = sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), wherecon);
if (sensor_count < 1) {
zlog_warn(zct, "device info not found %02x%02x ", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
return 1;
}
int next_duration = 0,next_task_id = 0;
int taskID;
ScheduleTask scheduleTask;
taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration, next_task_id);
zlog_info(zct, "DealAskTaskOld taskID = %d next_duration = %d next_task_id = %d", taskID, next_duration, next_task_id);
if(next_task_id == kScheduleUpgrade){
scheduleTask.cmd = REVIVE_DURATION;
scheduleTask.shortAddr = ushortAdd;
scheduleTask.duration = next_duration;
scheduleTask.next_taskID = UPGRADE;
TaskResp(scheduleTask);
}
if (taskID == kScheduleUpgrade){
UpdateWirelessNode(ushortAdd);
}
return 0;
}
void Uart::DealRecvData(const char *pData) {
uint16_t ushortAdd = BUILD_UINT16(pData[3] & 0xFF, pData[4] & 0xFF);
@ -640,6 +666,9 @@ void Uart::DealRecvData(const char *pData) {
case DEVICE_INF2:
DealDataNodeName(pData);
break;
case ASK_TASK:
DealAskTaskOld(ushortAdd);
break;
// case ASK_TASK:
// DealAskTask(ushortAdd);
// break;
@ -1306,9 +1335,9 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
memcpy(RecvBuf, (char *)&UartRecvBuf[i], 100);
DealDataNodeWave(RecvBuf, command);
mPackgeIndex = (unsigned int)UartRecvBuf[i + 6];
} else if (now_task != WAVE_CMD && ( command == DEVICE_INF || command == MEAS_EVAL || command == CONFIG || command == UPGRADE || command == DEVICE_INF2 || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == UPGRADE_ASK)) {
} else if (now_task != WAVE_CMD && (command == ASK_TASK || command == DEVICE_INF || command == MEAS_EVAL || command == CONFIG || command == UPGRADE || command == DEVICE_INF2 || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == UPGRADE_ASK)) {
char RecvBuf[100] = {0x00};
if (command == UPGRADE_ASK)
if (command == UPGRADE_ASK || command == ASK_TASK )
{
memcpy(RecvBuf, &UartRecvBuf[i], 8);
if (!CheckCrc(RecvBuf, 7)) {

View File

@ -166,6 +166,7 @@ public:
void Stop();
void UpdateZigbeeInfo(const char* pData);
int DealAskTaskOld(uint16_t ushortAdd);
void DealRecvData(const char* pData);
void DealDataNodeInfo(const char* pData);
void DealDataNodeName(const char* pData);

View File

@ -87,10 +87,15 @@ int Uart::DealDataNodeFeature(const char *pData, int flag) {
if (vecResult[0] == "3.0" || vecResult[0] == "4.0") {
return -2;
}
long nodetimestamp = BUILD_UINT32(pRecvData->Data[29], pRecvData->Data[28], pRecvData->Data[27], pRecvData->Data[26]);
long nodetimestamp_ = BUILD_UINT32(pRecvData->Data[29], pRecvData->Data[28], pRecvData->Data[27], pRecvData->Data[26]);
char localtimestamp[32] = {0};
sprintf(localtimestamp,"%ld",nodetimestamp);
char nodetimestamp[32] = {0};
sprintf(nodetimestamp,"%ld",nodetimestamp_);
// std::string nowTimetamp = std::string(localtimestamp);
// strTimetamp = nowTimetamp;
char localtimestamp[32] = { 0 };
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
strTimetamp = nowTimetamp;