modify a little.
This commit is contained in:
parent
6a7f2712e4
commit
4ddc9e8285
@ -40,7 +40,6 @@ public:
|
||||
std::string JsonCmd_51(Json::Value &recvBody);
|
||||
std::string JsonCmd_52(); // upload static data
|
||||
std::string JsonCmd_53(Json::Value &recvBody);
|
||||
void JsonCmd_38(Json::Value &recvBody); //获取原始数据
|
||||
|
||||
// web command parse
|
||||
std::string JsonCmd_Cgi_01(Param_01 ¶m); //用户操作处理
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
#include "communication_cmd.hpp"
|
||||
#include <zlog.h>
|
||||
|
||||
#include "dbaccess/sql_db.hpp"
|
||||
#include "platform/platform_init.hpp"
|
||||
#include "utility/md5.h"
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
std::string JsonData::JsonCmd_20(Param_20 ¶m) {
|
||||
Json::Value jsonVal;
|
||||
@ -29,9 +32,9 @@ std::string JsonData::JsonCmd_20(Param_20 ¶m) {
|
||||
Json::Value jsSystemInfo;
|
||||
Json::Value jsBody;
|
||||
|
||||
string strwebVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion");
|
||||
string strsystemVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion");
|
||||
string strGatewayVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion");
|
||||
std::string strwebVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion");
|
||||
std::string strsystemVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion");
|
||||
std::string strGatewayVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion");
|
||||
|
||||
jsSystemInfo["WebVersion"] = strwebVersion;
|
||||
jsSystemInfo["SystemVersion"] = strsystemVersion;
|
||||
@ -172,7 +175,7 @@ std::string JsonData::JsonCmd_25(Param_25 ¶m) {
|
||||
print_info("GateWay = %s\n", GateWay);
|
||||
system(GateWay);
|
||||
#endif
|
||||
platform->EquipIpInit(param.mNet);
|
||||
PlatformInit::EquipIpInit(param.mNet);
|
||||
|
||||
} else if (0 == param.mMode && param.mNetworkPortStatus == "DHCP") {
|
||||
WriteStr2Config(NETWORKCONFIG, param.mNet, "dnsName", "");
|
||||
@ -328,7 +331,7 @@ std::string JsonData::JsonCmd_50(Json::Value &recvBody) {
|
||||
jsonVal["message"] = "download failed";
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
string md5Val = md5file(updateName.c_str());
|
||||
std::string md5Val = md5file(updateName.c_str());
|
||||
zlog_info(zct, "md5Val = %s", md5Val.c_str());
|
||||
zlog_info(zct, "md5 = %s", md5.c_str());
|
||||
if (md5 != md5Val) {
|
||||
@ -337,7 +340,7 @@ std::string JsonData::JsonCmd_50(Json::Value &recvBody) {
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
if (updateDevice == "1") { // update sensor
|
||||
string strcmd = "tar xvf ";
|
||||
std::string strcmd = "tar xvf ";
|
||||
strcmd = strcmd + updateName;
|
||||
strcmd = strcmd + " -C /opt/";
|
||||
system(strcmd.c_str());
|
||||
@ -488,31 +491,6 @@ std::string JsonData::JsonCmd_29(Param_29 ¶m) {
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
|
||||
void JsonData::JsonCmd_38(Json::Value &recvBody) {
|
||||
Json::Value jsChannel = recvBody["channelArray"];
|
||||
print_info("jsChannel size : %d\n", jsChannel.size());
|
||||
if (jsChannel.isArray()) {
|
||||
for (int i = 0; i < jsChannel.size(); i++) {
|
||||
std::string strChannelid = jsChannel[i].asString();
|
||||
WAVE_GENERAL wavedata;
|
||||
|
||||
WAVE_CONTAIN wave;
|
||||
memset(wave.channelId, 0, 16);
|
||||
sprintf(wave.channelId, "%s", strChannelid.c_str());
|
||||
|
||||
memset(wave.SensorEngineeringUnit, 0, 32);
|
||||
sprintf(wave.SensorEngineeringUnit, "%s", wavedata.SensorEngineeringUnit.c_str());
|
||||
|
||||
wave.total = 1;
|
||||
wave.count = 1;
|
||||
wave.type = 0;
|
||||
wave.flag = 0;
|
||||
wave.number = wavedata.number;
|
||||
memcpy(wave.waveData, wavedata.waveData, wavedata.number * sizeof(float));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void JsonData::DataNodeStatusCheck() {
|
||||
array_t vetRes = sqlite_db_ctrl::instance().GetDataMultiLine(T_SENSOR_INFO(TNAME), "*", NULL);
|
||||
int nSize = vetRes.size();
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
#include "communication_cmd.hpp"
|
||||
#include <zlog.h>
|
||||
#include "dbaccess/sql_db.hpp"
|
||||
#include "platform/platform_init.hpp"
|
||||
#include "utility/md5.h"
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_01(Param_01 ¶m) {
|
||||
Json::Value jsonVal;
|
||||
@ -137,7 +139,6 @@ std::string JsonData::JsonCmd_Cgi_08() {
|
||||
}
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_09(Param_09 ¶m) {
|
||||
|
||||
Json::Value jsonVal;
|
||||
jsonVal.clear();
|
||||
|
||||
@ -262,6 +263,7 @@ std::string JsonData::JsonCmd_Cgi_09(Param_09 ¶m) {
|
||||
}
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_10(Param_10 ¶m) {
|
||||
Json::Value jsonVal;
|
||||
jsonVal.clear();
|
||||
@ -594,7 +596,7 @@ std::string JsonData::JsonCmd_Cgi_25(Param_25 ¶m) {
|
||||
zlog_info(zct, "GateWay = %s", GateWay);
|
||||
system(GateWay);
|
||||
#endif
|
||||
platform->EquipIpInit(param.mNet);
|
||||
Platform::EquipIpInit(param.mNet);
|
||||
|
||||
} else if (0 == param.mMode && param.mNetworkPortStatus == "DHCP") {
|
||||
WriteStr2Config(NETWORKCONFIG, param.mNet, "dnsName", "");
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
#include "communication_cmd.hpp"
|
||||
#include <zlog.h>
|
||||
#include "dbaccess/sql_db.hpp"
|
||||
#include "platform/platform_init.hpp"
|
||||
#include "utility/md5.h"
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
||||
Json::Value jsonVal;
|
||||
@ -84,7 +86,7 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
||||
jsSensorData["status"] = atoi(arrRes[j][37].c_str());
|
||||
jsSensorData["timeStamp"] = arrRes[j][38];
|
||||
jsSensorData["viff"] = atoi(arrRes[j][39].c_str());
|
||||
vector<string> vParam;
|
||||
std::vector<std::string> vParam;
|
||||
boost::split(vParam, arrRes[j][42], boost::is_any_of(","), boost::token_compress_on);
|
||||
|
||||
if (vParam.size() > 1)
|
||||
@ -92,7 +94,7 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) {
|
||||
else
|
||||
jsSensorData["loose"] = "0";
|
||||
|
||||
vector<string> vParamRSSI;
|
||||
std::vector<std::string> vParamRSSI;
|
||||
boost::split(vParamRSSI, arrRes[j][40], boost::is_any_of(","), boost::token_compress_on);
|
||||
if (vParamRSSI.size() > 1) {
|
||||
jsSensorData["RSSI"] = arrRes[j][40];
|
||||
@ -279,7 +281,7 @@ std::string JsonData::JsonCmd_Cgi_27(Param_27 ¶m) {
|
||||
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), param.mDataNodeNo.c_str());
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
sprintf(updateSql, "LooseValue = '0,2,");
|
||||
string strUpdateSql = string(updateSql) + string(localtimestamp) + "' ";
|
||||
std::string strUpdateSql = std::string(updateSql) + std::string(localtimestamp) + "' ";
|
||||
sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), strUpdateSql.c_str(), whereCon);
|
||||
} else {
|
||||
jsonVal["success"] = false;
|
||||
@ -436,7 +438,6 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) {
|
||||
} else {
|
||||
while (inFile.read((char *)&fTemp, sizeof(fTemp))) { // 取8K进行计算
|
||||
vecWave.push_back(fTemp);
|
||||
|
||||
}
|
||||
|
||||
//进行傅立叶变换
|
||||
@ -517,6 +518,7 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m) {
|
||||
jsonVal["content"] = jsBody;
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_40(Param_40 ¶m) {
|
||||
Json::Value jsonVal;
|
||||
Json::Value jsBody;
|
||||
@ -724,6 +726,7 @@ std::string JsonData::JsonCmd_Cgi_41(std::vector<Param_41> ¶m, int isServer)
|
||||
}
|
||||
return show_value_.write(jsonVal);
|
||||
}
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_42(Param_42 ¶m) {
|
||||
Json::Value jsonVal;
|
||||
jsonVal.clear();
|
||||
@ -735,7 +738,7 @@ std::string JsonData::JsonCmd_Cgi_42(Param_42 ¶m) {
|
||||
strcpy(cmd, "rm -rf /tmp/cgic*");
|
||||
system(cmd);
|
||||
if (param.fileName == "DataNode.tar") {
|
||||
string strcmd = "tar xvf /opt/";
|
||||
std::string strcmd = "tar xvf /opt/";
|
||||
strcmd = strcmd + param.fileName;
|
||||
strcmd = strcmd + " -C /opt/";
|
||||
zlog_info(zct, "strcmd = %s", strcmd.c_str());
|
||||
@ -759,7 +762,7 @@ std::string JsonData::JsonCmd_Cgi_42(Param_42 ¶m) {
|
||||
zlog_info(zct, "strcmd = %s", param.fileName.c_str());
|
||||
|
||||
int iRet = UpdataDataNodeConfig("/opt/DataNode.csv");
|
||||
string str = to_string(iRet) + "个传感器更新成功";
|
||||
std::string str = std::to_string(iRet) + "个传感器更新成功";
|
||||
if (iRet < 0) {
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["message"] = "更新失败!";
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
#include "communication_cmd.hpp"
|
||||
#include <zlog.h>
|
||||
#include "dbaccess/sql_db.hpp"
|
||||
#include "platform/platform_init.hpp"
|
||||
#include "utility/md5.h"
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_default() {
|
||||
Json::Value jsonVal;
|
||||
@ -118,7 +120,7 @@ std::string JsonData::JsonCmd_Cgi_51(Param_51 ¶m) {
|
||||
|
||||
char whereCon[1024] = {0};
|
||||
char updateSql[1024] = {0};
|
||||
string gatewayLocation = "";
|
||||
std::string gatewayLocation = "";
|
||||
|
||||
sprintf(updateSql, "gatewayLocation='%s'", param.strGateWayLocation.c_str());
|
||||
sprintf(whereCon, "gatewayMAC='%s'", param.strGateWayMAC.c_str());
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
#include "local_server.hpp"
|
||||
#include <zlog.h>
|
||||
#include <json/json.h>
|
||||
#include "utility/secure.hpp"
|
||||
#include "jsonparse/communication_cmd.hpp"
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
LocalServer::LocalServer() {}
|
||||
|
||||
@ -31,7 +33,7 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to
|
||||
} else {
|
||||
std::string cmdBody = recvValue["cmdBody"].asString();
|
||||
if (!recvReader.parse(cmdBody, recvBody)) {
|
||||
zlog_error(zct,"recv body error");
|
||||
zlog_error(zct, "recv body error, content:[%s]", cmdBody.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -202,6 +204,6 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to
|
||||
zlog_info(zct, "cmdType : %d ", cmdType);
|
||||
|
||||
} else {
|
||||
zlog_error(zct,"parase fail");
|
||||
zlog_error(zct, "parse fail, content:[%s]", pData.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
#include "platform_init.hpp"
|
||||
#include <fstream>
|
||||
#include <zlog.h>
|
||||
#include <fstream>
|
||||
#include "common/global.hpp"
|
||||
#include "dbaccess/sql_db.hpp"
|
||||
|
||||
/*********************全局变量声明***********************/
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
|
||||
int GlobalConfig::RUN_MODE = 0;
|
||||
int GlobalConfig::QuitFlag_G = 1;
|
||||
int GlobalConfig::LinkStatus_G = 0;
|
||||
@ -25,7 +27,7 @@ int GlobalConfig::ServerPort = 0;
|
||||
int GlobalConfig::threadStatus = 1;
|
||||
int GlobalConfig::day = 0;
|
||||
|
||||
extern map<string, compressWaveChannel> g_mapCompress;
|
||||
extern std::map<std::string, compressWaveChannel> g_mapCompress;
|
||||
|
||||
TopicList GlobalConfig::Topic_G;
|
||||
ZigbeeInfo GlobalConfig::ZigbeeInfo_G;
|
||||
@ -92,7 +94,7 @@ void PlatformInit::Init() {
|
||||
}
|
||||
#endif
|
||||
} catch (...) {
|
||||
print_error("PlatFormInit exception happend.\n");
|
||||
zlog_error(zbt, "PlatFormInit exception happend.");
|
||||
std::string errorinfo = "系统初始化异常";
|
||||
}
|
||||
vec_t vecResult = sqlite_db_ctrl::instance().GetDataMultiLineOfOneColumn(T_SENSOR_INFO(TNAME), " zigbeeShortAddr ", NULL);
|
||||
@ -104,35 +106,20 @@ void PlatformInit::Init() {
|
||||
|
||||
void PlatformInit::TopicInit() {
|
||||
GlobalConfig::Topic_G.mPubData = "wireless/statisticData/" + GlobalConfig::MacAddr_G;
|
||||
|
||||
GlobalConfig::Topic_G.mPubStatus = "wireless/status/" + GlobalConfig::MacAddr_G;
|
||||
|
||||
GlobalConfig::Topic_G.mPubHeart = "wireless/heart/" + GlobalConfig::MacAddr_G; //
|
||||
|
||||
GlobalConfig::Topic_G.mPubHeart = "wireless/heart/" + GlobalConfig::MacAddr_G;
|
||||
GlobalConfig::Topic_G.mPubConfig = "wireless/configureInfo/" + GlobalConfig::MacAddr_G;
|
||||
|
||||
GlobalConfig::Topic_G.mPubWaveData = "wireless/realTimeData/" + GlobalConfig::MacAddr_G;
|
||||
|
||||
GlobalConfig::Topic_G.mPubWaveSecondData = "wireless/secondTimeData/" + GlobalConfig::MacAddr_G;
|
||||
|
||||
GlobalConfig::Topic_G.mPubCmd = "wireless/cmd/" + GlobalConfig::MacAddr_G; //
|
||||
|
||||
GlobalConfig::Topic_G.mSubData = "cmd/" + GlobalConfig::MacAddr_G; //
|
||||
|
||||
GlobalConfig::Topic_G.mPubCmd = "wireless/cmd/" + GlobalConfig::MacAddr_G;
|
||||
GlobalConfig::Topic_G.mSubData = "cmd/" + GlobalConfig::MacAddr_G;
|
||||
GlobalConfig::Topic_G.mPubRep = "wireless/resp/" + GlobalConfig::MacAddr_G;
|
||||
|
||||
GlobalConfig::Topic_G.mPubTiming = "equipment/cmd/" + GlobalConfig::MacAddr_G;
|
||||
|
||||
GlobalConfig::Topic_G.mPubLocalWifi = "up/" + GlobalConfig::MacAddr_G + "/recive/wifi";
|
||||
|
||||
GlobalConfig::Topic_G.mPubLocalWaveServer = "up/" + GlobalConfig::MacAddr_G + "/recive/waveserver";
|
||||
|
||||
GlobalConfig::Topic_G.mPubLocalWaveQt = "up/" + GlobalConfig::MacAddr_G + "/recive/waveqt";
|
||||
|
||||
GlobalConfig::Topic_G.mPubLocalConfig = "up/" + GlobalConfig::MacAddr_G + "/recive/config";
|
||||
|
||||
GlobalConfig::Topic_G.mPubLocalTrigger = "up/" + GlobalConfig::MacAddr_G + "/recive/trigger";
|
||||
|
||||
GlobalConfig::Topic_G.mPubLocalCmd = "up/" + GlobalConfig::MacAddr_G + "/recive/cmd";
|
||||
}
|
||||
|
||||
@ -209,13 +196,14 @@ void PlatformInit::GPIOInit() {
|
||||
GlobalConfig::GPIO_G.errorLed = 130;
|
||||
#endif
|
||||
}
|
||||
|
||||
void PlatformInit::SystemInfoInit() {
|
||||
std::ifstream ifileOut(SYSTEMINFOFILE);
|
||||
Json::Reader recvReader;
|
||||
Json::Value Systeminfo;
|
||||
//从配置文件中读取json数据
|
||||
if (ifileOut.is_open()) {
|
||||
zlog_info(zbt,"open %s\n", SYSTEMINFOFILE);
|
||||
zlog_info(zbt, "open %s", SYSTEMINFOFILE);
|
||||
}
|
||||
if (!recvReader.parse(ifileOut, Systeminfo, false)) {
|
||||
if (ifileOut.is_open()) {
|
||||
|
||||
@ -13,6 +13,8 @@
|
||||
#include "common/common_func.hpp"
|
||||
#include "wifi_5g/wpa_client.h"
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
|
||||
void CheckThread() {
|
||||
zlog_info(zbt, "ENTER CHECK THREAD ");
|
||||
|
||||
@ -15,7 +15,9 @@
|
||||
#include <zlog.h>
|
||||
#include "utility/serial.h"
|
||||
|
||||
char g_UartRecvBuf[GENERAL_BUF_SIZE];
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
|
||||
int offSize = 0;
|
||||
pTestRecvCallBack pTestRecv;
|
||||
|
||||
@ -373,6 +375,7 @@ void Uart::UpdateZigbeeInfo(const char *pData) {
|
||||
WriteTranTimeout2Zigbee(TranTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
void int2bytes(int i, unsigned char *bytes, int size) {
|
||||
memset(bytes, 0, sizeof(unsigned char) * size);
|
||||
bytes[0] = (unsigned char)(0xff & i);
|
||||
@ -413,7 +416,7 @@ void Uart::DealRecvData(const char *pData) {
|
||||
void Uart::DealDataNodeName(const char *pData) {
|
||||
bSendTimeStamp = false;
|
||||
zlog_info(zct, "DealDataNodeName ");
|
||||
string strTime = GetLocalTimeWithMs();
|
||||
std::string strTime = GetLocalTimeWithMs();
|
||||
char szShortAdd[8] = {0x00};
|
||||
char shortAdd[8] = {0x00};
|
||||
char NodeName[64] = {0x00};
|
||||
@ -455,8 +458,8 @@ void Uart::DealDataNodeName(const char *pData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
string hardVersion = vecRes[0][2];
|
||||
string softVersion = vecRes[0][3];
|
||||
std::string hardVersion = vecRes[0][2];
|
||||
std::string softVersion = vecRes[0][3];
|
||||
if ((hardVersion == "3.0" && compareVersions(softVersion, "3.6") == -1) || (hardVersion == "4.0" && compareVersions(softVersion, "4.6") == -1)) {
|
||||
memcpy(MeasurementID, vecRes[0][0].c_str(), sizeof(MeasurementID));
|
||||
}
|
||||
@ -464,12 +467,12 @@ void Uart::DealDataNodeName(const char *pData) {
|
||||
zlog_info(zct, "strNodeName = %s", strNodeName.c_str());
|
||||
solve(gbkNodeName, NodeName);
|
||||
zlog_info(zct, "gbkNodeName = %s", gbkNodeName);
|
||||
string utfNodeName = GBKToUTF8(gbkNodeName);
|
||||
std::string utfNodeName = GBKToUTF8(gbkNodeName);
|
||||
zlog_info(zct, "NodeName = %s", NodeName);
|
||||
zlog_info(zct, "whereCon = %s", whereCon);
|
||||
sprintf(uplCon, "dataNodeName = '%s' , MeasurementID = '%s',NodeWaveSend = '%s'", gbkNodeName, MeasurementID, nodeWaveSend);
|
||||
iRet = sqlite_db_ctrl::instance().UpdateTableData(T_SENSOR_INFO(TNAME), uplCon, whereCon, 0);
|
||||
string strData = sqlite_db_ctrl::instance().GetNodeConfigureInfor(whereCon);
|
||||
std::string strData = sqlite_db_ctrl::instance().GetNodeConfigureInfor(whereCon);
|
||||
iRet = data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str());
|
||||
}
|
||||
|
||||
@ -565,7 +568,7 @@ void Uart::DealDataNodeInfo(const char *pData) {
|
||||
unsigned char shortAddr[2] = {0x00};
|
||||
memcpy(shortAddr, (unsigned char *)&pRecvData->Data[46], 2);
|
||||
modify_DistAddr(shortAddr); //修改目标地址
|
||||
string strTime = GetLocalTimeWithMs();
|
||||
std::string strTime = GetLocalTimeWithMs();
|
||||
|
||||
memset(buf, 0, 32);
|
||||
sprintf(buf, "%02x%02x", pRecvData->Data[48], pRecvData->Data[49]); // Zigbee 目标地址 2 byte
|
||||
@ -814,7 +817,7 @@ void Uart::ZigbeeParameterConfig() {
|
||||
}
|
||||
|
||||
int Uart::FindRecvPackage(int bytesRead, char *mUartRecvBuf, char *head) {
|
||||
string strTime = GetLocalTimeWithMs();
|
||||
std::string strTime = GetLocalTimeWithMs();
|
||||
char head1[] = {0xAB, 0xBC, 0xCD};
|
||||
char head2[] = {0xDE, 0xDF, 0xEF};
|
||||
int lastSize = 0;
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
#include "uart.hpp"
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
|
||||
void Uart::UpdateZigbeeInfoCtrl() {
|
||||
char command[5] = {0xab, 0xbc, 0xcd, 0xd1, 0xaa};
|
||||
WriteToUart(command, 5);
|
||||
|
||||
@ -7,10 +7,13 @@
|
||||
#include <sys/stat.h>
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
|
||||
std::vector<RecvData> g_VecWaveDataX;
|
||||
std::vector<RecvData> g_VecWaveDataY;
|
||||
std::vector<RecvData> g_VecWaveDataZ;
|
||||
map<std::string, compressWaveChannel> g_mapCompress;
|
||||
std::map<std::string, compressWaveChannel> g_mapCompress;
|
||||
|
||||
void Uart::RecordBattery(std::string &strLongAddr, DataRecvStatic &dataStatic, std::string &nowTimetamp) {
|
||||
char insertSql[1024] = {0};
|
||||
@ -40,7 +43,6 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
|
||||
if (vecResult.size() < 1) {
|
||||
zlog_error(zct, "device info not found %02x%02x ", pRecvData->ShortAddr[0], pRecvData->ShortAddr[1]);
|
||||
print_error("device info not found\n");
|
||||
return;
|
||||
}
|
||||
zlog_info(zct, "--------->the remote sensor short addr:%s strLongAddr=%s,softVersion = %s", buf, vecResult[1].c_str(), vecResult[0].c_str());
|
||||
@ -115,7 +117,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
packed_data |= (uint64_t)buffer[i] << (8 * (5 - i)); // 从高位开始组合
|
||||
}
|
||||
// 输出结果
|
||||
printf("Resulting 48-bit integer: 0x%012llX\n", packed_data);
|
||||
zlog_info(zct, "Resulting 48-bit integer: 0x%012llX\n", packed_data);
|
||||
// 提取 15 位的第一个数据
|
||||
tempchannel.CountX = (packed_data >> 33) & 0x7FFF; // 提取最高的 15 位
|
||||
|
||||
@ -259,7 +261,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
if (vecResult.size() > 0) {
|
||||
memset(whereCon, 0x00, sizeof(whereCon));
|
||||
sprintf(whereCon, "dataNodeNo = '%s'", strLongAddr.c_str());
|
||||
string staticInterval = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), "featureInterval", whereCon);
|
||||
std::string staticInterval = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), "featureInterval", whereCon);
|
||||
long nNowTimetamp = atol(vecResult[0].c_str()) - (atol(staticInterval.c_str()) * (atol(vecResult[1].c_str()) - staticIndex)) * 60;
|
||||
char tmp[10] = {0x00};
|
||||
sprintf(tmp, "%ld", nNowTimetamp);
|
||||
@ -393,23 +395,14 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
dataDymX.Amp5 = lowbit * n;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymX.EnvelopEnergy = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymX.Phase1 = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymX.Phase2 = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
memset(buf, 0, 8);
|
||||
|
||||
dataDymX.Phase3 = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
sprintf(buf, "%02x%02x", pRecvData->Data[35], pRecvData->Data[34]);
|
||||
|
||||
@ -539,23 +532,14 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
dataDymY.Amp5 = lowbit * n;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymY.EnvelopEnergy = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymY.Phase1 = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymY.Phase2 = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymY.Phase3 = 0;
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
dataDymY.Phase4 = 0;
|
||||
|
||||
memset(whereCon, 0, 1024);
|
||||
@ -776,7 +760,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag) {
|
||||
sprintf(whereCon, "dataNodeNo='%s'", strLongAddr.c_str());
|
||||
|
||||
std::string strBattery = sqlite_db_ctrl::instance().GetData(T_SENSOR_INFO(TNAME), "batteryPower", whereCon);
|
||||
vector<std::string> vBattery;
|
||||
std::vector<std::string> vBattery;
|
||||
vBattery.push_back("0");
|
||||
vBattery.push_back("0");
|
||||
if (strBattery.length() > 0) {
|
||||
@ -937,7 +921,6 @@ std::vector<float> Uart::DealData(int iChannel, float coe, int sampleRate, int A
|
||||
if (r == LZO_E_OK) {
|
||||
zlog_info(zct, "iChannel = %d ,ShortAddr = %s decompressed %lu bytes back into %lu bytes", iChannel, strShortAddr.c_str(), (unsigned long)j * 92, (unsigned long)new_len);
|
||||
} else {
|
||||
|
||||
zlog_error(zct, "internal error - decompression failed: %d,channel = %d,ShortAddr = %s", r, iChannel, strShortAddr.c_str());
|
||||
return vecData;
|
||||
}
|
||||
@ -986,6 +969,7 @@ std::vector<float> Uart::DealData(int iChannel, float coe, int sampleRate, int A
|
||||
}
|
||||
return vecData;
|
||||
}
|
||||
|
||||
void Uart::DealWave() {
|
||||
std::string strShortAddr = "";
|
||||
std::string strShortAddrTemp;
|
||||
@ -1059,6 +1043,7 @@ void Uart::DealWave() {
|
||||
wave_trans_ = false;
|
||||
}
|
||||
}
|
||||
|
||||
float Uart::Calcoe(int ran, int iChannel, string &product, int range) {
|
||||
float coe = 0.0;
|
||||
if (product == "01") {
|
||||
@ -1085,12 +1070,12 @@ float Uart::Calcoe(int ran, int iChannel, string &product, int range) {
|
||||
coe = 0.00048828125;
|
||||
}
|
||||
if (iChannel == 5) {
|
||||
|
||||
coe = 0.00172607421875;
|
||||
}
|
||||
}
|
||||
return coe;
|
||||
}
|
||||
|
||||
void Uart::WriteDatFile(int sampleRate, string &strMeasurementID, int iChannel, std::vector<float> &vecData) {
|
||||
if (vecData.size() <= 0) return;
|
||||
std::string strFileName = "";
|
||||
@ -1189,7 +1174,7 @@ void Uart::WriteDatFile(int sampleRate, string &strMeasurementID, int iChannel,
|
||||
sprintf(updateSql, "SendMsg = 0 ");
|
||||
sqlite_db_ctrl::instance().UpdateTableData("t_data_waveSend", updateSql, whereCon);
|
||||
zlog_error(zct, "send failed,filename %s,iRet = %d", strFileName.c_str(), iRet);
|
||||
string strFileName_failed = strFileName + "_" + nowTimetamp;
|
||||
std::string strFileName_failed = strFileName + "_" + nowTimetamp;
|
||||
char tmpCmd[128] = {0x00};
|
||||
sprintf(tmpCmd, "cp %s %s", strFileName.c_str(), strFileName_failed.c_str());
|
||||
system(tmpCmd);
|
||||
@ -1208,7 +1193,7 @@ void Uart::WriteDatFile(int sampleRate, string &strMeasurementID, int iChannel,
|
||||
sprintf(updateSql, "sendMsg = 0");
|
||||
int iRet2 = sqlite_db_ctrl::instance().UpdateTableData("t_data_waveSend", updateSql, whereCon);
|
||||
|
||||
string strFileName_failed = strFileName + "_" + nowTimetamp;
|
||||
std::string strFileName_failed = strFileName + "_" + nowTimetamp;
|
||||
char tmpCmd[128] = {0x00};
|
||||
sprintf(tmpCmd, "cp %s %s", strFileName.c_str(), strFileName_failed.c_str());
|
||||
system(tmpCmd);
|
||||
|
||||
@ -7,6 +7,9 @@
|
||||
#include <sys/stat.h>
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t* zct;
|
||||
extern zlog_category_t* zbt;
|
||||
|
||||
void Uart::openSwitch() {
|
||||
char buffer[100] = {0x00};
|
||||
int len;
|
||||
@ -112,12 +115,13 @@ bool Uart::ReadUpdatePackge(unsigned char* pDestShortAddr) {
|
||||
} else {
|
||||
zzlog_error(zct, zct, "Packge ACK send failed,shortAddr = %02x%02x", pDestShortAddr[0], pDestShortAddr[1]);
|
||||
}
|
||||
string strTime = GetLocalTimeWithMs();
|
||||
std::string strTime = GetLocalTimeWithMs();
|
||||
zlog_info(zct, "ReadUpdatePackge strTime = %s", strTime.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
void Uart::UpdateWirelessNode(unsigned short shortAdd) {
|
||||
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));
|
||||
|
||||
FILE* pFile = NULL;
|
||||
@ -125,8 +129,7 @@ void Uart::UpdateWirelessNode(unsigned short shortAdd) {
|
||||
char* buffer = NULL;
|
||||
int resendCount = 0;
|
||||
pFile = fopen(DataNodeUpdateFile.c_str(), "rb");
|
||||
if (pFile != NULL)
|
||||
{
|
||||
if (pFile != NULL) {
|
||||
while (fgetc(pFile) != EOF) {
|
||||
++thisSize;
|
||||
}
|
||||
@ -184,9 +187,7 @@ void Uart::UpdateWirelessNode(unsigned short shortAdd) {
|
||||
}
|
||||
gpio_set(GlobalConfig::GPIO_G.zigAckreset, 0);
|
||||
mssleep(2000);
|
||||
|
||||
memset(UpdateData, 0x00, sizeof(UpdateData));
|
||||
|
||||
mssleep(5000);
|
||||
}
|
||||
if (gpio_read(GlobalConfig::GPIO_G.zigAckrep) == 48) gpio_set(GlobalConfig::GPIO_G.zigAckreset, 1);
|
||||
@ -438,7 +439,7 @@ int Uart::UpdateConfig(unsigned char* pDestShortAddr) {
|
||||
unsigned short localAddr = 0x9999;
|
||||
GlobalConfig::EnterZigBeeWaveTransmittingFlag_G = ENTER_TRANSMITTING_STATUS;
|
||||
GlobalConfig::EnterZigBeeWaveTransmittingCnt_G = 0;
|
||||
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);
|
||||
|
||||
unsigned char UpdateData[100] = {0x00};
|
||||
//帧头[3byte] 节点地址[2byte] 数据类型[1byte] 序号[1byte] 数据包[92byte] CRC校验[1byte]
|
||||
@ -477,11 +478,13 @@ int Uart::UpdateConfig(unsigned char* pDestShortAddr) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} else {
|
||||
zlog_error(zct, "invalid vecResultNode[41]:%c", vecResultNode[41]);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int Uart::UpdateWirelessNodeTime(unsigned char* pDestShortAddr, int modifyaddr /*,int nodewaveindex,int nodetime,int nodeindex*/) {
|
||||
if (modifyaddr) modify_DistAddr(pDestShortAddr);
|
||||
mssleep(10000);
|
||||
@ -489,7 +492,7 @@ int Uart::UpdateWirelessNodeTime(unsigned char* pDestShortAddr, int modifyaddr /
|
||||
char localtimestamp[32] = {0x00};
|
||||
int millisecond = 0;
|
||||
|
||||
string rtcTime = GetRTC(localtimestamp, millisecond);
|
||||
std::string rtcTime = GetRTC(localtimestamp, millisecond);
|
||||
zlog_info(zct, "ShortAddr = %02x%02x,rtcTime = %s,localtimestamp = %s,millisecond = %d,bSendTimeStamp = %d ", pDestShortAddr[0], pDestShortAddr[1], rtcTime.c_str(), localtimestamp, millisecond, bSendTimeStamp);
|
||||
|
||||
unsigned char UpdateData[100] = {0x00};
|
||||
|
||||
@ -48,6 +48,7 @@ void Calculation::iFFT(int n, fftw_complex *in, fftw_complex *out) {
|
||||
fftw_destroy_plan(p);
|
||||
fftw_cleanup();
|
||||
}
|
||||
|
||||
void Calculation::_iFFT(std::vector<float> &vecrealData, std::vector<float> &vecimageData, std::vector<float> &veciFFTData) {
|
||||
fftw_complex *inFFt, *outFFt;
|
||||
int N = vecrealData.size();
|
||||
@ -67,6 +68,7 @@ void Calculation::_iFFT(std::vector<float> &vecrealData, std::vector<float> &vec
|
||||
fftw_free(inFFt);
|
||||
fftw_free(outFFt);
|
||||
}
|
||||
|
||||
void Calculation::_FFT(std::vector<float> &vecData, std::vector<float> &vecFFTrealData, std::vector<float> &vecFFTimageData) {
|
||||
fftw_complex *inHilFFt, *outHilFFt;
|
||||
inHilFFt = (fftw_complex *)fftw_malloc(sizeof(fftw_complex) * vecData.size());
|
||||
|
||||
@ -2,9 +2,11 @@
|
||||
#include <unistd.h>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <zlog.h>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
static const char* MULTICAST_HOST_NAME1 = "224.0.0.1"; //组播接收平台搜索信号地址
|
||||
static const int MULTICAST_PORT_RECV1 = 7301; //组播接收端口
|
||||
@ -26,9 +28,7 @@ void SearchDev::Init() {
|
||||
}
|
||||
}
|
||||
|
||||
void SearchDev::GwRouteInit() {
|
||||
|
||||
}
|
||||
void SearchDev::GwRouteInit() {}
|
||||
|
||||
void SearchDev::HandleSend_1(const char* pMsg, const boost::system::error_code& pEc) {
|
||||
if (pEc) {
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "secure.hpp"
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
@ -5,7 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include "SH_Secure.hpp"
|
||||
|
||||
|
||||
#define AES_ENCRYPT 2
|
||||
#define AES_DECRYPT 0
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
#include "tcp_cgi.hpp"
|
||||
#include <zlog.h>
|
||||
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
|
||||
TcpCgi::TcpCgi() { zlog_info(zbt, "TcpCgi Init"); }
|
||||
|
||||
@ -12,7 +14,7 @@ void TcpCgi::startCgiServer() {
|
||||
char buff[40960];
|
||||
int n;
|
||||
if ((listenfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||
zlog_info(zct,"create socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
zlog_error(zbt, "create socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
return;
|
||||
}
|
||||
setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, (char *)&mw_optval, sizeof(mw_optval));
|
||||
@ -23,23 +25,23 @@ void TcpCgi::startCgiServer() {
|
||||
servaddr.sin_port = htons(7305);
|
||||
|
||||
if (bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)) == -1) {
|
||||
zlog_info(zct,"bind socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
zlog_error(zbt, "bind socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
return;
|
||||
}
|
||||
|
||||
if (listen(listenfd, 10) == -1) {
|
||||
zlog_info(zct,"listen socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
zlog_error(zbt, "listen socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
return;
|
||||
}
|
||||
|
||||
while (1) {
|
||||
if ((connfd = accept(listenfd, (struct sockaddr *)NULL, NULL)) == -1) {
|
||||
zlog_info(zct,"accept socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
zlog_error(zct, "accept socket error: %s(errno: %d)", strerror(errno), errno);
|
||||
continue;
|
||||
}
|
||||
n = recv(connfd, buff, 40960, 0);
|
||||
if (n <= 0) {
|
||||
zlog_info(zct,("recv fail");
|
||||
zlog_info(zct, "recv 0 and will close");
|
||||
close(connfd);
|
||||
} else {
|
||||
buff[n] = '\0';
|
||||
|
||||
@ -1,25 +1,19 @@
|
||||
#include "udp_scan.hpp"
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <zlog.h>
|
||||
#include "common/common_func.hpp"
|
||||
#include "common/global.hpp"
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
extern zlog_category_t *zbt;
|
||||
|
||||
UdpSys::UdpSys():
|
||||
mIoSev(), udpSock(mIoSev, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 7303))
|
||||
{
|
||||
zlog_info(zct,"UdpQt Init");
|
||||
}
|
||||
UdpSys::UdpSys() : mIoSev(), udpSock(mIoSev, boost::asio::ip::udp::endpoint(boost::asio::ip::udp::v4(), 7303)) { zlog_info(zct, "UdpQt Init"); }
|
||||
|
||||
void UdpSys::ClearConnect() { remoteIp.clear(); }
|
||||
|
||||
void UdpSys::ClearConnect()
|
||||
{
|
||||
remoteIp.clear();
|
||||
}
|
||||
|
||||
void UdpSys::StartConnectSysUdp()
|
||||
{
|
||||
zlog_info(zct,"start connect QT");
|
||||
void UdpSys::StartConnectSysUdp() {
|
||||
zlog_info(zbt, "start connect QT");
|
||||
if (udpSock.is_open()) {
|
||||
boost::asio::socket_base::linger option1(true, 0);
|
||||
udpSock.set_option(option1);
|
||||
@ -32,9 +26,7 @@ void UdpSys::StartConnectSysUdp()
|
||||
}
|
||||
}
|
||||
|
||||
void UdpSys::handle_send_to(const boost::system::error_code& ec,
|
||||
size_t trans)
|
||||
{
|
||||
void UdpSys::handle_send_to(const boost::system::error_code& ec, size_t trans) {
|
||||
if (ec) {
|
||||
zlog_error(zct, "send the udp to sys error! ");
|
||||
} else {
|
||||
@ -42,36 +34,22 @@ void UdpSys::handle_send_to(const boost::system::error_code& ec,
|
||||
}
|
||||
}
|
||||
|
||||
void UdpSys::SendUdpToSingle(std::string pData)
|
||||
{
|
||||
void UdpSys::SendUdpToSingle(std::string pData) {
|
||||
boost::mutex::scoped_lock lock(udpMutex);
|
||||
int len = pData.length();
|
||||
if (len <= 0)
|
||||
return ;
|
||||
if (len <= 0) return;
|
||||
char* mi = new char[len + 3];
|
||||
memset(mi, 0, len + 3);
|
||||
strcpy(mi, pData.c_str());
|
||||
strcat(mi, "\r\n");
|
||||
zlog_info(zct, "sys send single : %s ", pData.c_str());
|
||||
udpSock.async_send_to(boost::asio::buffer(mi,len + 3), remoteEndPoint,
|
||||
boost::bind(&UdpSys::handle_send_to, this,
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
udpSock.async_send_to(boost::asio::buffer(mi, len + 3), remoteEndPoint, boost::bind(&UdpSys::handle_send_to, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||
delete[] mi;
|
||||
}
|
||||
|
||||
void UdpSys::recvUdpData()
|
||||
{
|
||||
udpSock.async_receive_from(boost::asio::buffer(m_buffer), senderEndPoint,
|
||||
boost::bind(&UdpSys::HandleRead, this,
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
}
|
||||
void UdpSys::recvUdpData() { udpSock.async_receive_from(boost::asio::buffer(m_buffer), senderEndPoint, boost::bind(&UdpSys::HandleRead, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred)); }
|
||||
|
||||
|
||||
void UdpSys::HandleRead(const boost::system::error_code& pEc,
|
||||
std::size_t pBytesTransferred)
|
||||
{
|
||||
void UdpSys::HandleRead(const boost::system::error_code& pEc, std::size_t pBytesTransferred) {
|
||||
std::string ip = senderEndPoint.address().to_string();
|
||||
if (pEc) {
|
||||
std::cerr << pEc.value() << std::endl;
|
||||
@ -92,8 +70,7 @@ void UdpSys::HandleRead(const boost::system::error_code& pEc,
|
||||
recvUdpData();
|
||||
}
|
||||
|
||||
void UdpSys::AnalysisDataSys(std::string cmd)
|
||||
{
|
||||
void UdpSys::AnalysisDataSys(std::string cmd) {
|
||||
zlog_info(zct, "%s", cmd.c_str());
|
||||
Json::Reader recvReader;
|
||||
Json::Value JsonVal;
|
||||
@ -111,8 +88,7 @@ void UdpSys::AnalysisDataSys(std::string cmd)
|
||||
}
|
||||
|
||||
zlog_info(zct, "strServerIp : %s ", strServerIp.c_str());
|
||||
if (strServerIp.compare(GlobalConfig::ServerIP) != 0 || localServerPort != GlobalConfig::ServerPort)
|
||||
{
|
||||
if (strServerIp.compare(GlobalConfig::ServerIP) != 0 || localServerPort != GlobalConfig::ServerPort) {
|
||||
GlobalConfig::ServerIP = strServerIp;
|
||||
GlobalConfig::ServerPort = localServerPort;
|
||||
|
||||
@ -128,44 +104,31 @@ void UdpSys::AnalysisDataSys(std::string cmd)
|
||||
Json::FastWriter fw;
|
||||
std::string str = fw.write(JsonVal);
|
||||
zlog_info(zct, "send info : %s ", str.c_str());
|
||||
boost::asio::ip::udp::endpoint remoteEP(boost::asio::ip::address::from_string(senderEndPoint.address().to_string()),
|
||||
MULTICAST_PORT_SEND);
|
||||
udpSock.async_send_to(boost::asio::buffer(str),remoteEP,
|
||||
boost::bind(&UdpSys::handle_send_to,this,boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
boost::asio::ip::udp::endpoint remoteEP(boost::asio::ip::address::from_string(senderEndPoint.address().to_string()), MULTICAST_PORT_SEND);
|
||||
udpSock.async_send_to(boost::asio::buffer(str), remoteEP, boost::bind(&UdpSys::handle_send_to, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||
} else {
|
||||
//TODO: add log here
|
||||
zlog_info(zbt, "server ip and port not change");
|
||||
}
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
case 4: {
|
||||
Json::FastWriter fw;
|
||||
std::string status = JsonVal["status"].asString();
|
||||
if(status.compare("REQ") == 0)
|
||||
{
|
||||
if (status.compare("REQ") == 0) {
|
||||
JsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G.c_str();
|
||||
JsonVal["localServerIpAddress"] = GlobalConfig::ServerIP;
|
||||
JsonVal["status"] = "ACK";
|
||||
std::string data = fw.write(JsonVal);
|
||||
boost::asio::ip::udp::endpoint remoteEP(boost::asio::ip::address::from_string(senderEndPoint.address().to_string()),
|
||||
MULTICAST_PORT_SEND);
|
||||
udpSock.async_send_to(boost::asio::buffer(data),remoteEP,
|
||||
boost::bind(&UdpSys::handle_send_to,this,boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred));
|
||||
boost::asio::ip::udp::endpoint remoteEP(boost::asio::ip::address::from_string(senderEndPoint.address().to_string()), MULTICAST_PORT_SEND);
|
||||
udpSock.async_send_to(boost::asio::buffer(data), remoteEP, boost::bind(&UdpSys::handle_send_to, this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||
}
|
||||
} break;
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}else
|
||||
{
|
||||
} else {
|
||||
zlog_error(zct, "json parse failed");
|
||||
}
|
||||
}
|
||||
|
||||
UdpSys::~UdpSys()
|
||||
{
|
||||
if (udpSock.is_open())
|
||||
udpSock.close();
|
||||
UdpSys::~UdpSys() {
|
||||
if (udpSock.is_open()) udpSock.close();
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
#include <zlog.h>
|
||||
#include "common/common_func.hpp"
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
Dial::Dial() {
|
||||
m_fd = 0;
|
||||
|
||||
@ -16,6 +16,8 @@
|
||||
#include <unistd.h>
|
||||
#include <zlog.h>
|
||||
|
||||
extern zlog_category_t *zct;
|
||||
|
||||
namespace wifi {
|
||||
|
||||
size_t strlcpy(char *dst, const char *src, size_t dst_sz) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user