Forráskód Böngészése

修改dns配置bug

guohui 2 éve%!(EXTRA string=óta)
szülő
commit
e26e438372
4 módosított fájl, 22 hozzáadás és 17 törlés
  1. 3 3
      output/t113i/etc/dnsmasq.conf
  2. 1 1
      pro/src/dflt.c
  3. 15 11
      pro/src/mqtt.c
  4. 3 2
      pro/src/sys.c

+ 3 - 3
output/t113i/etc/dnsmasq.conf

@@ -1,9 +1,9 @@
-
 interface=eth0
+no-hosts
+no-resolv
 
 server=8.8.8.8
 server=114.114.114.114
 
-no-hosts
-no-resolv
+
 

+ 1 - 1
pro/src/dflt.c

@@ -60,7 +60,7 @@ mqtt_info_t DFLT_MQTT={
         .cid = "",
         .proto = "mqtt",
         .name  = "server1",
-        .server = "192.168.1.12",
+        .server = "192.168.2.4",
         .port = "1883",
         .cert = "",
         .user = "gowone100",

+ 15 - 11
pro/src/mqtt.c

@@ -599,18 +599,18 @@ static int send_stat(mqtt_handle_t *h, int type)
 
         case MQTT_PUB_STAT_POWER_ALL:
         {
-            cJSON* root=cJSON_CreateObject();
-            if(root) {
-                int cnt=1;
-                pwrall_info_t *pall=websocket_get_pwrall();
+            int cnt=1;
+            pwrall_info_t *pall=websocket_get_pwrall();
 
-                if(pall->ph3) {
-                    cnt = 3;
-                }
+            if(pall->ph3) {
+                cnt = 3;
+            }
 
-                for(i=0; i<cnt; i++) {
-                    _OverAllPwrAckInfo *info=&pall->ch[i];
+            for(i=0; i<cnt; i++) {
+                _OverAllPwrAckInfo *info=&pall->ch[i];
 
+                cJSON* root=cJSON_CreateObject();
+                if(root) {
                     sprintf(buf, "L%d", i+1);
                     cJSON_AddStringToObject(root,"phase", buf);
                     cJSON_AddStringToObject(root,"voltage", get_float_str(info->voltage));
@@ -632,8 +632,9 @@ static int send_stat(mqtt_handle_t *h, int type)
                     content = cJSON_Print(root);    
                     my_pub(h, type, topic, content);
                     cJSON_free(content);
+
+                    cJSON_Delete(root);
                 }
-                cJSON_Delete(root);
             }
         }
         break;
@@ -985,12 +986,15 @@ static int my_recv(char *topic, char *data)
     int i,r,cmd;
 
 #ifdef USE_MQTT
-    char temp[512];
+    char *p,temp[512];
     uint32_t flag=0;
     mqtt_handle_t *h=&mqHandle;
 
     for(i=0; i<MQTT_SUB_MAX; i++) {
         snprintf(temp, sizeof(temp), topic_sub[i], h->prod_id);
+        p = strrchr(temp, '+');
+        if(p) p[0] = 0;
+        
         if(strstr(topic, temp)) {
             switch(i) {
                 case MQTT_SUB_CMD_POWER_ALL:

+ 3 - 2
pro/src/sys.c

@@ -133,6 +133,8 @@ int sys_set_factory(void)
     sqlite_deinit(__globalDeviceManage.db, &__globalDeviceManage.dbThreadlock);
 
     sys_get_path(dir, "");
+    LOGD("___ curdir: %s\n", dir);
+
     snprintf(src, sizeof(src), "%s/%s", dir, DATABASE_BAK_NAME);
     snprintf(dst, sizeof(dst), "%s/%s", dir, DATABASE_NAME);
 
@@ -613,7 +615,6 @@ static int set_dns(NetworkInfo_t *para)
     char buf[500];
     
     LOGD("_____ set_dns\n");
-
     int chk1=ip_check(para->dns1);
     int chk2=ip_check(para->dns2);
     if( chk1==IP_ERR && chk2==IP_ERR) {
@@ -622,7 +623,7 @@ static int set_dns(NetworkInfo_t *para)
     }
 
     memset(buf, 0, sizeof(buf));
-    strcpy(buf, "interface=eth0\n");
+    strcpy(buf, "interface=eth0\nno-hosts\nno-resolv\n\n");
 
     if(chk1) {
         sprintf(tmp, "server=%s\n", para->dns1);