diff --git a/Cidn-SH b/Cidn-SH index 187c284..3b81064 100644 Binary files a/Cidn-SH and b/Cidn-SH differ diff --git a/common/SH_CommonFunc.cpp b/common/SH_CommonFunc.cpp index 7f1a46c..8c957e3 100644 --- a/common/SH_CommonFunc.cpp +++ b/common/SH_CommonFunc.cpp @@ -805,7 +805,8 @@ void ImportConfig(std::string filename) 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()); + string apn = jsSystemSetting["APN"].asString(); + sprintf(APN,"sed -i '15c \t\t\t\t/opt/quectel-CM/quectel-CM -s %s > /dev/null &' /etc/init.d/S95check5G",apn.c_str()); system(APN); WriteStr2Config(ZIGBEECONFIG, "Zigbee", "channel", jsonValZigbee["channel"].asString()); diff --git a/dbaccess/SH_SqlDB.cpp b/dbaccess/SH_SqlDB.cpp index ba945a4..ec1fc33 100644 --- a/dbaccess/SH_SqlDB.cpp +++ b/dbaccess/SH_SqlDB.cpp @@ -858,6 +858,7 @@ int SqliteDB::CalculateDip() GetTimeNet(localtimestamp, 1); readStringValue("config", "loose",looseValue,(char*)GlobalConfig::Config_G.c_str()); vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), " * ", NULL); + print_info("vecRes = %d\n",vecRes.size()); for(int i = 0 ; i < vecRes.size(); i++){ vector vParam; print_info("vecRes =%s\n",vecRes[i][42].c_str()); @@ -872,14 +873,14 @@ int SqliteDB::CalculateDip() char szTablename[32]={0x00}; memset(whereCon,0x00,sizeof(whereCon)); if(vParam[1] == "2"){//人工干预 - sprintf(whereCon," timeStamp > %ld ",atol(vParam[2].c_str())); + sprintf(whereCon," timeStamp > '%ld' ",atol(vParam[2].c_str())); }else if(vParam[1] == "0"){//正常状态 - sprintf(whereCon," timeStamp > %ld ",atol(localtimestamp) - 86400);//一天数据 + sprintf(whereCon," timeStamp > '%ld' ",atol(localtimestamp) - 86400);//一天数据 }else if(vParam[1] == "1")//松动状态 { continue; } - + print_info("vParam[0]= %s,vParam[1]=%s\n",vParam[0].c_str(),vParam[1].c_str()); sprintf(szTablename,"t_dataStatic_%s",vecRes[i][0].c_str()); vec_Value vecResDip = GetDataMultiLineOfOneColumnDouble(szTablename," Dip ", whereCon); @@ -897,13 +898,20 @@ int SqliteDB::CalculateDip() }else if(vParam[1] == "1"){ }else if(vParam[1] == "2"){ + print_info("localtimestamp = %ld,vParam[2]=%d,%ld\n",atol(localtimestamp),atol(vParam[2].c_str()),atol(localtimestamp) - atol(vParam[2].c_str())); + if(atol(localtimestamp) - atol(vParam[2].c_str()) > 86400){ + sprintf(updateSql,"LooseValue = '%f,0' ",vParam[0].c_str()); + }else{ + sprintf(updateSql,"LooseValue = '%f,2,",vParam[0].c_str()); + string strUpdateSql = string(updateSql) + vParam[2] + "' " ; + memset(updateSql,0x00,sizeof(updateSql)); + memcpy(updateSql,strUpdateSql.c_str(),sizeof(updateSql)); + } 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()); - } + } } diff --git a/dbaccess/SH_SqlDB.hpp b/dbaccess/SH_SqlDB.hpp index afd1a7b..e6e8451 100644 --- a/dbaccess/SH_SqlDB.hpp +++ b/dbaccess/SH_SqlDB.hpp @@ -16,6 +16,7 @@ extern "C"{ #define T_DATASTATIC_INFO(x) T_DATASTATIC_INFO[T_DATASTATIC_INFO_##x] #define T_GATEWAY_INFO(x) T_GATEWAY_INFO[T_GATEWAY_INFO_##x] #define T_DATANODE_TIME(x) T_DATANODE_TIME[T_DATANODE_TIME_##x] +#define T_BATTERY_INFO(x) T_BATTERY_INFO[T_BATTERY_INFO##x] typedef std::map map_t; typedef std::vector vec_t; @@ -182,4 +183,25 @@ typedef enum { T_GATEWAY_INFO_MAC2, }T_GATEWAY_INFO_Index; const static char* T_GATEWAY_INFO[] = { "t_gateway_info","gatewayMAC","sensorVersion","gatewayLocation","zigbeePanID","zigbeeChannel","communicationType","signal","localIP","systemVersion","programVersion","webVersion","serverIP","serverPort","status","gateWayUpdate","MAC2"}; + +typedef enum { + T_BATTERY_INFO_TNAME = 0, + T_BATTERY_INFO_GATEWAYMAC, + T_GATEWAY_INFO_SENSORVER, + T_GATEWAY_INFO_GATEWAYLOCATION, + T_GATEWAY_INFO_ZIGBEEPANID, + T_GATEWAY_INFO_ZIGBEECHANNEL, + T_GATEWAY_INFO_COMMUNICATIONTYPE, + T_GATEWAY_INFO_SIGNAL, + T_GATEWAY_INFO_LOCALIP, + T_GATEWAY_INFO_SYSTEMVERSION, + T_GATEWAY_INFO_PROGRAMVERSION, + T_GATEWAY_INFO_WEBVERSION, + T_GATEWAY_INFO_SERVERIP, + T_GATEWAY_INFO_SERVERPORT, + T_GATEWAY_INFO_STATUS, + T_GATEWAY_INFO_GATEWAYUPDATE, + T_GATEWAY_INFO_MAC2, +}T_GATEWAY_INFO_Index; +const static char* T_GATEWAY_INFO[] = {}; #endif diff --git a/jsonparse/SH_JsonCmd.cpp b/jsonparse/SH_JsonCmd.cpp index 7892213..df002aa 100644 --- a/jsonparse/SH_JsonCmd.cpp +++ b/jsonparse/SH_JsonCmd.cpp @@ -1369,7 +1369,7 @@ std::string JsonData::JsonCmd_Cgi_26(Param_26 ¶m) 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]; + jsSensorData["RSSI"] = "0," + arrRes[j][40]; else jsSensorData["RSSI"] = strZigbeeSignal + "," + strZigbeeSignalNode; jsSensorData["update"] = atoi(arrRes[j][41].c_str()); @@ -1563,8 +1563,10 @@ std::string JsonData::JsonCmd_Cgi_27(Param_27 ¶m) vector 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); + sprintf(updateSql,"LooseValue = '%f,2,",vParam[0].c_str()); + string strUpdateSql = string(updateSql) + string(localtimestamp) + "' " ; + print_info("updateSql = %s\n",strUpdateSql.c_str()); + sql_ctl->UpdateTableData(T_SENSOR_INFO(TNAME),strUpdateSql.c_str(),whereCon); } else { jsonVal["success"] = false; jsonVal["message"] = "没有传感器号"; diff --git a/platform/SH_PlatformInit.cpp b/platform/SH_PlatformInit.cpp index f8a207f..ae84ba6 100644 --- a/platform/SH_PlatformInit.cpp +++ b/platform/SH_PlatformInit.cpp @@ -12,7 +12,7 @@ int GlobalConfig::LinkCount = 0; int GlobalConfig::net0Status = 1; -std::string GlobalConfig::Version = "3.0"; +std::string GlobalConfig::Version = "3.1"; std::string GlobalConfig::MacAddr_G = ""; std::string GlobalConfig::MacAddr_G2 = ""; std::string GlobalConfig::IpAddr_G = ""; diff --git a/threadfunc/SH_ThreadFunc.cpp b/threadfunc/SH_ThreadFunc.cpp index f1e580a..e9ec9bb 100644 --- a/threadfunc/SH_ThreadFunc.cpp +++ b/threadfunc/SH_ThreadFunc.cpp @@ -216,7 +216,7 @@ void CheckThread() // UpdateZigbee = 0; // pUart->UpdateZigbeeInfoCtrl(); // } - if(60 == loose_check){ + if(3600 == loose_check){ loose_check = 0; sql_ctl->CalculateDip(); }