[bugfix][T108][bug-view-1720][GNSS] Optimize the VTG Settings

Only Configure: No
Affected branch: GSW_V1453
Affected module: GNSS
Is it affected on IC: only ASR
Self-test: yes
Doc Update: no

Change-Id: I68efb2d9be15841f60ddf3bbf3bf76ccd4c03801
diff --git a/mbtk/libgsw_lib/gsw_gnss_interface.c b/mbtk/libgsw_lib/gsw_gnss_interface.c
index d6d7b01..00afd57 100755
--- a/mbtk/libgsw_lib/gsw_gnss_interface.c
+++ b/mbtk/libgsw_lib/gsw_gnss_interface.c
@@ -237,13 +237,10 @@
 int mbtk_gnss_set_VTG()

 {

     int ret;

-    char param_buf[32] = {0};

-    snprintf(param_buf, 32, "$MSGCFG,2,1000");

-    mbtk_gnss_setting=(int(*)(const char *setting_cmd, int))dlsym(dlHandle_gnss, "mbtk_gnss_setting");

-    ret = mbtk_gnss_setting(param_buf, QSER_GNSS_TIMEOUT);

+    ret = system("/usr/sbin/gnss_gpio.sh VTG > /dev/null 2>&1");

     if(ret != 0)

     {

-        LOGE("[qser_gnss] mbtk_gnss_setting fail.ret = [%d]", ret);

+        LOGE("[GSW_gnss] mbtk_gnss_set_VTG on fail.ret = [%d]", ret);

         return GSW_HAL_NORMAL_FAIL;

     }

     return GSW_HAL_SUCCESS;

@@ -482,6 +479,13 @@
         LOGE("[GSW_gnss] gnss_gpio.sh on fail.ret = [%d]", ret);

         return GSW_HAL_NORMAL_FAIL;

     }

+    // 记录mbtk_gnss_open前的时间戳

+    struct timespec start_time;

+    if (clock_gettime(CLOCK_MONOTONIC, &start_time) != 0) {

+        LOGE("[GSW_gnss] Failed to get start time");

+        return GSW_HAL_NORMAL_FAIL;

+    }

+

     mbtk_gnss_open=(int(*)(int,int))dlsym(dlHandle_gnss, "mbtk_gnss_open");

     ret = mbtk_gnss_open(255, QSER_GNSS_TIMEOUT);

     if(ret != 0)

@@ -499,11 +503,27 @@
     if (gnss_switch_op > 0)

         gsw_gnss_epo_switch(gnss_switch_op);

     */

+    

+    // 记录mbtk_gnss_set_VTG前的时间戳并计算等待时间

+    struct timespec end_time;

+    if (clock_gettime(CLOCK_MONOTONIC, &end_time) != 0) {

+        LOGE("[GSW_gnss] Failed to get end time");

+        return GSW_HAL_NORMAL_FAIL;

+    }

+    long start_ms = start_time.tv_sec * 1000 + start_time.tv_nsec / 1000000;

+    long end_ms = end_time.tv_sec * 1000 + end_time.tv_nsec / 1000000;

+    long diff_ms = end_ms - start_ms;

+    if (diff_ms < 700) {

+        long wait_ms = 700 - diff_ms;

+        usleep(wait_ms * 1000);  // 转换为微秒等待

+    }

+    

     mbtk_gnss_set_VTG();

 

     return GSW_HAL_SUCCESS;

 }

 

+

 /**

  * @brief SDK interface to stop gnss

  * @param