开启GNSS定位,延长定位超时时间 1587/1 1587/head 1588/target/1
authorSnickerSun <snickersun@163.com>
Tue, 31 Dec 2024 10:24:25 +0000 (18:24 +0800)
committerSnickerSun <snickersun@163.com>
Tue, 31 Dec 2024 10:24:25 +0000 (18:24 +0800)
code/sdk/zhihui/services/gnss/sample/gnss_sample/gnss_sample.c

index 296ad89..14481f8 100644 (file)
@@ -19,7 +19,7 @@
 #define MSG_CONTENT_IDX             2\r
 #define MSG_TYPE_BINRY              0\r
 #define MSG_TYPE_ASCII              1\r
-#define LISTEN_DATA_MAX_LINES       1000\r
+#define LISTEN_DATA_MAX_LINES       10000\r
 #define REPORT_MAX_BYTES            10000\r
 #define LISTEN_TIME_THR             1000\r
 \r
@@ -39,8 +39,18 @@ const uint8_t CFG_ACQ_LPW_ENABLE[] = {0x03 ,0x00 ,0x09 ,0x00 ,0x00 ,0x00 ,0x06 ,
 const uint8_t CFG_ACQ_LPW_DISABLE[] = {0x03 ,0x00 ,0x06 ,0x00 ,0x00 ,0x00 ,0x06 ,0x00 ,0x04 ,0x00 ,0x02 ,0x00 ,0x00 ,0x00};\r
                                          \r
 \r
+//定位模式自动,冷启动,热启动\r
+const uint8_t cfgAutoStartCmd[] = {0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00};\r
+const uint8_t cfgAltCstrCmd[] = {0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x05, 0x00, 0x12, 0x10, 0x01, 0x00, 0x00};\r
+const uint8_t cfgColdStartCmd[] = {0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01};\r
 \r
+//配置定位使用的卫星系统\r
+const uint8_t cfgFixModeGpsCmd[] = {0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00};\r
+const uint8_t cfgFixModeAllCmd[] = {0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x1f, 0x00, 0x00, 0x00};\r
 \r
+//配置NMEA显示内容\r
+const uint8_t cfgNmeaDefaultCmd[] = {0x03, 0x00, 0x16, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x02, 0x00, 0x11, 0x00};\r
+const uint8_t cfgNmeaAllCmd[] = {0x03, 0x00, 0x04, 0x01, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x02, 0x00, 0xff, 0x00};  \r
 \r
 typedef struct {\r
     uint16_t    sampleId;\r
@@ -49,11 +59,7 @@ typedef struct {
 \r
 int32_t CfgColdStartFixModeGpsNmeaAll(tiot_handle handle)\r
 {\r
-    const uint8_t cfgColdStartCmd[] = {0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01};\r
-    const uint8_t cfgFixModeGpsCmd[] = {0x03, 0x00, 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x01,\r
-        0x00, 0x00, 0x00};\r
-    const uint8_t cfgNmeaAllCmd[] = {0x03, 0x00, 0x04, 0x01, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x02, 0x00, 0xff,\r
-        0x00};\r
+\r
     // 配置启动模式:冷启动模式。\r
     int32_t ret = tiot_service_write(handle, cfgColdStartCmd, sizeof(cfgColdStartCmd));\r
     if (ret < 0) {\r
@@ -62,9 +68,9 @@ int32_t CfgColdStartFixModeGpsNmeaAll(tiot_handle handle)
     }\r
 \r
     // 配置使能的GNSS星座:GPS。\r
-    ret = tiot_service_write(handle, cfgFixModeGpsCmd, sizeof(cfgFixModeGpsCmd));\r
+    ret = tiot_service_write(handle, cfgFixModeAllCmd, sizeof(cfgFixModeAllCmd));\r
     if (ret < 0) {\r
-        printf("\nerror: cfgFixModeGpsCmd error: %d\n", ret);\r
+        printf("\nerror: cfgFixModeAllCmd error: %d\n", ret);\r
         return 0;\r
     }\r
 \r
@@ -92,14 +98,7 @@ int32_t CfgColdStartFixModeGpsNmeaAll(tiot_handle handle)
 // 如果有历史信息,自动模式启动会切换到热启动模式,如果无历史信息,则自动模式启动仍然为冷启动\r
 int32_t CfgAutoStartFixModeAllNmeaDefault(tiot_handle handle)\r
 {\r
-    const uint8_t cfgFixModeAllCmd[] = {0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x04, 0x00, 0x1f,\r
-        0x00, 0x00, 0x00};\r
-    const uint8_t cfgAutoStartCmd[] = {0x03, 0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00};\r
-    const uint8_t cfgNmeaDefaultCmd[] = {0x03, 0x00, 0x16, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x00, 0x02, 0x00, 0x11,\r
-        0x00};\r
-\r
-    const uint8_t cfgAltCstrCmd[] = {0x03, 0x00, 0x23, 0x00, 0x00, 0x00, 0x05, 0x00, 0x12, 0x10, 0x01, 0x00, 0x00};\r
-                                      \r
+     \r
 \r
     // 配置启动模式:自动模式。\r
     int32_t ret = tiot_service_write(handle, cfgAutoStartCmd, sizeof(cfgAutoStartCmd));\r
@@ -149,8 +148,8 @@ static int32_t QryVersion(tiot_handle handle)
 }\r
 \r
 static const GnssSamplesCfgTable g_gnssSamplesCfg[] = {\r
-    {COLDSTART_FIXMODEGPS_NMEAALL_SAMPLE,        CfgColdStartFixModeGpsNmeaAll},\r
-    // {AUTOSTART_FIXMODEALL_NMEADEF_SAMPLE,        CfgAutoStartFixModeAllNmeaDefault}\r
+    // {COLDSTART_FIXMODEGPS_NMEAALL_SAMPLE,        CfgColdStartFixModeGpsNmeaAll},\r
+    {AUTOSTART_FIXMODEALL_NMEADEF_SAMPLE,        CfgAutoStartFixModeAllNmeaDefault}\r
 };\r
 \r
 static int32_t StartGnss(tiot_handle handle)\r