Parcourir la source

1、修复MQTT各类服务状态上报不准问题;2、DHCP下网络改为动态获取;3、修复报警设备编号长度不够问题。

liyuezong il y a 1 an
Parent
commit
72996517ba
3 fichiers modifiés avec 54 ajouts et 24 suppressions
  1. 1 1
      pro/src/json_handle.h
  2. 30 20
      pro/src/mqtt.c
  3. 23 3
      pro/src/sys.c

+ 1 - 1
pro/src/json_handle.h

@@ -346,7 +346,7 @@ typedef struct
     char alarmNumber[16];
     char alarmDate[32];
     char alarmType;
-    char deviceNumber[16];
+    char deviceNumber[32];
     char deviceName[32];
     char alarmContent[128];
     struct list_head list;

+ 30 - 20
pro/src/mqtt.c

@@ -1181,11 +1181,21 @@ static int get_serv(char *json)
         }
     }
     else {
-        if(thread_is_running(THREAD_ID_NTP)) {
+        //if(thread_is_running(THREAD_ID_NTP)) {
+          //  BSET(flag, SERV_NTP);
+      //  }
+
+      //  if(thread_is_running(THREAD_ID_MAIL)) {
+         //   BSET(flag, SERV_SMTP);
+       // }
+
+        if (1 == _globalNTPManager.mode)
+        {
             BSET(flag, SERV_NTP);
         }
 
-        if(thread_is_running(THREAD_ID_MAIL)) {
+        if (1 == __globalDeviceManage.mailInfo.send.mode)
+        {
             BSET(flag, SERV_SMTP);
         }
 
@@ -1193,28 +1203,28 @@ static int get_serv(char *json)
             BSET(flag, SERV_MQTT);
         }
 
-#if 0
-        if(thread_is_running(SERV_MESG)) {
-            BSET(flag, SERV_MESG);
-        }
+        // if(thread_is_running(SERV_MESG)) {
+        //   BSET(flag, SERV_MESG);
+        // }
 
-        if(thread_is_running(THREAD_ID_CLOUD)) {
-            BSET(flag, SERV_CLOUD);
-        }
+        // BSET(flag, SERV_CLOUD);
+        BSET(flag, SERV_TELNET);
 
-        if(thread_is_running(THREAD_ID_TELNET)) {
-            BSET(flag, SERV_TELNET);
-        }
-#endif
-
-        if(sys_is_running("snmpd")) {
-            BSET(flag, SERV_NTP);
-        }
+        //  if(sys_is_running("snmpd")) {
+        //     BSET(flag, SERV_NTP);
+        //  }
 
-        if(thread_is_running(THREAD_ID_NTP)) {
-            BSET(flag, SERV_NTP);
+        if (1 == _globalSNMPManager.mode)
+        {
+            if (0 == _globalSNMPManager.version)
+                BSET(flag, SERV_SNMP_V1);
+            else if (1 == _globalSNMPManager.version)
+                BSET(flag, SERV_SNMP_V2C);
+            else if (2 == _globalSNMPManager.version)
+                BSET(flag, SERV_SNMP_V3);
+            if (1 == _globalSNMPManager.trapmode)
+                BSET(flag, SERV_SNMP_TRAP);
         }
-
     }
 
     return flag;

+ 23 - 3
pro/src/sys.c

@@ -682,6 +682,26 @@ static int get_net(NetworkInfo_t *para, int ipv)
     }
     get_dns(fbuf.buf, para->dns1, para->dns2);
 
+    if (para->mode == 0)
+    {
+        int r1;
+        int family = AF_INET;
+
+        r1 = get_ipaddr(family, DFLT_NIC, para->ip_address, para->mask);
+        if (r1)
+        {
+            LOGE("get_ipaddr failed\n");
+            return -1;
+        }
+
+        r1 = get_gateway(family, para->gateway);
+        if (r1)
+        {
+            LOGE("get_gateway failed\n");
+            return -1;
+        }
+    }
+
     return 0;
 }
 static int nw_check(NetworkInfo_t *para, int ipv)
@@ -882,19 +902,19 @@ int sys_get_net(NetworkInfo_t *para, int ipVersion)
 #elif defined USE_API  
     r = get_ipaddr(family, DFLT_NIC, para->ip_address, para->mask);
     if(r) {
-        LOGE("set_ipaddr failed\n");
+        LOGE("get_ipaddr failed\n");
         return r;
     }
     
     r = get_gateway(family, para->gateway);
     if(r) {
-        LOGE("set_gateway failed\n");
+        LOGE("get_gateway failed\n");
         return r;
     }
 
     r = get_dns(family, DFLT_NIC, para->dns1, para->dns2);
     if(r) {
-        LOGE("set_dns failed\n");
+        LOGE("get_dns failed\n");
         return r;
     }
 #endif