提高ppg cywee task优先级,添加cywee中断失效超时恢复机制. 712/1 712/head 713/target/1
authorpenglei <1624952103@qq.com>
Fri, 16 Aug 2024 11:18:20 +0000 (19:18 +0800)
committerpenglei <1624952103@qq.com>
Fri, 16 Aug 2024 11:18:20 +0000 (19:18 +0800)
增加cywee ble日志开关,

code/sdk/application/wearable/service/ble_service/bleservice/bleService.c
code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h
code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h
code/sdk/drivers/peripheral/cywee/service/cywee_ble_Service.c
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/cywee/src/board_yh601s.c
code/sdk/drivers/peripheral/cywee/src/main_dml.c
code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c
code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp

index 461471e..26dd320 100644 (file)
@@ -1083,6 +1083,8 @@ static void svr_ble_bt_gatts_characteristic_add_cb(uint8_t server_id, bt_uuid_t
             // WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "g_hid_server_handle  %d\r\n",g_hid_server_handle);\r
         ble_cywee_store_report_handle(result->value_handle);\r
         // }\r
+\r
+        ble_cywee_store_recv_handle(65) ;\r
     }\r
 #endif\r
     return;\r
index 959d558..079defc 100644 (file)
@@ -562,6 +562,8 @@ void cywee_get_acc_switch(int cmd);
 void cywee_stop(void);
 uint8_t cywee_get_active_state(void);
 uint8_t cywee_get_static_state(void);
+void cywee_restart_acc(void);
+void cywee_log_switch(int cmd);
 extern uint8_t hrs_mode_state;
 
 #pragma pack()
index 5a4d01b..e686ec3 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com
  * @Date: 2024-03-26 20:29:58
  * @LastEditors: penglei 1624952103@qq.com
- * @LastEditTime: 2024-08-12 12:08:23
+ * @LastEditTime: 2024-08-16 15:46:30
  * @FilePath: /FD230/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h
  * @Description: 
  * 
@@ -93,6 +93,8 @@ extern "C" {
 
 #define CYWEE_SERVICE_CMD_CLOSE_SEDENTARY 0x34
 
+#define CYWEE_SERVICE_CMD_RESTART_ACC 0x35
+
 errcode_t uapi_cywee_service_init(void);
 void uapi_cywee_service_deinit(void);
 
index 9cf9f62..cda7cd4 100644 (file)
@@ -161,7 +161,7 @@ void cywee_recv_cmd_data(uint8_t *buf, uint16_t event_size,uint16_t handle)
     if(buf != NULL)
         printf("cywee_recv_cmd_data len %d , handle 0x%X ,*buf 0x%02X\r\n",event_size,handle,*buf);
     /****此处为接收指令,处理后反馈结果的参考**/
- 
+    cywee_log_switch(*buf);
     /*****参考结束****/
 }
 
index 2849854..9e0d689 100644 (file)
@@ -404,7 +404,9 @@ static void cywee_service_check_task(void const *arg)
             case CYWEE_SERVICE_CMD_CLOSE_SEDENTARY:
                 cywee_set_sedentary_switch(0);
             break;
-            
+            case CYWEE_SERVICE_CMD_RESTART_ACC:
+                cywee_restart_acc();
+            break;
             default:
                 PRINT("unkonw cmd \r\n");
                 break;
@@ -434,7 +436,7 @@ errcode_t uapi_cywee_service_init(void)
     app_task_definition_t taskcfg = {0};
     taskcfg.create_queue_handle = create_cywee_queue;
     taskcfg.attr.name = "cywee_service";
-    taskcfg.attr.priority = osPriorityBelowNormal1;
+    taskcfg.attr.priority = osPriorityBelowNormal4;
     taskcfg.attr.stack_size = CYWEE_APP_BOARD_TASK_SIZE;
     taskcfg.func = cywee_service_check_task;
     taskcfg.use_mem = USE_EXTEND_MEM;
