修改嵌入式web页面输入IP错误时,增加验证
This commit is contained in:
parent
06b5339acf
commit
4c916b2a34
83
.autotools
Normal file
83
.autotools
Normal file
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configurations>
|
||||
<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.600849340">
|
||||
<option id="configure" value="configure"/>
|
||||
<option id="configdir" value=""/>
|
||||
<option id="cache-file" value=""/>
|
||||
<option id="help" value="false"/>
|
||||
<option id="no-create" value="false"/>
|
||||
<option id="quiet" value="false"/>
|
||||
<option id="version" value="false"/>
|
||||
<option id="host" value=""/>
|
||||
<option id="build" value=""/>
|
||||
<option id="target" value=""/>
|
||||
<option id="prefix" value=""/>
|
||||
<option id="exec-prefix" value=""/>
|
||||
<option id="libdir" value=""/>
|
||||
<option id="bindir" value=""/>
|
||||
<option id="sbindir" value=""/>
|
||||
<option id="includedir" value=""/>
|
||||
<option id="datadir" value=""/>
|
||||
<option id="sysconfdir" value=""/>
|
||||
<option id="infodir" value=""/>
|
||||
<option id="mandir" value=""/>
|
||||
<option id="srcdir" value=""/>
|
||||
<option id="localstatedir" value=""/>
|
||||
<option id="sharedstatedir" value=""/>
|
||||
<option id="libexecdir" value=""/>
|
||||
<option id="oldincludedir" value=""/>
|
||||
<option id="program-prefix" value=""/>
|
||||
<option id="program-suffix" value=""/>
|
||||
<option id="program-transform-name" value=""/>
|
||||
<option id="env_vars" value=""/>
|
||||
<option id="enable-maintainer-mode" value="false"/>
|
||||
<flag id="CFLAGS" value="CFLAGS|CXXFLAGS">
|
||||
<flagvalue id="cflags-debug" value="false"/>
|
||||
<flagvalue id="cflags-gprof" value="false"/>
|
||||
<flagvalue id="cflags-gcov" value="false"/>
|
||||
</flag>
|
||||
<option id="user" value=""/>
|
||||
<option id="autogen" value="autogen.sh"/>
|
||||
<option id="autogenOpts" value=""/>
|
||||
</configuration>
|
||||
<configuration id="org.eclipse.linuxtools.cdt.autotools.core.configuration.build.debug.861628562">
|
||||
<option id="configure" value="configure"/>
|
||||
<option id="configdir" value=""/>
|
||||
<option id="cache-file" value=""/>
|
||||
<option id="help" value="false"/>
|
||||
<option id="no-create" value="false"/>
|
||||
<option id="quiet" value="false"/>
|
||||
<option id="version" value="false"/>
|
||||
<option id="host" value=""/>
|
||||
<option id="build" value=""/>
|
||||
<option id="target" value=""/>
|
||||
<option id="prefix" value=""/>
|
||||
<option id="exec-prefix" value=""/>
|
||||
<option id="libdir" value=""/>
|
||||
<option id="bindir" value=""/>
|
||||
<option id="sbindir" value=""/>
|
||||
<option id="includedir" value=""/>
|
||||
<option id="datadir" value=""/>
|
||||
<option id="sysconfdir" value=""/>
|
||||
<option id="infodir" value=""/>
|
||||
<option id="mandir" value=""/>
|
||||
<option id="srcdir" value=""/>
|
||||
<option id="localstatedir" value=""/>
|
||||
<option id="sharedstatedir" value=""/>
|
||||
<option id="libexecdir" value=""/>
|
||||
<option id="oldincludedir" value=""/>
|
||||
<option id="program-prefix" value=""/>
|
||||
<option id="program-suffix" value=""/>
|
||||
<option id="program-transform-name" value=""/>
|
||||
<option id="env_vars" value=""/>
|
||||
<option id="enable-maintainer-mode" value="false"/>
|
||||
<flag id="CFLAGS" value="CFLAGS|CXXFLAGS">
|
||||
<flagvalue id="cflags-debug" value="false"/>
|
||||
<flagvalue id="cflags-gprof" value="false"/>
|
||||
<flagvalue id="cflags-gcov" value="false"/>
|
||||
</flag>
|
||||
<option id="user" value="CFLAGS='-g -O0' CXXFLAGS='-g -O0'"/>
|
||||
<option id="autogen" value="autogen.sh"/>
|
||||
<option id="autogenOpts" value=""/>
|
||||
</configuration>
|
||||
</configurations>
|
18
.cproject
18
.cproject
@ -36,18 +36,18 @@
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/jsoncpp/include"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/sqlite/include"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.dialect.std.1150808616" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/>
|
||||
<option id="gnu.cpp.compiler.option.dialect.std.745589380" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1387553514" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.310128155" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool command="g++" commandLinePattern="${COMMAND} ${FLAGS} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS}" errorParsers="org.eclipse.cdt.core.GLDErrorParser" id="cdt.managedbuild.tool.gnu.cross.cpp.linker.1049583485" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.paths.1174701783" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" useByScannerDiscovery="false" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/boost/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/curl/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/DataWatchThirdParty/curl/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/DataWatchThirdParty/ssl/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/fftw/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/jsoncpp"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/mqtt1410/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/DataWatchThirdParty/mqtt1410/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/sqlite/lib"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.link.option.libs.1027000140" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">
|
||||
@ -113,33 +113,31 @@
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/jsoncpp/include"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/sqlite/include"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.compiler.option.dialect.std.603357595" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.542083696" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
|
||||
</tool>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.c.linker.1480789657" name="Cross GCC Linker" superClass="cdt.managedbuild.tool.gnu.cross.c.linker"/>
|
||||
<tool id="cdt.managedbuild.tool.gnu.cross.cpp.linker.762964696" name="Cross G++ Linker" superClass="cdt.managedbuild.tool.gnu.cross.cpp.linker">
|
||||
<option id="gnu.cpp.link.option.paths.1792108116" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" useByScannerDiscovery="false" valueType="libPaths">
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/boost/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/curl/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/curl/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/DataWatchThirdParty/ssl/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/fftw/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/jsoncpp"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/mqtt1410/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/DataWatchThirdParty/mqtt1410/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/DataWatchThirdParty/curl/lib"/>
|
||||
<listOptionValue builtIn="false" value="/nfsroot/eclipse-workspace/GatewayThirdParty/sqlite/lib"/>
|
||||
</option>
|
||||
<option id="gnu.cpp.link.option.libs.2006599708" name="Libraries (-l)" superClass="gnu.cpp.link.option.libs" useByScannerDiscovery="false" valueType="libs">
|
||||
<listOptionValue builtIn="false" value="sqlite3"/>
|
||||
<listOptionValue builtIn="false" value="curl"/>
|
||||
<listOptionValue builtIn="false" value="ssl"/>
|
||||
<listOptionValue builtIn="false" value="crypto"/>
|
||||
<listOptionValue builtIn="false" value="boost_system"/>
|
||||
<listOptionValue builtIn="false" value="pthread"/>
|
||||
<listOptionValue builtIn="false" value="boost_thread"/>
|
||||
<listOptionValue builtIn="false" value="boost_date_time"/>
|
||||
<listOptionValue builtIn="false" value="fftw3"/>
|
||||
<listOptionValue builtIn="false" value="ssl"/>
|
||||
<listOptionValue builtIn="false" value="crypto"/>
|
||||
<listOptionValue builtIn="false" value="json"/>
|
||||
<listOptionValue builtIn="false" value="mosquitto"/>
|
||||
<listOptionValue builtIn="false" value="curl"/>
|
||||
</option>
|
||||
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.1442843267" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
|
@ -5,7 +5,7 @@
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1734643904566128475" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1795775469460424669" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
@ -16,7 +16,7 @@
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="1734643904566128475" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<provider class="org.eclipse.cdt.internal.build.crossgcc.CrossGCCBuiltinSpecsDetector" console="false" env-hash="-1795775469460424669" id="org.eclipse.cdt.build.crossgcc.CrossGCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <sys/time.h>
|
||||
#include "SH_global.h"
|
||||
#include "SH_CommonFunc.hpp"
|
||||
|
||||
#include <boost/xpressive/xpressive_dynamic.hpp>
|
||||
|
||||
|
||||
static boost::mutex s_config_mu;
|
||||
@ -440,16 +440,37 @@ std::string GetFileContent(std::string filename, int line)
|
||||
}
|
||||
|
||||
|
||||
//BOOST用正则表达式验证ip地址合法
|
||||
bool CheckIP(const char *ip)
|
||||
{
|
||||
using namespace boost::xpressive;
|
||||
/* 定义正则表达式 */
|
||||
cregex reg_ip = cregex::compile("(25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])[.](25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])[.](25[0-5]|2[0-5][0-9]|1[0-9][0-9]|[1-9][0-9]|[1-9])");
|
||||
return regex_match(ip, reg_ip);
|
||||
}
|
||||
|
||||
bool IsValidMask(std::string mask) {
|
||||
int iRet = -1;
|
||||
|
||||
// 将IP地址由“点分十进制”转换成 “二进制整数”
|
||||
struct in_addr s;
|
||||
iRet = inet_pton(AF_INET, mask.c_str(), &s);
|
||||
|
||||
// 转换成功返回1,说明是有效的IP地址
|
||||
if (iRet == 1) {
|
||||
// 从网络字节顺序转换为主机字节顺序
|
||||
unsigned int addr = ntohl(s.s_addr);
|
||||
|
||||
// 转换为二进制字符串
|
||||
std::bitset<32> b((int)addr);
|
||||
std::string strMask = b.to_string();
|
||||
|
||||
// 查找二进制字符串中的"01",如果不存在,说明是有效的子网掩码
|
||||
return (strMask.find("01") == std::string::npos);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
// int StatusPub()
|
||||
// {
|
||||
// long mem_used = -1;
|
||||
|
@ -572,7 +572,8 @@ extern void ZoneConfig(std::string zoneid);
|
||||
*/
|
||||
extern std::string GetSysStatus();
|
||||
|
||||
|
||||
extern bool CheckIP(const char *ip);
|
||||
bool IsValidMask(std::string mask);
|
||||
//read update config file
|
||||
extern std::vector <std::string> ReadStrByOpt(std::string filename,std::string strUpdataFileName);
|
||||
|
||||
|
@ -49,6 +49,9 @@ std::string JsonData::JsonCmd_20(Param_20 ¶m)
|
||||
jsSystemInfo["zigbeePanId"] = GlobalConfig::ZigbeeInfo_G.PanID;
|
||||
jsSystemInfo["zigbeeChannel"] = GlobalConfig::ZigbeeInfo_G.Channel;
|
||||
jsSystemInfo["zigbeeAddr"] = GlobalConfig::ZigbeeInfo_G.MyAddr;
|
||||
jsSystemInfo[JSON_FIELD_SERVERIP] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress");
|
||||
jsSystemInfo[JSON_FIELD_SERVERPORT] = boost::lexical_cast<int>(ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort"));
|
||||
jsSystemInfo[JSON_FIELD_CommMode] = boost::lexical_cast<int>(ReadStrByOpt(SERVERCONFIG, "Server", "CommMode"));
|
||||
jsBody["SystemInfo"] = jsSystemInfo;
|
||||
|
||||
std::string dataBody = showValue.write(jsBody);
|
||||
@ -136,6 +139,7 @@ std::string JsonData::JsonCmd_25(Param_25 ¶m)
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "subnetMask", param.mSubnetMask);
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "ipAddress", param.mIp);
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "hostName", param.mHostName);
|
||||
system("reboot");
|
||||
}
|
||||
|
||||
jsonVal["cmd"] = "25";
|
||||
@ -491,7 +495,27 @@ std::string JsonData::JsonCmd_Cgi_07()
|
||||
}
|
||||
return showValue.write(jsonVal);
|
||||
}
|
||||
std::string JsonData::JsonCmd_07()
|
||||
{
|
||||
Json::Value jsonVal;
|
||||
jsonVal.clear();
|
||||
std::string sysStatus = GetSysStatus();
|
||||
|
||||
print_info("sysStatus : %s\n", sysStatus.c_str());
|
||||
Json::Features f = Json::Features::strictMode();
|
||||
Json::Reader recvReader(f);
|
||||
Json::Value recvSys;
|
||||
jsonVal[JSON_FIELD_CMD] = "07";
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
if (recvReader.parse(sysStatus, recvSys)){
|
||||
jsonVal["cmdBody"] = sysStatus;
|
||||
} else {
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["message"] = "状态获取失败";
|
||||
}
|
||||
return showValue.write(jsonVal);
|
||||
}
|
||||
std::string JsonData::JsonCmd_Cgi_08()
|
||||
{
|
||||
Json::Value jsonVal;
|
||||
@ -662,18 +686,22 @@ std::string JsonData::JsonCmd_Cgi_23(Param_23 ¶m)
|
||||
{
|
||||
Json::Value jsonVal;
|
||||
jsonVal.clear();
|
||||
// SET 指令,则param.mMode = 0,将设置的数据写入配置文件中 SERVERCONFIG "/opt/configenv/ServerConfig.json"
|
||||
if (0 == param.mMode) {
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", param.mServerIp);
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", param.mPort);
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "communicationMode", param.mCommMode);
|
||||
}
|
||||
|
||||
jsonVal[JSON_FIELD_CMD] = "23";
|
||||
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
|
||||
jsonVal["cmdSerial"] = param.mCmdSerial;
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
// SET 指令,则param.mMode = 0,将设置的数据写入配置文件中 SERVERCONFIG "/opt/configenv/ServerConfig.json"
|
||||
|
||||
if (0 == param.mMode && CheckIP(param.mServerIp.c_str())) {
|
||||
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", param.mServerIp);
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", param.mPort);
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "communicationMode", param.mCommMode);
|
||||
system("reboot");
|
||||
}else if(0 == param.mMode && !(CheckIP(param.mServerIp.c_str()))){
|
||||
jsonVal["success"] = false;
|
||||
}
|
||||
|
||||
Json::Value jsSystemSetting;
|
||||
Json::Value jsBody;
|
||||
@ -694,8 +722,15 @@ std::string JsonData::JsonCmd_Cgi_25(Param_25 ¶m)
|
||||
{
|
||||
Json::Value jsonVal;
|
||||
jsonVal.clear();
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
jsonVal["cmd"] = "25";
|
||||
if (0 == param.mMode) {
|
||||
bool bFlag1 = CheckIP(param.mGateway.c_str());
|
||||
bool bFlag2 = IsValidMask(param.mSubnetMask);
|
||||
bool bFlag3 = CheckIP(param.mIp.c_str());
|
||||
bool bFlag4 = CheckIP(param.mDnsName.c_str());
|
||||
|
||||
if (0 == param.mMode &&(bFlag1 && bFlag2 && bFlag3 && bFlag4)) {
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "dnsName", param.mDnsName);
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "networkPortStatus", param.mNetworkPortStatus);
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "gateway", param.mGateway);
|
||||
@ -703,9 +738,11 @@ std::string JsonData::JsonCmd_Cgi_25(Param_25 ¶m)
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "ipAddress", param.mIp);
|
||||
WriteStr2Config(NETWORKCONFIG, "Net", "hostName", param.mHostName);
|
||||
platform->EquipIpInit();
|
||||
system("reboot");
|
||||
}else if(0 == param.mMode &&(!bFlag1 || !bFlag2 || !bFlag3 || !bFlag4)){
|
||||
jsonVal["success"] = false;
|
||||
}
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
|
||||
jsonVal["content"]["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "Net", "dnsName");
|
||||
jsonVal["content"]["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "Net", "networkPortStatus");
|
||||
jsonVal["content"]["gateway"] = ReadStrByOpt(NETWORKCONFIG, "Net", "gateway");
|
||||
|
@ -35,6 +35,7 @@ public :
|
||||
std::string JsonCmd_Cgi_01(Param_01 ¶m); //用户操作处理
|
||||
std::string JsonCmd_Cgi_02(Param_02 ¶m); //时间校准接口
|
||||
std::string JsonCmd_Cgi_07(); //获取系统内存温度硬盘等信息
|
||||
std::string JsonCmd_07(); //获取系统内存温度硬盘等信息
|
||||
std::string JsonCmd_Cgi_08(); //重启
|
||||
std::string JsonCmd_Cgi_09(); //实时数据获取
|
||||
std::string JsonCmd_Cgi_20(Param_20 ¶m); //终端信息获取
|
||||
@ -75,6 +76,7 @@ static const char* JSON_FIELD_TIMEZONE = "timezone";
|
||||
|
||||
|
||||
|
||||
|
||||
//cmd "21"
|
||||
// static const char* JSON_FIELD_CMD = "cmd";//协议: 命令字段
|
||||
// static const char* JSON_FIELD_NAME = "dataWatchName";//协议: 终端名称
|
||||
|
@ -33,15 +33,20 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to
|
||||
Json::Value recvValue;
|
||||
Json::Value recvBody;
|
||||
if (recvReader.parse(pData, recvValue)) {
|
||||
/* std::string cmdBody = recvValue["cmdBody"].asString();
|
||||
std::string cmdBody = recvValue["cmdBody"].asString();
|
||||
if (!recvReader.parse(cmdBody, recvBody)) {
|
||||
print_error("recv body error");
|
||||
return;
|
||||
}*/
|
||||
recvBody = recvValue["cmdBody"];
|
||||
}
|
||||
// recvBody = recvValue["cmdBody"];
|
||||
std::string str = recvBody["timestamp"].asString();
|
||||
int cmdType = atoi(recvValue["cmd"].asString().c_str());
|
||||
switch (cmdType) {
|
||||
case 7:{
|
||||
JsonData jd;
|
||||
std::string data = jd.JsonCmd_07();
|
||||
data_publish(data.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
}break;
|
||||
case 10:{
|
||||
recvValue["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
|
||||
recvValue["status"] = "ACK";
|
||||
@ -68,14 +73,14 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to
|
||||
std::string zoneid = recvValue["ZoneId"].asString();
|
||||
ZoneConfig(zoneid);
|
||||
}
|
||||
Json::Value retVal;
|
||||
/* Json::Value retVal;
|
||||
retVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
|
||||
retVal["cmd"] = 12;
|
||||
retVal["success"] = true;
|
||||
retVal["message"] = "校时成功";
|
||||
Json::FastWriter fw;
|
||||
std::string strjson = fw.write(retVal);
|
||||
data_publish(strjson.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
data_publish(strjson.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());*/
|
||||
}
|
||||
break;
|
||||
case 13:{
|
||||
@ -203,7 +208,6 @@ void LocalServer::HandleFromServer(const char *pData_r, int pLen, const char *to
|
||||
} else {
|
||||
print_error("parase fail \n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::string LocalServer::HandleCgi_cmd(std::string &pData)
|
||||
@ -321,6 +325,7 @@ try{
|
||||
}
|
||||
JsonData jd;
|
||||
std::string data = jd.JsonCmd_Cgi_23(param);
|
||||
|
||||
return data;
|
||||
}
|
||||
break;
|
||||
|
@ -194,7 +194,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result)
|
||||
// jsData["cmdBody"] = "";
|
||||
|
||||
std::string strCmd15 = fw.write(jsData);
|
||||
data_publish(strCmd15.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
// data_publish(strCmd15.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
|
||||
std::string instr = std::string(reply_string);
|
||||
std::string topic = "equipment/state/" + GlobalConfig::MacAddr_G;
|
||||
@ -215,7 +215,7 @@ void my_connect_callback(struct mosquitto *mosq, void *obj, int result)
|
||||
sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}",
|
||||
GlobalConfig::MacAddr_G.c_str());
|
||||
std::string str = std::string(buf);
|
||||
data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
// data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
std::string runinfo = "本地服务器连接成功";
|
||||
|
||||
}
|
||||
|
@ -279,6 +279,7 @@ void Uart::UpdateWirelessNode(unsigned char* id)
|
||||
break;
|
||||
}
|
||||
}
|
||||
printf("thisindex = %d\n",thisindex);
|
||||
if(thisindex < 0)
|
||||
return;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user