Merge "[Feature][T106][task-view-595]Adjust the code of gnss"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h
index 8208056..a88e181 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/lynq_qser_gnss.h
@@ -34,7 +34,7 @@
     char*   password;
 };
 
-static struct login_information *login_information_t = NULL;
+
 
 #define     QL_LOC_GPS_SUPPORT_SVS_MAX   32  /**  Maximum number of satellites in view. */
 typedef struct 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
index 3cb883d..172ff02 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/include/mbtk_gnss_internal.h
@@ -219,38 +219,6 @@
     char     nmea_ver[4];
 };
 
-static const char *enableMask[]=
-    {
-        "GPS L1",
-        "GLONASS G1",
-        "BEIDOU B1",
-        "",
-        "GALILEO E1",
-        "QZSS L1",
-        "SBAS L1",
-        "IRNSS L5",
-        "GPS L1C",
-        "GPS L5",
-        "GPS L2C",
-        "",
-        "",
-        "GLONASS G2",
-        "BEIDOU B1C",
-        "BEIDOU B2A",
-        "BEIDOU B3I",
-        "BEIDOU B5",
-        "BEIDOU B2",
-        "",
-        "GALILEO E5A",
-        "GALILEO E5B",
-        "GALILEO E6",
-        "",
-        "QZSS L6",
-        "QZSS L1C",
-        "QZSS L5",
-        "QZSS L2C"
-    };
-
 #define gnss_log ALOGD
 
 #endif
@@ -318,23 +286,9 @@
 
 
 #define MAX_GPIO_NUM 144
-static void *test_gpio_handle[MAX_GPIO_NUM]={NULL};
-static struct mopen_gnss_device_info_t mopen_gnss_device_info;
-static struct mbtk_gnss_handle_t *mbtk_gnss_handle = NULL;
-static int firmware_extren_state = 0;
 
-static char g_no_sv = 0;// 参与定位的卫星数量
 int mopen_gnss_get_nmea_config(uint32 h_gnss);
 int mopen_gnss_get_ant_state_info(uint32 h_gnss);
-
-static void get_gnss_time_info(int cmd, char *str, void *data);
-static void get_gnss_agnss_state(int cmd, char *str, void *data);
-static void get_gnss_device_info(int type, char *str, void *usr_ptr);
-static void gnss_uart_info(int cmd, char *str, void *data);
-static void gnss_gsa_info(int cmd, char *str, void *data);
-static int mopen_uart_change(int fd, int check);
-
-static int select_read( int fd, int timeout );
 ssize_t deal_read(int fd, void *buf, size_t count);
 
 
@@ -361,7 +315,7 @@
 int lynq_gnss_get_aidinfo(uint32 h_gnss);
 int lynq_gnss_get_device_info(uint32 h_gnss);
 int lynq_gnss_get_uart(uint32 h_gnss);
-int lynq_gnss_get_ap_data(void);
+//int lynq_gnss_get_ap_data(void);
 int lynq_gnss_output_frq(int frequency);
 int lynq_gnss_start();
 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
index 15914d0..9e44fb0 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/lynq_qser_gnss.cpp
@@ -48,6 +48,8 @@
 int inited = 0;
 int event = 0;
 int lock_fd = 0;
