Merge "[Feature][ZXW-276]wifi module compilation"
diff --git a/allbins/zx297520v3/prj_vehicle/nv/drv_nvrw_0x00012000.bin b/allbins/zx297520v3/prj_vehicle/nv/drv_nvrw_0x00012000.bin
index 856876c..65a0327 100755
--- a/allbins/zx297520v3/prj_vehicle/nv/drv_nvrw_0x00012000.bin
+++ b/allbins/zx297520v3/prj_vehicle/nv/drv_nvrw_0x00012000.bin
Binary files differ
diff --git a/ap/lib/libps/220A1_vehicle_dc/ps/nas.a b/ap/lib/libps/220A1_vehicle_dc/ps/nas.a
index 3ce3827..57d21c5 100755
--- a/ap/lib/libps/220A1_vehicle_dc/ps/nas.a
+++ b/ap/lib/libps/220A1_vehicle_dc/ps/nas.a
Binary files differ
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-atcid/lynq_atsvc_plugin.xml b/cap/zx297520v3/src/lynq/framework/lynq-atcid/lynq_atsvc_plugin.xml
index f774aaa..357941c 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-atcid/lynq_atsvc_plugin.xml
+++ b/cap/zx297520v3/src/lynq/framework/lynq-atcid/lynq_atsvc_plugin.xml
@@ -6,7 +6,7 @@
   />
   <module name="/lib/liblynq-qser-gnss.so"
                  register="lynq_register_gnss"
-                 cmd="AT+CGPS;AT+CGPSNMEA"
+                 cmd="AT+CGPS;AT+CGPSNMEA;AT+NAVSAT;AT+GNSSVER"
   />
   <module name="/lib/liblynq-at-common.so"
                  register="lynq_register_at_common"
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp
index 32edd33..dd0b7ff 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp
@@ -222,6 +222,7 @@
 void resetEcallIVSandAudio(int mode, RIL_SOCKET_ID id) {
     RequestInfo* pRI = creatRILInfoAndInit(RIL_REQUEST_ECALL_RESET_IVS, mode, id);
     resetIVS(0, NULL, id, pRI);
+    RLOGE("ecall now is unmute");//add by hq at 20240423 for querying mute state for upper layer
 //    char* argv[2] = { "RIL_REQUEST_SET_MUTE", "0" };
 //    setMute(2, argv, id, NULL);
 }
@@ -599,6 +600,7 @@
     }
     case RIL_UNSOL_ECALL_SENDING_MSD: // = 2,
     {
+        RLOGE("ecall now is mute"); //add by hq at 20240423 for querying mute state for upper layer
         stop_ecall_timer(sT5, sT5_sig_value); //add by hq at 20240410 for match zxic
         start_ecll_timer(sT7,sT7_sig_value, T7_TIMEOUT);
         act_fecall_socid = soc_id;
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 5ae667a..c6486d8 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
@@ -202,6 +202,38 @@
     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"
+    };
+
 #ifdef DEBUG
 #define gnss_log(...)                    printf(__VA_ARGS__)
 #else
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 e2e4833..c976162 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
@@ -45,7 +45,7 @@
 int g_gnss_sync_enable_flag = 0;
 int g_gnss_sync_done = 0;
 int inited = 0;
