修复gps死机,优化心率计算 3132/1 3132/head 3133/target/1
authorCaisking <zhihui@LAPTOP-RI2L5AAG.localdomain>
Sat, 24 Jan 2026 08:55:53 +0000 (16:55 +0800)
committerCaisking <zhihui@LAPTOP-RI2L5AAG.localdomain>
Sat, 24 Jan 2026 08:55:53 +0000 (16:55 +0800)
code/sdk/zhihui/drivers/ppg/hx3695/hx3695.c
code/sdk/zhihui/services/gnss/sample/pgnss_sample/pgnss_sample.c
code/sdk/zhihui/services/gnss/src/decodenmea.c
code/sdk/zhihui/services/gnss/src/uart_gnss.c

index f30fe86..e35d83a 100644 (file)
@@ -1575,6 +1575,10 @@ void hx3695_ppg_Int_handle(ppg_sensor_data_t *ppg_sensor_dat)
     // printf("count:%d\n",count);\r
     if(count > 0)\r
     {\r
+        if(work_mode_flag == HRS_MODE && count > 9)\r
+        {\r
+            count = 8;\r
+        }\r
         hx3695_check_wear(ppg_sensor_dat,count);\r
         if(wear_status == MSG_WEAR)\r
         {\r
index 7ffc61c..b1cf10f 100644 (file)
@@ -511,7 +511,7 @@ static void ListenGnssData(tiot_handle handle)
 {
     int32_t i = 0;
     int32_t timeout_count = 0;  // 连续超时计数器
-    char temp_buf[512] = {0};
+    // char temp_buf[512] = {0};
 
     // 初始化GNSS服务缓冲区
     if (init_gnss_service_buffer() != 0) {
@@ -587,30 +587,30 @@ static void ListenGnssData(tiot_handle handle)
                     {
                         if (decode_nmea(pbuf[index])==1)
                         {
-                        dump_location_data(&g_global_gpsData);
-                        memset_s(temp_buf,sizeof(temp_buf),0,sizeof(temp_buf));
+                        // dump_location_data(&g_global_gpsData);
+                        // memset_s(temp_buf,sizeof(temp_buf),0,sizeof(temp_buf));
                         // char *temp_buf = (char *)malloc(512);
                         // if (temp_buf == NULL) {
                         //     printf("error: malloc temp_buf failed!\n");
                         //     continue;
                         // }
-                        dump_location_data_to_buf(&g_global_gpsData, temp_buf, 512);
+                        // dump_location_data_to_buf(&g_global_gpsData, temp_buf, 512);
                         
                         // printf("temp_buf : %s\n",temp_buf);
 
                         // 追加到pgnss_log中
-                        if (pgnss_log != NULL) {
-                            int current_len = strlen(pgnss_log);
-                            int data_len = strlen(temp_buf);
-                            if (current_len + data_len < 2047) {  // 留1字节给字符串结束符
-                                snprintf(pgnss_log + current_len, 2048 - current_len, "%s", temp_buf);
-                            } else {
-                                // 内存满了,清空从头开始存储
-                                printf("pgnss_log memory full, clearing and restarting\n");
-                                memset(pgnss_log, 0, 2048);
-                                snprintf(pgnss_log, 2048, "%s", temp_buf);
-                            }
-                        }
+                        // if (pgnss_log != NULL) {
+                        //     int current_len = strlen(pgnss_log);
+                        //     int data_len = strlen(temp_buf);
+                        //     if (current_len + data_len < 2047) {  // 留1字节给字符串结束符
+                        //         snprintf(pgnss_log + current_len, 2048 - current_len, "%s", temp_buf);
+                        //     } else {
+                        //         // 内存满了,清空从头开始存储
+                        //         printf("pgnss_log memory full, clearing and restarting\n");
+                        //         memset(pgnss_log, 0, 2048);
+                        //         snprintf(pgnss_log, 2048, "%s", temp_buf);
+                        //     }
+                        // }
                         
                         // printf("decode_nmea done\r\n");
                         // free(temp_buf);
@@ -837,10 +837,10 @@ void PGnssServerStartAutoModeStart(void)
         g_is_pgnss_poweron = 0;
         g_is_pgnss_start = 0;
         g_pgnss_stopflag = 1;
-        if (pgnss_log != NULL) {
-            free(pgnss_log);
-            pgnss_log = NULL;
-        }
+        // if (pgnss_log != NULL) {
+        //     free(pgnss_log);
+        //     pgnss_log = NULL;
+        // }
         return;
     }
 
@@ -850,10 +850,10 @@ void PGnssServerStartAutoModeStart(void)
         g_gnssLogFp = fopen("/user/userdata/gnsslog.txt", "w");
         if (g_gnssLogFp == NULL) {
             printf("error: open log file error\n");
-            if (pgnss_log != NULL) {
-                free(pgnss_log);
-                pgnss_log = NULL;
-            }
+            // if (pgnss_log != NULL) {
+            //     free(pgnss_log);
+            //     pgnss_log = NULL;
+            // }
             return;
         }
         // 写入日志开启时间戳
@@ -869,10 +869,10 @@ void PGnssServerStartAutoModeStart(void)
         g_is_pgnss_poweron = 0;
         g_is_pgnss_start = 0;
         g_pgnss_stopflag = 1;
-        if (pgnss_log != NULL) {
-            free(pgnss_log);
-            pgnss_log = NULL;
-        }
+        // if (pgnss_log != NULL) {
+        //     free(pgnss_log);
+        //     pgnss_log = NULL;
+        // }
         return;
     }
     printf("open tiot service success for auto start\n");
@@ -942,11 +942,11 @@ void PGnssServerStartAutoModeStart(void)
     
 
     // 释放pgnss_log内存
-    if (pgnss_log != NULL) {
-        printf("gnss_log: %s\r\n", pgnss_log);
-        free(pgnss_log);
-        pgnss_log = NULL;
-    }
+    // if (pgnss_log != NULL) {
+    //     printf("gnss_log: %s\r\n", pgnss_log);
+    //     free(pgnss_log);
+    //     pgnss_log = NULL;
+    // }
 }
 
 // 辅助函数:检查指定文件夹的文件数量
@@ -1307,15 +1307,15 @@ void PGnssServerStart(void)
 
     printf("\nenter gnss samples\r\n");
     
-    if (pgnss_log == NULL) 
-    {
-        pgnss_log = (char *)malloc(2048);
-        if (pgnss_log == NULL) {
-            printf("error: malloc pgnss_log failed!\n");
-            return;
-        }
-        memset(pgnss_log, 0, 2048);
-    }
+    // if (pgnss_log == NULL) 
+    // {
+    //     pgnss_log = (char *)malloc(2048);
+    //     if (pgnss_log == NULL) {
+    //         printf("error: malloc pgnss_log failed!\n");
+    //         return;
+    //     }
+    //     memset(pgnss_log, 0, 2048);
+    // }
 
 
     uapi_pm_add_sleep_veto(PM_ID_SYS);
@@ -1341,10 +1341,10 @@ void PGnssServerStart(void)
         g_is_pgnss_poweron = 0;
         g_is_pgnss_start = 0;
         g_pgnss_stopflag = 1;
-        if (pgnss_log != NULL) {
-            free(pgnss_log);
-            pgnss_log = NULL;
-        }
+        // if (pgnss_log != NULL) {
+        //     free(pgnss_log);
+        //     pgnss_log = NULL;
+        // }
         return;
     }
 
@@ -1354,10 +1354,10 @@ void PGnssServerStart(void)
         g_gnssLogFp = fopen("/user/userdata/gnsslog.txt", "w");
         if (g_gnssLogFp == NULL) {
             printf("error: open log file error\n");
-            if (pgnss_log != NULL) {
-                free(pgnss_log);
-                pgnss_log = NULL;
-            }
+            // if (pgnss_log != NULL) {
+            //     free(pgnss_log);
+            //     pgnss_log = NULL;
+            // }
             return;
         }
         // 写入日志开启时间戳
@@ -1374,10 +1374,10 @@ void PGnssServerStart(void)
         g_is_pgnss_start = 0;
         g_pgnss_stopflag = 1;
         g_cold_start_pgnss_stopflag = 1;
-        if (pgnss_log != NULL) {
-            free(pgnss_log);
-            pgnss_log = NULL;
-        }
+        // if (pgnss_log != NULL) {
+        //     free(pgnss_log);
+        //     pgnss_log = NULL;
+        // }
         return;
     }
     printf("open tiot service success\r\n");
@@ -1448,11 +1448,11 @@ void PGnssServerStart(void)
     
 
     // 释放pgnss_log内存
-    if (pgnss_log != NULL) {
-        printf("pgnss_log:%s\r\n",pgnss_log);
-        free(pgnss_log);
-        pgnss_log = NULL;
-    }
+    // if (pgnss_log != NULL) {
+    //     printf("pgnss_log:%s\r\n",pgnss_log);
+    //     free(pgnss_log);
+    //     pgnss_log = NULL;
+    // }
     if(g_cold_start_pgnss_stopflag == 1)
     {
         PGnssServerStartAutoModeStart();
index b45018b..0889589 100644 (file)
@@ -65,14 +65,14 @@ int decode_nmea(char c)
         // printf("%c",c);
     if(nmea_decode(&g_nmeadata,c) ==1) ///调用解析函数
     {
-        printf("%s\r\n",tmpbuf);
+        // printf("%s\r\n",tmpbuf);
         memset(tmpbuf,0,sizeof(tmpbuf));
         count=0;
         dump_nmea_str(&(g_nmeadata.gpsParse));
         if (g_nmeadata.gpsParse.sentence_type == GPS_SENTENCE_TH002)
         {
             //一组数据最后一条
-            dump_location_data(&(g_nmeadata.gpsData));
+            // dump_location_data(&(g_nmeadata.gpsData));
             memset(&g_nmeadata,0,sizeof(g_nmeadata));
         }
     } 
index 33a073b..9e7aa8f 100644 (file)
@@ -219,7 +219,7 @@ void gnss_receive_handler(uint8_t *buffer, int32_t size)
 }
 
 #define GNSS_CMD_TASK_MSG_COUNT 128
-#define GNSS_CMD_TASK_SIZE (0x2500)
+#define GNSS_CMD_TASK_SIZE (0x3000)
 #define GNSS_CMD_TASK_PRIO 4
 void create_gnss_uart_queue(void)
 {