add upgrade and config

This commit is contained in:
zhangsheng 2024-11-10 16:43:15 +08:00
parent b80656106f
commit 7cc1a2326e
9 changed files with 177 additions and 134 deletions

View File

@ -14,7 +14,7 @@
</extensions> </extensions>
</storageModule> </storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0"> <storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="cdt.managedbuild.config.gnu.cross.exe.debug.534720554" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="" postbuildStep="" preannouncebuildStep="" prebuildStep=""> <configuration artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser" id="cdt.managedbuild.config.gnu.cross.exe.debug.534720554" name="Debug" optionalBuildProperties="org.eclipse.cdt.docker.launcher.containerbuild.property.selectedvolumes=,org.eclipse.cdt.docker.launcher.containerbuild.property.volumes=" parent="cdt.managedbuild.config.gnu.cross.exe.debug" postannouncebuildStep="" postbuildStep="cp WirelessGateway Cidn-SH;arm-linux-gnueabihf-strip Cidn-SH" preannouncebuildStep="" prebuildStep="">
<folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.534720554." name="/" resourcePath=""> <folderInfo id="cdt.managedbuild.config.gnu.cross.exe.debug.534720554." name="/" resourcePath="">
<toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.414193457" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug"> <toolChain errorParsers="" id="cdt.managedbuild.toolchain.gnu.cross.exe.debug.414193457" name="Cross GCC" superClass="cdt.managedbuild.toolchain.gnu.cross.exe.debug">
<option id="cdt.managedbuild.option.gnu.cross.prefix.1212588849" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" useByScannerDiscovery="false" value="arm-linux-gnueabihf-" valueType="string"/> <option id="cdt.managedbuild.option.gnu.cross.prefix.1212588849" name="Prefix" superClass="cdt.managedbuild.option.gnu.cross.prefix" useByScannerDiscovery="false" value="arm-linux-gnueabihf-" valueType="string"/>
@ -46,6 +46,9 @@
<tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1049583485" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker"> <tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1049583485" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
<option id="gnu.cpp.link.option.paths.1174701783" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" useByScannerDiscovery="false" valueType="libPaths"> <option id="gnu.cpp.link.option.paths.1174701783" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" useByScannerDiscovery="false" valueType="libPaths">
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/boost/lib"/> <listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/boost/lib"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/zlog/lib"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/NewWLG/WLG"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/zlog/include"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/ssl/lib"/> <listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/ssl/lib"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/fftw/lib"/> <listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/fftw/lib"/>
<listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/jsoncpp"/> <listOptionValue builtIn="false" value="/home/chaos/WorkSpace/Tools/GatewayThirdParty/jsoncpp"/>
@ -55,6 +58,8 @@
</option> </option>
<option id="gnu.cpp.link.option.libs.1027000140" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs"> <option id="gnu.cpp.link.option.libs.1027000140" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">
<listOptionValue builtIn="false" value="sqlite3"/> <listOptionValue builtIn="false" value="sqlite3"/>
<listOptionValue builtIn="false" value="zlog"/>
<listOptionValue builtIn="false" value="boost_filesystem"/>
<listOptionValue builtIn="false" value="boost_system"/> <listOptionValue builtIn="false" value="boost_system"/>
<listOptionValue builtIn="false" value="pthread"/> <listOptionValue builtIn="false" value="pthread"/>
<listOptionValue builtIn="false" value="boost_thread"/> <listOptionValue builtIn="false" value="boost_thread"/>

View File

@ -385,7 +385,6 @@ std::string JsonData::JsonCmd_Cgi_20(Param_20 &param) {
WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate", nowTimetamp); WriteStr2Config(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate", nowTimetamp);
} }
std::string boardtype = GetFileContent(BOARDTYPE, 1);
std::string ip = IpAddrInit(); std::string ip = IpAddrInit();
std::string sn = GetFileContent(SN, 1); std::string sn = GetFileContent(SN, 1);
jsonVal[JSON_FIELD_CMD] = "20"; jsonVal[JSON_FIELD_CMD] = "20";
@ -402,7 +401,6 @@ std::string JsonData::JsonCmd_Cgi_20(Param_20 &param) {
jsSystemInfo[JSON_FIELD_ASSETID] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAssetId"); jsSystemInfo[JSON_FIELD_ASSETID] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAssetId");
jsSystemInfo[JSON_FIELD_ADDEDBY] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedBy"); jsSystemInfo[JSON_FIELD_ADDEDBY] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedBy");
jsSystemInfo[JSON_FIELD_ADDEDDATE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate"); jsSystemInfo[JSON_FIELD_ADDEDDATE] = ReadStrByOpt(SYSTEMINFOFILE, "SystemInfo", "dataNodeGatewayAddedDate");
jsSystemInfo[JSON_FIELD_DEVICETYPE] = boardtype;
jsSystemInfo[JSON_FIELD_IPADDRESS] = ip; jsSystemInfo[JSON_FIELD_IPADDRESS] = ip;
jsSystemInfo[JSON_FIELD_SN] = sn; jsSystemInfo[JSON_FIELD_SN] = sn;
jsSystemInfo[JSON_FIELD_VERSION] = GlobalConfig::Version; jsSystemInfo[JSON_FIELD_VERSION] = GlobalConfig::Version;

View File

@ -690,7 +690,7 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 &param){
return show_value_.write(jsonVal); return show_value_.write(jsonVal);
} }
sprintf(insertSql, " '%s','%s','','','','','%d.%d','%s',1",param.dataNodeNo[i].c_str(),localtimestamp,sf_ver_m,sf_ver_s,vecResult[1].c_str()); sprintf(insertSql, " '%s','%s','','','','','%d.%d','%s',1,'%s'",vecResult[3].c_str(),localtimestamp,sf_ver_m,sf_ver_s,vecResult[1].c_str(),param.fileName.c_str());
sqlite_db_ctrl::instance().InsertData(" firmware_upgrade ", insertSql); sqlite_db_ctrl::instance().InsertData(" firmware_upgrade ", insertSql);
scheduler::instance().UpgradeSensor(atoi(vecResult[3].c_str()),std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version)); scheduler::instance().UpgradeSensor(atoi(vecResult[3].c_str()),std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version));
} }
@ -702,7 +702,7 @@ std::string JsonData::JsonCmd_Cgi_61(Param_61 &param){
Json::Value jsonVal; Json::Value jsonVal;
jsonVal.clear(); jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "10"; jsonVal[JSON_FIELD_CMD] = "61";
jsonVal["success"] = true; jsonVal["success"] = true;
jsonVal["message"] = " "; jsonVal["message"] = " ";
vec_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL); vec_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL);

