[Feature][ZXW-274]ADD AT command to ota GNSS-firmware

Only Configure: No
Affected branch: master
Affected module: AT
Is it affected on both ZXIC and MTK:only zxic
Self-test: Yes
Doc Update:Yes

Change-Id: I2a77c0531bec3833cc38c916382754bb84e27a39
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
index 5bf2eeb..79b141c 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
@@ -442,6 +442,9 @@
 #MOBILETEK_ADB_LOGIN value:"YES","NO"
 MOBILETEK_ADB_LOGIN = "NO"
 
+#cz.li@20240221 add for MOBILETEK_GNSS_UPDATE_ENABLE value: "yes","no"
+MOBILETEK_GNSS_UPDATE_ENABLE = "no"
+
 LYNQ_CONFIG_COMMITID = "e2a3410390ff0ad762462ccb6af8faa5e16dcd61"
 LYNQ_CONFIG_VERSION = "T106_ap_version_cap_0425"
 LYNQ_CONFIG_SW_VERSION = "T106_ap_version_MR3.02b06.00"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
index dd13fc7..ee700c0 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-gnss/liblynq-qser-gnss.bb
@@ -47,13 +47,15 @@
     if [ -d "${WORKONSRC}" ] ; then

         install -d ${D}${includedir}/

         cp -raf ${SRC-DIR}/include/ ${D}${includedir}/

+    fi

+    if [ "${MOBILETEK_GNSS_UPDATE_ENABLE}" = "yes" ]; then

         install -d ${D}/data/gnss_update

         install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin ${D}/data/gnss_update

-        install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin ${D}/data/gnss_update

+        install -m 644 ${WORKONSRC}HD8122.YIKE.GN3.115200.0037.dbd12.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240416R1.bin ${D}/data/gnss_update

         install -m 644 ${WORKONSRC}agps.conf ${D}/data/gnss_update

         ln -sf ./HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQALS.ANT.EPH.CFG.PPS13.240115R1.bin ${D}/data/gnss_update/HD.bin

-        ln -sf ./HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin ${D}/data/gnss_update/HD_BD.bin

-    fi 

+        ln -sf ./HD8122.YIKE.GN3.115200.0037.dbd12.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240416R1.bin ${D}/data/gnss_update/HD_BD.bin

+    fi

 }

 

 addtask bachclean

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 357941c..ce7d965 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;AT+NAVSAT;AT+GNSSVER"
+                 cmd="AT+CGPS;AT+CGPSNMEA;AT+NAVSAT;AT+GNSSVER;AT+GNSSOTA"
   />
   <module name="/lib/liblynq-at-common.so"
                  register="lynq_register_at_common"
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin
deleted file mode 100755
index cb718dc..0000000
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0035.720e5.53ef0.GQBS.B1C.ANT.EPH.CFG.PPS13.240308R1.bin
+++ /dev/null
Binary files differ
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0037.dbd12.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240416R1.bin b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0037.dbd12.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240416R1.bin
new file mode 100755
index 0000000..9fc2a9b
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-gnss/HD8122.YIKE.GN3.115200.0037.dbd12.53ef0.GAQBS.B1C.ANT.EPH.CFG.PPS13.240416R1.bin
Binary files differ
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 c976162..7360f71 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
@@ -587,6 +587,46 @@
     return 0;
 }
 
+int lynq_at_gnssota(int gnss_ver_symbol)
+{
+    FILE *fp;
+    int mask = -1;
+    char FileName[16];
+    char cmd[64];
+    char buf[256] = {0};
+    gps_channel_init();
+    lynq_open_gps(1);
+    usleep(100000);
+    if(gnss_ver_symbol == 1)
+    {
+        strcpy(FileName,"HD.bin");
+    }
+    else if(gnss_ver_symbol == 2)
+    {
+        strcpy(FileName,"HD_BD.bin");
+    }
+    else 
+        return -1;
+    sprintf(cmd,"lynq-gnss-update -B /data/gnss_update/%s",FileName);
+    fp = popen(cmd, "r");
+    if(fp == NULL)
+    {
+        ALOGE("error open\n");
+        return -1;
+    }
+    while(fgets(buf, sizeof(buf) - 1, fp) != NULL)
+    {
+        write(device_fd, buf, strlen(buf));
+        if(strncmp("upgrade sucess!\r\n",buf,strlen(buf)) == 0)
+        {
+            mask = 0;
+        }
+        memset(buf,0,sizeof(buf));
+    }
+    pclose(fp);
+    return mask;
+}
+
 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;
@@ -813,6 +853,16 @@
             return;
         }
     }
+    else if (!strcmp(parse_atcmd, "AT+GNSSOTA"))
+    {
+        res = lynq_at_gnssota(gnss_state_type);
+        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;