+static struct login_information *login_information_t = NULL;
+
 int qser_Gnss_Init(uint32_t *h_gnss)
 {
     ret = lynq_gnss_client_init(h_gnss);
@@ -747,7 +749,6 @@
 
 int lynq_at_cgpsnmea(int at_type,int gnss_state_type)
 {
-    int ret = 0;
     char cgpsnmea_at_res[64]={};
     if (at_type == 0)
     {
@@ -764,7 +765,6 @@
     }
     else if(at_type == 2)
     {
-        pthread_t thread;
         if (at_gpsnmea_status != gnss_state_type)
         {
             at_gpsnmea_status = gnss_state_type;
@@ -943,7 +943,6 @@
 
 lynq_atsvc_incb lynq_register_gnss(lynq_atsvc_outcb out_cb)
 {
-    char reg_return[50] = {0};
     if(NULL == out_cb)
     {
         ALOGE("out cb is null");
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
index 988711c..c238eee 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/src/mbtk_gnss.cpp
@@ -90,6 +90,38 @@
     return ret;
 }
 
+const char *enableMask[]=
+    {
+        "GPS L1",
+        "GLONASS G1",
+        "BEIDOU B1",
+        "",
+        "GALILEO E1",
+        "QZSS L1",
+        "SBAS L1",
+        "IRNSS L5",
+        "GPS L1C",
+        "GPS L5",
+        "GPS L2C",
+        "",
+        "",
+        "GLONASS G2",
+        "BEIDOU B1C",
+        "BEIDOU B2A",
+        "BEIDOU B3I",
+        "BEIDOU B5",
+        "BEIDOU B2",
+        "",
+        "GALILEO E5A",
+        "GALILEO E5B",
+        "GALILEO E6",
+        "",
+        "QZSS L6",
+        "QZSS L1C",
+        "QZSS L5",
+        "QZSS L2C"
+    };
+
 void navsat(char *data,char *result)
 {
     int nav_info = *((int*)(data+6));
@@ -143,20 +175,7 @@
 static void *test_gpio_handle[MAX_GPIO_NUM]={NULL};
 static struct mopen_gnss_device_info_t mopen_gnss_device_info;
 static struct mbtk_gnss_handle_t *mbtk_gnss_handle = NULL;
-static struct mbtk_gnss_cmd_msg_t mbtk_gnss_cmd_msg_map[] = {
-{ 1,     "$OK",         NULL,                 0},
-{ 2,     "$Fail",       NULL,                 0},
-{ 3,     "RMC",         get_gnss_time_info,   1},
-{ 4,     "GGA",         get_gnss_time_info,   1},
-{ 5,     "$PDTINFO",    get_gnss_device_info, 0},
-{ 6,     "$CFGNMEA",    get_gnss_device_info, 0},
-{ 7,     "$CFGPRT",     gnss_uart_info,       0},
-{ 8,     "$CFGAID",     get_gnss_agnss_state, 0},
-{ 9,     "$ANTSTAT",    NULL,                 0},
-#if TTFF_TEST
-{10,     "GSA",         gnss_gsa_info,        1},
-#endif
-};
+
 
 /**
  *  \brief strstr_n
@@ -540,7 +559,6 @@
     file_name++;
     time(&now);
     dir = opendir(dir_path);
-
     while(dir != NULL && (ent = readdir(dir)) != NULL)
     {
         if(strstr(ent->d_name, "gpslog") != NULL)
@@ -684,7 +702,7 @@
         _mopen_location_info->altitude = atof(tmp_str);
     }
 }
-
+static char g_no_sv = 0;// 参与定位的卫星数量
 static void get_gnss_time_info(int cmd, char *str, void *data)
 {
     int ret;
@@ -738,6 +756,21 @@
     gnss_log("Uart bandrate: %d\n" , mopen_gnss_device_info.usrt_bandrate);
     gnss_log("*************************\n");
 }
+
+static struct mbtk_gnss_cmd_msg_t mbtk_gnss_cmd_msg_map[] = {
+    { 1,     "$OK",         NULL,                 0},
+    { 2,     "$Fail",       NULL,                 0},
+    { 3,     "RMC",         get_gnss_time_info,   1},
+    { 4,     "GGA",         get_gnss_time_info,   1},
+    { 5,     "$PDTINFO",    get_gnss_device_info, 0},
+    { 6,     "$CFGNMEA",    get_gnss_device_info, 0},
+    { 7,     "$CFGPRT",     gnss_uart_info,       0},
+    { 8,     "$CFGAID",     get_gnss_agnss_state, 0},
+    { 9,     "$ANTSTAT",    NULL,                 0},
+    #if TTFF_TEST
+    {10,     "GSA",         gnss_gsa_info,        1},
+    #endif
+    };
 /**
  *  \brief function description
  *
@@ -748,7 +781,6 @@
  */
 static void process_gnss_callback(struct mbtk_gnss_handle_t *handle, char *data, int data_len)
 {
-    int ret = 0;
     int i = 0;
     int location = 17;
     static struct mopen_location_info_t mopen_location_info;
@@ -916,51 +948,74 @@
     }
     return 0 ;
 }
+
+static int select_read( int fd, int timeout ) //1ms
+{
+    fd_set set;
+    struct timeval t;
+    int ret;
+    int i = timeout;
+
+    do {
+        FD_ZERO(&set);
+        FD_SET(fd, &set);
+        t.tv_sec = 0;
+        t.tv_usec = 100;
+
+        ret = select(FD_SETSIZE, &set, NULL, NULL, &t );
+        if(ret == 0) continue;
+        if(ret < 0 && errno == EINTR)continue;
+        else return ret;
+    } while(i--);
+
+    return ret;
+}
+
 /*
   自适应波特率设置
  */
-static int auto_set_uart_baudrate(int fd)
-{
-    char rbuf[512];
-    int rByte = 0;
-    int b[3] = {B115200, B9600, 0};
-    int ret = B9600;
-    struct timeval time_m, time_n;
-    // 时间超时标志
-    int timeout_sign = 0;
-    // 先测试默认的9600波特率
-    SET_TIME_OUT(3);
-    do {
-        gettimeofday(&time_n, NULL);
-        if(time_n.tv_sec > time_m.tv_sec) {
-            //printf("Baudrate--test-9600--- timeout!\n");
-            if(timeout_sign)
-                break;
-            set_baudrate(fd, B115200);
-            ret = B115200;
-            timeout_sign = 1;
-            SET_TIME_OUT(3);
-            continue;
-        }
+// static int auto_set_uart_baudrate(int fd)
+// {
+//     char rbuf[512];
+//     int rByte = 0;
+//     int b[3] = {B115200, B9600, 0};
+//     int ret = B9600;
+//     struct timeval time_m, time_n;
+//     // 时间超时标志
+//     int timeout_sign = 0;
+//     // 先测试默认的9600波特率
+//     SET_TIME_OUT(3);
+//     do {
+//         gettimeofday(&time_n, NULL);
+//         if(time_n.tv_sec > time_m.tv_sec) {
+//             //printf("Baudrate--test-9600--- timeout!\n");
+//             if(timeout_sign)
+//                 break;
+//             set_baudrate(fd, B115200);
+//             ret = B115200;
+//             timeout_sign = 1;
+//             SET_TIME_OUT(3);
+//             continue;
+//         }
 
-        if(select_read(fd, 1) > 0)
-            usleep(50000);
-        else
-            continue;
+//         if(select_read(fd, 1) > 0)
+//             usleep(50000);
+//         else
+//             continue;
 
-        rByte = deal_read(fd,&rbuf,sizeof(rbuf));
-        if(rByte > 0) {
-            gnss_log("Auto Baudrate[%d]%s\n", rByte, rbuf);
-            if(strstr(rbuf, "$"))
-                return ret;
-            memset(rbuf, 0, sizeof(rbuf));
-        } else {
-            printf("*** read error\n");
-        }
-    }while(1);
+//         rByte = deal_read(fd,&rbuf,sizeof(rbuf));
+//         if(rByte > 0) {
+//             gnss_log("Auto Baudrate[%d]%s\n", rByte, rbuf);
+//             if(strstr(rbuf, "$"))
+//                 return ret;
+//             memset(rbuf, 0, sizeof(rbuf));
+//         } else {
+//             printf("*** read error\n");
+//         }
+//     }while(1);
 
-    return 0;
-}
+//     return 0;
+// }
 
 int mopen_gnss_open(char *dev, int baudrate)
 {
@@ -1191,63 +1246,43 @@
 #endif
 }
 
-static int select_read( int fd, int timeout ) //1ms
-{
-    fd_set set;
-    struct timeval t;
-    int ret;
-    int i = timeout;
 
-    do {
-        FD_ZERO(&set);
-        FD_SET(fd, &set);
-        t.tv_sec = 0;
-        t.tv_usec = 100;
-
-        ret = select(FD_SETSIZE, &set, NULL, NULL, &t );
-        if(ret == 0) continue;
-        if(ret < 0 && errno == EINTR)continue;
-        else return ret;
-    } while(i--);
-
-    return ret;
-}
 
 // check: 是否需要校验
-static int mopen_uart_change(int fd, int check)
-{
-    int rByte = 0, i = 20;
-    char name[32];
-    char rbuf[1024];
+// static int mopen_uart_change(int fd, int check)
+// {
+//     int rByte = 0, i = 20;
+//     char name[32];
+//     char rbuf[1024];
 
-    sprintf(name,"$CFGPRT,1,h0,115200,129,3\r\n");
-    rByte = write( fd, name, strlen(name));
-    tcdrain(fd);//阻塞直到发送完成
+//     sprintf(name,"$CFGPRT,1,h0,115200,129,3\r\n");
+//     rByte = write( fd, name, strlen(name));
+//     tcdrain(fd);//阻塞直到发送完成
 
-    set_baudrate(fd, B115200);
-    usleep(200000);
-    tcflush(fd, TCIFLUSH);//清空缓存区数据
+//     set_baudrate(fd, B115200);
+//     usleep(200000);
+//     tcflush(fd, TCIFLUSH);//清空缓存区数据
 
-    if (0 == check)
-        return 0;
-    do{
-        rByte = 0;
-        memset(rbuf, 0, sizeof(rbuf));
-        if(select_read(fd, 1) > 0) {
-            rByte = deal_read(fd, &rbuf, sizeof(rbuf) - 1);
-            rbuf[rByte] = 0;
-            gnss_log("%s: %s", __FUNCTION__, rbuf);
-        }
-        if(strstr(rbuf, "$")) {
-            return 0;
-        } else {
-            gnss_log("%d rByte = %d, [%s]\n", 20 - i, rByte, rbuf);
-        }
-        usleep(5000 * 100);
-    }while(i--);
+//     if (0 == check)
+//         return 0;
+//     do{
+//         rByte = 0;
+//         memset(rbuf, 0, sizeof(rbuf));
+//         if(select_read(fd, 1) > 0) {
+//             rByte = deal_read(fd, &rbuf, sizeof(rbuf) - 1);
+//             rbuf[rByte] = 0;
+//             gnss_log("%s: %s", __FUNCTION__, rbuf);
+//         }
+//         if(strstr(rbuf, "$")) {
+//             return 0;
+//         } else {
+//             gnss_log("%d rByte = %d, [%s]\n", 20 - i, rByte, rbuf);
+//         }
+//         usleep(5000 * 100);
+//     }while(i--);
 
-    return -1;
-}
+//     return -1;
+// }
 
 int lynq_open_gps(int state)
 {
@@ -1334,7 +1369,6 @@
 
 int lynq_gnss_start()
 {
-    int ret;
     lynq_open_gps(1);
     if (check_status())
         return -1;