Compare commits
No commits in common. "1b1b74168d99e4f31c073b732bd0e057d735a5f1" and "e59d824ce86ef730b640bfe5d87c6f18a1f9c5a6" have entirely different histories.
1b1b74168d
...
e59d824ce8
@ -339,11 +339,10 @@ struct Param_61 {
|
|||||||
};
|
};
|
||||||
struct Param_62 {
|
struct Param_62 {
|
||||||
std::string MeasurementID;
|
std::string MeasurementID;
|
||||||
std::string straxis;
|
|
||||||
std::string timeStart;
|
std::string timeStart;
|
||||||
std::string timeEnd;
|
std::string timeEnd;
|
||||||
int mPackageFlag;
|
int mPackageFlag;
|
||||||
Param_62() : MeasurementID(""),straxis(""),timeStart(""),timeEnd(""),mPackageFlag(0){};
|
Param_62() : MeasurementID(""),timeStart(""),timeEnd(""),mPackageFlag(0){};
|
||||||
};
|
};
|
||||||
struct Param_63 {
|
struct Param_63 {
|
||||||
|
|
||||||
|
|||||||
@ -900,10 +900,8 @@ std::string JsonData::JsonCmd_Cgi_62(Param_62 ¶m){
|
|||||||
char szTableName[100] = {0x00}, whereCon[256] = {0x00};
|
char szTableName[100] = {0x00}, whereCon[256] = {0x00};
|
||||||
sprintf(szTableName, " receive_wave_status ");
|
sprintf(szTableName, " receive_wave_status ");
|
||||||
|
|
||||||
if(param.straxis == "")
|
sprintf(whereCon, " data_nodeno = '%s' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
||||||
sprintf(whereCon, " data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
|
||||||
else
|
|
||||||
sprintf(whereCon, " data_nodeno = '%s-%s' and timeStamp < '%s' and timeStamp > '%s' ", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str());
|
|
||||||
|
|
||||||
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
|
int rows = sqlite_db_ctrl::instance().GetTableRows(szTableName, whereCon);
|
||||||
int packgeNo = param.mPackageFlag;
|
int packgeNo = param.mPackageFlag;
|
||||||
@ -932,12 +930,7 @@ std::string JsonData::JsonCmd_Cgi_62(Param_62 ¶m){
|
|||||||
}
|
}
|
||||||
|
|
||||||
memset(whereCon, 0x00, sizeof(whereCon));
|
memset(whereCon, 0x00, sizeof(whereCon));
|
||||||
if(param.straxis == "")
|
sprintf(whereCon, "data_nodeno = '%s' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
||||||
{
|
|
||||||
sprintf(whereCon, "data_nodeno like '%%%s%%' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
|
||||||
}else{
|
|
||||||
sprintf(whereCon, "data_nodeno = %s-%s' and timeStamp < '%s' and timeStamp > '%s' order by timeStamp asc LIMIT %d OFFSET %d", param.MeasurementID.c_str(),param.straxis.c_str(), param.timeEnd.c_str(), param.timeStart.c_str(), 550, packgeNum);
|
|
||||||
}
|
|
||||||
array_t vecRes;
|
array_t vecRes;
|
||||||
|
|
||||||
vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(szTableName, "*", whereCon);
|
vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(szTableName, "*", whereCon);
|
||||||
|
|||||||
@ -434,7 +434,6 @@ std::string LocalServer::HandleCgi_cmd(std::string &pData) {
|
|||||||
param.mPackageFlag = recvBody["package"].asInt();
|
param.mPackageFlag = recvBody["package"].asInt();
|
||||||
param.timeStart = recvBody["timeStart"].asString();
|
param.timeStart = recvBody["timeStart"].asString();
|
||||||
param.timeEnd = recvBody["timeEnd"].asString();
|
param.timeEnd = recvBody["timeEnd"].asString();
|
||||||
param.straxis = recvBody["Raxis"].asString();
|
|
||||||
param.MeasurementID = recvBody["MeasurementID"].asString();
|
param.MeasurementID = recvBody["MeasurementID"].asString();
|
||||||
std::string data = jd.JsonCmd_Cgi_62(param);
|
std::string data = jd.JsonCmd_Cgi_62(param);
|
||||||
return data;
|
return data;
|
||||||
|
|||||||
@ -32,14 +32,19 @@ void CheckThread() {
|
|||||||
int commSignal = 0;
|
int commSignal = 0;
|
||||||
int loose_check = 0;
|
int loose_check = 0;
|
||||||
int mqttresend = 0;
|
int mqttresend = 0;
|
||||||
int checkNet0 = 0;
|
|
||||||
int wifi_reconnect_count = 0;
|
|
||||||
while (GlobalConfig::QuitFlag_G) {
|
while (GlobalConfig::QuitFlag_G) {
|
||||||
GlobalConfig::threadStatus = 1;
|
GlobalConfig::threadStatus = 1;
|
||||||
sleep(1);
|
sleep(1);
|
||||||
if (10 == heart_count) {
|
if (10 == heart_count) {
|
||||||
if (GlobalConfig::LinkCount > 30) {
|
if (GlobalConfig::LinkCount > 30) {
|
||||||
zlog_error(zct, "MQTT connect failed ");
|
zlog_error(zct, "MQTT connect failed ");
|
||||||
|
char connect[10] = {0x00};
|
||||||
|
readStringValue("config", "connect", connect, (char *)GlobalConfig::Config_G.c_str());
|
||||||
|
if (atoi(connect)) {
|
||||||
|
zlog_error(zct, "MQTT connect failed,reboot");
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
std::string ipTemp = IpAddrInit();
|
std::string ipTemp = IpAddrInit();
|
||||||
GlobalConfig::IpAddr_G = ipTemp;
|
GlobalConfig::IpAddr_G = ipTemp;
|
||||||
@ -60,62 +65,33 @@ void CheckThread() {
|
|||||||
iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||||
if (iRet != 0) {
|
if (iRet != 0) {
|
||||||
zlog_error(zct, "MQTT connect failed ,time check");
|
zlog_error(zct, "MQTT connect failed ,time check");
|
||||||
#ifdef Q4G_MODULE
|
char connect[10] = {0x00};
|
||||||
char localtimestamp[32] = { 0 };
|
readStringValue("config", "connect", connect, (char *)GlobalConfig::Config_G.c_str());
|
||||||
GetTimeNet(localtimestamp, 1);
|
if (atoi(connect)) {
|
||||||
char whereCon[100]={0};
|
zlog_error(zct, "MQTT connect failed,time check ,reboot");
|
||||||
sprintf(whereCon,"DATE(timestamp, 'unixepoch') = DATE('now') ORDER BY timeStamp DESC limit 0,1");
|
exit(0);
|
||||||
std::string strCount = sqlite_db_ctrl::instance().GetData(" reboot_record ", "count", whereCon);
|
|
||||||
if (atoi(strCount.c_str()) < 3)//当天大于三次不再重启进程
|
|
||||||
{
|
|
||||||
char insertSql[64] = {0};
|
|
||||||
sprintf(insertSql, "'%s',%d,'%s'",localtimestamp,atoi(strCount.c_str())+1,"4G connect failed ");
|
|
||||||
sqlite_db_ctrl::instance().InsertData(" reboot_record ", insertSql);
|
|
||||||
gpio_set(GlobalConfig::GPIO_G.commPower,0);
|
|
||||||
zlog_warn(zct,"commPower start\n");
|
|
||||||
sleep(2);
|
|
||||||
gpio_set(GlobalConfig::GPIO_G.commPower,1);
|
|
||||||
zlog_warn(zct,"commPower End\n");
|
|
||||||
sleep(2);
|
|
||||||
system("reboot");
|
|
||||||
}else{
|
|
||||||
zlog_error(zct,"Q4G_MODULE error\n");
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#ifdef NR5G_MODULE
|
#ifdef NR5G_MODULE
|
||||||
dial.closePort();
|
dial.closePort();
|
||||||
gpio_set(GlobalConfig::GPIO_G.commPower, 0);
|
gpio_set(GlobalConfig::GPIO_G.commRest, 0);
|
||||||
zlog_warn(zct, "commPower start");
|
zlog_warn(zct, "GPIO 8 start");
|
||||||
sleep(2);
|
sleep(2);
|
||||||
gpio_set(GlobalConfig::GPIO_G.commPower, 1);
|
gpio_set(GlobalConfig::GPIO_G.commRest, 1);
|
||||||
zlog_warn(zct, "commPower End");
|
zlog_warn(zct, "GPIO 8 End");
|
||||||
sleep(20);
|
sleep(20);
|
||||||
connectCount++;
|
|
||||||
if (connectCount > 10) {
|
|
||||||
zlog_error(zct, "5G reset error ,reboot!");
|
|
||||||
system("reboot");
|
|
||||||
}
|
|
||||||
dial.openPort("/dev/ttyUSB2");
|
dial.openPort("/dev/ttyUSB2");
|
||||||
dial.setState();
|
dial.setState();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#ifdef WIFI_MODULE
|
#ifdef WIFI_MODULE
|
||||||
zlog_warn(zct, "WiFi reset!");
|
zlog_warn(zct, "WiFi reset!");
|
||||||
system("/etc/init.d/wpa_restart");
|
gpio_set(GlobalConfig::GPIO_G.wifiReset, 0);
|
||||||
sleep(5);
|
sleep(5);
|
||||||
std::string strip = GetGwIp_("wlan0");
|
|
||||||
zlog_warn(zct,"strip = %s", strip.c_str());
|
|
||||||
|
|
||||||
gpio_set(GlobalConfig::GPIO_G.wifiReset, 1);
|
gpio_set(GlobalConfig::GPIO_G.wifiReset, 1);
|
||||||
sleep(5);
|
sleep(5);
|
||||||
gpio_set(GlobalConfig::GPIO_G.wifiReset, 0);
|
|
||||||
sleep(30);
|
|
||||||
wifi::WPAClient wpa;
|
wifi::WPAClient wpa;
|
||||||
wpa.ReconnectWiFi();
|
wpa.ReconnectWiFi();
|
||||||
system("/etc/init.d/wpa_restart");
|
system("/etc/init.d/wpa_restart");
|
||||||
sleep(5);
|
system("udhcpc -i wlan2 &");
|
||||||
system("udhcpc -b -i wlan0 &");
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,14 +100,6 @@ void CheckThread() {
|
|||||||
jd.JsonCmd_07();
|
jd.JsonCmd_07();
|
||||||
HardStatus = 0;
|
HardStatus = 0;
|
||||||
}
|
}
|
||||||
if(checkNet0 == 5){
|
|
||||||
checkNet0 = 0;
|
|
||||||
int iStatus = get_netlink_status("eth0");
|
|
||||||
if(iStatus == 1 && GlobalConfig::net0Status == 0){
|
|
||||||
system("ifconfig eth0:1 192.168.188.188 netmask 255.255.255.0");
|
|
||||||
}
|
|
||||||
GlobalConfig::net0Status = iStatus;
|
|
||||||
}
|
|
||||||
if (mqttresend == 7200) {
|
if (mqttresend == 7200) {
|
||||||
mqttresend = 0;
|
mqttresend = 0;
|
||||||
zlog_info(zct, "mqttresend check");
|
zlog_info(zct, "mqttresend check");
|
||||||
@ -149,9 +117,9 @@ void CheckThread() {
|
|||||||
|
|
||||||
if (1800 == online_check) {
|
if (1800 == online_check) {
|
||||||
online_check = 0;
|
online_check = 0;
|
||||||
|
JsonData jd;
|
||||||
int Count = sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), NULL);
|
int Count = sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), NULL);
|
||||||
if (Count > 0) {
|
if (Count > 0) {
|
||||||
JsonData jd;
|
|
||||||
jd.DataNodeStatusCheck();
|
jd.DataNodeStatusCheck();
|
||||||
char localtimestamp[32] = {0};
|
char localtimestamp[32] = {0};
|
||||||
GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
@ -163,20 +131,21 @@ void CheckThread() {
|
|||||||
long lTime = atol(nowTimetamp.c_str()) - atol(strTime.c_str());
|
long lTime = atol(nowTimetamp.c_str()) - atol(strTime.c_str());
|
||||||
zlog_info(zct, "online check = %ld", lTime);
|
zlog_info(zct, "online check = %ld", lTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if (7200 == Battery) {
|
if (7200 == Battery) {
|
||||||
Battery = 0;
|
Battery = 0;
|
||||||
zlog_warn(zct, "Battery");
|
zlog_info(zct, "Battery");
|
||||||
sqlite_db_ctrl::instance().CalculateBattery();
|
sqlite_db_ctrl::instance().CalculateBattery();
|
||||||
JsonData jd;
|
JsonData jd;
|
||||||
jd.JsonCmd_30();
|
|
||||||
jd.JsonCmd_07();
|
jd.JsonCmd_07();
|
||||||
jd.JsonCmd_29();
|
jd.JsonCmd_29();
|
||||||
|
jd.JsonCmd_30();
|
||||||
jd.JsonCmd_31();
|
jd.JsonCmd_31();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (3500 == loose_check) {
|
if (3500 == loose_check) {
|
||||||
zlog_warn(zct, "loosecheck\n");
|
zlog_info(zct, "loosecheck\n");
|
||||||
loose_check = 0;
|
loose_check = 0;
|
||||||
sqlite_db_ctrl::instance().CalculateDip();
|
sqlite_db_ctrl::instance().CalculateDip();
|
||||||
}
|
}
|
||||||
@ -217,9 +186,8 @@ void CheckThread() {
|
|||||||
char localtimestamp[32] = {0};
|
char localtimestamp[32] = {0};
|
||||||
GetTimeNet(localtimestamp, 1);
|
GetTimeNet(localtimestamp, 1);
|
||||||
char whereCon[1024] = {0};
|
char whereCon[1024] = {0};
|
||||||
sprintf(whereCon, " timestamp < '%ld' ", atol(localtimestamp) - 2592000 * 2); //删除2个月前的数据
|
sprintf(whereCon, " timestamp < '%ld' ", atol(localtimestamp) - 2592000); //删除1个月前的数据
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
|
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
|
||||||
|
|
||||||
sqlite_db_ctrl::instance().DeleteTableData(" receive_wave_status ", whereCon);
|
sqlite_db_ctrl::instance().DeleteTableData(" receive_wave_status ", whereCon);
|
||||||
}
|
}
|
||||||
#ifdef WIFI_MODULE
|
#ifdef WIFI_MODULE
|
||||||
@ -237,7 +205,7 @@ void CheckThread() {
|
|||||||
if (currentssid.length() > 0) {
|
if (currentssid.length() > 0) {
|
||||||
char buf[64] = {0};
|
char buf[64] = {0};
|
||||||
std::string rssiSend = "";
|
std::string rssiSend = "";
|
||||||
rssiSend = "/usr/sbin/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='";
|
rssiSend = "/opt/Cidn/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='";
|
||||||
system_custom(rssiSend.c_str(), buf);
|
system_custom(rssiSend.c_str(), buf);
|
||||||
std::string Rssi = std::string(buf);
|
std::string Rssi = std::string(buf);
|
||||||
|
|
||||||
@ -268,7 +236,6 @@ void CheckThread() {
|
|||||||
logClean++;
|
logClean++;
|
||||||
loose_check++;
|
loose_check++;
|
||||||
mqttresend++;
|
mqttresend++;
|
||||||
checkNet0 ++;
|
|
||||||
#ifdef WIFI_MODULE
|
#ifdef WIFI_MODULE
|
||||||
wifi_reconnect_count++;
|
wifi_reconnect_count++;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -511,7 +511,7 @@ void Uart::DealRecvData(const char *pData) {
|
|||||||
uint8_t command = pData[5] & 0xFF;
|
uint8_t command = pData[5] & 0xFF;
|
||||||
uint8_t recvcode = pData[7] & 0xFF;
|
uint8_t recvcode = pData[7] & 0xFF;
|
||||||
|
|
||||||
|
zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command);
|
||||||
switch (command) {
|
switch (command) {
|
||||||
case DEVICE_INF:
|
case DEVICE_INF:
|
||||||
DealDataNodeInfo(pData);
|
DealDataNodeInfo(pData);
|
||||||
@ -563,7 +563,6 @@ void Uart::DealRecvData(const char *pData) {
|
|||||||
break;
|
break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Uart::DealDataNodeName(const char *pData) {
|
void Uart::DealDataNodeName(const char *pData) {
|
||||||
@ -682,13 +681,6 @@ void Uart::DealDataNodeInfo(const char *pData) {
|
|||||||
memset(buf, 0, 32);
|
memset(buf, 0, 32);
|
||||||
sprintf(buf, "%.1f", 0.1 * chTemp);
|
sprintf(buf, "%.1f", 0.1 * chTemp);
|
||||||
dataNodeInfo.HardVersion = std::string(buf);
|
dataNodeInfo.HardVersion = std::string(buf);
|
||||||
zlog_info(zct, "dataNodeInfo.HardVersion = %s", dataNodeInfo.HardVersion.c_str());
|
|
||||||
if (dataNodeInfo.HardVersion != "3.0" && dataNodeInfo.HardVersion != "4.0" && dataNodeInfo.HardVersion != "1.0" && dataNodeInfo.HardVersion != "2.0") {
|
|
||||||
DealDataNodeFeatureTransition(pData,0);
|
|
||||||
zlog_info(zct, "DealDataNodeFeatureTransition");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
chTemp = pRecvData->Data[10]; //软件版本 1 byte
|
chTemp = pRecvData->Data[10]; //软件版本 1 byte
|
||||||
memset(buf, 0, 32);
|
memset(buf, 0, 32);
|
||||||
|
|||||||
@ -177,7 +177,6 @@ public:
|
|||||||
|
|
||||||
// feature parse
|
// feature parse
|
||||||
void DealDataNodeFeature(const char* pData, int flag);
|
void DealDataNodeFeature(const char* pData, int flag);
|
||||||
void DealDataNodeFeatureTransition(const char* pData,int flag = 0);
|
|
||||||
void RecordBattery(std::string& strLongAddr, DataRecvStatic& dataStatic, std::string& nowTimetamp);
|
void RecordBattery(std::string& strLongAddr, DataRecvStatic& dataStatic, std::string& nowTimetamp);
|
||||||
void DealDataNodeWave(const char* pData, int comand);
|
void DealDataNodeWave(const char* pData, int comand);
|
||||||
void DealWaveThread();
|
void DealWaveThread();
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user