diff --git a/dbaccess/sql_db.cpp b/dbaccess/sql_db.cpp index 1f8852d..742346e 100644 --- a/dbaccess/sql_db.cpp +++ b/dbaccess/sql_db.cpp @@ -109,7 +109,13 @@ void SqliteDB::SqliteInit(const char *pDbName) { memset(sql_exec, 0, 2048); sprintf(sql_exec,"update t_sensor_info set MeasurementID = dataNodeNo where MeasurementID = '' ;"); UpdateTableData(sql_exec); - + memset(sql_exec, 0, 2048); + sprintf(sql_exec,"update t_sensor_info set NodeWaveSend = '0,0,0' where NodeWaveSend = '' ;"); + UpdateTableData(sql_exec); + memset(sql_exec, 0, 2048); + sprintf(sql_exec,"update t_sensor_info set NodeWaveSend = '0,0,0' where NodeWaveSend IS NULL ;"); + UpdateTableData(sql_exec); + //创建传感器数据存储表 memset(sql_exec, 0, 2048); sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s,%s);", diff --git a/localserver/web_cmd.cpp b/localserver/web_cmd.cpp index d56c44f..a868912 100644 --- a/localserver/web_cmd.cpp +++ b/localserver/web_cmd.cpp @@ -48,20 +48,20 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) { std::string data = jd.JsonCmd_Cgi_01(param); return data; } break; - case kWebTiming: { - Param_02 param; - std::string type = recvBody["type"].asString(); - if (0 == type.compare("SET")) { - param.mMode = 0; - param.mTimeStamp = recvBody["timeStamp"].asInt(); - param.mSetType = recvBody["setType"].asInt(); - } else if (0 == type.compare("GET")) { - param.mMode = 1; - } - JsonData jd; - std::string data = jd.JsonCmd_Cgi_02(param); - return data; - } break; + // case kWebTiming: { + // Param_02 param; + // std::string type = recvBody["type"].asString(); + // if (0 == type.compare("SET")) { + // param.mMode = 0; + // param.mTimeStamp = recvBody["timeStamp"].asInt(); + // param.mSetType = recvBody["setType"].asInt(); + // } else if (0 == type.compare("GET")) { + // param.mMode = 1; + // } + // JsonData jd; + // std::string data = jd.JsonCmd_Cgi_02(param); + // return data; + // } break; case kWebHWStatus: { JsonData jd; std::string data = jd.JsonCmd_Cgi_07(); diff --git a/threadfunc/check_thread.cpp b/threadfunc/check_thread.cpp index a6e7688..abe306f 100644 --- a/threadfunc/check_thread.cpp +++ b/threadfunc/check_thread.cpp @@ -91,97 +91,97 @@ void CheckThread() { GlobalConfig::net0Status = iStatus; } #endif - if (7200 == time_check) { // 2h - char buf[256] = {0}; - char buf2[256] = {0}; - sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str()); - sprintf(buf2, "{\"dataWatchNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str()); - std::string str = std::string(buf); - std::string str2 = std::string(buf2); - time_check = 0; - int iRet = data_publish(str.c_str(), GlobalConfig::Topic_G.mPubTiming.c_str()); - iRet = data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); - iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubTiming.c_str()); - iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); - if (iRet != 0) { - zlog_error(zct, "MQTT connect failed ,time check"); -#ifdef IMX6UL_GATEWAY - char connect[10] = {0x00}; - readStringValue("config", "connect", connect, (char *)GlobalConfig::Config_G.c_str()); - if (atoi(connect)) { - zlog_error(zct, "MQTT connect failed,time check ,reboot"); - exit(0); - } -#endif -#ifdef NR5G_MODULE -#ifdef IMX6UL_GATEWAY - dial.closePort(); - gpio_set(GlobalConfig::GPIO_G.commRest, 0); - zlog_warn(zct, "GPIO 8 start"); - sleep(2); - gpio_set(GlobalConfig::GPIO_G.commRest, 1); - zlog_warn(zct, "GPIO 8 End"); - sleep(20); - dial.openPort("/dev/ttyUSB2"); - dial.setState(); -#endif -#ifdef G2UL_GATEWAY - dial.closePort(); - gpio_set(GlobalConfig::GPIO_G.commPower, 0); - zlog_warn(zct, "commPower start"); - sleep(2); - gpio_set(GlobalConfig::GPIO_G.commPower, 1); - zlog_warn(zct, "commPower End"); - sleep(20); - connectCount++; - if (connectCount > 10) { - zlog_error(zct, "5G reset error ,reboot!"); - system("reboot"); - } -#ifndef NR5G_MEIGE - dial.openPort("/dev/ttyUSB2"); - dial.setState(); -#else - char szquectel[100] = {0x00}; - std::string strAPN = ReadStrByOpt(SERVERCONFIG, "Server", "APN"); - sprintf(szquectel, "/opt/quectel-CM/Meig-CM -s %s &", strAPN.c_str()); - system(szquectel); -#endif -#endif -#endif -#ifdef WIFI_MODULE - zlog_warn(zct, "WiFi reset!"); -#ifdef IMX6UL_GATEWAY - gpio_set(GlobalConfig::GPIO_G.wifiReset, 0); - sleep(5); - gpio_set(GlobalConfig::GPIO_G.wifiReset, 1); - sleep(5); - wifi::WPAClient wpa; - wpa.ReconnectWiFi(); - system("/etc/init.d/wpa_restart"); - system("udhcpc -i wlan2 &"); -#endif -#ifdef G2UL_GATEWAY - system("/etc/init.d/wpa_restart"); - sleep(5); - string strip = GetGwIp_("wlan0"); - print_info("strip = %s\n", strip.c_str()); - if (strip.compare("0.0.0.0") != 0) { - } else { - gpio_set(GlobalConfig::GPIO_G.wifiReset, 1); - sleep(5); - gpio_set(GlobalConfig::GPIO_G.wifiReset, 0); - sleep(30); - wifi::WPAClient wpa; - wpa.ReconnectWiFi(); - system("/etc/init.d/wpa_restart"); - sleep(5); - system("udhcpc -b -i wlan0 &"); - } -#endif -#endif - } - } +// if (7200 == time_check) { // 2h //校时暂时不测 +// char buf[256] = {0}; +// char buf2[256] = {0}; +// sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str()); +// sprintf(buf2, "{\"dataWatchNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}", GlobalConfig::MacAddr_G.c_str()); +// std::string str = std::string(buf); +// std::string str2 = std::string(buf2); +// time_check = 0; +// int iRet = data_publish(str.c_str(), GlobalConfig::Topic_G.mPubTiming.c_str()); +// iRet = data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); +// iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubTiming.c_str()); +// iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); +// if (iRet != 0) { +// zlog_error(zct, "MQTT connect failed ,time check"); +// #ifdef IMX6UL_GATEWAY +// char connect[10] = {0x00}; +// readStringValue("config", "connect", connect, (char *)GlobalConfig::Config_G.c_str()); +// if (atoi(connect)) { +// zlog_error(zct, "MQTT connect failed,time check ,reboot"); +// exit(0); +// } +// #endif +// #ifdef NR5G_MODULE +// #ifdef IMX6UL_GATEWAY +// dial.closePort(); +// gpio_set(GlobalConfig::GPIO_G.commRest, 0); +// zlog_warn(zct, "GPIO 8 start"); +// sleep(2); +// gpio_set(GlobalConfig::GPIO_G.commRest, 1); +// zlog_warn(zct, "GPIO 8 End"); +// sleep(20); +// dial.openPort("/dev/ttyUSB2"); +// dial.setState(); +// #endif +// #ifdef G2UL_GATEWAY +// dial.closePort(); +// gpio_set(GlobalConfig::GPIO_G.commPower, 0); +// zlog_warn(zct, "commPower start"); +// sleep(2); +// gpio_set(GlobalConfig::GPIO_G.commPower, 1); +// zlog_warn(zct, "commPower End"); +// sleep(20); +// connectCount++; +// if (connectCount > 10) { +// zlog_error(zct, "5G reset error ,reboot!"); +// system("reboot"); +// } +// #ifndef NR5G_MEIGE +// dial.openPort("/dev/ttyUSB2"); +// dial.setState(); +// #else +// char szquectel[100] = {0x00}; +// std::string strAPN = ReadStrByOpt(SERVERCONFIG, "Server", "APN"); +// sprintf(szquectel, "/opt/quectel-CM/Meig-CM -s %s &", strAPN.c_str()); +// system(szquectel); +// #endif +// #endif +// #endif +// #ifdef WIFI_MODULE +// zlog_warn(zct, "WiFi reset!"); +// #ifdef IMX6UL_GATEWAY +// gpio_set(GlobalConfig::GPIO_G.wifiReset, 0); +// sleep(5); +// gpio_set(GlobalConfig::GPIO_G.wifiReset, 1); +// sleep(5); +// wifi::WPAClient wpa; +// wpa.ReconnectWiFi(); +// system("/etc/init.d/wpa_restart"); +// system("udhcpc -i wlan2 &"); +// #endif +// #ifdef G2UL_GATEWAY +// system("/etc/init.d/wpa_restart"); +// sleep(5); +// string strip = GetGwIp_("wlan0"); +// print_info("strip = %s\n", strip.c_str()); +// if (strip.compare("0.0.0.0") != 0) { +// } else { +// gpio_set(GlobalConfig::GPIO_G.wifiReset, 1); +// sleep(5); +// gpio_set(GlobalConfig::GPIO_G.wifiReset, 0); +// sleep(30); +// wifi::WPAClient wpa; +// wpa.ReconnectWiFi(); +// system("/etc/init.d/wpa_restart"); +// sleep(5); +// system("udhcpc -b -i wlan0 &"); +// } +// #endif +// #endif +// } +// } if (HardStatus == 3600) { // one hour 3600 JsonData jd; std::string data = jd.JsonCmd_07(); diff --git a/uart/uart.cpp b/uart/uart.cpp index ebc3cbc..b402452 100644 --- a/uart/uart.cpp +++ b/uart/uart.cpp @@ -16,6 +16,7 @@ #include #include "mqttclient/mqtt_client.h" #include "utility/serial.h" +#include "scheduler/schedule.hpp" extern zlog_category_t *zct; extern zlog_category_t *zbt; @@ -37,54 +38,30 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) { char head[] = {0xAA, 0x55, 0xAA}; char szbuffer[BUF_LENGTH] = {0x00}; while (1) { - if (now_task == kWaveForm) { + if (now_task == WAVE_CMD) { memset(buff, 0, sizeof(buff)); ret = read_data(fd, buff, BUF_LENGTH, 10); if (ret <= 0) { - if (!bUpdate && !bUpdateconfig) { - timeoutflag++; - if (timeoutflag > 300) { - zlog_info(zct, "===============0x9999 timeout= %d offSize = %d===============", timeoutflag, offSize); - zlog_info(zct, "0x9999 timeout %d===============Size = %d", timeoutflag, offSize); - FindRecvPackage(offSize, mUartRecvTmpBuf, head); - GlobalConfig::Zigbee_G.MyAddr = 0x8888; - now_task = -1; - timeoutflag = 0; - offSize = 0; - maxSize = 0; - tcflush(fd, TCIFLUSH); - bModifyAddr = true; - modify_LocalAddr(0x8888); - bSendTimeStamp = false; - mssleep(10000); - wave_trans_ = true; - memset(mUartRecvTmpBuf, 0, BUF_LENGTH); - GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; - GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; - - zlog_info(zct, "wave end"); - } - mssleep(10000); - } else if (bUpdatePre || (bUpdateconfig && GlobalConfig::EnterZigBeeWaveTransmittingCnt_G > 15)) { - timeoutflag++; - if (timeoutflag > 300) { - zlog_info(zct, "bUpdateconfig %d===============", timeoutflag); - GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; - GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; - timeoutflag = 0; - offSize = 0; - maxSize = 0; - bUpdate = false; - bUpdatePre = false; - bUpdateconfig = false; - bModifyAddr = true; - bSendTimeStamp = false; - modify_LocalAddr(0x8888); - mssleep(10000); - GlobalConfig::Zigbee_G.MyAddr = 0x8888; - } + timeoutflag++; + if (timeoutflag > 300) { + DealReviveDuration(wave_shortAddr); + zlog_info(zct, "===============0x9999 timeout= %d offSize = %d===============", timeoutflag, offSize); + zlog_info(zct, "0x9999 timeout %d===============Size = %d", timeoutflag, offSize); + FindRecvPackage(offSize, mUartRecvTmpBuf, head); + + GlobalConfig::Zigbee_G.MyAddr = 0x8888; + now_task = -1; + wave_shortAddr = 0; + timeoutflag = 0; + offSize = 0; + maxSize = 0; + tcflush(fd, TCIFLUSH); mssleep(10000); + wave_trans_ = true; + memset(mUartRecvTmpBuf, 0, BUF_LENGTH); + zlog_info(zct, "wave end"); } + mssleep(10000); } else if (ret > 0) { maxSize += ret; @@ -108,16 +85,11 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) { offSize = 0; maxSize = 0; tcflush(fd, TCIOFLUSH); - bModifyAddr = true; - modify_LocalAddr(0x8888); - GlobalConfig::Zigbee_G.MyAddr = 0x8888; - GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS; - GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; } } } - } else if ((unsigned short)GlobalConfig::Zigbee_G.MyAddr == 0x8888) { + } else { #ifdef IMX6UL_GATEWAY memset(buff, 0, sizeof(buff)); ret = read_data(fd, buff, BUF_LENGTH, 50); @@ -177,6 +149,7 @@ Uart::Uart() : mUart(mIoSev), mStrand(mIoSev) { memset(mUartRecvTmpBuf, 0, BUF_LENGTH); bTest = false; TestFd = 0; + wave_shortAddr = 0; DataNodeUpdateFile = ""; strTimetamp = ""; bZigbeeSinal = false; @@ -393,13 +366,48 @@ void int2bytes(int i, unsigned char *bytes, int size) { bytes[3] = (unsigned char)((0xff000000 & i) >> 24); } -int Uart::DealAskTask(unsigned short ushortAdd){ +int Uart::DealAskTask(uint16_t ushortAdd){ - //1.特征值 - //2.波形 - now_task = kWaveForm; - //3.升级 - //4.更新配置 + ModifyDistAddr(ushortAdd); + int next_duration = 0; + int taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration); + ScheduleTask scheduleTask; + if (taskID == kScheduleEigenValue) //1.特征值 + { + char localtimestamp[32] = {0x00}; + int millisecond = 0; + std::string rtcTime = GetRTC(localtimestamp, millisecond); + scheduleTask.cmd = MEAS_EVAL; + scheduleTask.shortAddr = ushortAdd; + scheduleTask.timeStamp = atoi(localtimestamp); + TaskResp(scheduleTask); + } + else if (taskID == kScheduleWaveForm) //2.波形 + { + now_task = WAVE_CMD; + scheduleTask.cmd = WAVE_CMD; + scheduleTask.shortAddr = ushortAdd; + wave_shortAddr = ushortAdd; + TaskResp(scheduleTask); + } + else if (taskID == kScheduleUpgrade) //3.升级 + { + scheduleTask.cmd = UPGRADE; + scheduleTask.shortAddr = ushortAdd; + TaskResp(scheduleTask); + }else if (taskID == kScheduleConfigSensor) //4.更新配置 + { + scheduleTask.cmd = CONFIG; + scheduleTask.shortAddr = ushortAdd; + TaskResp(scheduleTask); + }else if (taskID == kScheduleWrongTime) //5.异常连接 + { + scheduleTask.cmd = REVIVE_DURATION; + scheduleTask.shortAddr = ushortAdd; + scheduleTask.duration = next_duration; + TaskResp(scheduleTask); + } + return 0; } @@ -408,6 +416,13 @@ int Uart::DealException(const char* pData){ } int Uart::DealReviveDuration(uint16_t ushortAdd){ + + ScheduleTask scheduleTask; + uint16_t next_duration = scheduler::instance().GetNextDuration(ushortAdd); + scheduleTask.cmd = REVIVE_DURATION; + scheduleTask.shortAddr = ushortAdd; + scheduleTask.duration = next_duration; + TaskResp(scheduleTask); return 0; } @@ -432,28 +447,27 @@ void Uart::DealRecvData(const char *pData) { } zlog_info(zct, "shortAdd = %d,command = %d,recvcode = %d ",ushortAdd,command,recvcode); switch (command) { - // case 1: { // 0x01:设备信息 - // DealDataNodeInfo(pData); - // } break; - // case 7: { - // DealDataNodeName(pData); - // } break; - case kAskTask: + case DEVICE_INF: { + DealDataNodeInfo(pData); + } break; + case DEVICE_INF2: { + DealDataNodeName(pData); + } break; + case ASK_TASK: DealAskTask(ushortAdd); break; - case kException: + case DEVICE_EXCEPTION: DealException(pData); break; - case kEigenValue: + case MEAS_EVAL: DealDataNodeFeature(pData, 0); - break; - case kReviveDuration: DealReviveDuration(ushortAdd); break; - case kConfig: + case CONFIG: DealConfig(ushortAdd); + DealReviveDuration(ushortAdd); break; - case kUpgrade: + case UPGRADE: UpdateWirelessNode(ushortAdd); break; default: break; @@ -936,7 +950,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { break; } - if (now_task == kWaveForm && (command == 3 || command == 4 || command == 5)) { + if (now_task == WAVE_CMD && (command == WAVE_X || command == WAVE_Y || command == WAVE_Z)) { if (!CheckCrc(&UartRecvBuf[i], 99)) { m_TimeStamp = 0; mPackgeIndex = -1; @@ -977,7 +991,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) { } memcpy(RecvBuf, (char *)&UartRecvBuf[i], 100); DealDataNodeWave(RecvBuf, command); - } else if (now_task != kWaveForm && (command == 1 || command == 4 || command == 11 || command == 21 || command == 22 || command == 24)) { + } 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)) { char RecvBuf[100] = {0x00}; memcpy(RecvBuf, &UartRecvBuf[i], 100); if (!CheckCrc(RecvBuf, 99)) { diff --git a/uart/uart.hpp b/uart/uart.hpp index 8694694..e2207a6 100644 --- a/uart/uart.hpp +++ b/uart/uart.hpp @@ -13,23 +13,20 @@ typedef void (*pTestRecvCallBack)(int Status); // 无关网关与传感器交互命令 1 ~ 255 enum InteractiveCommand { - // 传感器发给网关 - kAskTask = 1, // 请求任务 - kReviveConfig = 2, // 请求基本的复活配置, 使用新的传感器时 - kVersionInfo = 3, // 版本信息 - kException = 4, // 异常: 外设 - // 交互命令 - kEigenValue = 11, // 特征值 - kWaveForm = 12, // 波形 - // kBatteryLevel = 14, // 电池电量 特征值里面带 - - // 网关发给传感器 - kReviveDuration = 21, // 复活时长 - kConfig = 22, // 配置 - // kExecuteTask = 23, // 需要无线传感器执行的任务 - kUpgrade = 24, // 升级 - kSignalStrength = 25, // 信号强度 + ASK_TASK = 1, // 请求任务 只从传感器发出 + DEVICE_INF = 2, // 上线发送通道配置,版本信息, 会收到REVIVE_DURATION = 8, + MEAS_EVAL = 3, // 特征值 校时信息带给传感器 + WAVE_CMD = 4, // 只从无线网关发出,x,y,z + WAVE_X = 5, // 只从传感器发出 + WAVE_Y = 6, // 只从传感器发出 + WAVE_Z = 7, // 只从传感器发出 + REVIVE_DURATION = 8, // 复活时长 + CONFIG = 9, // 配置 只从无线网关发出 + UPGRADE = 10, // 升级, 升级给这条信息 + DEVICE_INF2 = 11, // 测点名称,测点编号 + SIGNAL_STRENGTH = 12, // 信号强度 + DEVICE_EXCEPTION = 13, // 异常: 外设 }; // 无线传感器请求任务 typedef struct { @@ -115,7 +112,8 @@ typedef struct { typedef struct { uint8_t cmd; uint16_t shortAddr; - uint8_t to_exec_cmd; // 需要传感器立即执行的任务 + uint16_t duration; + uint32_t timeStamp; } ScheduleTask; // 升级任务 @@ -157,7 +155,7 @@ public: int UartRecv(int fd, char srcshow, char* buffer); int FindRecvPackage(int bytesRead, char* mUartRecvBuf, char* head); - int DealAskTask(unsigned short ushortAdd); + int DealAskTask(uint16_t ushortAdd); int DealException(const char* pData); int DealReviveDuration(uint16_t ushortAdd); int DealConfig(uint16_t ushortAdd); @@ -178,6 +176,7 @@ public: void modify_distaddr_info(unsigned short id, char* zigbee, unsigned char* distAddr); void modify_LocalAddr(unsigned short id); void modify_DistAddr(unsigned char* distAddr); + void ModifyDistAddr(uint16_t distAddr); void modify_Localchannel(unsigned char pad); void modify_LocalPanID(unsigned short padID); void getZigbeeSignal(unsigned char* distAddr); @@ -222,6 +221,7 @@ private: std::string strTimetamp; std::string m_strDestShortAddr; + uint16_t wave_shortAddr; int now_task; int waittime; diff --git a/uart/uart_cmd.cpp b/uart/uart_cmd.cpp index 20583ba..a1aec5f 100644 --- a/uart/uart_cmd.cpp +++ b/uart/uart_cmd.cpp @@ -41,6 +41,18 @@ void Uart::modify_DistAddr(unsigned char *distAddr) { command[5] = distAddr[1]; WriteToUart(command, 6); } +void Uart::ModifyDistAddr(uint16_t distAddr){ + char command[6] = {0x00}; + memset(command, 0x00, sizeof(command)); + command[0] = 0xDE; + command[1] = 0xDF; + command[2] = 0xEF; + command[3] = 0xD2; + command[4] = (distAddr >> 8) & 0xFF; + command[5] = distAddr & 0xFF; + WriteToUart(command, 6); +} + void Uart::modify_LocalAddr(unsigned short id) { char command[6] = {0x00}; command[0] = 0xDE; diff --git a/uart/uart_parameter_config.cpp b/uart/uart_parameter_config.cpp index 77d020a..407ff7b 100644 --- a/uart/uart_parameter_config.cpp +++ b/uart/uart_parameter_config.cpp @@ -528,8 +528,18 @@ int Uart::TaskResp(ScheduleTask scheduleTask){ UpdateData[4] = scheduleTask.shortAddr & 0xFF; UpdateData[5] = scheduleTask.cmd & 0xFF; UpdateData[6] = 0x00; - UpdateData[7] = scheduleTask.to_exec_cmd & 0xFF; - + if (scheduleTask.cmd == REVIVE_DURATION) + { + UpdateData[7] = (scheduleTask.duration >> 8) & 0xFF; + UpdateData[8] = scheduleTask.duration & 0xFF; + } + if (scheduleTask.cmd == MEAS_EVAL) + { + UpdateData[9] = UINT32_LOW_2(scheduleTask.timeStamp); + UpdateData[10] = UINT32_LOW_1(scheduleTask.timeStamp); + UpdateData[11] = UINT32_HIGH_2(scheduleTask.timeStamp); + UpdateData[12] = UINT32_HIGH_1(scheduleTask.timeStamp); + } unsigned char tmp = 0x00; for (int k = 0; k < 99; k++) { tmp += UpdateData[k];