WLG/jsonparse/web_cmd_parse3.cpp
2025-05-20 17:47:29 +08:00

1222 lines
48 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "communication_cmd.hpp"
#include <fstream>
#include <boost/algorithm/string.hpp>
#include <zlog.h>
#include "common/global.hpp"
#include "dbaccess/sql_db.hpp"
#include "platform/platform_init.hpp"
#include "utility/md5.h"
#include "wifi_5g/wpa_client.h"
#include "utility/calculation.hpp"
#include "scheduler/schedule.hpp"
extern zlog_category_t *zct;
extern const char *JSON_FIELD_CMD;
std::string JsonData::JsonCmd_Cgi_default() {
Json::Value jsonVal;
jsonVal.clear();
jsonVal["success"] = false;
jsonVal["message"] = "功能不支持";
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_45(Param_45 &param) {
Json::Value jsonVal;
jsonVal.clear();
if (0 == param.mMode) {
char localtimestamp[32] = {0};
GetTimeNet(localtimestamp, 1);
std::string nowTimetamp = std::string(localtimestamp);
WriteStr2Config(SYSTEMINFOFILE, "Area", "countryId", param.mCountryId);
WriteStr2Config(SYSTEMINFOFILE, "Area", "provincesId", param.mProvincesId);
WriteStr2Config(SYSTEMINFOFILE, "Area", "cityListId", param.mCityListId);
}
jsonVal[JSON_FIELD_CMD] = "45";
jsonVal["success"] = true;
jsonVal["message"] = "区域配置成功";
Json::Value jsBody;
jsBody["countryId"] = ReadStrByOpt(SYSTEMINFOFILE, "Area", "countryId");
jsBody["provincesId"] = ReadStrByOpt(SYSTEMINFOFILE, "Area", "provincesId");
jsBody["cityListId"] = ReadStrByOpt(SYSTEMINFOFILE, "Area", "cityListId");
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_46(Param_46 &param) {
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "46";
jsonVal["success"] = true;
jsonVal["message"] = "升级失败";
std::string strFile = "/var/" + param.mFileName;
if (access(strFile.c_str(), 0) >= 0) {
std::string strCmd = "mv " + strFile + " /tmp/upgrade.tar.gz";
system(strCmd.c_str());
system("/etc/init.d/sysupgrade.sh");
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有升级包";
return show_value_.write(jsonVal);
}
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_47(Param_47 &param) {
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "47";
jsonVal["success"] = true;
jsonVal["message"] = "logo配置成功";
std::string strFile = "/var/" + param.mFileName;
if (access(strFile.c_str(), 0) >= 0) {
std::string strCmd = "mv " + strFile + " /var/www/html/static/media/logo.svg";
system(strCmd.c_str());
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有找到logo";
return show_value_.write(jsonVal);
}
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_50() {
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "50";
jsonVal["success"] = true;
jsonVal["message"] = "";
std::string strFileName = "", strSoftVersion = "";
Json::Value root;
Json::Value jsBody;
Json::Reader reader;
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");
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_51(Param_51 &param) {
Json::Value jsonVal;
jsonVal.clear();
Json::Value jsBody;
jsonVal[JSON_FIELD_CMD] = "51";
jsonVal["success"] = true;
jsonVal["message"] = "";
char whereCon[1024] = {0};
char updateSql[1024] = {0};
std::string gatewayLocation = "";
sprintf(updateSql, "gatewayLocation='%s'", param.strGateWayLocation.c_str());
sprintf(whereCon, "gatewayMAC='%s'", param.strGateWayMAC.c_str());
if (param.mMode == 0) {
int iRet = sqlite_db_ctrl::instance().UpdateTableData(T_GATEWAY_INFO(TNAME), updateSql, whereCon);
if (iRet != 0) jsonVal["success"] = false;
} else {
gatewayLocation = sqlite_db_ctrl::instance().GetData(T_GATEWAY_INFO(TNAME), "gatewayLocation", NULL);
jsBody["gateWayLocation"] = gatewayLocation;
}
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_52(Param_52 &param) {
Json::Value jsonVal;
Json::Value jsBody;
jsonVal.clear();
jsonVal["cmd"] = "52";
jsonVal["dataWatchNo"] = GlobalConfig::MacAddr_G;
jsonVal["cmdSerial"] = param.mCmdSerial;
jsonVal["success"] = true;
jsonVal["message"] = " ";
#ifndef WIFI_MODULE
jsonVal["success"] = false;
jsonVal["message"] = " ";
jsonVal["enable"] = false;
return show_value_.write(jsonVal);
#endif
jsonVal["enable"] = true;
if (0 == param.mMode) { // 扫描
wifi::WPAClient wpa;
std::string netssid = wpa.GetNetSsid();
std::vector<std::string> vecSsid;
boost::split(vecSsid, netssid, boost::is_any_of("\n"), boost::token_compress_off);
jsBody["type"] = "SCAN";
zlog_info(zct,"netssid : %s ==== %d", netssid.c_str(), vecSsid.size());
for (unsigned int i = 1; i < vecSsid.size() - 1; i++) {
std::vector<std::string> data;
boost::split(data, vecSsid[i], boost::is_any_of("\t"), boost::token_compress_off);
Json::Value wifiInfo;
wifiInfo["bssid"] = data[0];
wifiInfo["frequency"] = data[1];
wifiInfo["signallevel"] = data[2];
wifiInfo["secure"] = data[3];
wifiInfo["ssid"] = data[4];
jsBody["wifilist"].append(wifiInfo);
}
} else if (1 == param.mMode) { // 设置
zlog_info(zct,"set WiFi");
wifi::WPAClient wpa;
jsBody["ssid"] = param.mSsid;
if (param.mPassWord.length() > 0) {
if (wpa.ConnectWiFi(param.mSsid.c_str(), param.mPassWord.c_str())) {
jsBody["status"] = true;
} else {
jsBody["status"] = false;
}
} else {
if (wpa.ConnectWiFiWithNoPassword(param.mSsid.c_str())) {
jsBody["status"] = true;
} else {
jsBody["status"] = false;
}
}
} else if (2 == param.mMode) { // 获取
wifi::WPAClient wpa;
std::string ssid = " ";
int rssi = 0;
ssid = wpa.GetCurrentSSID();
rssi = wpa.GetWiFiRssi();
jsBody["ssid"] = ssid;
jsBody["rssi"] = rssi;
} else if (3 == param.mMode) {
wifi::WPAClient wpa;
if (wpa.CleanWifi()) {
jsonVal["message"] = "wifi断开成功";
} else {
jsonVal["message"] = "wifi断开失败";
}
}
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_53(std::vector<Param_53> &param) {
Json::Value jsonVal;
jsonVal.clear();
jsonVal["cmd"] = "53";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = " ";
char whereCon[1024] = {0};
char updateSql[1024] = {0};
for (size_t i = 0; i < param.size(); i++) {
sprintf(whereCon, "dataNodeNo='%s'", param[i].mdataNodeNo.c_str());
std::string zigbeeShortAddr = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", whereCon);
uint16_t short_addr;
char *end_ptr = NULL;
short_addr = strtol(zigbeeShortAddr.c_str(), &end_ptr, 16);
int res = scheduler::instance().UpdateSensorConfig(short_addr);
if (res != 0){
jsonVal["success"] = false;
jsonVal["message"] = "update config error";
return show_value_.write(jsonVal);
}
if (param[i].mUpdateKey2 == "") {
sprintf(updateSql, "%s='%s',UpdateFlag = 0", param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str());
} else if (param[i].mUpdateKey3 == "" && param[i].mUpdateKey2 != "") {
sprintf(updateSql, "%s='%s',%s='%s',UpdateFlag = 0", param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str(), param[i].mUpdateKey2.c_str(), param[i].mUpdateValue2.c_str());
} else if (param[i].mUpdateKey3 != "" && param[i].mUpdateKey2 != "") {
sprintf(updateSql, "%s='%s',%s='%s',%s='%s',UpdateFlag = 0", param[i].mUpdateKey.c_str(), param[i].mUpdateValue.c_str(), param[i].mUpdateKey2.c_str(), param[i].mUpdateValue2.c_str(), param[i].mUpdateKey3.c_str(), param[i].mUpdateValue3.c_str());
}
sprintf(whereCon, "dataNodeNo='%s'", param[i].mdataNodeNo.c_str());
int iRet = sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon);
memset(whereCon, 0x00, sizeof(whereCon));
memset(updateSql, 0x00, sizeof(updateSql));
if (iRet != 0) jsonVal["success"] = false;
}
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_55(Param_55 &param) {
Json::Value jsonVal;
Json::Value jsBody;
Json::Value SystemSetting;
jsonVal.clear();
jsonVal["cmd"] = "55";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = " ";
std::vector<float> vecWave;
std::vector<float> IntegrationWave;
char whereCon[64] = {};
sprintf(whereCon, "dataNodeNo='%s'", param.mDataNodeNo.c_str());
vec_t res = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " * ", whereCon);
int SampleRate = 0;
double resolution = 0.0;
SampleRate = atoi(res[23].c_str());
zlog_info(zct,"sensor type %s", res[17].c_str());
char localtimestamp[32] = {0};
std::string strWaveData = "";
std::string filename = "/opt/data/" + param.mChannelId + ".dat";
if (access(filename.c_str(), 0) >= 0) {
std::ifstream inFile(filename.c_str(), std::ios::in | std::ios::binary);
if (!inFile) {
zlog_error(zct, "read channel data error, filename:%s", filename.c_str());
jsonVal["success"] = false;
jsonVal["message"] = "error";
} else {
float fTemp = 0;
std::vector<float> hanningWave;
inFile.read((char *)localtimestamp, sizeof(localtimestamp));
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
vecWave.push_back(fTemp);
}
if (res[17] == "01") {
zlog_info(zct,"sample_rate=%d", SampleRate);
resolution = (((double)SampleRate / 1000) * 1016) / vecWave.size();
} else if (res[17] == "02") {
std::string::size_type comper = param.mChannelId.find("Z");
if (comper != std::string::npos) {
resolution = (double)SampleRate / vecWave.size();
zlog_info(zct,"sample_rate=%d,resolution = %f", SampleRate, resolution);
} else {
SampleRate = 8000;
zlog_info(zct,"sample_rate=%d", SampleRate);
resolution = (((double)SampleRate / 1024) * 1024) / 8192;
}
}
//积分
Calculation::Integration(vecWave, IntegrationWave, resolution);
int flag = param.mPackageFlag;
flag = (flag + 1) * 1024;
int number = IntegrationWave.size();
int start = param.mPackageFlag * 1024;
if (number < 1024) {
flag = number;
start = 0;
}
char buf[32];
for (int i = start; i < flag; i++) {
if (i == start) {
memset(buf, 0, 32);
sprintf(buf, "%.2f", IntegrationWave[i]);
std::string waveTemp(buf);
strWaveData = waveTemp;
} else {
memset(buf, 0, 32);
sprintf(buf, "%.2f", IntegrationWave[i]);
std::string waveTemp(buf);
strWaveData = strWaveData + "," + waveTemp;
}
}
int max = number / 1024;
if (max == 0 && number > 0) {
max = 1;
}
jsBody["packageMax"] = max;
}
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有数据文件";
}
jsBody["channelId"] = param.mChannelId;
jsBody["package"] = param.mPackageFlag;
zlog_info(zct,"vecWave.size() = %d,sample = %d,second = %f", IntegrationWave.size(), atoi(res[23].c_str()), float(IntegrationWave.size() / atoi(res[23].c_str())));
std::string::size_type comper = param.mChannelId.find("Z");
if (comper != std::string::npos && res[17] == "02") {
jsBody["second"] = float((float)IntegrationWave.size() / (float)atoi(res[23].c_str()));
} else if (res[17] == "01") {
jsBody["second"] = float((float)IntegrationWave.size() / (float)atoi(res[23].c_str()));
} else {
jsBody["second"] = 1;
}
jsBody["Data"] = strWaveData;
jsBody["timestamp"] = std::string(localtimestamp);
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_56(Param_56 &param) {
Json::Value jsonVal;
Json::Value jsBody;
Json::Value SystemSetting;
jsonVal.clear();
jsonVal["cmd"] = "56";
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
jsonVal["success"] = true;
jsonVal["message"] = "";
std::string strWaveData;
std::string filename = "/opt/data/" + param.mChannelId + ".dat";
char localtimestamp[32] = {0};
std::vector<float> vecWave;
std::vector<float> hanningWave;
std::vector<float> addhanningWave;
std::vector<float> fftWave;
std::vector<float> IntegrationWave;
int sampleRateReference = 0;
char whereCon[64] = {0};
sprintf(whereCon, "dataNodeNo='%s'", param.mDataNodeNo.c_str());
vec_t res = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " * ", whereCon);
int SampleRate = 0;
double resolution = 0.0;
SampleRate = atoi(res[23].c_str());
zlog_info(zct,"sensor type %s", res[17].c_str());
if (access(filename.c_str(), 0) >= 0) {
std::ifstream inFile(filename.c_str(), std::ios::in | std::ios::binary);
if (!inFile) {
zlog_error(zct, "read channel data error, filename:%s", filename.c_str());
jsonVal["success"] = "false";
jsonVal["message"] = "error";
} else {
float fTemp = 0;
inFile.read((char *)localtimestamp, sizeof(localtimestamp));
std::string::size_type comper = param.mChannelId.find("Z");
if (comper != std::string::npos && res[17] == "02") {
while (inFile.read((char *)&fTemp, sizeof(fTemp))) {
vecWave.push_back(fTemp);
}
//积分
resolution = (double)SampleRate / vecWave.size();
Calculation::Integration(vecWave, IntegrationWave, resolution);
Calculation::FFTSpec(IntegrationWave, fftWave);
sampleRateReference = 1000;
} else {
while (inFile.read((char *)&fTemp, sizeof(fTemp))) { // 取8K进行计算
vecWave.push_back(fTemp);
}
if (res[17] == "01") {
zlog_info(zct,"sample_rate=%d", SampleRate);
resolution = (((double)SampleRate / 1000) * 1016) / vecWave.size();
} else if (res[17] == "02") {
std::string::size_type comper = param.mChannelId.find("Z");
if (comper != std::string::npos) {
SampleRate = atoi(res[23].c_str());
resolution = (double)SampleRate / vecWave.size();
zlog_info(zct,"sample_rate=%d,resolution = %f", SampleRate, resolution);
} else {
SampleRate = 8192;
zlog_info(zct,"sample_rate=%d", SampleRate);
if (vecWave.size() < 8192) {
resolution = (double)SampleRate / vecWave.size();
} else {
resolution = (double)SampleRate / 8192;
}
}
}
// 积分
Calculation::Integration(vecWave, IntegrationWave, resolution);
Calculation::FFTSpec(IntegrationWave, fftWave);
sampleRateReference = 1024;
}
zlog_info(zct,"2---------------------------------------------->vecWave = %d,fftWave = %d", vecWave.size(), fftWave.size());
int flag = param.mPackageFlag;
flag = (flag + 1) * sampleRateReference;
int number = fftWave.size();
zlog_info(zct,"number---------------------------------------------->%d", number);
int start = param.mPackageFlag * sampleRateReference;
zlog_info(zct,"param.mPackageFlag = %d", param.mPackageFlag);
zlog_info(zct,"param.start = %d", start);
zlog_info(zct,"param.flag = %d", flag);
if (number < sampleRateReference) {
flag = number;
start = 0;
}
char buf[32];
for (int i = start; i < flag; i++) {
if (i == start) {
memset(buf, 0, 32);
sprintf(buf, "%.6f", fftWave[i]);
std::string waveTemp(buf);
strWaveData = waveTemp;
} else {
memset(buf, 0, 32);
sprintf(buf, "%.6f", fftWave[i]);
std::string waveTemp(buf);
strWaveData = strWaveData + "," + waveTemp;
}
}
int max = number / sampleRateReference;
if (max == 0 && number > 0) {
max = 1;
}
jsBody["packageMax"] = max;
}
} else {
jsonVal["success"] = false;
jsonVal["message"] = "没有数据文件";
}
jsBody["channelId"] = param.mChannelId;
jsBody["package"] = param.mPackageFlag;
jsBody["timestamp"] = std::string(localtimestamp);
jsBody["Data"] = strWaveData;
zlog_info(zct,"the sample rate is %d,the resolution %f", SampleRate, resolution);
char buf[32];
memset(buf, 0, 32);
sprintf(buf, "%f", resolution);
jsBody["resolution"] = std::string(buf);
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_57(Param_57 &param) {
Json::Value jsonVal;
jsonVal.clear();
Json::Value jsBody;
jsonVal[JSON_FIELD_CMD] = "57";
jsonVal["success"] = true;
jsonVal["message"] = "";
int zigbeepowerEnable = -1;
if (param.mMode == 1) {
zigbeepowerEnable = writeIntValue("config", "zigbeepowerEnable", param.mZigbeePowerEnable, (char *)GlobalConfig::Config_G.c_str());
} else if (param.mMode == 0) {
zigbeepowerEnable = readIntValue("config", "zigbeepowerEnable", (char *)GlobalConfig::Config_G.c_str());
}
jsBody["zigbeepowerEnable"] = zigbeepowerEnable;
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_58(Param_58 &param) {
Json::Value jsonVal;
jsonVal.clear();
Json::Value jsBody;
jsonVal[JSON_FIELD_CMD] = "58";
jsonVal["success"] = true;
jsonVal["message"] = "";
int ret = 0,sensorCount = 0;
std::string error_msg = "";
if (param.mMode == 1)
{
ret = scheduler::instance().Config(param.featureInterVal,param.waveInterVal,param.featureInterTime,param.waveInterTime,param.maxSensorNum,error_msg);
}else if (param.mMode == 0)
{
sensorCount = sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), NULL);
ret = scheduler::instance().GetScheduleConfig(param.featureInterVal,param.waveInterVal,param.featureInterTime,param.waveInterTime,param.maxSensorNum);
}
if (ret == 0)
{
jsBody["featureInterVal"] = param.featureInterVal;
jsBody["featureInterTime"] = param.featureInterTime;
jsBody["waveInterVal"] = param.waveInterVal;
jsBody["waveInterTime"] = param.waveInterTime;
jsBody["maxSensorNum"] = param.maxSensorNum;
jsBody["sensorCount"] = sensorCount;
}else{
jsonVal["success"] = false;
jsonVal["message"] = error_msg;
}
jsonVal["content"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_59(Param_59 &param) {
Json::Value jsonVal;
jsonVal.clear();
Json::Value jsBody;
jsonVal[JSON_FIELD_CMD] = "59";
jsonVal["success"] = true;
jsonVal["message"] = "";
char table_name[50] ={0};
char sql[1024]={0};
int featureInterVal = 0;
int featureInterTime = 0;
int waveInterVal = 0;
int waveInterTime = 0;
int maxSensorNum = 0;
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
if (param.mMode == 1)
{
sprintf(table_name,"t_dataStatic_%s",param.DataNodeNo.c_str());
snprintf(sql, sizeof(sql),
"WITH CTE AS ("
" SELECT timestamp, "
" LAG(timestamp) OVER (ORDER BY timestamp) AS prev_timestamp "
" FROM %s"
") "
"SELECT timestamp, "
" prev_timestamp, "
" timestamp - prev_timestamp AS interval_seconds "
"FROM CTE "
"WHERE prev_timestamp IS NOT NULL "
" AND (timestamp - prev_timestamp) > %d;",
table_name,featureInterVal + 6);
}else if (param.mMode == 2)
{
sprintf(table_name,"t_data_waveSend");
snprintf(sql, sizeof(sql),
"WITH CTE AS ("
" SELECT timestamp, "
" LAG(timestamp) OVER (ORDER BY timestamp) AS prev_timestamp "
" FROM %s WHERE channelID = '%s-%s'"
") "
"SELECT timestamp, "
" prev_timestamp, "
" timestamp - prev_timestamp AS interval_seconds "
"FROM CTE "
"WHERE prev_timestamp IS NOT NULL "
" AND (timestamp - prev_timestamp) > %d;",
table_name,param.DataNodeNo.c_str(),param.straxis.c_str(),waveInterVal + 40);
jsonVal["Raxis"] = param.straxis;
}
array_t arrResult = sqlite_db_ctrl::instance().GetDataMultiLine(sql);
Json::Value valData;
if (arrResult.size() > 0)
{
for (size_t i = 0; i < arrResult.size(); i++)
{
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;
}else{
jsonVal["success"] = false;
jsonVal["message"] = "获取数据失败!";
jsonVal["content"].resize(0);
}
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_60(Param_60 &param){
Json::Value jsonVal;
jsonVal.clear();
Json::Value jsBody;
jsonVal[JSON_FIELD_CMD] = "60";
jsonVal["success"] = true;
jsonVal["message"] = "";
char file_path[64]={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());
zlog_info(zct,"file_path = %s",file_path);
FILE * pFile=NULL;
size_t thisSize = 0;
char *buffer=NULL;
pFile = fopen (file_path,"rb");
if (pFile==NULL) {
zlog_error(zct,"Error opening file");
jsonVal["success"] = false;
jsonVal["message"] = "Error opening file";
return show_value_.write(jsonVal);
}
else
{
while (fgetc(pFile) != EOF) {
++thisSize;
}
rewind(pFile);
buffer = (char*)malloc(thisSize);
fread (buffer, sizeof (char), thisSize, pFile);
fclose (pFile);
}
zlog_info(zct,"Read %zu bytes", thisSize);
char sensor_type[6] = {0};
char sf_version[10] = {0};
memcpy(sensor_type, buffer, 5);
zlog_info(zct,"model:%s", sensor_type);
if (param.product == 1 ){
if (strcmp(sensor_type,"DN101") != 0){
jsonVal["success"] = false;
jsonVal["message"] = "product error";
free(buffer);
return show_value_.write(jsonVal);
}
}else if(param.product == 2){
if (strcmp(sensor_type,"DN102") != 0){
jsonVal["success"] = false;
jsonVal["message"] = "product error";
free(buffer);
return show_value_.write(jsonVal);
}
}
char c[2] = {0};
c[0] = buffer[5];
uint8_t hw_ver = atoi(c);
c[0] = buffer[6];
uint8_t sf_ver_m = atoi(c);
c[0] = buffer[7];
uint8_t sf_ver_s = atoi(c);
sprintf(sf_version,"%d.%d",sf_ver_m,sf_ver_s);
unsigned char ch_crc = 0x00;
int packgeSize = 0;
ch_crc = buffer[12];
packgeSize = BUILD_UINT32(buffer[8],buffer[9],buffer[10],buffer[11]);
zlog_info(zct,"sf_ver_m = %d",sf_ver_m);
zlog_info(zct,"sf_ver_s = %d",sf_ver_s);
zlog_info(zct,"hw_ver = %d",hw_ver);
zlog_info(zct,"sensor_type = %s",sensor_type);
zlog_info(zct,"packgeSize = %d",packgeSize);
zlog_info(zct,"ch_crc = %02x",ch_crc);
unsigned char sum = 0x00;
for(size_t i = 13; i < thisSize;i++){
sum += buffer[i];
}
if (sum % 256 != ch_crc)
{
jsonVal["success"] = false;
jsonVal["message"] = "package CRC error";
free(buffer);
return show_value_.write(jsonVal);
}
zlog_info(zct,"sum = %x\n",sum % 256);
char localtimestamp[32] = {0};
GetTimeNet(localtimestamp, 1);
for (size_t i = 0; i < param.dataNodeNo.size(); i++)
{
char wherecon[100] = {0};
char insertSql[200] = {0};
char updateSql[100] = {0};
sprintf(wherecon," dataNodeNo = '%s' ",param.dataNodeNo[i].c_str());
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(T_SENSOR_INFO(TNAME), " hardVersion,softVersion,ProductNo,zigbeeShortAddr ", wherecon);
if (hw_ver != atoi(vecResult[0].c_str()))
{
jsonVal["success"] = false;
jsonVal["message"] = "hardVersion error";
free(buffer);
return show_value_.write(jsonVal);
}
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);
//0 默认状态1 升级中2 升级成功,3 升级失败
memset(wherecon,0,sizeof(wherecon));
memset(updateSql,0,sizeof(updateSql));
sprintf(wherecon," zigbeeShortAddr = '%s'",vecResult[3].c_str());
sprintf(updateSql, " upgradeStatus = %d ", 1);
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), updateSql,wherecon);
uint16_t short_addr;
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)
{
jsonVal["success"] = false;
jsonVal["message"] = "UpgradeSensor error";
free(buffer);
return show_value_.write(jsonVal);
}
}
free(buffer);
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_61(Param_61 &param){
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "61";
jsonVal["success"] = true;
jsonVal["message"] = " ";
vec_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL);
int nSize = vetRes.size();
if (nSize > 0) {
char selectCon[256] = {0}, szTableName[100] = {0x00}, whereCon[256] = {0x00};
sprintf(selectCon, " channelID,timeStamp,sendMsg,error_code ");
sprintf(szTableName, "t_data_waveSend");
if (param.timeEnd == "") {
sprintf(whereCon, "channelID = '%s-%s'", param.MeasurementID.c_str(),param.straxis.c_str());
} else {
sprintf(whereCon, " channelID = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
}
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
int packgeNo = param.mPackageFlag;
int packgeMax = 0;
int packgeNum = 0;
jsonVal["package"] = packgeNo;
int lastSize = rows % 550;
int index = rows / 550;
if (lastSize > 0 && index > 0) {
packgeMax = index + 1;
if (packgeNo + 1 == packgeMax) {
packgeNum = rows - lastSize;
jsonVal["packageMax"] = index + 1;
} else {
packgeNum = (packgeNo)*550;
jsonVal["packageMax"] = index + 1;
}
} else if (lastSize == 0 && index > 0) {
packgeNum = (packgeNo + 1) * 550;
packgeMax = index;
jsonVal["packageMax"] = index;
} else if (lastSize > 0 && index == 0) {
packgeNum = 0;
packgeMax = index + 1;
jsonVal["packageMax"] = index;
}
memset(whereCon, 0x00, sizeof(whereCon));
if (param.timeEnd == "") {
sprintf(whereCon, "channelID = '%s-%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.straxis.c_str(), 550, packgeNum);
} else {
sprintf(whereCon, "channelID = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
}
array_t vecRes;
vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(szTableName, selectCon, whereCon);
zlog_info(zct, "vecRes = %d", vecRes.size());
if (vecRes.size() > 0) {
Json::Value jsStaticData;
for (size_t i = 0; i < vecRes.size(); i++) {
Json::Value iTem;
if (vecRes[i][0] == param.MeasurementID + "-X") {
iTem.append(vecRes[i][1]);
iTem.append(vecRes[i][2]);
if (vecRes[i][3] == "4"){
iTem.append("MOSQ_ERR_NO_CONN");
}else if (vecRes[i][3] == "14"){
iTem.append("MOSQ_ERR_ERRNO");
}else{
iTem.append(vecRes[i][3]);
}
jsStaticData["X"].append(iTem);
}
if (vecRes[i][0] == param.MeasurementID + "-Y") {
iTem.append(vecRes[i][1]);
iTem.append(vecRes[i][2]);
if (vecRes[i][3] == "4"){
iTem.append("MOSQ_ERR_NO_CONN");
}else if (vecRes[i][3] == "14"){
iTem.append("MOSQ_ERR_ERRNO");
}else{
iTem.append(vecRes[i][3]);
}
jsStaticData["Y"].append(iTem);
}
if (vecRes[i][0] == param.MeasurementID + "-Z") {
iTem.append(vecRes[i][1]);
iTem.append(vecRes[i][2]);
if (vecRes[i][3] == "4"){
iTem.append("MOSQ_ERR_NO_CONN");
}else if (vecRes[i][3] == "14"){
iTem.append("MOSQ_ERR_ERRNO");
}else{
iTem.append(vecRes[i][3]);
}
jsStaticData["Z"].append(iTem);
}
}
if (jsStaticData.size() == 0) {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
} else {
jsonVal["content"] = (jsStaticData);
}
zlog_info(zct, "vecRes = %d,channelID = %s", vecRes.size(), vecRes[0][0].c_str());
} else {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
}
} else {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
}
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_62(Param_62 &param){
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "62";
jsonVal["success"] = true;
jsonVal["message"] = " ";
vec_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), T_SENSOR_INFO(DATANODENO), NULL);
int nSize = vetRes.size();
if (nSize > 0) {
char szTableName[100] = {0x00}, whereCon[256] = {0x00},selectCon[100] = {0x00};
if (param.mMode == 1){
sprintf(selectCon," dataNodeNo,channelID,timeStamp,sendMsg,sendMsg,nodeResend ");
sprintf(szTableName,"t_data_%s",param.MeasurementID.c_str());
}else{
sprintf(selectCon," * ");
sprintf(szTableName, " receive_wave_status ");
}
if(param.straxis == ""){
if (param.mMode == 1){
sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
}else{
sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
}
}
else{
if (param.mMode == 1){
sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
}else{
sprintf(whereCon, " data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null)", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
}
}
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
int packgeNo = param.mPackageFlag;
int packgeMax = 0;
int packgeNum = 0;
jsonVal["package"] = packgeNo;
int lastSize = rows % 550;
int index = rows / 550;
if (lastSize > 0 && index > 0) {
packgeMax = index + 1;
if (packgeNo + 1 == packgeMax) {
packgeNum = rows - lastSize;
jsonVal["packageMax"] = index + 1;
} else {
packgeNum = (packgeNo)*550;
jsonVal["packageMax"] = index + 1;
}
} else if (lastSize == 0 && index > 0) {
packgeNum = (packgeNo + 1) * 550;
packgeMax = index;
jsonVal["packageMax"] = index;
} else if (lastSize > 0 && index == 0) {
packgeNum = 0;
packgeMax = index + 1;
jsonVal["packageMax"] = index;
}
memset(whereCon, 0x00, sizeof(whereCon));
if(param.straxis == "")
{
if (param.mMode == 1){
sprintf(whereCon, " channelID like '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
}else{
sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
}
}else{
if (param.mMode == 1){
sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
}else{
sprintf(whereCon, "data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' and (nodeResend = '0' or nodeResend is null) order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
}
}
array_t vecRes;
vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(szTableName, selectCon, whereCon);
zlog_info(zct, "vecRes = %d", vecRes.size());
if (vecRes.size() > 0) {
Json::Value jsStaticData;
for (size_t i = 0; i < vecRes.size(); i++) {
Json::Value iTem;
iTem.append(vecRes[i][2]);
iTem.append(vecRes[i][4]);
iTem.append(vecRes[i][5]);
jsStaticData.append(iTem);
}
if (jsStaticData.size() == 0) {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
} else {
jsonVal["content"] = (jsStaticData);
}
zlog_info(zct, "vecRes = %d,channelID = %s", vecRes.size(), vecRes[0][0].c_str());
} else {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
}
} else {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
}
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_63(Param_63 &param)
{
Json::Value jsonVal;
jsonVal.clear();
Json::Value jsBody;
jsonVal[JSON_FIELD_CMD] = "63";
jsonVal["success"] = true;
jsonVal["message"] = "";
if (param.mMode == 0)
{
std::vector<FeatureEntryUploadCfg> cfg;
wave_feature_set_inst::instance().GetAllFeatureCfg(cfg);
if (cfg.size() > 0)
{
for (size_t i = 0; i < cfg.size(); i++)
{
Json::Value xyz_status;
xyz_status.append(cfg[i].x);
xyz_status.append(cfg[i].y);
xyz_status.append(cfg[i].z);
if (cfg[i].short_addr == 0)
{
jsBody["global"] = xyz_status;
}else{
char buf[8] = {0};
snprintf(buf, 8, "%02x%02x", UINT16_HIGH(cfg[i].short_addr), UINT16_LOW(cfg[i].short_addr));
jsBody[buf] = xyz_status;
}
}
}else{
jsonVal["success"] = false;
jsonVal["message"] = "";
}
}else if(param.mMode == 1){
if (param.partial)
{
zlog_info(zct, "63 short_addr = %d,x = %d,y = %d,z = %d", param.cfg[0].short_addr, param.cfg[0].x, param.cfg[0].y, param.cfg[0].z);
wave_feature_set_inst::instance().SetFeatureCfg(param.cfg[0].short_addr, param.cfg[0].x, param.cfg[0].y, param.cfg[0].z);
}else{
wave_feature_set_inst::instance().SetAllFeatureCfg(param.cfg);
}
}
jsonVal["cmdBody"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_64(Param_64 &param)
{
Json::Value jsonVal;
jsonVal.clear();
Json::Value jsBody;
jsonVal[JSON_FIELD_CMD] = "64";
jsonVal["success"] = true;
jsonVal["message"] = "";
if (param.mMode == 0)
{
std::vector<FeatureEntryUploadCfg> cfg;
wave_feature_set_inst::instance().GetAllWaveCfg(cfg);
zlog_info(zct,"cfg size = %d",cfg.size());
if (cfg.size() > 0)
{
for (size_t i = 0; i < cfg.size(); i++)
{
Json::Value xyz_status;
xyz_status.append(cfg[i].x);
xyz_status.append(cfg[i].y);
xyz_status.append(cfg[i].z);
if (cfg[i].short_addr == 0)
{
jsBody["global"] = xyz_status;
}else{
char buf[8] = {0};
snprintf(buf, 8, "%02x%02x", UINT16_HIGH(cfg[i].short_addr), UINT16_LOW(cfg[i].short_addr));
jsBody[buf] = xyz_status;
}
}
}else{
jsonVal["success"] = false;
jsonVal["message"] = "";
}
}else if(param.mMode == 1){
if (param.partial)
{
zlog_info(zct, "64 short_addr = %d,x = %d,y = %d,z = %d", param.cfg[0].short_addr, param.cfg[0].x, param.cfg[0].y, param.cfg[0].z);
wave_feature_set_inst::instance().SetWaveCfg(param.cfg[0].short_addr, param.cfg[0].x, param.cfg[0].y, param.cfg[0].z);
}else{
wave_feature_set_inst::instance().SetAllWaveCfg(param.cfg);
}
}
jsonVal["cmdBody"] = jsBody;
return show_value_.write(jsonVal);
}
std::string JsonData::JsonCmd_Cgi_65(Param_65 &param){
Json::Value jsonVal;
jsonVal.clear();
jsonVal[JSON_FIELD_CMD] = "65";
jsonVal["success"] = true;
jsonVal["message"] = " ";
array_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), " dataNodeName,MeasurementID,RSSI ", NULL);
size_t nSize = vetRes.size();
std::string MeasurementID = "";
char szTableName[100] = {0x00}, whereCon[256] = {0x00};
if (nSize > 0) {
int interval = atol(param.timeEnd.c_str()) - atol(param.timeStart.c_str());
int featureInterVal = 0,waveInterVal = 0,featureInterTime = 0,waveInterTime = 0,maxSensorNum = 0;
scheduler::instance().GetScheduleConfig(featureInterVal,waveInterVal,featureInterTime,waveInterTime,maxSensorNum);
Json::Value jsBody;
char count_sql[1024] = {0};
int recive_feature = 0, send_feature = 0,resend_feature = 0;
int recive_x = 0, recive_y = 0, recive_z = 0,resend_z = 0;
//int send_x = 0, send_y = 0, send_z = 0;
for (size_t i = 0; i < nSize; i++)
{
Json::Value iTem;
MeasurementID = vetRes[i][1];
iTem.append(vetRes[i][0]);
memset(szTableName,0,sizeof(szTableName));
memset(whereCon,0,sizeof(whereCon));
sprintf(szTableName,"t_data_%s",vetRes[i][1].c_str());
sprintf(whereCon, " channelID = '%s-X' and timeStamp < '%s' and timeStamp > '%s' ", MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
memset(count_sql,0,sizeof(count_sql));
snprintf(count_sql,sizeof(count_sql),
"SELECT "
"COUNT(*) FILTER (WHERE channelID = '%s-X' and nodeResend = 0 AS recive_feature,"
"COUNT(*) FILTER (WHERE channelID = '%s-X' and sendMsg = 1 and nodeResend = 0 ) AS send_feature "
"COUNT(*) FILTER (WHERE channelID = '%s-X' and nodeResend <> 0) AS send_feature "
"FROM ( "
"SELECT * FROM %s "
"WHERE timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),szTableName,param.timeStart.c_str(),param.timeEnd.c_str());
vec_t vecResult = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql);
if (vecResult.size() > 0)
{
recive_feature = atoi(vecResult[0].c_str());
send_feature = atoi(vecResult[1].c_str());
resend_feature = atoi(vecResult[2].c_str());
}
iTem.append(MeasurementID);
memset(count_sql,0,sizeof(count_sql));
snprintf(count_sql,sizeof(count_sql),
"SELECT "
"COUNT(*) FILTER (WHERE data_nodeno = '%s-X') AS recive_x,"
"COUNT(*) FILTER (WHERE data_nodeno = '%s-Y') AS recive_y,"
"COUNT(*) FILTER (WHERE data_nodeno = '%s-Z') AS recive_z "
"COUNT(*) FILTER (WHERE data_nodeno = '%s-Z' and resend is not null) AS resend_z "
"FROM ( "
"SELECT * FROM receive_wave_status "
"WHERE error_code = 1 and timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),param.timeStart.c_str(),param.timeEnd.c_str());
vec_t vecResult2 = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql);
if (vecResult2.size() > 0)
{
recive_x = atoi(vecResult2[0].c_str());
recive_y = atoi(vecResult2[1].c_str());
recive_z = atoi(vecResult2[2].c_str());
resend_z = atoi(vecResult2[3].c_str());
iTem.append((float(recive_feature)/(interval/featureInterVal)));
iTem.append(recive_feature);
iTem.append((float( recive_x)/(interval/waveInterVal)));
iTem.append(recive_x);
iTem.append((float(recive_y)/(interval/waveInterVal)));
iTem.append(recive_y);
iTem.append((float(recive_z)/(interval/waveInterVal)));
iTem.append(recive_z);
}
// memset(count_sql,0,sizeof(count_sql));
// snprintf(count_sql,sizeof(count_sql),
// "SELECT "
// "COUNT(*) FILTER (WHERE channelID = '%s-X') AS send_x,"
// "COUNT(*) FILTER (WHERE channelID = '%s-Y') AS send_y,"
// "COUNT(*) FILTER (WHERE channelID = '%s-Z') AS send_z "
// "FROM ( "
// "SELECT * FROM t_data_waveSend "
// "WHERE sendMsg = 1 and timeStamp BETWEEN '%s' AND '%s');",MeasurementID.c_str(),MeasurementID.c_str(),MeasurementID.c_str(),param.timeStart.c_str(),param.timeEnd.c_str());
// vec_t vecResult3 = sqlite_db_ctrl::instance().GetDataSingleLine(count_sql);
// if (vecResult3.size() > 0)
// {
// send_x = atoi(vecResult3[0].c_str());
// send_y = atoi(vecResult3[1].c_str());
// send_z = atoi(vecResult3[2].c_str());
// iTem.append((float(send_feature)/(interval/featureInterVal)));
// iTem.append(send_feature);
// iTem.append((float(send_x)/(interval/waveInterVal)));
// iTem.append(send_x);
// iTem.append((float(send_y)/(interval/waveInterVal)));
// iTem.append(send_y);
// iTem.append((float(send_z)/(interval/waveInterVal)));
// iTem.append(send_z);
//}
iTem.append(0);
iTem.append(0);
iTem.append(0);
iTem.append(0);
iTem.append(0);
iTem.append(0);
iTem.append(0);
iTem.append(0);
iTem.append(resend_feature);
iTem.append(resend_z);
std::vector<std::string> vRssi;
boost::split(vRssi, vetRes[i][2], boost::is_any_of(","), boost::token_compress_on);
if (vRssi.size() > 0 ){
iTem.append(atof(vRssi[0].c_str())/float(255));
iTem.append(atof(vRssi[1].c_str())/float(255));
}
jsBody.append(iTem);
}
if (jsBody.size() == 0) {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
} else {
jsonVal["content"] = (jsBody);
}
} else {
jsonVal["success"] = false;
jsonVal["content"].resize(0);
}
return show_value_.write(jsonVal);
}