index 957803b..e637801 100644 (file)
@@ -45,6 +45,7 @@
 
 static uint8_t g_cywee_installed = 0;
 
+extern uint8_t cywee_ble_service_flag;
 
 /************************/
 /*** Function Defines ***/
@@ -239,9 +240,8 @@ void CWM_OS_free(void *ptr)
 int CWM_OS_dbgOutput(const char * format)
 {
     PRINT("%s", format); 
-#if 0
-    ble_cywee_server_send_input_report((uint8_t *)format,strlen(format));
-#endif
+    if(cywee_ble_service_flag)
+        ble_cywee_server_send_input_report((uint8_t *)format,strlen(format));
     return 0;
 }
 
index c1e1766..12d6744 100644 (file)
@@ -61,7 +61,7 @@ int history_fat_=0; //一小时前燃脂数据
 
 static char chipInfo[64] = {0};
 
-static int get_acc_swtich = 0;
+static int get_acc_swtich = 1;
 
 static int sedentary_interval = 1;
 
@@ -76,9 +76,47 @@ static uint8_t cywee_is_active = 0;
 
 static uint8_t is_static_state = 0;
 
+uint8_t cywee_ble_service_flag = 0;
+
 int cm__hs1__init(void);
 int cm__hs1__deinit(void);
 
