From f406bd903ac72b14e41db270b47ecc73d37fbc5f Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Thu, 29 May 2025 21:34:17 +0800 Subject: [PATCH] add code --- uart/uart.cpp | 35 ++++++++++++++++++++++++++++++----- uart/uart.hpp | 1 + 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/uart/uart.cpp b/uart/uart.cpp index 5701a83..8148eda 100644 --- a/uart/uart.cpp +++ b/uart/uart.cpp @@ -403,7 +403,32 @@ int Uart::DealAskTask(uint16_t ushortAdd){ zlog_info(zct, " DealAskTask end" ); 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; +} int Uart::DealException(const char* pData){ return 0; } @@ -613,9 +638,9 @@ void Uart::DealRecvData(const char *pData) { case DEVICE_INF2: DealDataNodeName(pData); break; - // case ASK_TASK: - // DealAskTask(ushortAdd); - // break; + case ASK_TASK: + DealAskTaskOld(ushortAdd); + break; case DEVICE_EXCEPTION: DealException(pData); break; @@ -1280,9 +1305,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)) { diff --git a/uart/uart.hpp b/uart/uart.hpp index f9c71a6..2e9ccea 100644 --- a/uart/uart.hpp +++ b/uart/uart.hpp @@ -175,6 +175,7 @@ public: int FindRecvPackage(int bytesRead, char* mUartRecvBuf, char* head); int DealAskTask(uint16_t ushortAdd); + int DealAskTaskOld(uint16_t ushortAdd); int DealFeatureValue(const char* pData, uint16_t ushortAdd); int DealException(const char* pData); int DealReviveDuration(uint16_t ushortAdd);