From 86822f2e9521de10cd268f17dfd43422172ca815 Mon Sep 17 00:00:00 2001 From: zhangsheng Date: Sat, 21 Dec 2024 14:32:49 +0800 Subject: [PATCH] fix bugs,version 5.2 --- common/global.hpp | 2 +- dbaccess/sql_db.cpp | 17 +++++++++-------- threadfunc/check_thread.cpp | 11 ++++++++++- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/common/global.hpp b/common/global.hpp index ac03d9a..2ff7763 100644 --- a/common/global.hpp +++ b/common/global.hpp @@ -18,7 +18,7 @@ enum enumZigBeeTransmitStatus { //#define NR5G_MODULE -//#define Q4G_MODULE +#define Q4G_MODULE //#define WIFI_MODULE //#define NR5G_MEIGE diff --git a/dbaccess/sql_db.cpp b/dbaccess/sql_db.cpp index a0bdf5c..c0f803f 100644 --- a/dbaccess/sql_db.cpp +++ b/dbaccess/sql_db.cpp @@ -825,7 +825,7 @@ int SqliteDB::CalculateBattery() { memset(selectSql, 0x00, sizeof(selectSql)); char updateSql[1024] = {0}; int res = 0; - sprintf(selectSql, " dataNodeNo,StaticTime,WaveTime,featureInterVal,waveInterVal,samplingRate,batteryPower "); + sprintf(selectSql, " MeasurementID,StaticTime,WaveTime,featureInterVal,waveInterVal,samplingRate,batteryPower "); array_t vecRes = GetDataMultiLine(T_SENSOR_INFO(TNAME), selectSql, NULL); zlog_info(zct, "Size = %d", vecRes.size()); if (vecRes.size() > 0) { @@ -848,11 +848,12 @@ int SqliteDB::CalculateBattery() { startCapacity = capacity; sprintf(updateSql, "batteryPower = '%f,%f' ", startCapacity, startCapacity); - + memset(whereCon, 0x00, sizeof(whereCon)); + sprintf(whereCon, "MeasurementID = '%s' ", vecRes[i][0].c_str()); res = UpdateTableData(T_SENSOR_INFO(TNAME), updateSql, whereCon); if(res !=0 ){ zlog_error(zct, "res = %d", res); - break; + continue; } memset(whereCon, 0x00, sizeof(whereCon)); sprintf(whereCon, " dataNodeNo = '%s' order by timeStamp asc limit 0,1 ", vecRes[i][0].c_str()); @@ -930,7 +931,7 @@ int SqliteDB::CalculateBattery() { res = UpdateTableData(T_BATTERY_INFO(TNAME), updateSql, whereCon); if(res !=0 ){ zlog_error(zct, "res = %d", res); - break; + continue; } memset(whereCon, 0x00, sizeof(whereCon)); memset(updateSql, 0x00, sizeof(updateSql)); @@ -940,15 +941,15 @@ int SqliteDB::CalculateBattery() { res = ExeSql(insertSql); if(res !=0 ){ zlog_error(zct, "res = %d", res); - break; + continue; } sprintf(deleteSql, "delete from t_battery_info where timeStamp < '%s' and dataNodeNo = '%s'", strtimeStamp.c_str(), vecRes[i][0].c_str()); res = ExeSql(deleteSql); if(res !=0 ){ zlog_error(zct, "res = %d", res); - break; + continue; } - sprintf(whereCon, "dataNodeNo = '%s' ", vecRes[i][0].c_str()); + sprintf(whereCon, "MeasurementID = '%s' ", vecRes[i][0].c_str()); if (startCapacity > 0) { sprintf(updateSql, "batteryPower = '%f,%f' ", startCapacity, remainBattery); } else { @@ -960,7 +961,7 @@ int SqliteDB::CalculateBattery() { res = data_publish(strData.c_str(), GlobalConfig::Topic_G.mPubConfig.c_str()); if(res !=0 ){ zlog_error(zct, "data_publish res = %d", res); - break; + continue; } } } diff --git a/threadfunc/check_thread.cpp b/threadfunc/check_thread.cpp index 3c62eda..a57d81b 100644 --- a/threadfunc/check_thread.cpp +++ b/threadfunc/check_thread.cpp @@ -32,7 +32,7 @@ void CheckThread() { int commSignal = 0; int loose_check = 0; int mqttresend = 0; - + int checkNet0 = 0; while (GlobalConfig::QuitFlag_G) { GlobalConfig::threadStatus = 1; sleep(1); @@ -103,6 +103,14 @@ void CheckThread() { jd.JsonCmd_07(); 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) { mqttresend = 0; zlog_info(zct, "mqttresend check"); @@ -239,6 +247,7 @@ void CheckThread() { logClean++; loose_check++; mqttresend++; + checkNet0 ++; #ifdef WIFI_MODULE wifi_reconnect_count++; #endif