View File

@ -420,8 +420,11 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) {
case kWaveRecords:{ case kWaveRecords:{
JsonData jd; JsonData jd;
Param_61 param; Param_61 param;
param.straxis = recvBody["Raxis"].asString(); param.straxis = recvBody["Raxis"].asString();
param.mPackageFlag = recvBody["package"].asInt();
param.timeStart = recvBody["timeStart"].asString();
param.timeEnd = recvBody["timeEnd"].asString();
param.MeasurementID = recvBody["MeasurementID"].asString();
std::string data = jd.JsonCmd_Cgi_61(param); std::string data = jd.JsonCmd_Cgi_61(param);
return data; return data;
}break; }break;

View File

@ -219,7 +219,6 @@ int data_publish(const char *str, const char *topic) {
memset(base64_aes, 0, pData.length() * 2); memset(base64_aes, 0, pData.length() * 2);
secure::instance().Base64Encode((unsigned char *)pData.c_str(), base64_aes, pData.length()); secure::instance().Base64Encode((unsigned char *)pData.c_str(), base64_aes, pData.length());
ret = mosquitto_publish(mosq, &mid_sent, topic, strlen(base64_aes), base64_aes, ud.topic_qos, false); ret = mosquitto_publish(mosq, &mid_sent, topic, strlen(base64_aes), base64_aes, ud.topic_qos, false);
if (base64_aes != NULL) delete[] base64_aes; if (base64_aes != NULL) delete[] base64_aes;
if (ret != MOSQ_ERR_SUCCESS) { if (ret != MOSQ_ERR_SUCCESS) {
zlog_error(zct, "fail to send mqtt msg, ret: [%s], topic: %s, str: %s", mosquitto_strerror(ret), topic, str); zlog_error(zct, "fail to send mqtt msg, ret: [%s], topic: %s, str: %s", mosquitto_strerror(ret), topic, str);
@ -230,10 +229,13 @@ int data_publish(const char *str, const char *topic) {
zlog_error(zct, "fail to send mqtt msg, ret: [%s], topic: %s, str: %s", mosquitto_strerror(ret), topic, str); zlog_error(zct, "fail to send mqtt msg, ret: [%s], topic: %s, str: %s", mosquitto_strerror(ret), topic, str);
} }
} }
if (ret != 0) {
disconnect();
}
}else{
zlog_warn(zct,"mosq == NULL");
} }
if (ret != 0) {
disconnect();
}
return ret; return ret;
} }
@ -356,6 +358,7 @@ int start_client(const char *boardname, const char *gwid, const char *gwip, cons
free(ud.topics); free(ud.topics);
mosquitto_destroy(mosq); mosquitto_destroy(mosq);
mosquitto_lib_cleanup(); mosquitto_lib_cleanup();
mosq = NULL;
zlog_error(zct, "Error: No free space 1"); zlog_error(zct, "Error: No free space 1");
return -1; return -1;
} }
@ -366,6 +369,7 @@ int start_client(const char *boardname, const char *gwid, const char *gwip, cons
free(ud.topics); free(ud.topics);
mosquitto_destroy(mosq); mosquitto_destroy(mosq);
mosquitto_lib_cleanup(); mosquitto_lib_cleanup();
mosq = NULL;
zlog_error(zct, "Error: No free space 2"); zlog_error(zct, "Error: No free space 2");
free(psk); free(psk);
return -1; return -1;
@ -403,6 +407,7 @@ int start_client(const char *boardname, const char *gwid, const char *gwip, cons
mosq_free: mosq_free:
mosquitto_destroy(mosq); mosquitto_destroy(mosq);
mosquitto_lib_cleanup(); mosquitto_lib_cleanup();
mosq = NULL;
if (ud.topics != NULL) { if (ud.topics != NULL) {
free(ud.topics); free(ud.topics);
} }

View File

@ -32,38 +32,10 @@ void CheckThread() {
int commSignal = 0; int commSignal = 0;
int loose_check = 0; int loose_check = 0;
int mqttresend = 0; int mqttresend = 0;
int ModifyAddr = 0;
while (GlobalConfig::QuitFlag_G) { while (GlobalConfig::QuitFlag_G) {
GlobalConfig::threadStatus = 1; GlobalConfig::threadStatus = 1;
sleep(1); sleep(1);
if (GlobalConfig::EnterZigBeeWaveTransmittingFlag_G == ENTER_TRANSMITTING_STATUS) {
GlobalConfig::EnterZigBeeWaveTransmittingCnt_G++;
if (GlobalConfig::EnterZigBeeWaveTransmittingCnt_G >= 180) {
GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS;
GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0;
zlog_error(zct, "[---- ZigBee error--!] ZigBee PanID is 9999 over time for 3 minutes !");
// 重新写入 0x8888
uart_inst::instance().modify_LocalAddr(0x8888);
GlobalConfig::Zigbee_G.MyAddr = 0x8888;
// 延时1秒
sleep(1);
// 重新读回 GlobalConfig::ZigbeeInfo_G.PanID
uart_inst::instance().UpdateZigbeeInfoCtrl();
uart_inst::instance().bUpdateconfig = false;
uart_inst::instance().bUpdate = false;
uart_inst::instance().bSendTimeStamp = false;
// 延时1秒
sleep(1);
std::string str("8888");
if (GlobalConfig::ZigbeeInfo_G.MyAddr.compare(str) == 0) {
zlog_warn(zct, "[---- ZigBee INFO ----!] ZigBee PanID come back to be 8888 !");
} else {
zlog_error(zct, "[---- ZigBee error--!] ZigBee PanID cannot come back to be 8888 !");
}
}
continue;
}
if (10 == heart_count) { if (10 == heart_count) {
if (GlobalConfig::LinkCount > 30) { if (GlobalConfig::LinkCount > 30) {
zlog_error(zct, "MQTT connect failed "); zlog_error(zct, "MQTT connect failed ");
@ -237,14 +209,6 @@ void CheckThread() {
loose_check = 0; loose_check = 0;
sqlite_db_ctrl::instance().CalculateDip(); sqlite_db_ctrl::instance().CalculateDip();
} }
if (ModifyAddr == 3600) {
zlog_info(zct, "ModifyAddr check");
ModifyAddr = 0;
if (uart_inst::instance().bModifyAddr) {
zlog_error(zct, "ModifyAddr failed ");
exit(0);
}
}
if (18000 == commSignal) { // 5h if (18000 == commSignal) { // 5h
Json::Value jsBody, jsonVal; Json::Value jsBody, jsonVal;
@ -341,7 +305,6 @@ void CheckThread() {
HardStatus++; HardStatus++;
logClean++; logClean++;
loose_check++; loose_check++;
ModifyAddr++;
mqttresend++; mqttresend++;
#ifdef WIFI_MODULE #ifdef WIFI_MODULE
wifi_reconnect_count++; wifi_reconnect_count++;

View File

@ -63,29 +63,19 @@ int Uart::UartRecv(int fd, char srcshow, char *buffer) {
mssleep(10000); mssleep(10000);
} else if (ret > 0) { } else if (ret > 0) {
maxSize += ret; maxSize += ret;
timeoutflag = 0;
timeoutflag = 0; m_TimeStamp = 0;
memcpy(mUartRecvTmpBuf + offSize, buff, ret);
if ((bUpdatePre || bUpdateconfig)) { offSize = offSize + ret;
for (int i = 0; i < ret; i++) { if (offSize > BUF_LENGTH * 15) {
printf("%02x ", buff[i] & 0xff); zlog_info(zct, "maxSize = %d", offSize);
} memset(mUartRecvTmpBuf, 0, BUF_LENGTH);
timeoutflag = 0;
FindRecvPackage(ret, buff, head); offSize = 0;
maxSize = 0;
} else { tcflush(fd, TCIOFLUSH);
m_TimeStamp = 0;
memcpy(mUartRecvTmpBuf + offSize, buff, ret);
offSize = offSize + ret;
if (offSize > BUF_LENGTH * 15) {
zlog_info(zct, "maxSize = %d", offSize);
memset(mUartRecvTmpBuf, 0, BUF_LENGTH);
timeoutflag = 0;
offSize = 0;
maxSize = 0;
tcflush(fd, TCIOFLUSH);
}
} }
} }
} else { } else {
@ -152,9 +142,6 @@ Uart::Uart() : mUart(mIoSev), mStrand(mIoSev) {
DataNodeUpdateFile = ""; DataNodeUpdateFile = "";
strTimetamp = ""; strTimetamp = "";
bZigbeeSinal = false; bZigbeeSinal = false;
bModifyAddr = false;
bUpdatePre = false;
bSendTimeStamp = false;
m_waveCountX = 0; m_waveCountX = 0;
m_waveCountY = 0; m_waveCountY = 0;
m_waveCountZ = 0; m_waveCountZ = 0;
@ -372,7 +359,7 @@ int Uart::DealAskTask(uint16_t ushortAdd){
int next_duration = 0; int next_duration = 0;
int taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration); int taskID = scheduler::instance().StartSchedule(ushortAdd,next_duration);
ScheduleTask scheduleTask; ScheduleTask scheduleTask;
taskID = 5; taskID = 2;
zlog_info(zct, "taskID = %d ", taskID); zlog_info(zct, "taskID = %d ", taskID);
if (taskID == kScheduleEigenValue) //1.特征值 if (taskID == kScheduleEigenValue) //1.特征值
{ {
@ -394,13 +381,15 @@ int Uart::DealAskTask(uint16_t ushortAdd){
} }
else if (taskID == kScheduleUpgrade) //3.升级 else if (taskID == kScheduleUpgrade) //3.升级
{ {
zlog_info(zct, "taskID123 = %d ", taskID);
UpdateWirelessNode(ushortAdd); UpdateWirelessNode(ushortAdd);
}else if (taskID == kScheduleConfigSensor) //4.更新配置 }else if (taskID == kScheduleConfigSensor) //4.更新配置
{ {
scheduleTask.cmd = CONFIG; scheduleTask.cmd = CONFIG;
scheduleTask.shortAddr = ushortAdd; scheduleTask.shortAddr = ushortAdd;
mssleep(50000);
TaskResp(scheduleTask); TaskResp(scheduleTask);
mssleep(50000);
UpdateConfig(ushortAdd);
}else if (taskID == kScheduleWrongTime) //5.异常连接 }else if (taskID == kScheduleWrongTime) //5.异常连接
{ {
scheduleTask.cmd = REVIVE_DURATION; scheduleTask.cmd = REVIVE_DURATION;
@ -408,12 +397,6 @@ int Uart::DealAskTask(uint16_t ushortAdd){
scheduleTask.duration = next_duration; scheduleTask.duration = next_duration;
zlog_info(zct, "next_duration = %d ", next_duration); zlog_info(zct, "next_duration = %d ", next_duration);
TaskResp(scheduleTask); TaskResp(scheduleTask);
}else if (taskID == kScheduleConfigSensor) //6.更新配置
{
scheduleTask.cmd = CONFIG;
scheduleTask.shortAddr = ushortAdd;
TaskResp(scheduleTask);
UpdateConfig(ushortAdd);
} }
return 0; return 0;
@ -467,7 +450,38 @@ int Uart::DealWaveCompress(const char *pData,uint16_t ushortAdd){
zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ); zlog_info(zct, "compress X = %d,Y = %d,Z = %d ", tempchannel.compressChannelX, tempchannel.compressChannelY, tempchannel.compressChannelZ);
return 0; return 0;
} }
int Uart::DealSensorRSSI(const char *pData,uint16_t ushortAdd){
char localtimestamp[32] = {0};
GetTimeNet(localtimestamp, 1);
char sensor_rssi[10] = {0x00};
sprintf(sensor_rssi, "%02d", pData[7] & 0xFF);
if (!strcmp(sensor_rssi, "00") || !strcmp(sensor_rssi, "0")) {
char errorInfo[100] = {0x00};
sprintf(errorInfo, "未检测到信号!%s", sensor_rssi);
zlog_error(zct, errorInfo);
} else {
char insertSql[1024] = {0};
char tableName[100] = {0x00};
char whereCon[100] = {0};
char updateSql[100] = {0};
sprintf(whereCon, "zigbeeShortAddr='%02x%02x'", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
vec_t vecDataNodeNo = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " MeasurementID,RSSI ", whereCon);
sprintf(insertSql, "'%s','%s-S','','','','', '%02d','','%s','','','','','' ", vecDataNodeNo[0].c_str(),vecDataNodeNo[0].c_str(),atoi(sensor_rssi),localtimestamp); // zigbeeRSSIType = 0 传感器获取网关信号强度
sprintf(tableName, "t_dataStatic_%s", (char *)vecDataNodeNo[0].c_str());
sqlite_db_ctrl::instance().InsertData(tableName, insertSql);
std::vector<std::string> vParamRSSI;
boost::split(vParamRSSI, vecDataNodeNo[1], boost::is_any_of(","), boost::token_compress_on);
if (vParamRSSI.size() > 0) {
sprintf(updateSql, "RSSI = '%s,%02d' ", vParamRSSI[0].c_str(), pData[7] & 0xFF);
sprintf(whereCon, "dataNodeNo='%s'", (char *)vecDataNodeNo[0].c_str());
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
}
}
return 0;
}
void Uart::DealRecvData(const char *pData) { void Uart::DealRecvData(const char *pData) {
uint16_t ushortAdd = BUILD_UINT16(pData[3] & 0xFF, pData[4] & 0xFF); uint16_t ushortAdd = BUILD_UINT16(pData[3] & 0xFF, pData[4] & 0xFF);
@ -492,7 +506,7 @@ void Uart::DealRecvData(const char *pData) {
DealDataNodeFeature(pData, 0); DealDataNodeFeature(pData, 0);
DealReviveDuration(ushortAdd); DealReviveDuration(ushortAdd);
break; break;
case UPGRADE_FIRMWARE: case UPGRADE:
if (recvcode == 0) if (recvcode == 0)
{ {
scheduler::instance().UpgradeResult(ushortAdd,0); scheduler::instance().UpgradeResult(ushortAdd,0);
@ -500,7 +514,7 @@ void Uart::DealRecvData(const char *pData) {
zlog_error(zct, "shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode); zlog_error(zct, "shortAdd = %02x%02x,command = %d,recvcode = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command,recvcode);
} }
break; break;
case CONFIG_INF2: case CONFIG:
if (recvcode == 0) if (recvcode == 0)
{ {
DealReviveDuration(ushortAdd); DealReviveDuration(ushortAdd);
@ -513,12 +527,14 @@ void Uart::DealRecvData(const char *pData) {
case WAVE_COMPRESS: case WAVE_COMPRESS:
DealWaveCompress(pData,ushortAdd); DealWaveCompress(pData,ushortAdd);
break; break;
case SIGNAL_STRENGTH:
DealSensorRSSI(pData,ushortAdd);
break;
default: break; default: break;
} }
} }
void Uart::DealDataNodeName(const char *pData) { void Uart::DealDataNodeName(const char *pData) {
bSendTimeStamp = false;
zlog_info(zct, "DealDataNodeName "); zlog_info(zct, "DealDataNodeName ");
std::string strTime = GetLocalTimeWithMs(); std::string strTime = GetLocalTimeWithMs();
char szShortAdd[8] = {0x00}; char szShortAdd[8] = {0x00};
@ -965,13 +981,13 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
sprintf(buf, "%02d", UartRecvBuf[i + 5]); sprintf(buf, "%02d", UartRecvBuf[i + 5]);
int command = atoi(buf); int command = atoi(buf);
//zlog_info(zct, "command = %d ShortAddr :%s", command, strShortAddr.c_str()); //zlog_info(zct, "command = %d ShortAddr :%s", command, strShortAddr.c_str());
if ((mPackgeIndex == -1 || (unsigned int)UartRecvBuf[i + 6] == 0) && (!bUpdatePre && !bUpdateconfig)) { if ((mPackgeIndex == -1 || (unsigned int)UartRecvBuf[i + 6] == 0) ) {
mPackgeIndex = UartRecvBuf[i + 6] & 0xFF; mPackgeIndex = UartRecvBuf[i + 6] & 0xFF;
} else if ((unsigned int)mPackgeIndex == (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && (!bUpdatePre && !bUpdateconfig) && command != 2) { } else if ((unsigned int)mPackgeIndex == (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && command != 2) {
zlog_warn(zct, "mPackgeIndex same index1:%d,index2:%02d ShortAddr :%s ", mPackgeIndex, UartRecvBuf[i + 6] & 0xff, strShortAddr.c_str()); zlog_warn(zct, "mPackgeIndex same index1:%d,index2:%02d ShortAddr :%s ", mPackgeIndex, UartRecvBuf[i + 6] & 0xff, strShortAddr.c_str());
continue; continue;
} else if ((unsigned int)mPackgeIndex + 1 != (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && (!bUpdatePre && !bUpdateconfig) && command != 2) { } else if ((unsigned int)mPackgeIndex + 1 != (unsigned int)UartRecvBuf[i + 6] && mPackgeIndex != -1 && command != 2) {
m_TimeStamp = 0; m_TimeStamp = 0;
zlog_error(zct, "mPackgeIndex error index1:%d,index2:%02d ShortAddr :%s ", mPackgeIndex, UartRecvBuf[i + 6] & 0xff, strShortAddr.c_str()); zlog_error(zct, "mPackgeIndex error index1:%d,index2:%02d ShortAddr :%s ", mPackgeIndex, UartRecvBuf[i + 6] & 0xff, strShortAddr.c_str());
@ -1001,15 +1017,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
strcat(tmp2, tmp); strcat(tmp2, tmp);
} }
zlog_error(zct, "error str = %s", tmp2); zlog_error(zct, "error str = %s", tmp2);
GlobalConfig::Zigbee_G.MyAddr = 0x8888;
tcflush(fd, TCIOFLUSH);
sleep(1);
modify_LocalAddr(0x8888);
bModifyAddr = true;
sleep(1);
bSendTimeStamp = false;
GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = NO_ENTER_TRANSMITTING_STATUS;
GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0;
m_waveCountX = 0; m_waveCountX = 0;
m_waveCountY = 0; m_waveCountY = 0;
m_waveCountZ = 0; m_waveCountZ = 0;
@ -1038,7 +1045,7 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
break; break;
} }
} }
if (command == CONFIG || command == CONFIG_INF2 || command == UPGRADE_FIRMWARE || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS) if (command == CONFIG || command == CONFIG_INF2 || command == UPGRADE || command == SIGNAL_STRENGTH || command == DEVICE_EXCEPTION || command == WAVE_COMPRESS)
{ {
memcpy(RecvBuf, &UartRecvBuf[i], 9); memcpy(RecvBuf, &UartRecvBuf[i], 9);
if (!CheckCrc(RecvBuf, 8)) { if (!CheckCrc(RecvBuf, 8)) {
@ -1115,7 +1122,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
if (command == 209) { if (command == 209) {
UpdateZigbeeInfo(&UartRecvBuf[i]); UpdateZigbeeInfo(&UartRecvBuf[i]);
} else if (command == 220) { // DC } else if (command == 220) { // DC
bModifyAddr = false;
zlog_info(zct, "zigbeeShortAddr = %s , ret = %02d", m_strDestShortAddr.c_str(), UartRecvBuf[i + 6] & 0xFF); zlog_info(zct, "zigbeeShortAddr = %s , ret = %02d", m_strDestShortAddr.c_str(), UartRecvBuf[i + 6] & 0xFF);
if ((UartRecvBuf[i + 6] & 0xFF) != 0) { if ((UartRecvBuf[i + 6] & 0xFF) != 0) {
modify_LocalAddr(0x8888); modify_LocalAddr(0x8888);
@ -1136,7 +1142,6 @@ int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
} else if (command == 219) { // DB } else if (command == 219) { // DB
pTestRecv(command); pTestRecv(command);
} else if (command == 220) { // DC } else if (command == 220) { // DC
bModifyAddr = false;
zlog_info(zct, "%02x,%02x,%02x,%02x,%02x ", UartRecvBuf[i], UartRecvBuf[i + 1], UartRecvBuf[i + 2], UartRecvBuf[i + 3], UartRecvBuf[i + 4]); zlog_info(zct, "%02x,%02x,%02x,%02x,%02x ", UartRecvBuf[i], UartRecvBuf[i + 1], UartRecvBuf[i + 2], UartRecvBuf[i + 3], UartRecvBuf[i + 4]);
zlog_info(zct, "zigbeeShortAddr = %s , ret = %02d", m_strDestShortAddr.c_str(), UartRecvBuf[i + 4] & 0xFF); zlog_info(zct, "zigbeeShortAddr = %s , ret = %02d", m_strDestShortAddr.c_str(), UartRecvBuf[i + 4] & 0xFF);

View File

@ -171,6 +171,7 @@ public:
int DealReviveDuration(uint16_t ushortAdd); int DealReviveDuration(uint16_t ushortAdd);
int DealConfig(uint16_t ushortAdd); int DealConfig(uint16_t ushortAdd);
int DealWaveCompress(const char *pData,uint16_t ushortAdd); int DealWaveCompress(const char *pData,uint16_t ushortAdd);
int DealSensorRSSI(const char *pData,uint16_t ushortAdd);
// feature parse // feature parse
void DealDataNodeFeature(const char* pData, int flag); void DealDataNodeFeature(const char* pData, int flag);
@ -216,8 +217,6 @@ public:
public: public:
int fd, TestFd; int fd, TestFd;
bool bUpdate; bool bUpdate;
bool bUpdatePre;
bool bUpdateconfig;
bool bTest; bool bTest;
bool bZigbeeSinal; bool bZigbeeSinal;
bool bModifyAddr; bool bModifyAddr;

View File

@ -165,6 +165,31 @@ bool Uart::ReadUpdatePackge(unsigned short shortAdd) {
void Uart::UpdateWirelessNode(uint16_t shortAdd) { void Uart::UpdateWirelessNode(uint16_t shortAdd) {
int upgrade_status = 2;
char localtimestamp[32] = {0};
GetTimeNet(localtimestamp, 1);
char insertSql[100] = {0};
char wherecon[50] = {0};
sprintf(wherecon," shortAddr = '%02x%02x' order by start_timestamp DESC",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
std::string spend_count = sqlite_db_ctrl::instance().GetData(" firmware_upgrade ","spend_count",wherecon);
if (atoi(spend_count.c_str()) >= 10){
zlog_warn(zbt, "UpdateWirelessNode spend_count %d,shortAddr = %02x%02x", atoi(spend_count.c_str()), UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
return ;
}
if (spend_count == "")spend_count = "0";
memset(wherecon,0,sizeof(wherecon));
sprintf(wherecon," shortAddr = '%02x%02x' order by submit_timestamp DESC",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
std::string firmware_name = sqlite_db_ctrl::instance().GetData(" firmware_upgrade ","firmware_name",wherecon);
memset(wherecon,0,sizeof(wherecon));
sprintf(wherecon," zigbeeShortAddr = '%02x%02x' ",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " hardVersion,softVersion,ProductNo,upgradeStatus ", wherecon);
if (vecResult[3] == "2")
{
zlog_warn(zbt, "UpdateWirelessNode already ,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
return;
}
std::string strTime = GetLocalTimeWithMs(); std::string strTime = GetLocalTimeWithMs();
zlog_info(zct, "UpdateWirelessNode start = %s UpdateWirelessNode id = %02x %02x", strTime.c_str(), UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd)); zlog_info(zct, "UpdateWirelessNode start = %s UpdateWirelessNode id = %02x %02x", strTime.c_str(), UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
bUpdate = true; bUpdate = true;
@ -175,7 +200,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
int compress = 0; int compress = 0;
memset(fw_outdata,0,sizeof(fw_outdata)); memset(fw_outdata,0,sizeof(fw_outdata));
memset(fw_senddata,0,sizeof(fw_senddata)); memset(fw_senddata,0,sizeof(fw_senddata));
DataNodeUpdateFile = "/opt/DataNode/Time_Trigger_CubeMX.bin.new"; DataNodeUpdateFile = "/opt/DataNode/" + firmware_name;
zlog_info(zct, "strFileName = %s", DataNodeUpdateFile.c_str()); zlog_info(zct, "strFileName = %s", DataNodeUpdateFile.c_str());
pFile = fopen(DataNodeUpdateFile.c_str(), "rb"); pFile = fopen(DataNodeUpdateFile.c_str(), "rb");
if (pFile != NULL) { if (pFile != NULL) {
@ -187,28 +212,55 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
fread(buffer, sizeof(unsigned char), thisSize, pFile); fread(buffer, sizeof(unsigned char), thisSize, pFile);
fclose(pFile); fclose(pFile);
int r = lzo1x_1_compress(buffer, thisSize, fw_outdata, &out_len, wrkmem); char sensor_type[6] = {0};
if (r == LZO_E_OK){ char sf_version[10] = {0};
printf("compressed %lu bytes into %lu bytes\n", memcpy(sensor_type, buffer, 5);
(unsigned long) thisSize, (unsigned long) out_len); printf("model:%s\n", sensor_type);
if (out_len < thisSize){ char c[2] = {0};
zlog_warn(zct, "compressed %lu bytes into %lu bytes", (unsigned long)thisSize, (unsigned long)out_len); c[0] = buffer[5];
memcpy(fw_senddata,fw_outdata,out_len); uint8_t hw_ver = atoi(c);
thisSize = out_len; c[0] = buffer[6];
compress = 1; uint8_t sf_ver_m = atoi(c);
} c[0] = buffer[7];
} uint8_t sf_ver_s = atoi(c);
else sprintf(sf_version,"%d.%d",sf_ver_m,sf_ver_s);
{ unsigned char ch_crc = 0x00;
/* this should NEVER happen */ int packgeSize = 0;
zlog_error(zct,"internal error - compression failed: %d", r); ch_crc = buffer[12];
} packgeSize = BUILD_UINT32(buffer[8],buffer[9],buffer[10],buffer[11]);
/* check for an incompressible block */ zlog_info(zct,"sf_ver_m = %d\n",sf_ver_m);
if (out_len >= thisSize) zlog_info(zct,"sf_ver_s = %d\n",sf_ver_s);
{ zlog_info(zct,"hw_ver = %d\n",hw_ver);
zlog_warn(zct,"This block contains incompressible data.out_len = %lu,thisSize = %lu",out_len,thisSize); zlog_info(zct,"sensor_type = %s\n",sensor_type);
memcpy(fw_senddata,buffer,thisSize); zlog_info(zct,"packgeSize = %d\n",packgeSize);
} zlog_info(zct,"ch_crc = %02x\n",ch_crc);
sprintf(insertSql, " '%02x%02x','','%s','','','%d','%d.%d','%s',1,''",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd),localtimestamp,atoi(spend_count.c_str()) + 1,sf_ver_m,sf_ver_s,vecResult[1].c_str());
sqlite_db_ctrl::instance().InsertData(" firmware_upgrade ", insertSql);
// int r = lzo1x_1_compress(buffer, thisSize, fw_outdata, &out_len, wrkmem);
// if (r == LZO_E_OK){
// printf("compressed %lu bytes into %lu bytes\n",
// (unsigned long) thisSize, (unsigned long) out_len);
// if (out_len < thisSize){
// zlog_warn(zct, "compressed %lu bytes into %lu bytes", (unsigned long)thisSize, (unsigned long)out_len);
// memcpy(fw_senddata,fw_outdata,out_len);
// thisSize = out_len;
// compress = 1;
// }
// }
// else
// {
// /* this should NEVER happen */
// zlog_error(zct,"internal error - compression failed: %d", r);
// }
// /* check for an incompressible block */
// if (out_len >= thisSize)
// {
// zlog_warn(zct,"This block contains incompressible data.out_len = %lu,thisSize = %lu",out_len,thisSize);
// memcpy(fw_senddata,buffer,thisSize);
// }
memcpy(fw_senddata,buffer,thisSize);
unsigned char Data[100] = {0x00}; unsigned char Data[100] = {0x00};
unsigned char size[4] = {0x00}; unsigned char size[4] = {0x00};
zlog_info(zct, "thisSize = %d", (int)thisSize); zlog_info(zct, "thisSize = %d", (int)thisSize);
@ -245,12 +297,11 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
zlog_error(zct, "Packge ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd)); zlog_error(zct, "Packge ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
} }
mssleep(10000); mssleep(10000);
zlog_info(zct,"senddata size = %d",strlen((char*)fw_senddata));
int Count = thisSize / 92; int Count = thisSize / 92;
int lastSize = thisSize % 92; int lastSize = thisSize % 92;
unsigned char UpdateData[100] = {0x00}; unsigned char UpdateData[100] = {0x00};
//帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 数据包[92byte] CRC校验[1byte] //帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 数据包[92byte] CRC校验[1byte]
zlog_warn(zct, "Start Update!!! file Size = %d,Count = %d,lastSize = %d", (int)thisSize,Count,lastSize); zlog_info(zbt, "Start Update!!! file Size = %d,fileName = %s,Count = %d,lastSize = %d,shortAddr = %02x%02x", (int)thisSize,DataNodeUpdateFile.c_str(),Count,lastSize,UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
tmp = 0x00; tmp = 0x00;
gpio_set(GlobalConfig::GPIO_G.zigAckreset, 0); gpio_set(GlobalConfig::GPIO_G.zigAckreset, 0);
mssleep(1000); mssleep(1000);
@ -264,7 +315,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
UpdateData[4]=UINT16_LOW(shortAdd); UpdateData[4]=UINT16_LOW(shortAdd);
UpdateData[5]=0x10; UpdateData[5]=0x10;
UpdateData[6]=0xff & j; UpdateData[6]=0xff & j;
memcpy(&UpdateData[7],fw_senddata+92*j,92); memcpy(&UpdateData[7],fw_senddata + 92 * j,92);
tmp = 0x00; tmp = 0x00;
for(int k = 0; k < 99;k++){ for(int k = 0; k < 99;k++){
tmp +=UpdateData[k]; tmp +=UpdateData[k];
@ -285,6 +336,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
zlog_error(zct, "gpio_read failed shortAdd %02x %02x,index = %d", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd),j); zlog_error(zct, "gpio_read failed shortAdd %02x %02x,index = %d", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd),j);
zlog_error(zct, "gpio_read failed \n"); zlog_error(zct, "gpio_read failed \n");
bUpdate = false; bUpdate = false;
upgrade_status = 3;
goto endUpdate; goto endUpdate;
} }
gpio_set(GlobalConfig::GPIO_G.zigAckreset,0); gpio_set(GlobalConfig::GPIO_G.zigAckreset,0);
@ -328,6 +380,7 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
zlog_error(zct, "gpio_read failed shortAdd %02x %02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd)); zlog_error(zct, "gpio_read failed shortAdd %02x %02x", UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
zlog_error(zct, "gpio_read failed \n"); zlog_error(zct, "gpio_read failed \n");
bUpdate = false; bUpdate = false;
upgrade_status = 3;
goto endUpdate; goto endUpdate;
} }
memset(UpdateData, 0x00, sizeof(UpdateData)); memset(UpdateData, 0x00, sizeof(UpdateData));
@ -337,13 +390,27 @@ void Uart::UpdateWirelessNode(uint16_t shortAdd) {
zlog_error(zct, "open file failed "); zlog_error(zct, "open file failed ");
} }
endUpdate: endUpdate:
char localtimestamp_end[32] = {0};
GetTimeNet(localtimestamp_end, 1);
char updateSql[1024] = { 0 };
memset(wherecon,0,sizeof(wherecon));
sprintf(wherecon," start_timestamp = '%s' and short_addr = '%02x%02x'",localtimestamp,UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
sprintf(updateSql, " end_timestamp = '%s',spend_time = %ld,status = %d",localtimestamp_end,atol(localtimestamp_end)-atol(localtimestamp), upgrade_status);
sqlite_db_ctrl::instance().UpdateTableData(" firmware_upgrade ", updateSql,wherecon);
memset(wherecon,0,sizeof(wherecon));
memset(updateSql,0,sizeof(updateSql));
sprintf(wherecon," zigbeeShortAddr = '%02x%02x'",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
sprintf(updateSql, " upgradeStatus = %d", upgrade_status);
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql,wherecon);
free(buffer); free(buffer);
tcflush(fd, TCIFLUSH); tcflush(fd, TCIFLUSH);
sleep(1); sleep(1);
bUpdate = false; bUpdate = false;
bSendTimeStamp = false; bSendTimeStamp = false;
DataNodeUpdateFile = ""; DataNodeUpdateFile = "";
zlog_warn(zct, "UpdateWirelessNode end"); zlog_info(zbt, "UpdateWirelessNode end,shortAddr = %02x%02x",UINT16_HIGH(shortAdd), UINT16_LOW(shortAdd));
} }
int Uart::UpdateConfig(uint16_t ushortAdd) { int Uart::UpdateConfig(uint16_t ushortAdd) {
@ -355,7 +422,6 @@ int Uart::UpdateConfig(uint16_t ushortAdd) {
if (vecResultNode.size() <= 0) return -1; if (vecResultNode.size() <= 0) return -1;
zlog_info(zct, "UpdateConfig"); zlog_info(zct, "UpdateConfig");
bUpdateconfig = true;
GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = ENTER_TRANSMITTING_STATUS; GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = ENTER_TRANSMITTING_STATUS;
GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0; GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0;
@ -363,7 +429,6 @@ int Uart::UpdateConfig(uint16_t ushortAdd) {
sprintf(tmpbuf, "%02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); sprintf(tmpbuf, "%02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
m_strDestShortAddr = std::string(tmpbuf); m_strDestShortAddr = std::string(tmpbuf);
GlobalConfig::Zigbee_G.MyAddr = 0x9999;
mssleep(500); mssleep(500);
vec_t vecResult; vec_t vecResult;
sprintf(selCon, "featureInterVal,waveInterVal,range,samplingRate,ACCSampleTime,startBrands,stopBrands,\ sprintf(selCon, "featureInterVal,waveInterVal,range,samplingRate,ACCSampleTime,startBrands,stopBrands,\
@ -380,7 +445,7 @@ int Uart::UpdateConfig(uint16_t ushortAdd) {
UpdateData[2] = 0xAA; UpdateData[2] = 0xAA;
UpdateData[3] = UINT16_HIGH(ushortAdd); UpdateData[3] = UINT16_HIGH(ushortAdd);
UpdateData[4] = UINT16_LOW(ushortAdd); UpdateData[4] = UINT16_LOW(ushortAdd);
UpdateData[5] = 0x10; UpdateData[5] = 0x0A;
UpdateData[6] = 0x00; UpdateData[6] = 0x00;
UpdateData[7] = 0x01; UpdateData[7] = 0x01;
UpdateData[8] = UINT16_LOW(atoi(vecResult[0].c_str())); UpdateData[8] = UINT16_LOW(atoi(vecResult[0].c_str()));
@ -524,7 +589,7 @@ int Uart::UpdateConfig(uint16_t ushortAdd) {
zlog_error(zct, "updataconfig ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd)); zlog_error(zct, "updataconfig ACK send failed,shortAddr = %02x%02x", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
} }
mssleep(10000); mssleep(50000);
std::string strName = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " dataNodeName ", whereCon); std::string strName = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " dataNodeName ", whereCon);
memset(UpdateData,0x00,sizeof(UpdateData)); memset(UpdateData,0x00,sizeof(UpdateData));
@ -534,10 +599,10 @@ int Uart::UpdateConfig(uint16_t ushortAdd) {
UpdateData[2] = 0xAA; UpdateData[2] = 0xAA;
UpdateData[3] = UINT16_HIGH(ushortAdd); UpdateData[3] = UINT16_HIGH(ushortAdd);
UpdateData[4] = UINT16_LOW(ushortAdd); UpdateData[4] = UINT16_LOW(ushortAdd);
UpdateData[5] = 0x10; UpdateData[5] = 0x0A;
UpdateData[6] = 0x00; UpdateData[6] = 0x01;
UpdateData[7] = 0x02; UpdateData[7] = 0x02;
char hex[200] = {0X00}; char hex[200] = {0x00};
stringToHex(strName.c_str(), hex); stringToHex(strName.c_str(), hex);
bytesSize = strlen(hex) / 2; bytesSize = strlen(hex) / 2;
bytes = (unsigned char*)malloc(bytesSize); bytes = (unsigned char*)malloc(bytesSize);