-
+int event = 0;
 int qser_Gnss_Init(uint32_t *h_gnss)
 {
     ret = lynq_gnss_client_init(h_gnss);
@@ -472,10 +472,10 @@
 int lynq_at_cgps(int at_type,int gnss_state_type);
 int lynq_at_cgpsnmea(int at_type,int gnss_state_type);
 lynq_atsvc_outcb atsvc_gnss_outcb;
+uint32_t h_gnss;
 int at_gps_status = 0;
 int at_gpsnmea_status = 0;
 int pthread_state = 1;
-int tty_fd = -1;
 int device_fd = -1;
 
 int strUpper(char * str)
@@ -520,45 +520,77 @@
 int gps_channel_init()
 {
     int ret = 0;
-    tty_fd = open("/dev/ttyS2", O_RDWR);
-    ALOGD("tty_fd:%d\n",tty_fd);
-    if (tty_fd == -1)
-    {
-        ALOGE("Failed to open serial port\n");
-        return -1;
-    }
     device_fd = open("/dev/armps_rpmsgch30", O_RDWR);//30 is AT-channel;31 is modem-channel
     ALOGD("device_fd:%d\n",device_fd);
     if (device_fd == -1)
     {
         ALOGE("Failed to open device file\n");
-        close(tty_fd);
         return -1;
     }
     ret = channel_config(device_fd);
     if(ret < 0)
     {
-        close(tty_fd);
         close(device_fd);
         return -1;
     }
     return 0;
 }
 
-void read_gps_data()
+time_t start;
+time_t end;
+int lynq_at_navsat(uint32_t h_gnss)
 {
-    char gnss_buf[256];
-    while (at_gpsnmea_status)
+    struct mbtk_gnss_handle_t *gnss_handle = (struct mbtk_gnss_handle_t *)h_gnss;
+    event = 1;
+    char send_buf[] = {0xF1,0xD9,0x06,0x0C,0x00,0x00,0x12,0x3C};
+    ret = write(gnss_handle->dev_fd, send_buf, sizeof(send_buf));
+    if(ret < 0)
     {
-        bzero(gnss_buf,256);
-        ssize_t gnss_lenth = read(tty_fd,  gnss_buf, sizeof(gnss_buf));
-        if (gnss_lenth > 0)
+        ALOGE("send navsat faild");
+        return -1;
+    }
+    time(&start);
+    while(event)
+    {
+        usleep(500000);
+        time(&end);
+        if(difftime(end,start) > 2)
         {
-            write(device_fd, gnss_buf, gnss_lenth);
+            return -1;
         }
     }
-    pthread_state = 0;
-    return;
+    
+    return 0;
+}
+
+int lynq_at_gnssver(uint32_t h_gnss)
+{
+    struct mbtk_gnss_handle_t *gnss_handle = (struct mbtk_gnss_handle_t *)h_gnss;
+    event = 2;
+    char send_buf[] = {0xF1,0xD9,0x0A,0x04,0x00,0x00,0x0E,0x34};
+    ret = write(gnss_handle->dev_fd, send_buf, sizeof(send_buf));
+    if(ret < 0)
+    {
+        ALOGE("send gnssver faild");
+        return -1;
+    }
+    time(&start);
+    while(event)
+    {
+        usleep(500000);
+        time(&end);
+        if(difftime(end,start) > 2)
+        {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+void at_callback(uint32_t h_loc,e_msg_id_t e_msg_id,void *pv_data,void *context_ptr)
+{
+    mopen_gnss_nmea_info_t  *pt_nmea = (mopen_gnss_nmea_info_t *)pv_data;
+    write(device_fd, pt_nmea->nmea, strlen(pt_nmea->nmea));
 }
 
 int gnss_at_cmd_parse(char *cmd,char *parse_cmd,int* gnss_state_type,int* at_type)
@@ -647,9 +679,7 @@
         }
         if (at_gps_status == 0)
         {
-            lynq_open_gps(0);
-            close(device_fd);
-            close(tty_fd);
+            qser_Gnss_Deinit(h_gnss);  
         }
         else if(at_gps_status == 1)
         {
@@ -658,20 +688,8 @@
             {
                 return -1;
             }
-            lynq_open_gps(1);
-        #if defined(HD_GNSS)
-                ret = set_baudrate(tty_fd, B115200);
-                if(-1 == ret)
-                {
-                return  -2;
-                }
-        #elif defined(HX_GNSS)
-                ret = set_baudrate(tty_fd, B9600);
-                if(-1 == ret)
-                {
-                    return  -2;
-                }
-        #endif
+            qser_Gnss_Init(&h_gnss);
+            qser_AddRxIndMsgHandler(&at_callback,h_gnss);
         }
         else
         {
@@ -715,21 +733,11 @@
 
         if (at_gpsnmea_status == 0)
         {
-            ALOGD("gpsnmea_status = %d\n",at_gpsnmea_status);
-            for(int i = 0;i < 20;i++)
-            {
-                if(pthread_state == 0)
-                {
-                    ALOGD("pthread down\n");
-                    sleep(1);
-                    break;
-                }
-            }
+            qser_Gnss_Stop(h_gnss);
         }
         else if(at_gpsnmea_status == 1)
         {
-            ALOGE("gpsnmea_status = %d\n",at_gpsnmea_status);
-            pthread_create(&thread, NULL, read_gps_data, NULL);
+            qser_Gnss_Start(h_gnss);
         }
 
         else
@@ -747,7 +755,6 @@
     int res = 0;
     int income_at_type = 0;
     int gnss_state_type = -1;
-    //char at_cmd[128]={0};
     char gnss_at_cmd[64] = {0};
     char parse_atcmd[128] = {0}; 
     if(NULL == input)
@@ -786,6 +793,26 @@
             return;
         }
     }
+    else if (!strcmp(parse_atcmd, "AT+NAVSAT"))
+    {
+        res = lynq_at_navsat(h_gnss);
+        if (res != 0)
+        {
+            sprintf(gnss_at_cmd,"+CME ERROR: 100\r\n");
+            atsvc_gnss_outcb(gnss_at_cmd,strlen(gnss_at_cmd),0);
+            return;
+        }
+    }
+    else if (!strcmp(parse_atcmd, "AT+GNSSVER"))
+    {
+        res = lynq_at_gnssver(h_gnss);
+        if (res != 0)
+        {
+            sprintf(gnss_at_cmd,"+CME ERROR: 100\r\n");
+            atsvc_gnss_outcb(gnss_at_cmd,strlen(gnss_at_cmd),0);
+            return;
+        }
+    }
     sprintf(gnss_at_cmd,"OK\r\n");
     atsvc_gnss_outcb(gnss_at_cmd,strlen(gnss_at_cmd),0);
     return;
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 0bb8d1f..d4b774f 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
@@ -29,7 +29,8 @@
 extern long timezone;
 extern int g_gnss_sync_enable_flag;
 extern int g_gnss_sync_done;
-
+extern int event;
+extern int device_fd;
 typedef int (*sc_rtc_time_get_cb)(unsigned int src_id, unsigned long ulsec);
 extern int sc_rtc_timer_init(void);
 extern int sc_rtc_timer_uninit(void);
@@ -37,7 +38,6 @@
 extern int sc_cfg_get(char *name, char* buf, int bufLen);
 extern int sc_cfg_set (char *name, char *value);
 
-
 static inline int update_system_time(time_t timestamp)
 {
     struct timeval tv;
@@ -81,6 +81,22 @@
     return ret;
 }
 
+void navsat(char *data,char *result)
+{
+    int nav_info = *((int*)(data+6));
+    for (int i = 0; i < 28; i++)
+    {
+        if ((nav_info & (1 << i)) != 0)
+        {
+            if (strlen(result) > 0)
+            {
+                strcat(result, "+");
+            }
+            strcat(result, enableMask[i]);
+        }
+    }   
+}
+
 struct mbtk_gnss_handle_t
 {
     int dev_fd;
@@ -501,11 +517,11 @@
     nmea_info.length = data_len;
     memcpy(nmea_info.nmea, data, data_len);
     //gnss_log("nmea:[%d] %s", data_len, data);
-    if( handle->mode == 3 && nmea_info.timestamp &&handle->gnss_handler_func)
+    if(handle->gnss_handler_func)//handle->mode == 3 && nmea_info.timestamp &&
     {
         handle->gnss_handler_func((uint32)handle, E_MT_LOC_MSG_ID_NMEA_INFO, &nmea_info, NULL);
     }
-    if(handle->gnss_handler_func && handle->mode == 1 && mopen_location_info.timestamp && mopen_location_info.flags)
+    else if(handle->mode == 1 && handle->gnss_handler_func && mopen_location_info.timestamp && mopen_location_info.flags)
     {
         
         handle->gnss_handler_func((uint32)handle, E_MT_LOC_MSG_ID_LOCATION_INFO, &mopen_location_info, NULL);
@@ -541,45 +557,34 @@
  */
 static int get_gnss_from_str(struct mbtk_gnss_handle_t *handle, char *data, int data_len)
 {
-    char *tail = NULL;
-    static int seek = 0;
-    // 等待 OK, 如果20条结果没有等到,就异常
-    static int reset_count = 0;
-    int i = 0, ret = -1;
-
-    if (handle->reset_state)
+    if(event)
     {
-        // 等待 reset 回复的 OK
-        if(0 != memcmp(data, "$OK", 3) && reset_count < 20) {
-            printf("gnss reset invalid: [%s]\n", data);
-            reset_count++;
-            return -1;
+        char tar[] = {0xF1,0xD9};
+        char tar2[] = {0x04,0x20};
+        char result[64] = {0};
+        char buf[64];
+        if(strncmp(data,tar,2) == 0 && event == 1)
+        {
+            navsat(data,result);
+            sprintf(buf, "+Navsat:%s\n", result);
+            event = 0;
+            write(device_fd, buf, strlen(buf));
         }
-        if (reset_count > 19) {
-            printf("%s: device reset timeout!!!\n", __FUNCTION__);
-            LOGI("%s: device reset timeout!!!\n", __FUNCTION__);
+        else if(strncmp(data,tar2,2) == 0 && event == 2)
+        {
+            sprintf(buf,"+Gnssver:%.11s\n", data+19);//The 19th word of this statement starts with the software version number, which is a total of 11 words
+            event = 0;
+            write(device_fd, buf, strlen(buf));
         }
-        reset_count = 0;
-        gnss_log("reset ok: %s\n", data);
-#if BAUDRATE_115200
-        ret = mopen_uart_change(handle->dev_fd, 0);
-        if(ret) {
-            printf("reset Uart set 115200 error\n");
-        }
-#endif
-        pthread_mutex_lock(&handle->_cond_mutex);
-        handle->reset_state = 0;
-        pthread_mutex_unlock(&handle->_cond_mutex);
+        memset(result,0,sizeof(result));
+        memset(buf,0,sizeof(result));
     }
 
     if((data[0] == '$' || data[0] == '#') &&
             data[data_len - 1] == '\n' &&
             data_len < 128) {
         process_gnss_callback(handle, data, data_len);
-    } else {
-        gnss_log("nmea error: %s\n", data);
     }
-
     return 1;
 }
 
@@ -790,7 +795,6 @@
         ret = ring_buffer_dequeue_arr(&gnss_handle->ring_buffer, tmp_arr, i + 1);
 
         if(ret > 0 && 0 == mbtk_gnss_handle->getap_status) {
-            // gnss_log("NEMA:[%d] %s", ret, tmp_arr);
             get_gnss_from_str(gnss_handle, tmp_arr, ret);
             memset(tmp_arr, 0, sizeof(tmp_arr));
         } else {
@@ -825,7 +829,6 @@
             ret = mopen_gnss_read(gnss_handle->dev_fd, buf, MBTK_UART_RECV_BUFFER_SIZE);
             nmea_reading = 0;
             if(ret > 0) {
-                printf("%s\n",buf);
                 ring_buffer_queue_arr(&gnss_handle->ring_buffer, buf, ret);
                 memset(buf, 0, sizeof(buf));
             } else {
@@ -942,14 +945,8 @@
         }
 
     #if defined(HD_GNSS)
-            test_gpio_handle[15] = sc_gpio_init(15,1,0,0);
+            test_gpio_handle[15] = sc_gpio_init(15,0,0,0);
             test_gpio_handle[84] = sc_gpio_init(84,1,0,0);
-            ret = sc_gpio_value_set(test_gpio_handle[15],0);
-            if(ret)
-            {
-                ALOGE("gpio15 set value 0 error\n");
-            }
-            usleep(10000);
             ret = sc_gpio_value_set(test_gpio_handle[84],0);
             if(ret)
             {
@@ -970,14 +967,8 @@
     {
         nmea_state = 1;
     #if defined(HD_GNSS)
-            test_gpio_handle[15] = sc_gpio_init(15,1,0,0);
             test_gpio_handle[84] = sc_gpio_init(84,1,0,0);
-            ret = sc_gpio_value_set(test_gpio_handle[15],1);
-            if(ret)
-            {
-                ALOGE("gpio15 set value 1 error\n");
-            }
-            usleep(10000);
+            test_gpio_handle[15] = sc_gpio_init(15,0,0,0);
             ret = sc_gpio_value_set(test_gpio_handle[84],1);
             if(ret)
             {
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci.config b/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci.config
index 7193768..c08d25b 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci.config
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci.config
@@ -14,7 +14,7 @@
 config  lynq_autosuspend  'lynq_autosuspend'

         option auto_enable '0'

         option debug '1'

-        option whitelist_state '0000'

+        option whitelist_state '1011'

         

 config debug_mode 'debug_mode'

        option sysinfo_debug_status '1'