优化了web页面,松动逻辑优化,增加网关和无线传感器配置导入导出
This commit is contained in:
parent
427db9825d
commit
fa77947c88
@ -130,7 +130,29 @@ std::string UTFtoGBK(const char* utf8)
|
||||
return "";
|
||||
}
|
||||
}
|
||||
std::string convertEncoding(const std::string& input, const char* fromEncoding, const char* toEncoding) {
|
||||
iconv_t conv = iconv_open(toEncoding, fromEncoding);
|
||||
if (conv == (iconv_t)-1) {
|
||||
throw std::runtime_error("iconv_open failed");
|
||||
}
|
||||
|
||||
size_t inBytesLeft = input.size();
|
||||
size_t outBytesLeft = inBytesLeft * 2; // GBK may require up to twice the space of UTF-8
|
||||
char* inBuf = const_cast<char*>(input.c_str());
|
||||
char* outBuf = new char[outBytesLeft];
|
||||
char* outPtr = outBuf;
|
||||
|
||||
if (iconv(conv, &inBuf, &inBytesLeft, &outPtr, &outBytesLeft) == (size_t)-1) {
|
||||
delete[] outBuf;
|
||||
iconv_close(conv);
|
||||
throw std::runtime_error("iconv failed");
|
||||
}
|
||||
|
||||
std::string result(outBuf, outPtr);
|
||||
delete[] outBuf;
|
||||
iconv_close(conv);
|
||||
return result;
|
||||
}
|
||||
|
||||
void InitGpio(unsigned int gpioN,unsigned int inout)
|
||||
{
|
||||
@ -430,13 +452,16 @@ int read_data(int fd, char *buff, int len, int timeout)
|
||||
FD_ZERO(&rdfds);
|
||||
FD_SET(fd, &rdfds);
|
||||
|
||||
if (timeout > 0) {
|
||||
ret = select(fd+1, &rdfds, NULL, NULL, &to);
|
||||
if (ret <= 0) {
|
||||
// printf("zigbee doesn't respond!\n");
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
// if (timeout > 0) {
|
||||
// ret = select(fd+1, &rdfds, NULL, NULL, &to);
|
||||
// if (ret <= 0) {
|
||||
// // printf("zigbee doesn't respond!\n");
|
||||
// return ret;
|
||||
// }
|
||||
// }
|
||||
if (ioctl(fd, FIONREAD, &len) == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = read(fd,buff,len);
|
||||
if(ret < 0) {
|
||||
@ -729,6 +754,72 @@ void ReadStrConfig(std::string filename)
|
||||
}
|
||||
is.close();
|
||||
}
|
||||
void ImportConfig(std::string filename)
|
||||
{
|
||||
Json::Value root,gateWay,dataNode;
|
||||
std::fstream is;
|
||||
Json::Reader reader;
|
||||
is.open(filename.c_str(), std::ios::in);
|
||||
string zigbeeChannel;
|
||||
|
||||
Json::Value jsSystemSetting,jsonValnet,jsonValnet1,jsSystemInfo,jsonValZigbee,jsondataNodeArray;
|
||||
if (reader.parse(is, root)) {
|
||||
jsSystemInfo = root["SystemInfo"];
|
||||
jsonValZigbee = root["zigbee"];
|
||||
jsonValnet1 = root["eth1"];
|
||||
jsonValnet = root["eth0"];
|
||||
jsSystemSetting = root["ServerConfig"];
|
||||
jsondataNodeArray = root["dataNodeArray"];
|
||||
char insertSql[1024] = { 0 };
|
||||
for(int i = 0; i < jsondataNodeArray.size();i++){
|
||||
Json::Value valNode = jsondataNodeArray[i];
|
||||
vector<string> vecDataNode;
|
||||
for (size_t j = 0; j < valNode.size(); j++)
|
||||
{
|
||||
vecDataNode.push_back(string(valNode[j].asString()));
|
||||
}
|
||||
char dataNodeName[100]={0x00};
|
||||
hexToAscii(vecDataNode[1].c_str(),dataNodeName);
|
||||
sprintf(insertSql, "'%s','%s','%s','%s','%s','%s','%s','%s',\
|
||||
'%s','%s','%s','%s','%s','%s',\
|
||||
'%s','%s','%s','%s','%s','%s',\
|
||||
'%s','%s','%s','%s','%s','%s','%s','%s',\
|
||||
'%s','%s','%s','%s','%s',\
|
||||
'%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s'",
|
||||
vecDataNode[0].c_str(),dataNodeName,vecDataNode[2].c_str(),vecDataNode[3].c_str(),vecDataNode[4].c_str(),\
|
||||
vecDataNode[5].c_str(),vecDataNode[6].c_str(),vecDataNode[7].c_str(),vecDataNode[8].c_str(),vecDataNode[9].c_str(),\
|
||||
vecDataNode[10].c_str(),vecDataNode[11].c_str(),vecDataNode[12].c_str(),vecDataNode[13].c_str(),vecDataNode[14].c_str(),\
|
||||
vecDataNode[15].c_str(),vecDataNode[16].c_str(),vecDataNode[17].c_str(),vecDataNode[18].c_str(),vecDataNode[19].c_str(),\
|
||||
vecDataNode[20].c_str(),vecDataNode[21].c_str(),vecDataNode[22].c_str(),vecDataNode[23].c_str(),vecDataNode[24].c_str(),\
|
||||
vecDataNode[25].c_str(),vecDataNode[26].c_str(),vecDataNode[27].c_str(),vecDataNode[28].c_str(),vecDataNode[29].c_str(),\
|
||||
vecDataNode[30].c_str(),vecDataNode[31].c_str(),vecDataNode[32].c_str(),vecDataNode[33].c_str(),vecDataNode[34].c_str(),\
|
||||
vecDataNode[35].c_str(),vecDataNode[36].c_str(),vecDataNode[37].c_str(),vecDataNode[38].c_str(),vecDataNode[39].c_str(),\
|
||||
vecDataNode[40].c_str(),vecDataNode[41].c_str(),vecDataNode[42].c_str(),vecDataNode[43].c_str());
|
||||
sql_ctl->InsertData(T_SENSOR_INFO(TNAME), insertSql);
|
||||
}
|
||||
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "localServerIpAddress", jsSystemSetting["ServerIpAddress"].asString());
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "localServerPort", jsSystemSetting["ServerPort"].asString());
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "CommMode", /*param.mCommMode*/"2");
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "UserName", jsSystemSetting["UserName"].asString());
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "Password", jsSystemSetting["Password"].asString());
|
||||
WriteStr2Config(SERVERCONFIG, "Server", "APN", jsSystemSetting["APN"].asString());
|
||||
char APN[100]={0x00};
|
||||
sprintf(APN,"sed -i '15c \t\t\t\t/opt/quectel-CM/quectel-CM -s %s > /dev/null &' /etc/init.d/S95check5G",jsSystemSetting["APN"].asString());
|
||||
system(APN);
|
||||
|
||||
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", jsonValZigbee["channel"].asString());
|
||||
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "PanID", jsonValZigbee["PanID"].asString());
|
||||
|
||||
WriteStr2Config(SYSTEMINFOFILE, "Version", "GateWayVersion", jsSystemInfo["GateWayVersion"].asString());
|
||||
WriteStr2Config(SYSTEMINFOFILE, "Version", "SystemVersion", jsSystemInfo["SystemVersion"].asString());
|
||||
WriteStr2Config(SYSTEMINFOFILE, "Version", "WebVersion", jsSystemInfo["WebVersion"].asString());
|
||||
WriteStr2Config(SYSTEMINFOFILE, "Version", "GateWayHwVesion", jsSystemInfo["GateWayHwVesion"].asString());
|
||||
WriteStr2Config(SYSTEMINFOFILE, "Version", "GateWayProduct", jsSystemInfo["GateWayProduct"].asString());
|
||||
|
||||
}
|
||||
//system("reboot");
|
||||
}
|
||||
int UpdataDataNodeConfig(std::string filename)
|
||||
{
|
||||
vector<DataNodeInfo> vecDataNode; //声明一个字符串向量
|
||||
@ -1378,7 +1469,28 @@ std::string GetSysStatus()
|
||||
return strJson;
|
||||
}
|
||||
|
||||
void stringToHex(const char* str, char* hexStr) {
|
||||
while (*str) {
|
||||
sprintf(hexStr, "%02x", (unsigned char)*str);
|
||||
hexStr += 2;
|
||||
str++;
|
||||
}
|
||||
*hexStr = '\0';
|
||||
}
|
||||
void hexToAscii(const char* hexStr, char* asciiStr) {
|
||||
int len = strlen(hexStr);
|
||||
int i, j = 0;
|
||||
|
||||
for (i = 0; i < len; i += 2) {
|
||||
// 读取两个字符并将其转换为整数
|
||||
int byte;
|
||||
sscanf(&hexStr[i], "%2x", &byte);
|
||||
// 将整数转换为对应的ASCII字符
|
||||
asciiStr[j++] = (char)byte;
|
||||
}
|
||||
// 添加字符串结束符
|
||||
asciiStr[j] = '\0';
|
||||
}
|
||||
unsigned char ch2hex(char ch)
|
||||
{
|
||||
static const char *hex="0123456789ABCDEF";
|
||||
|
@ -310,8 +310,9 @@ struct Param_01 {
|
||||
|
||||
struct Param_02 {
|
||||
int mMode; //0:配置时间 1:获取时间
|
||||
int mSetType;
|
||||
int mTimeStamp;
|
||||
Param_02():mMode(0),mTimeStamp(0){};
|
||||
Param_02():mMode(0),mSetType(0),mTimeStamp(0){};
|
||||
};
|
||||
|
||||
|
||||
@ -398,7 +399,8 @@ struct Param_27 {
|
||||
int mMode;
|
||||
std::string mCmdSerial;
|
||||
std::string mDataNodeNo;
|
||||
Param_27():mMode(0),mCmdSerial(""),mDataNodeNo(""){};
|
||||
std::string mType;
|
||||
Param_27():mMode(0),mCmdSerial(""),mDataNodeNo(""),mType(""){};
|
||||
|
||||
};
|
||||
|
||||
@ -459,7 +461,8 @@ struct Param_31 {
|
||||
int mMode;
|
||||
//int mChannelId;
|
||||
std::string mChannelId;
|
||||
Param_31():mMode(0),mChannelId(""){};
|
||||
std::string mPanID;
|
||||
Param_31():mMode(0),mChannelId(""),mPanID(""){};
|
||||
};
|
||||
|
||||
|
||||
@ -552,7 +555,14 @@ struct Param_53 {
|
||||
string mUpdateValue3;
|
||||
Param_53():mUpdateKey2(""),mUpdateValue2(""),mUpdateKey3(""),mUpdateValue3(""){};
|
||||
};
|
||||
struct Param_54 {
|
||||
int mMode;
|
||||
std::string mCmdSerial;
|
||||
std::string mDataNodeNo;
|
||||
int mPackageFlag;
|
||||
Param_54():mMode(0),mCmdSerial(""),mDataNodeNo(""),mPackageFlag(0){};
|
||||
|
||||
};
|
||||
typedef struct DataNodeUpdate{
|
||||
std::string strUpdataFileName;
|
||||
std::string strSoftVersion;
|
||||
@ -567,6 +577,8 @@ struct ethtool_value {
|
||||
|
||||
extern std::string GBKToUTF8(const std::string& strGBK);
|
||||
extern std::string UTFtoGBK(const char* utf8);
|
||||
extern void hexToAscii(const char* hexStr, char* asciiStr);
|
||||
extern void stringToHex(const char* str, char* hexStr);
|
||||
extern string GetLocalTimeWithMs(void);
|
||||
extern void InitGpio(unsigned int gpioN,unsigned int inout);
|
||||
extern int gpio_set(unsigned int gpioN,char x);
|
||||
@ -732,6 +744,7 @@ bool IsValidMask(std::string mask);
|
||||
extern std::vector <DataNodeUpdate> ReadStrUpdate(std::string filename);
|
||||
|
||||
extern void ReadStrConfig(std::string filename);
|
||||
extern void ImportConfig(std::string filename);
|
||||
extern int UpdataDataNodeConfig(std::string filename);
|
||||
extern char* solve(char *dest,const char *src);
|
||||
extern void swap(char *data);
|
||||
|
@ -174,6 +174,7 @@ void SqliteDB::SqliteInit(const char *pDbName, bool isDB2)
|
||||
if(iRet == 0){
|
||||
CreateTable("ALTER TABLE t_data_waveSend ADD COLUMN 'save'");
|
||||
}
|
||||
|
||||
/*memset(sql_exec, 0, 2048);
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s integer,%s integer ,%s integer ,%s integer,%s integer);",
|
||||
T_DATANODE_TIME(TNAME),
|
||||
@ -254,7 +255,7 @@ void SqliteDB::CreatedataStatictable(const char *ptableName)
|
||||
char sql_exec[2048];
|
||||
//创建传感器数据存储表
|
||||
memset(sql_exec, 0, 2048);
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s,%s);",
|
||||
sprintf(sql_exec, "create table if not exists %s(%s,%s,%s,%s,%s,%s,%s,%s integer,%s,%s,%s,%s integer);",
|
||||
ptableName,
|
||||
T_DATASTATIC_INFO(DATANODENO),
|
||||
T_DATASTATIC_INFO(CHANNELID),
|
||||
@ -266,8 +267,8 @@ void SqliteDB::CreatedataStatictable(const char *ptableName)
|
||||
"StaticIndex",
|
||||
T_DATASTATIC_INFO(TIMESTAMP),
|
||||
"sendMsg",
|
||||
"nodeResend"
|
||||
//"zigbeeRSSIType"
|
||||
"nodeResend",
|
||||
"zigbeeSignalNode"
|
||||
);
|
||||
CreateTable(sql_exec, 0);
|
||||
memset(sql_exec, 0, 2048);
|
||||
@ -852,17 +853,60 @@ int SqliteDB::CalculateDip()
|
||||
memset(selectSql,0x00,sizeof(selectSql));
|
||||
sprintf(selectSql," DataNodeNo");
|
||||
array_t vecRes ;
|
||||
vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), selectSql, NULL);
|
||||
char looseValue[10]={0x00};
|
||||
char localtimestamp[32] = { 0 };
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
readStringValue("config", "loose",looseValue,(char*)GlobalConfig::Config_G.c_str());
|
||||
vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), " * ", NULL);
|
||||
for(int i = 0 ; i < vecRes.size(); i++){
|
||||
char szTablename[32]={0x00};
|
||||
sprintf(szTablename,"t_dataStatic_%s",vecRes[i][0].c_str());
|
||||
vec_Value vecResDip = GetDataMultiLineOfOneColumnDouble(szTablename," Dip ", NULL);
|
||||
float sample_variance = pCalculation->getSample_variance(vecResDip);
|
||||
print_info("sample_variance = %f\n",sample_variance);
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
memset(updateSql,0x00,sizeof(updateSql));
|
||||
sprintf(whereCon,"dataNodeNo = '%s' ",vecRes[i][0].c_str());
|
||||
sprintf(updateSql,"LooseValue = '%f' ",sample_variance);
|
||||
vector<string> vParam;
|
||||
print_info("vecRes =%s\n",vecRes[i][42].c_str());
|
||||
boost::split( vParam, vecRes[i][42], boost::is_any_of( "," ), boost::token_compress_on );
|
||||
print_info("vParam size = %d\n",vParam.size());
|
||||
if(vParam.size() < 2)
|
||||
{
|
||||
sprintf(updateSql,"LooseValue = '%f,0' ",atof(vParam[0].c_str()));
|
||||
sprintf(whereCon,"dataNodeNo = '%s' ",vecRes[i][0].c_str());
|
||||
UpdateTableData(T_SENSOR_INFO(TNAME),updateSql,whereCon);
|
||||
}else{
|
||||
char szTablename[32]={0x00};
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
if(vParam[1] == "2"){//人工干预
|
||||
sprintf(whereCon," timeStamp > %ld ",atol(vParam[2].c_str()));
|
||||
}else if(vParam[1] == "0"){//正常状态
|
||||
sprintf(whereCon," timeStamp > %ld ",atol(localtimestamp) - 86400);//一天数据
|
||||
}else if(vParam[1] == "1")//松动状态
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
sprintf(szTablename,"t_dataStatic_%s",vecRes[i][0].c_str());
|
||||
vec_Value vecResDip = GetDataMultiLineOfOneColumnDouble(szTablename," Dip ", whereCon);
|
||||
float sample_variance = pCalculation->getSample_variance(vecResDip);
|
||||
print_info("sample_variance = %f\n",sample_variance);
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
memset(updateSql,0x00,sizeof(updateSql));
|
||||
sprintf(whereCon,"dataNodeNo = '%s' ",vecRes[i][0].c_str());
|
||||
if(vParam[1] == "0"){
|
||||
if(sample_variance > atol(looseValue)){
|
||||
sprintf(updateSql,"LooseValue = '%f,1' ",sample_variance);
|
||||
}else{
|
||||
sprintf(updateSql,"LooseValue = '%f,0' ",sample_variance);
|
||||
}
|
||||
}else if(vParam[1] == "1"){
|
||||
|
||||
}else if(vParam[1] == "2"){
|
||||
if(sample_variance > atol(looseValue))
|
||||
{
|
||||
sprintf(updateSql,"LooseValue = '%f,1' ",sample_variance);
|
||||
}
|
||||
if(atol(localtimestamp) - atol(vParam[2].c_str()) > 86400){
|
||||
sprintf(updateSql,"LooseValue = '%f,0' ",vParam[0].c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpdateTableData(T_SENSOR_INFO(TNAME),updateSql,whereCon);
|
||||
}
|
||||
}
|
||||
@ -876,12 +920,16 @@ int SqliteDB::InintGateway()
|
||||
string strsystemVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion");
|
||||
string strGatewayVersion = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion");
|
||||
std::string strchan = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "channel");
|
||||
std::string strPanID = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "PanID");
|
||||
if(strPanID == ""){
|
||||
strPanID = GlobalConfig::MacAddr_G.substr(8);
|
||||
}
|
||||
if(0 == sql_ctl->GetTableRows(T_GATEWAY_INFO(TNAME), NULL)){
|
||||
|
||||
char strSql[1024] = { 0 };
|
||||
sprintf(strSql,"insert into t_gateway_info(gatewayMAC,zigbeePanID,zigbeeChannel,\
|
||||
localIP,systemVersion,programVersion,webVersion,serverIP,serverPort,MAC2)\
|
||||
values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s');",GlobalConfig::MacAddr_G.c_str(),GlobalConfig::MacAddr_G.substr(8).c_str(),strchan.c_str(),strIP.c_str(),\
|
||||
values('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s');",GlobalConfig::MacAddr_G.c_str(),strPanID.c_str(),strchan.c_str(),strIP.c_str(),\
|
||||
strsystemVersion.c_str(),strGatewayVersion.c_str(),strwebVersion.c_str(),strServerIP.c_str(),strServerPort.c_str(),GlobalConfig::MacAddr_G2.c_str());
|
||||
sql_ctl->InsertData(strSql);
|
||||
print_info("strSql = %s\n",strSql);
|
||||
@ -889,7 +937,7 @@ int SqliteDB::InintGateway()
|
||||
char whereCon[1024] = {0};
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(updateSql, "zigbeePanID = '%s',zigbeeChannel = '%s',localIP = '%s',systemVersion='%s',programVersion='%s',webVersion='%s',serverIP='%s',serverPort='%s'",\
|
||||
GlobalConfig::MacAddr_G.substr(8).c_str(),strchan.c_str(),strIP.c_str(),\
|
||||
strPanID.c_str(),strchan.c_str(),strIP.c_str(),\
|
||||
strsystemVersion.c_str(),strGatewayVersion.c_str(),strwebVersion.c_str(),strServerIP.c_str(),strServerPort.c_str());
|
||||
sprintf(whereCon, "gatewayMAC='%s'", GlobalConfig::MacAddr_G.c_str());
|
||||
sql_ctl->UpdateTableData(T_GATEWAY_INFO(TNAME), updateSql, whereCon);
|
||||
|
@ -134,7 +134,7 @@ std::string JsonData::JsonCmd_23(Param_23 ¶m)
|
||||
Json::Value jsHeart;
|
||||
Json::FastWriter fw;
|
||||
jsHeart["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
|
||||
jsHeart["status"] = "online_V1.0.1";
|
||||
jsHeart["status"] = "online_V3.0";
|
||||
std::string strJson = fw.write(jsHeart);
|
||||
int iRet = data_publish(strJson.c_str(), GlobalConfig::Topic_G.mPubHeart.c_str());
|
||||
if(iRet == 0){
|
||||
@ -579,13 +579,15 @@ void JsonData::DataNodeStatusCheck()
|
||||
LOG_DEBUG("离线 DataNodeStatusCheck lNowTime = %d,llastTime = %d,interval = %s\n",lNowTime,llastTime,vetRes[i][21].c_str());
|
||||
char whereCon[32] = { 0 };
|
||||
sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
|
||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='0'", whereCon);
|
||||
}else if(lTimeTemp > (loseTime * atoi(vetRes[i][21].c_str()) * 60)){
|
||||
LOG_DEBUG("掉线 DataNodeStatusCheck lNowTime = %d,llastTime = %d,interval = %s\n",lNowTime,llastTime,vetRes[i][21].c_str());
|
||||
char whereCon[32] = { 0 };
|
||||
sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
|
||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='2'", whereCon);
|
||||
}else {
|
||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='0'", whereCon);
|
||||
}
|
||||
// }else if(lTimeTemp > (loseTime * atoi(vetRes[i][21].c_str()) * 60)){
|
||||
// LOG_DEBUG("掉线 DataNodeStatusCheck lNowTime = %d,llastTime = %d,interval = %s\n",lNowTime,llastTime,vetRes[i][21].c_str());
|
||||
// char whereCon[32] = { 0 };
|
||||
// sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
|
||||
// sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='2'", whereCon);
|
||||
// }
|
||||
else {
|
||||
char whereCon[32] = { 0 };
|
||||
sprintf(whereCon, "dataNodeNo='%s'", strDataNodeNo.c_str());
|
||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME), "status='1'", whereCon);
|
||||
@ -656,9 +658,17 @@ std::string JsonData::JsonCmd_Cgi_02(Param_02 ¶m)
|
||||
jsonVal["cmd"] = "02";
|
||||
if (0 == param.mMode) {
|
||||
jsonVal["type"] = "SET";
|
||||
SetTime((unsigned long)param.mTimeStamp);
|
||||
usleep(200);
|
||||
system("hwclock -w");
|
||||
if(param.mMode == 0){//本地校时
|
||||
SetTime((unsigned long)param.mTimeStamp);
|
||||
usleep(200);
|
||||
system("hwclock -w");
|
||||
}else if(param.mMode == 1){//与服务器校时
|
||||
char buf[256] = {0};
|
||||
sprintf(buf, "{\"dataNodeGatewayNo\":\"%s\",\"cmd\":\"12\",\"status\":\"REQ\"}",
|
||||
GlobalConfig::MacAddr_G.c_str());
|
||||
std::string str = std::string(buf);
|
||||
int iRet = data_publish(str.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
}
|
||||
} else if (1 == param.mMode) {
|
||||
char cmd[256] = { 0 };
|
||||
char localtimestamp[32] = { 0 };
|
||||
@ -829,10 +839,10 @@ std::string JsonData::JsonCmd_Cgi_09(Param_09 ¶m)
|
||||
jsStaticData["ChannelType"] = "STATUS";
|
||||
jsStaticData["ChannelId"] = vecRes[1];
|
||||
jsStaticData["TimeStamp"] = vecRes[8];
|
||||
jsStaticData["battery"] = vecRes[13];
|
||||
jsStaticData["battery"] = vecRes[14];
|
||||
jsStaticData["dataNodeNo"] = strDataNodeNo;
|
||||
jsStaticData["status"] = vecRes[11];
|
||||
if(atof(looseValue) < atof(vecRes[12].c_str())){
|
||||
jsStaticData["status"] = vecRes[12];
|
||||
if(atof(looseValue) < atof(vecRes[13].c_str())){
|
||||
jsStaticData["loose"] = "1";
|
||||
}else{
|
||||
jsStaticData["loose"] = "0";
|
||||
@ -875,7 +885,9 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 ¶m)
|
||||
int nSize = vetRes.size();
|
||||
if (nSize > 0) {
|
||||
char selectCon[256] = { 0 },szTableName[100] = {0x00},whereCon[256]={0x00};
|
||||
|
||||
sprintf(selectCon, "%s,channelID,timeStamp",param.strStatic.c_str());
|
||||
|
||||
if(param.straxis == "S")
|
||||
{
|
||||
sprintf(szTableName,"t_dataStatic_%s",param.strDataNode.c_str());
|
||||
@ -883,11 +895,15 @@ std::string JsonData::JsonCmd_Cgi_10(Param_10 ¶m)
|
||||
sprintf(szTableName,"t_data_%s",param.strDataNode.c_str());
|
||||
}
|
||||
if(param.timeEnd == ""){
|
||||
sprintf(whereCon,"dataNodeNo = '%s' and %s <> '' ",\
|
||||
param.strDataNode.c_str(),param.strStatic.c_str());
|
||||
|
||||
sprintf(whereCon,"dataNodeNo = '%s' and %s <> ''",\
|
||||
param.strDataNode.c_str(),param.strStatic.c_str());
|
||||
|
||||
}else{
|
||||
|
||||
sprintf(whereCon,"dataNodeNo = '%s' and %s <> '' and timeStamp < '%s' and timeStamp > '%s' ",\
|
||||
param.strDataNode.c_str(),param.strStatic.c_str(),param.timeEnd.c_str(),param.timeStart.c_str());
|
||||
param.strDataNode.c_str(),param.strStatic.c_str(),param.timeEnd.c_str(),param.timeStart.c_str());
|
||||
|
||||
}
|
||||
int rows = sql_ctl->GetTableRows(szTableName,whereCon);
|
||||
printf("rows : %d\n",rows);
|
||||
@ -1335,7 +1351,9 @@ 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());
|
||||
if(atof(looseValue) < atof(arrRes[j][42].c_str())){
|
||||
vector<string> vParam;
|
||||
boost::split( vParam, arrRes[j][42], boost::is_any_of( "," ), boost::token_compress_on );
|
||||
if(atof(looseValue) < atof(vParam[0].c_str())){
|
||||
jsSensorData["loose"] = "1";
|
||||
}else{
|
||||
jsSensorData["loose"] = "0";
|
||||
@ -1347,10 +1365,13 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m)
|
||||
memset(selectCon,0x00,sizeof(selectCon));
|
||||
sprintf(selectCon, "zigbeeSignal <> '' ORDER BY timeStamp desc LIMIT 0,1");
|
||||
string strZigbeeSignal = sql_ctl->GetData(szTableName, "zigbeeSignal", selectCon);
|
||||
memset(selectCon,0x00,sizeof(selectCon));
|
||||
sprintf(selectCon, "zigbeeSignalNode <> '' ORDER BY timeStamp desc LIMIT 0,1");
|
||||
string strZigbeeSignalNode = sql_ctl->GetData(szTableName, "zigbeeSignalNode", selectCon);
|
||||
if(strZigbeeSignal == "")
|
||||
jsSensorData["RSSI"] = arrRes[j][40];
|
||||
else
|
||||
jsSensorData["RSSI"] = strZigbeeSignal;
|
||||
jsSensorData["RSSI"] = strZigbeeSignal + "," + strZigbeeSignalNode;
|
||||
jsSensorData["update"] = atoi(arrRes[j][41].c_str());
|
||||
jsArray.append(jsSensorData);
|
||||
}
|
||||
@ -1364,6 +1385,153 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m)
|
||||
return showValue.write(jsonVal);
|
||||
}
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_54(Param_54 ¶m)
|
||||
{
|
||||
Json::Value jsonVal;
|
||||
jsonVal.clear();
|
||||
|
||||
jsonVal["cmd"] = "54";
|
||||
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
|
||||
Json::Value jsArray,nodeArray,gatewayArray;
|
||||
array_t arrRes;
|
||||
arrRes = sql_ctl->GetDataMultiLineTransaction(T_SENSOR_INFO(TNAME), "*", NULL);
|
||||
int iResult = arrRes.size();
|
||||
if (iResult > 0) {
|
||||
int packgeNo = param.mPackageFlag;
|
||||
int packgeMax = 0;
|
||||
int packgeNum = 0;
|
||||
jsonVal["package"] = packgeNo;
|
||||
int lastSize = iResult % 10;
|
||||
int index = iResult / 10;
|
||||
if(lastSize > 0 && index > 0){
|
||||
packgeMax = index +1;
|
||||
if(packgeNo +1 == packgeMax){
|
||||
packgeNum = iResult;
|
||||
jsonVal["packageMax"] = index + 1;
|
||||
}
|
||||
else{
|
||||
packgeNum = (packgeNo+1) * 10;
|
||||
jsonVal["packageMax"] = index +1;}
|
||||
}
|
||||
else if(lastSize == 0 && index > 0){
|
||||
packgeNum = (packgeNo+1) * 10;
|
||||
packgeMax = index;
|
||||
jsonVal["packageMax"] = index;
|
||||
}else if(lastSize > 0 && index == 0){
|
||||
packgeNum = lastSize;
|
||||
packgeMax = index+1;
|
||||
jsonVal["packageMax"] = index;
|
||||
}
|
||||
|
||||
for (int j = packgeNo * 10; j < packgeNum; j++) {
|
||||
Json::Value nodeArray;
|
||||
char hex[100];
|
||||
nodeArray.append(arrRes[j][0]);
|
||||
stringToHex(arrRes[j][1].c_str(),hex);
|
||||
print_info("hex = %s\n",hex);
|
||||
nodeArray.append(hex);
|
||||
nodeArray.append(arrRes[j][2]);
|
||||
nodeArray.append(arrRes[j][3]);
|
||||
nodeArray.append(arrRes[j][4]);
|
||||
nodeArray.append(arrRes[j][5]);
|
||||
nodeArray.append(arrRes[j][6]);
|
||||
nodeArray.append(arrRes[j][7]);
|
||||
nodeArray.append(arrRes[j][8]);
|
||||
nodeArray.append(arrRes[j][9]);
|
||||
nodeArray.append(arrRes[j][10]);
|
||||
nodeArray.append(arrRes[j][11]);
|
||||
nodeArray.append(arrRes[j][12]);
|
||||
nodeArray.append(arrRes[j][13]);
|
||||
nodeArray.append(arrRes[j][14]);
|
||||
nodeArray.append(arrRes[j][15]);
|
||||
nodeArray.append(arrRes[j][16]);
|
||||
nodeArray.append(arrRes[j][17]);
|
||||
nodeArray.append(arrRes[j][18]);
|
||||
nodeArray.append(arrRes[j][19]);
|
||||
nodeArray.append(arrRes[j][20]);
|
||||
nodeArray.append(arrRes[j][21]);
|
||||
nodeArray.append(arrRes[j][22]);
|
||||
nodeArray.append(arrRes[j][23]);
|
||||
nodeArray.append(arrRes[j][24]);
|
||||
nodeArray.append(arrRes[j][25]);
|
||||
nodeArray.append(arrRes[j][26]);
|
||||
nodeArray.append(arrRes[j][27]);
|
||||
nodeArray.append(arrRes[j][28]);
|
||||
nodeArray.append(arrRes[j][29]);
|
||||
nodeArray.append(arrRes[j][30]);
|
||||
nodeArray.append(arrRes[j][31]);
|
||||
nodeArray.append(arrRes[j][32]);
|
||||
nodeArray.append(arrRes[j][33]);
|
||||
nodeArray.append(arrRes[j][34]);
|
||||
nodeArray.append(arrRes[j][35]);
|
||||
nodeArray.append(arrRes[j][36]);
|
||||
nodeArray.append(arrRes[j][37]);
|
||||
nodeArray.append(arrRes[j][38]);
|
||||
nodeArray.append(arrRes[j][39]);
|
||||
nodeArray.append(arrRes[j][40]);
|
||||
nodeArray.append(arrRes[j][41]);
|
||||
nodeArray.append(arrRes[j][42]);
|
||||
nodeArray.append(arrRes[j][43]);
|
||||
jsArray.append(nodeArray);
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
jsArray.resize(0);
|
||||
jsonVal["success"] = true;
|
||||
}
|
||||
Json::Value jsSystemSetting,jsonValnet,jsonValnet1,jsSystemInfo,jsonValZigbee;
|
||||
Json::Value jsBody;
|
||||
|
||||
jsSystemSetting["ServerIpAddress"] = ReadStrByOpt(SERVERCONFIG, "Server", "localServerIpAddress");
|
||||
jsSystemSetting["ServerPort"] = (ReadStrByOpt(SERVERCONFIG, "Server", "localServerPort").c_str());
|
||||
jsSystemSetting["CommMode"] = (ReadStrByOpt(SERVERCONFIG, "Server", "CommMode").c_str());
|
||||
jsSystemSetting["UserName"] = ReadStrByOpt(SERVERCONFIG, "Server", "UserName");
|
||||
jsSystemSetting["Password"] = ReadStrByOpt(SERVERCONFIG, "Server", "Password");
|
||||
jsSystemSetting["APN"] = ReadStrByOpt(SERVERCONFIG, "Server", "APN");
|
||||
jsBody["ServerConfig"] = jsSystemSetting;
|
||||
jsonVal["content"] = jsBody;
|
||||
|
||||
jsonValnet["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "dnsName");
|
||||
jsonValnet["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "networkPortStatus");
|
||||
jsonValnet["gateway"] = ReadStrByOpt(NETWORKCONFIG, "eth0" ,"gateway");
|
||||
jsonValnet["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "subnetMask");
|
||||
jsonValnet["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "ipAddress");
|
||||
jsonValnet["hostName"] = ReadStrByOpt(NETWORKCONFIG, "eth0", "hostName");
|
||||
jsonVal["content"]["eth0"] = jsonValnet;
|
||||
jsonVal["content"]["gatewaytype"] = 0;
|
||||
|
||||
#ifdef G2UL_GATEWAY
|
||||
jsonValnet1["dnsName"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "dnsName");
|
||||
jsonValnet1["networkPortStatus"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "networkPortStatus");
|
||||
jsonValnet1["gateway"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "gateway");
|
||||
jsonValnet1["subnetMask"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "subnetMask");
|
||||
jsonValnet1["dataWatchIpAddress"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "ipAddress");
|
||||
jsonValnet1["hostName"] = ReadStrByOpt(NETWORKCONFIG, "eth1", "hostName");
|
||||
jsonVal["content"]["eth1"] =jsonValnet1;
|
||||
jsonVal["content"]["gatewaytype"] = 1;
|
||||
#endif
|
||||
|
||||
jsSystemInfo["GateWayVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayVersion");
|
||||
jsSystemInfo["SystemVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "SystemVersion");
|
||||
jsSystemInfo["WebVersion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "WebVersion");
|
||||
jsSystemInfo["GateWayHwVesion"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayHwVesion");
|
||||
jsSystemInfo["GateWayProduct"] = ReadStrByOpt(SYSTEMINFOFILE, "Version", "GateWayProduct");
|
||||
jsonVal["content"]["SystemInfo"] =jsSystemInfo;
|
||||
|
||||
jsonValZigbee["channel"] = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "channel");
|
||||
jsonValZigbee["PanID"] = ReadStrByOpt(ZIGBEECONFIG, "Zigbee", "PanID");
|
||||
jsonVal["content"]["zigbee"] =jsonValZigbee;
|
||||
|
||||
jsonVal["gatewayMac"] = GlobalConfig::MacAddr_G ;
|
||||
jsonVal["gatewayIP"] = GlobalConfig::IpAddr_G ;
|
||||
jsonVal["content"]["dataNodeArray"] = jsArray;
|
||||
jsonVal["content"]["gateWay"] = gatewayArray;
|
||||
return showValue.write(jsonVal);
|
||||
}
|
||||
|
||||
std::string JsonData::JsonCmd_Cgi_27(Param_27 ¶m)
|
||||
{
|
||||
@ -1374,9 +1542,9 @@ std::string JsonData::JsonCmd_Cgi_27(Param_27 ¶m)
|
||||
jsonVal["dataNodeGatewayNo"] = GlobalConfig::MacAddr_G;
|
||||
jsonVal["success"] = true;
|
||||
jsonVal["message"] = " ";
|
||||
|
||||
if (param.mDataNodeNo.length() > 0) {
|
||||
char whereCon[128] = { 0 };
|
||||
char whereCon[128] = { 0 };
|
||||
char localtimestamp[32] = { 0 };
|
||||
if (param.mDataNodeNo.length() > 0 && param.mType == "DELETE") {
|
||||
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), param.mDataNodeNo.c_str());
|
||||
sql_ctl->DeleteTableData(T_SENSOR_INFO(TNAME), whereCon);
|
||||
sql_ctl->DeleteTableData(T_DATA_INFO(TNAME), whereCon);
|
||||
@ -1388,7 +1556,16 @@ std::string JsonData::JsonCmd_Cgi_27(Param_27 ¶m)
|
||||
memset(szTableName,0x00,sizeof(szTableName));
|
||||
sprintf(szTableName,"DROP TABLE t_dataStatic_%s",param.mDataNodeNo.c_str());
|
||||
sql_ctl->CreateTable(szTableName, 0);
|
||||
} else {
|
||||
}else if(param.mDataNodeNo.length() > 0 && param.mType == "CORRECT"){
|
||||
char updateSql[1024] = { 0 };
|
||||
sprintf(whereCon, "%s= '%s'", T_SENSOR_INFO(DATANODENO), param.mDataNodeNo.c_str());
|
||||
string strLooseValue = sql_ctl->GetData(T_SENSOR_INFO(TNAME)," LooseValue ",whereCon);
|
||||
vector<string> vParam;
|
||||
boost::split( vParam, strLooseValue, boost::is_any_of( "," ), boost::token_compress_on );
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
sprintf(updateSql,"LooseValue = '%f,2,%s' ",vParam[0].c_str(),localtimestamp);
|
||||
sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME),updateSql,whereCon);
|
||||
} else {
|
||||
jsonVal["success"] = false;
|
||||
jsonVal["message"] = "没有传感器号";
|
||||
}
|
||||
@ -1639,14 +1816,11 @@ std::string JsonData::JsonCmd_Cgi_30(Param_30 ¶m)
|
||||
jsonVal["message"] = "没有数据文件";
|
||||
}
|
||||
|
||||
|
||||
jsBody["channelId"] = param.mChannelId;
|
||||
jsBody["package"] = param.mPackageFlag;
|
||||
jsBody["timestamp"] = string(localtimestamp);
|
||||
jsBody["Data"] = strWaveData;
|
||||
|
||||
|
||||
|
||||
double resolution = 0.0;
|
||||
int SampleRate =0;
|
||||
print_info("sensor type %s\n",res[17].c_str());
|
||||
@ -1906,6 +2080,8 @@ std::string JsonData::JsonCmd_Cgi_42(Param_42 ¶m)
|
||||
print_info("strcmd = %s\n",param.fileName.c_str());
|
||||
|
||||
ReadStrConfig("/opt/update.json");
|
||||
}else if(param.fileName == "backup.json"){
|
||||
ImportConfig("/opt/backup.json");
|
||||
}else if(param.fileName == "DataNode.csv"){
|
||||
print_info("strcmd = %s\n",param.fileName.c_str());
|
||||
|
||||
@ -1939,6 +2115,7 @@ std::string JsonData::JsonCmd_Cgi_31(Param_31 ¶m)
|
||||
print_red("@@@@@@@@@@@@@@@@,,,,,%s\n",buf);
|
||||
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", std::string(buf));*/
|
||||
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", param.mChannelId);
|
||||
WriteStr2Config(ZIGBEECONFIG, "Zigbee", "PanID", param.mPanID);
|
||||
//pUart->ZigbeeInit();
|
||||
//pUart->UpdateZigbeeInfoCtrl();
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ public :
|
||||
std::string JsonCmd_Cgi_51(Param_51 ¶m); //
|
||||
std::string JsonCmd_Cgi_52(Param_52 ¶m);
|
||||
std::string JsonCmd_Cgi_53(std::vector<Param_53> ¶m);
|
||||
std::string JsonCmd_Cgi_54(Param_54 ¶m);
|
||||
std::string JsonCmd_Cgi_default();
|
||||
|
||||
private :
|
||||
|
@ -293,6 +293,7 @@ try{
|
||||
if ( 0 == type.compare("SET")) {
|
||||
param.mMode = 0;
|
||||
param.mTimeStamp = recvBody["timeStamp"].asInt();
|
||||
param.mSetType = recvBody["setType"].asInt();
|
||||
} else if (0 == type.compare("GET")) {
|
||||
param.mMode = 1;
|
||||
}
|
||||
@ -430,6 +431,7 @@ try{
|
||||
case 27:{
|
||||
Param_27 param;
|
||||
param.mDataNodeNo = recvBody["dataNodeNo"].asString();
|
||||
param.mType = recvBody["type"].asString();
|
||||
JsonData jd;
|
||||
std::string data = jd.JsonCmd_Cgi_27(param);
|
||||
return data;
|
||||
@ -473,7 +475,7 @@ try{
|
||||
{
|
||||
param.mMode = 0;
|
||||
param.mChannelId = recvBody["channel"].asString();
|
||||
//param.mChannelId = recvBody["channel"].asInt();
|
||||
param.mPanID = recvBody["PanID"].asString();
|
||||
data = jd.JsonCmd_Cgi_31(param);
|
||||
sleep(1);
|
||||
system("reboot");
|
||||
@ -599,6 +601,14 @@ try{
|
||||
data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str());
|
||||
return data;
|
||||
}break;
|
||||
case 54:{
|
||||
JsonData jd;
|
||||
Param_54 param;
|
||||
param.mPackageFlag = recvBody["package"].asInt();
|
||||
std::string data = jd.JsonCmd_Cgi_54(param);
|
||||
return data;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
JsonData jd;
|
||||
std::string data = jd.JsonCmd_Cgi_default();
|
||||
|
2
main.cpp
2
main.cpp
@ -136,6 +136,8 @@ int main(int argc, char *argv[])
|
||||
printf("temp = %02x ",szRes[i]);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
int fd = OpenWatchDog();
|
||||
|
||||
while (GlobalConfig::QuitFlag_G) {
|
||||
|
@ -216,15 +216,13 @@ void CheckThread()
|
||||
// UpdateZigbee = 0;
|
||||
// pUart->UpdateZigbeeInfoCtrl();
|
||||
// }
|
||||
if(21000 == loose_check){
|
||||
if(60 == loose_check){
|
||||
loose_check = 0;
|
||||
sql_ctl->CalculateDip();
|
||||
}
|
||||
if(ModifyAddr == 21000 && pUart->bModifyAddr){
|
||||
//#ifdef IMX6UL_GATEWAY
|
||||
LOG_ERROR("ModifyAddr failed \n");
|
||||
exit(0);
|
||||
//#endif
|
||||
}
|
||||
if(ModifyAddr == 21000){
|
||||
ModifyAddr = 0;
|
||||
|
@ -45,7 +45,7 @@ int Uart::UartRecv(int fd, char srcshow,char* buffer)
|
||||
|
||||
if((unsigned short)GlobalConfig::Zigbee_G.MyAddr == 0x9999){
|
||||
memset(buff, 0, sizeof(buff));
|
||||
ret = read_data(fd, buff, BUF_LENGTH, 10);
|
||||
ret = read_data(fd, buff, BUF_LENGTH, 1);
|
||||
if (ret <= 0 ){
|
||||
if(!bUpdate && !bUpdateconfig && GlobalConfig::EnterZigBeeWaveTransmittingCnt_G > 15){
|
||||
timeoutflag ++;
|
||||
@ -627,7 +627,7 @@ int Uart::FindRecvPackage(int bytesRead, char* mUartRecvBuf,char* head)
|
||||
sprintf(whereCon, "zigbeeShortAddr='%s'", strShortAddr.c_str());
|
||||
vec_t vecDataNodeNo = sql_ctl->GetDataSingleLine(T_SENSOR_INFO(TNAME), " dataNodeNo,LooseValue ", whereCon);
|
||||
memset(whereCon,0x00,sizeof(whereCon));
|
||||
sprintf(updateSql, "zigbeeSignal = '%02d' ",UartRecvBuf[i+14]&0xFF);//zigbeeRSSIType = 0 传感器获取网关信号强度
|
||||
sprintf(updateSql, "zigbeeSignalNode = '%02d' ",UartRecvBuf[i+14]&0xFF);//zigbeeRSSIType = 0 传感器获取网关信号强度
|
||||
sprintf(whereCon, "dataNodeNo='%s' and timeStamp = '%s'", (char*)vecDataNodeNo[0].c_str(),strTimetamp.c_str());
|
||||
sprintf(tableName,"t_dataStatic_%s",(char*)vecDataNodeNo[0].c_str());
|
||||
sql_ctl->UpdateTableData(tableName, updateSql, whereCon);
|
||||
@ -1466,7 +1466,7 @@ void Uart::DealDataNodeName(const char* pData)
|
||||
unsigned char shortAdd[8]={0x00};
|
||||
char NodeName[64]={0x00};
|
||||
memcpy(shortAdd,&pData[3],2);
|
||||
memcpy(NodeName,&pData[7],64);
|
||||
//memcpy(NodeName,&pData[7],64);
|
||||
|
||||
//DealNodeSendTime((unsigned char*)shortAdd);
|
||||
UpdateWirelessNodeTime((unsigned char*)shortAdd,1);
|
||||
@ -1481,7 +1481,7 @@ void Uart::DealDataNodeName(const char* pData)
|
||||
solve(gbkNodeName,NodeName);
|
||||
print_info("gbkNodeName = %s\n",gbkNodeName);
|
||||
string utfNodeName = GBKToUTF8(gbkNodeName);
|
||||
print_info("utfNodeName = %s\n",utfNodeName.c_str());
|
||||
print_info("NodeName = %s\n",NodeName);
|
||||
//LOG_INFO("gbkNodeName:%s \n",gbkNodeName);
|
||||
//LOG_INFO("utfNodeName:%s \n",utfNodeName.c_str());
|
||||
unsigned short ushortAdd = BUILD_UINT16(pData[3]&0xFF,pData[4]&0xFF);
|
||||
@ -1747,7 +1747,7 @@ void Uart::DealDataNodeInfo(const char *pData)
|
||||
'%d','%d','%d','%s','%d','%s',\
|
||||
'%s','%u','%d','%d','%s','%d', '%s', '%s',\
|
||||
'%s','%d','%s','%s','%s',\
|
||||
'%d','%d','%d','%d','%s','%s', '%d', '%d','1','0',''",
|
||||
'%d','%d','%d','%d','%s','%s', '%d', '%d','1','0,0',''",
|
||||
dataNodeInfo.ZigbeeLongAddr.c_str(), " ", dataNodeInfo.InitFlag, dataNodeInfo.AccFlag, dataNodeInfo.ZigbeeFlag, dataNodeInfo.TemTopFlag, dataNodeInfo.TemBotFlag,dataNodeInfo.EquipSta,\
|
||||
dataNodeInfo.HardVersion.c_str(), dataNodeInfo.SoftVersion.c_str(), dataNodeInfo.BpNo.c_str(), dataNodeInfo.SerialNo.c_str(), dataNodeInfo.FirstPowerTime.c_str(), dataNodeInfo.WakeupTime,\
|
||||
dataNodeInfo.StaticTime,dataNodeInfo.WaveTime,dataNodeInfo.BateryV,dataNodeInfo.ProductNo.c_str(),dataNodeInfo.ConfigFlag, dataNodeInfo.StartBrands.c_str(), \
|
||||
@ -2049,7 +2049,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
|
||||
if ( /*0 == sql_ctl->GetTableRows(T_DATASTATIC_INFO(TNAME), whereCon)*/ (Count * 3 < SAVE_COUNT && lTime < OneWeek ) || strTime.size() == 0 ) {
|
||||
print_info("insert static data to sql\n");
|
||||
char insertSql[1024] = { 0 };
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%d','%d','',%d,'%s','1',%d",
|
||||
sprintf(insertSql, "'%s','%s','%f','%f','%d','%d','',%d,'%s','1',%d,''",
|
||||
strLongAddr.c_str(), (strLongAddr + "-S").c_str(), dataStatic.TemTop, dataStatic.TemBot, dataStatic.Dip, dataStatic.Voltage, staticIndex,nowTimetamp.c_str(),nodeResend);
|
||||
sql_ctl->InsertData(szTableName, insertSql);
|
||||
|
||||
@ -3226,7 +3226,7 @@ void Uart::DealDataNodeFeature(const char *pData, int flag)
|
||||
memset(selectCon,0x00,sizeof(selectCon));
|
||||
sprintf(selectCon, "zigbeeSignal <> '' ORDER BY timeStamp desc LIMIT 0,1");
|
||||
strTime = sql_ctl->GetData(szTableNameStatic, "timeStamp", selectCon);
|
||||
if((atol(nowTimetamp.c_str()) - atol(strTime.c_str()) > 3600) &&
|
||||
if(/*(atol(nowTimetamp.c_str()) - atol(strTime.c_str()) > 3600)*/(1 == flag) &&
|
||||
(unsigned short)GlobalConfig::Zigbee_G.MyAddr == 0x9999)// 24h = 86400s ; 8h = 36000 ; 16h = 72000
|
||||
{
|
||||
LOG_DEBUG("Zigbee Signal !\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user