+void cywee_log_switch(int cmd)
+{
+    if(cmd)
+    {
+        memset(&scl, 0, sizeof(scl));
+        scl.iData[0] = 1;
+        scl.iData[3] = 9;
+        scl.iData[4] = 5;
+        scl.iData[7] = -1;
+        CWM_SettingControl(SCL_LOG, &scl); 
+        cywee_ble_service_flag = 1;
+    }
+    else
+    {
+        memset(&scl, 0, sizeof(scl));
+        scl.iData[0] = 1;
+        CWM_SettingControl(SCL_LOG, &scl);
+        cywee_ble_service_flag = 0; 
+    }
+}
+
+
+void cywee_restart_acc(void)
+{
+    memset(&scl, 0, sizeof(scl));
+    scl.iData[0] = 1;
+    scl.iData[1] = 1;
+    scl.iData[2] = 0;
+    CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl);
+    memset(&scl, 0, sizeof(scl));
+    scl.iData[0] = 1;
+    scl.iData[1] = 1;
+    scl.iData[2] = 1;  //1=acc,1+2=a+g,1+2+4=a+g+m
+    CWM_SettingControl(SCL_DML_DRV_ENABLE, &scl);
+}
+
 uint8_t cywee_get_static_state(void)
 {
     return is_static_state;
@@ -579,6 +617,10 @@ void gsensor_get_n_data(uint8_t cnt,gsenson_t t[])
         t[i].y= gxyz_t_queue[left_falg].y;
         t[i].z= gxyz_t_queue[left_falg].z;
 
+        gxyz_t_queue[left_falg].x = 0.0f;
+        gxyz_t_queue[left_falg].y = 0.0f;
+        gxyz_t_queue[left_falg].z = 0.0f;
+        
         if(num_falg)
         {
             left_falg++;
@@ -606,9 +648,9 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) {
         gxyz_t.z = sensorEVT->fData[2];
 
         // CWM_OS_dbgPrintf("acc: x=%.3f, y=%.3f, z=%.3f\n",
-        //                                            sensorEVT->fData[0] * 4096 / 10,
-        //                                            sensorEVT->fData[1] * 4096 / 10,
-        //                                            sensorEVT->fData[2] * 4096 / 10
+        //                                            sensorEVT->fData[0],
+        //                                            sensorEVT->fData[1],
+        //                                            sensorEVT->fData[2]
         //                                             );
 
         if(get_acc_swtich)
@@ -1123,15 +1165,6 @@ int cywee_main_dml(void)
     //设置运动识别
     cywee_ar_alert_switch(get_motion_recognition_from_config_model());
 
-#if 0
-    memset(&scl, 0, sizeof(scl));
-    scl.iData[0] = 1;
-    scl.iData[3] = 9;
-    scl.iData[4] = 5;
-    scl.iData[7] = -1;
-    CWM_SettingControl(SCL_LOG, &scl); 
-#endif
-
     //呼叫任一個CWM_Sensor_Enable 前呼叫此指令 设置手动或自动模式
     memset(&scl, 0, sizeof(scl));
     scl.iData[0] = 1;
index a826903..41326e1 100644 (file)
@@ -128,6 +128,8 @@ int wear_mode_status = -1;
 \r
 static uint8_t hx3695_chip_id = 0;\r
 \r
+static int timeout = 0;\r
+\r
 //////// spo2 para and switches\r
 const  uint8_t   COUNT_BLOCK_NUM = 25;            //delay the block of some single good signal after a series of bad signal\r
 const  uint8_t   SPO2_LOW_XCORR_THRE = 30;        //(64*xcorr)'s square below this threshold, means error signal\r
@@ -2820,6 +2822,18 @@ void hx3695_hrs_ppg_Int_handle(void)
 \r
     for(ii=0; ii<*count; ii++)\r
     {\r
+      if(gsensordata[ii].x == 0.0f && gsensordata[ii].y == 0.0f && gsensordata[ii].z == 0.0f)\r
+      {\r
+          timeout++;\r
+          if(timeout > 20)\r
+          {\r
+              do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESTART_ACC,NULL);\r
+          }\r
+      }\r
+      else\r
+      {\r
+          timeout = 0;\r
+      }\r
       if(ii == 8)\r
       {\r
           gsen_fifo_x_send[ii] = gsen_fifo_x_send[ii - 1];\r
@@ -2834,6 +2848,7 @@ void hx3695_hrs_ppg_Int_handle(void)
       }\r
       //PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
       //PRINT("hxdata:%d/%d %d %d %d %d %d %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsen_fifo_x_send[ii],gsen_fifo_y_send[ii],gsen_fifo_z_send[ii],ppg_s_data.green_cur);\r
+      PRINT("hxdata:%d/%d %d %d %.3f %.3f %.3f %d\r\n" ,1+ii,*count,PPG_buf[ii],ir_buf[0],gsensordata[ii].x,gsensordata[ii].y,gsensordata[ii].z,ppg_s_data.green_cur);\r
 \r
     }\r
     hrs_wear_status = hx3695_hrs_get_wear_status();\r
index cacb663..672d27e 100644 (file)
@@ -280,7 +280,7 @@ static void ppg_service_check_task(void  *arg)
             wear_mode_timeout_handler(NULL);
             continue;
         }else if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_TEST){
-            do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL);
+            //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_OPEN_GET_ACC,NULL);
             cmd = "hrs";
             enable = 1;
             uapi_pm_add_sleep_veto(PM_ID_HEART);
@@ -313,7 +313,7 @@ static void ppg_service_check_task(void  *arg)
             enable = 0;
             wear_mode_state = 0;
         }else if (mail == PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST){
-            do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_GET_ACC,NULL);
+            //do_cywee_service_check_msg(CYWEE_SERVICE_CMD_CLOSE_GET_ACC,NULL);
             cmd = "hrs";
             enable = 0;
             uapi_pm_remove_sleep_veto(PM_ID_HEART);
@@ -386,7 +386,7 @@ errcode_t uapi_ppg_service_init(void)
     app_task_definition_t taskcfg={0};
     taskcfg.create_queue_handle = create_ppg_queue;
     taskcfg.attr.name="ppg_service";
-    taskcfg.attr.priority = osPriorityBelowNormal1;
+    taskcfg.attr.priority = osPriorityBelowNormal4;
     taskcfg.attr.stack_size = PPG_SERVICE_TASK_SIZE;
     taskcfg.func = ppg_service_check_task;
     taskcfg.use_mem = USE_EXTEND_MEM;