add codes
This commit is contained in:
parent
7f00e1ce52
commit
07c30f4a60
8
Makefile
8
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
|
||||
|
||||
@ -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 = "";
|
||||
|
||||
@ -106,6 +106,11 @@ std::string JsonData::JsonCmd_Cgi_50() {
|
||||
std::vector<std::string> value;
|
||||
std::vector<DataNodeUpdate> 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);
|
||||
|
||||
}
|
||||
|
||||
@ -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_);
|
||||
|
||||
@ -47,49 +47,47 @@ int UpgradeCfg::ReadCfg(std::map<int, UpgradeInfo> &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();
|
||||
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<int, UpgradeInfo> &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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user