fix bugs
This commit is contained in:
parent
072cd7fd7c
commit
67151d7a47
@ -32,19 +32,14 @@ void CheckThread() {
|
||||
int commSignal = 0;
|
||||
int loose_check = 0;
|
||||
int mqttresend = 0;
|
||||
|
||||
int checkNet0 = 0;
|
||||
int wifi_reconnect_count = 0;
|
||||
while (GlobalConfig::QuitFlag_G) {
|
||||
GlobalConfig::threadStatus = 1;
|
||||
sleep(1);
|
||||
if (10 == heart_count) {
|
||||
if (GlobalConfig::LinkCount > 30) {
|
||||
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();
|
||||
GlobalConfig::IpAddr_G = ipTemp;
|
||||
@ -65,33 +60,62 @@ void CheckThread() {
|
||||
iRet = data_publish(str2.c_str(), GlobalConfig::Topic_G.mPubCmd.c_str());
|
||||
if (iRet != 0) {
|
||||
zlog_error(zct, "MQTT connect failed ,time check");
|
||||
char connect[10] = {0x00};
|
||||
readStringValue("config", "connect", connect, (char *)GlobalConfig::Config_G.c_str());
|
||||
if (atoi(connect)) {
|
||||
zlog_error(zct, "MQTT connect failed,time check ,reboot");
|
||||
exit(0);
|
||||
#ifdef Q4G_MODULE
|
||||
char localtimestamp[32] = { 0 };
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
char whereCon[100]={0};
|
||||
sprintf(whereCon,"DATE(timestamp, 'unixepoch') = DATE('now') ORDER BY timeStamp DESC limit 0,1");
|
||||
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
|
||||
dial.closePort();
|
||||
gpio_set(GlobalConfig::GPIO_G.commRest, 0);
|
||||
zlog_warn(zct, "GPIO 8 start");
|
||||
gpio_set(GlobalConfig::GPIO_G.commPower, 0);
|
||||
zlog_warn(zct, "commPower start");
|
||||
sleep(2);
|
||||
gpio_set(GlobalConfig::GPIO_G.commRest, 1);
|
||||
zlog_warn(zct, "GPIO 8 End");
|
||||
gpio_set(GlobalConfig::GPIO_G.commPower, 1);
|
||||
zlog_warn(zct, "commPower End");
|
||||
sleep(20);
|
||||
connectCount++;
|
||||
if (connectCount > 10) {
|
||||
zlog_error(zct, "5G reset error ,reboot!");
|
||||
system("reboot");
|
||||
}
|
||||
dial.openPort("/dev/ttyUSB2");
|
||||
dial.setState();
|
||||
|
||||
#endif
|
||||
#ifdef WIFI_MODULE
|
||||
zlog_warn(zct, "WiFi reset!");
|
||||
gpio_set(GlobalConfig::GPIO_G.wifiReset, 0);
|
||||
system("/etc/init.d/wpa_restart");
|
||||
sleep(5);
|
||||
std::string strip = GetGwIp_("wlan0");
|
||||
zlog_warn(zct,"strip = %s", strip.c_str());
|
||||
|
||||
gpio_set(GlobalConfig::GPIO_G.wifiReset, 1);
|
||||
sleep(5);
|
||||
gpio_set(GlobalConfig::GPIO_G.wifiReset, 0);
|
||||
sleep(30);
|
||||
wifi::WPAClient wpa;
|
||||
wpa.ReconnectWiFi();
|
||||
system("/etc/init.d/wpa_restart");
|
||||
system("udhcpc -i wlan2 &");
|
||||
sleep(5);
|
||||
system("udhcpc -b -i wlan0 &");
|
||||
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -100,6 +124,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");
|
||||
@ -117,9 +149,9 @@ void CheckThread() {
|
||||
|
||||
if (1800 == online_check) {
|
||||
online_check = 0;
|
||||
JsonData jd;
|
||||
int Count = sqlite_db_ctrl::instance().GetTableRows(T_SENSOR_INFO(TNAME), NULL);
|
||||
if (Count > 0) {
|
||||
JsonData jd;
|
||||
jd.DataNodeStatusCheck();
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
@ -131,21 +163,20 @@ void CheckThread() {
|
||||
long lTime = atol(nowTimetamp.c_str()) - atol(strTime.c_str());
|
||||
zlog_info(zct, "online check = %ld", lTime);
|
||||
}
|
||||
|
||||
}
|
||||
if (7200 == Battery) {
|
||||
Battery = 0;
|
||||
zlog_info(zct, "Battery");
|
||||
zlog_warn(zct, "Battery");
|
||||
sqlite_db_ctrl::instance().CalculateBattery();
|
||||
JsonData jd;
|
||||
jd.JsonCmd_30();
|
||||
jd.JsonCmd_07();
|
||||
jd.JsonCmd_29();
|
||||
jd.JsonCmd_30();
|
||||
jd.JsonCmd_31();
|
||||
}
|
||||
|
||||
if (3500 == loose_check) {
|
||||
zlog_info(zct, "loosecheck\n");
|
||||
zlog_warn(zct, "loosecheck\n");
|
||||
loose_check = 0;
|
||||
sqlite_db_ctrl::instance().CalculateDip();
|
||||
}
|
||||
@ -186,8 +217,9 @@ void CheckThread() {
|
||||
char localtimestamp[32] = {0};
|
||||
GetTimeNet(localtimestamp, 1);
|
||||
char whereCon[1024] = {0};
|
||||
sprintf(whereCon, " timestamp < '%ld' ", atol(localtimestamp) - 2592000); //删除1个月前的数据
|
||||
sprintf(whereCon, " timestamp < '%ld' ", atol(localtimestamp) - 2592000 * 2); //删除2个月前的数据
|
||||
sqlite_db_ctrl::instance().DeleteTableData(" t_battery_history ", whereCon);
|
||||
|
||||
sqlite_db_ctrl::instance().DeleteTableData(" receive_wave_status ", whereCon);
|
||||
}
|
||||
#ifdef WIFI_MODULE
|
||||
@ -205,7 +237,7 @@ void CheckThread() {
|
||||
if (currentssid.length() > 0) {
|
||||
char buf[64] = {0};
|
||||
std::string rssiSend = "";
|
||||
rssiSend = "/opt/Cidn/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='";
|
||||
rssiSend = "/usr/sbin/wpa_cli signal_poll|grep RSSI | cut -f 2 -d '='";
|
||||
system_custom(rssiSend.c_str(), buf);
|
||||
std::string Rssi = std::string(buf);
|
||||
|
||||
@ -236,6 +268,7 @@ void CheckThread() {
|
||||
logClean++;
|
||||
loose_check++;
|
||||
mqttresend++;
|
||||
checkNet0 ++;
|
||||
#ifdef WIFI_MODULE
|
||||
wifi_reconnect_count++;
|
||||
#endif
|
||||
|
||||
@ -516,10 +516,10 @@ void Uart::DealRecvData(const char *pData) {
|
||||
zlog_info(zct, "whereCon = %s", whereCon);
|
||||
array_t vecRes = sqlite_db_ctrl::instance().GetDataMultiLine(T_SENSOR_INFO(TNAME), " dataNodeNo, MeasurementID,hardVersion,softVersion", whereCon);
|
||||
zlog_info(zct, "vecRes = %d", vecRes.size());
|
||||
if(vecRes.size() == 0){
|
||||
zlog_warn(zct, "device info not found %02x%02x ", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
|
||||
return;
|
||||
}
|
||||
// if(vecRes.size() == 0){
|
||||
// zlog_warn(zct, "device info not found %02x%02x ", UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd));
|
||||
// return;
|
||||
// }
|
||||
std::string hardVersion = vecRes[0][2];
|
||||
std::string softVersion = vecRes[0][3];
|
||||
zlog_info(zct, "shortAdd = %02x%02x,command = %d ",UINT16_HIGH(ushortAdd),UINT16_LOW(ushortAdd),command);
|
||||
@ -696,7 +696,7 @@ void Uart::DealDataNodeInfo(const char *pData) {
|
||||
sprintf(buf, "%.1f", 0.1 * chTemp);
|
||||
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") {
|
||||
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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user