diff --git a/Makefile b/Makefile index 23ab0d4..f09e5ae 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ LIBS = -L../Tools/renesas_thirdparty/lib \ -L../Tools/renesas_thirdparty/lib \ -lsqlite3 -lboost_system -lpthread -lboost_thread -lboost_date_time -lboost_filesystem -lfftw3 -ljsoncpp -lmosquitto -lcurl -lzlog -CFLAGS = -O0 -fpermissive -fstack-protector-all #-Wall -Werror +CFLAGS = -O0 -g -std=c++14 -fpermissive -fstack-protector-all #-Wall -Werror LINKFLAGS = AllDirs :=$(shell ls -R | grep '^\./.*:' | awk '{if( \ @@ -67,8 +67,8 @@ install: $(TARGET) uninstall: rm -f $(PREFIX_BIN)/$(TARGET) -strip: - $(STRIP) $(TARGET) - cp $(TARGET) ~/tftpboot +#strip: +# $(STRIP) $(TARGET) +# cp $(TARGET) ~/tftpboot rebuild: clean compile diff --git a/jsonparse/cmt_parse.cpp b/jsonparse/cmt_parse.cpp index 3f7dcec..a8d3aec 100644 --- a/jsonparse/cmt_parse.cpp +++ b/jsonparse/cmt_parse.cpp @@ -226,7 +226,7 @@ void JsonData::CmtCmd_82(char* MeasurementID,char* send_data,int& channel,int& s free(buffer); } -void JsonData::CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_length) +void JsonData:: CmtCmd_83(char* recv_body,int& count,char* send_data,int& send_length) { vec_t vecRes; std::string filename = ""; diff --git a/jsonparse/web_cmd_parse3.cpp b/jsonparse/web_cmd_parse3.cpp index 953ea90..d38dd5f 100644 --- a/jsonparse/web_cmd_parse3.cpp +++ b/jsonparse/web_cmd_parse3.cpp @@ -106,6 +106,11 @@ std::string JsonData::JsonCmd_Cgi_50() { std::vector value; std::vector vecDataNodeUpdate; DataNodeUpdate datanodeUpdate; + std::fstream is; + is.open("/opt/DataNode/config.json", std::ios::in); + if (reader.parse(is, root)) { + jsBody["sensor"] = root; + } jsBody["GateWayVersion"] = GlobalConfig::Version; jsBody["SystemVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion"); jsBody["WebVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion"); @@ -614,14 +619,6 @@ std::string JsonData::JsonCmd_Cgi_59(Param_59 ¶m) { Json::Value iTem; iTem.append(arrResult[i][1]); iTem.append(arrResult[i][0]); - int time = 0; - int lost_data_time = atol(arrResult[i][1].c_str()) - atol(arrResult[i][1].c_str()); - if (param.mMode == 1){ - time = abs(lost_data_time/featureInterVal); - }else if(param.mMode == 2){ - time = abs(lost_data_time/waveInterVal); - } - iTem.append(time); valData.append(iTem); } jsonVal["content"] = valData; @@ -644,7 +641,7 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){ jsonVal["success"] = true; jsonVal["message"] = ""; char file_path[64]={0}; - char cmd[128]={0}; + char cmd[64]={0}; sprintf(cmd, "mv /opt/%s /opt/DataNode/",param.fileName.c_str()); system(cmd); sprintf(file_path, "/opt/DataNode/%s",param.fileName.c_str()); @@ -751,17 +748,16 @@ std::string JsonData::JsonCmd_Cgi_60(Param_60 ¶m){ char *end_ptr = NULL; short_addr = strtol(vecResult[3].c_str(), &end_ptr, 16); int res = scheduler::instance().UpgradeSensor(short_addr,std::string(sensor_type),atoi(vecResult[0].c_str()),vecResult[1],std::string(sf_version)); - if (res != 0){ + if (res != 0) + { jsonVal["success"] = false; jsonVal["message"] = "UpgradeSensor error"; free(buffer); return show_value_.write(jsonVal); } - zlog_info(zct,"000000000000"); } free(buffer); - zlog_info(zct,"11111111111"); return show_value_.write(jsonVal); } diff --git a/scheduler/schedule.cpp b/scheduler/schedule.cpp index e12ce63..fb9fcfa 100644 --- a/scheduler/schedule.cpp +++ b/scheduler/schedule.cpp @@ -319,7 +319,7 @@ SensorScheduler::SensorScheduler() { ShortAddrCfg::ReadCfg(short_addr_map_); // read upgrade config file: UPGRADE_CONFIG - UpgradeCfg::ReadCfg(upgrade_); + //UpgradeCfg::ReadCfg(upgrade_); // read config update file: CONFIG_UPDATE UpdateCfg::ReadCfg(update_); diff --git a/scheduler/upgrade_cfg.cpp b/scheduler/upgrade_cfg.cpp index e61276d..c6a2ca2 100644 --- a/scheduler/upgrade_cfg.cpp +++ b/scheduler/upgrade_cfg.cpp @@ -47,49 +47,47 @@ int UpgradeCfg::ReadCfg(std::map &upgrade) { info.current_sw_version = item["current_sw_version"].asString(); info.upgrade_sw_version = item["upgrade_sw_version"].asString(); info.submit_time = item["submit_time"].asString(); - for (const auto &time_item : item["try_world_time"]) { - info.try_world_time1.push_back(time_item.asString()); + if (info.try_times > 0) { + for (const auto &time_item : item["try_world_time"]) { + info.try_world_time1.push_back(time_item.asString()); + } } upgrade[item["id"].asInt()] = info; zlog_info(zbt, "[UpgradeCfg] id:%d need to upgrade from:%s to %s", item["id"].asInt(), info.current_sw_version.c_str(), info.upgrade_sw_version.c_str()); } + return 0; } int UpgradeCfg::WriteCfg(std::map &upgrade) { - // if (upgrade.size() == 0) { - // ClearCfg(); - // return 0; - // } - zlog_info(zct,"123 = %d",upgrade.size()); - // Json::Value root; - // for (auto item : upgrade) { - // zlog_info(zct,"1111"); - // Json::Value upgrade_item; - // upgrade_item["id"] = item.first; - // upgrade_item["try_times"] = item.second.try_times; - // upgrade_item["type"] = item.second.sensor_type; - // upgrade_item["hw_version"] = item.second.hw_version; - // upgrade_item["current_sw_version"] = item.second.current_sw_version; - // upgrade_item["upgrade_sw_version"] = item.second.upgrade_sw_version; - // upgrade_item["submit_time"] = item.second.submit_time; - // Json::Value try_world_time; - // zlog_info(zct,"2222"); - // for (auto entry : item.second.try_world_time1) { - // try_world_time.append(entry); - // } - // zlog_info(zct,"333"); - // upgrade_item["try_world_time"] = try_world_time; - // root.append(upgrade_item); - // zlog_info(zct,"444"); - // } - // zlog_info(zct,"456"); - // Json::StyledStreamWriter streamWriter; - // std::ofstream out_file(UPGRADE_CONFIG); - // streamWriter.write(out_file, root); - // out_file.close(); + if (upgrade.size() == 0) { + ClearCfg(); + return 0; + } + + Json::Value root; + for (auto item : upgrade) { + Json::Value upgrade_item; + upgrade_item["id"] = item.first; + upgrade_item["try_times"] = item.second.try_times; + upgrade_item["type"] = item.second.sensor_type; + upgrade_item["hw_version"] = item.second.hw_version; + upgrade_item["current_sw_version"] = item.second.current_sw_version; + upgrade_item["upgrade_sw_version"] = item.second.upgrade_sw_version; + upgrade_item["submit_time"] = item.second.submit_time; + Json::Value try_world_time; + for (auto entry : item.second.try_world_time1) { + try_world_time.append(entry); + } + upgrade_item["try_world_time"] = try_world_time; + root.append(upgrade_item); + } + Json::StyledStreamWriter streamWriter; + std::ofstream out_file(UPGRADE_CONFIG); + streamWriter.write(out_file, root); + out_file.close(); return 0; } diff --git a/threadfunc/check_thread.cpp b/threadfunc/check_thread.cpp index a57d81b..8aee5e4 100644 --- a/threadfunc/check_thread.cpp +++ b/threadfunc/check_thread.cpp @@ -39,7 +39,7 @@ void CheckThread() { if (10 == heart_count) { if (GlobalConfig::LinkCount > 30) { zlog_error(zct, "MQTT connect failed "); - } + } std::string ipTemp = IpAddrInit(); GlobalConfig::IpAddr_G = ipTemp; heart_count = 0; @@ -51,7 +51,7 @@ void CheckThread() { 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); + std::string str2 = std::string(buf2); 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());