diff --git a/common/common_func.cpp b/common/common_func.cpp index 862557c..90c3051 100644 --- a/common/common_func.cpp +++ b/common/common_func.cpp @@ -699,6 +699,12 @@ void ImportConfig(std::string filename) { WriteStr2Config(SYSTEMINFOFILE, "Version", "WebVersion", jsSystemInfo["WebVersion"].asString()); WriteStr2Config(SYSTEMINFOFILE, "Version", "GateWayHwVesion", jsSystemInfo["GateWayHwVesion"].asString()); WriteStr2Config(SYSTEMINFOFILE, "Version", "GateWayProduct", jsSystemInfo["GateWayProduct"].asString()); + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + sprintf(updateSql, "zigbeePanID = '%s',zigbeeChannel = '%s'",\ + jsonValZigbee["PanID"].asString().c_str(),jsonValZigbee["channel"].asString().c_str()); + sprintf(whereCon, "gatewayMAC='%s'", GlobalConfig::MacAddr_G.c_str()); + sqlite_db_ctrl::instance().UpdateTableData(T_GATEWAY_INFO(TNAME), updateSql, whereCon); } int UpdataDataNodeConfig(std::string filename) { diff --git a/common/global.hpp b/common/global.hpp index f8b3ec6..ad8569c 100644 --- a/common/global.hpp +++ b/common/global.hpp @@ -18,7 +18,7 @@ enum enumZigBeeTransmitStatus { //#define NR5G_MODULE -//#define Q4G_MODULE +#define Q4G_MODULE //#define WIFI_MODULE //#define NR5G_MEIGE diff --git a/jsonparse/web_cmd_parse2.cpp b/jsonparse/web_cmd_parse2.cpp index e50725f..85844c8 100644 --- a/jsonparse/web_cmd_parse2.cpp +++ b/jsonparse/web_cmd_parse2.cpp @@ -768,6 +768,13 @@ std::string JsonData::JsonCmd_Cgi_31(Param_31 ¶m) { if (0 == param.mMode) { WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", param.mChannelId); WriteStr2Config(ZIGBEECONFIG, "Zigbee", "PanID", param.mPanID); + char whereCon[1024] = {0}; + char updateSql[1024] = { 0 }; + sprintf(updateSql, "zigbeePanID = '%s',zigbeeChannel = '%s'",\ + param.mPanID.c_str(),param.mChannelId.c_str()); + sprintf(whereCon, "gatewayMAC='%s'", GlobalConfig::MacAddr_G.c_str()); + sqlite_db_ctrl::instance().UpdateTableData(T_GATEWAY_INFO(TNAME), updateSql, whereCon); + system("reboot"); } Json::Value jsBody; jsonVal["message"] = "设置完成"; diff --git a/threadfunc/check_thread.cpp b/threadfunc/check_thread.cpp index 2ce56e4..42d27f8 100644 --- a/threadfunc/check_thread.cpp +++ b/threadfunc/check_thread.cpp @@ -59,6 +59,28 @@ void CheckThread() { iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str()); if (iRet != 0) { zlog_error(zct, "MQTT connect failed ,time check"); +#ifdef Q4G_MODULE + char localtimestamp[32] = { 0 }; + GetTimeNet(localtimestamp, 1); + char whereCon[100]={0}; + sprintf(whereCon,"DATE(timestamp, 'unixepoch') = DATE('now') ORDER BY timeStamp DESC limit 0,1"); + std::string strCount = sqlite_db_ctrl::instance().GetData(" reboot_record ", "count", whereCon); + if (atoi(strCount.c_str()) < 3)//当天大于三次不再重启进程 + { + char insertSql[64] = {0}; + sprintf(insertSql, "'%s',%d,'%s'",localtimestamp,atoi(strCount.c_str())+1,"4G connect failed "); + sqlite_db_ctrl::instance().InsertData(" reboot_record ", insertSql); + gpio_set(GlobalConfig::GPIO_G.commPower,0); + zlog_warn(zct,"commPower start\n"); + sleep(2); + gpio_set(GlobalConfig::GPIO_G.commPower,1); + zlog_warn(zct,"commPower End\n"); + sleep(2); + system("reboot"); + }else{ + zlog_error(zct,"Q4G_MODULE error\n"); + } +#endif #ifdef NR5G_MODULE dial.closePort(); gpio_set(GlobalConfig::GPIO_G.commPower, 0);