Преглед изворни кода

1、修复ini配置锁带来死锁问题;2、修改4G在线状态检测方式

liyuezong пре 1 година
родитељ
комит
b25f26a47c
2 измењених фајлова са 27 додато и 1 уклоњено
  1. 26 1
      pro/src/Cellular.c
  2. 1 0
      pro/src/paras.c

+ 26 - 1
pro/src/Cellular.c

@@ -56,6 +56,9 @@
 
 #define SMS_SEND_MAX                    100
 
+#define UNLINK_MAX                    3
+
+int UnLinkCount=0;
 
 enum {
     AT_OK=0,
@@ -829,9 +832,11 @@ static int cell_get_ping(cell_handle_t *h, cell_stat_t *stat)
     char buf[200],utc[32],date[32];
 
     if(h->stat==AT_STAT_UNINIT) {
+        stat->linked = 0;
         return -1;
     }
 
+    /*
     r = send_cmd(h, AT_CMD_QPING, "=1,\"www.baidu.com\",3,2,", buf, sizeof(buf));
     if(r!=AT_OK) {
         stat->linked = 0;
@@ -844,13 +849,33 @@ static int cell_get_ping(cell_handle_t *h, cell_stat_t *stat)
         return -1;
     }
 
-     LOGD("QPING: %d\n", ret);
     if(ret==0) {
         stat->linked = 1;
     }
     else {
         stat->linked = 0;
     }
+    */
+
+
+    r = send_cmd(h, AT_CMD_CGATT, "?", buf, sizeof(buf));
+    if(r!=AT_OK) {
+        stat->linked = 0;
+        return -1;
+    }
+
+    r = sscanf(str_get(buf,'+'), "+CGATT: %d", &ret);
+    if(r<1) {
+        stat->linked = 0;
+        return -1;
+    }
+
+    if(ret==1) {
+        stat->linked = 1;
+    }
+    else {
+        stat->linked = 0;
+    }
     return 0;
 }
 static int cell_get_time(cell_handle_t *h, cell_stat_t *stat)

+ 1 - 0
pro/src/paras.c

@@ -3834,6 +3834,7 @@ int paras_PhListInit(void)
     sys_get_path(path, PH_INI_FILE_NAME);
     dictionary *dic=iniparser_load(path);
     if(dic == NULL){
+        lock_s_release(LOCK_ID_PARAS);
         return -1;
     }
     for (size_t i = 0; i < __globalDeviceManage.brdMax; i++)