From 482d4c3863c7f368f4ee81a5bb9d2f46bacb3ace Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Fri, 16 Aug 2024 19:18:20 +0800 Subject: [PATCH] =?utf8?q?=E6=8F=90=E9=AB=98ppg=20cywee=20task=E4=BC=98?= =?utf8?q?=E5=85=88=E7=BA=A7,=E6=B7=BB=E5=8A=A0cywee=E4=B8=AD=E6=96=AD?= =?utf8?q?=E5=A4=B1=E6=95=88=E8=B6=85=E6=97=B6=E6=81=A2=E5=A4=8D=E6=9C=BA?= =?utf8?q?=E5=88=B6.=20=E5=A2=9E=E5=8A=A0cywee=20ble=E6=97=A5=E5=BF=97?= =?utf8?q?=E5=BC=80=E5=85=B3,?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../ble_service/bleservice/bleService.c | 2 + .../drivers/peripheral/cywee/Inc/cywee_hal.h | 2 + .../peripheral/cywee/Inc/cywee_service.h | 4 +- .../cywee/service/cywee_ble_Service.c | 2 +- .../peripheral/cywee/service/cywee_service.c | 6 +- .../peripheral/cywee/src/board_yh601s.c | 6 +- .../drivers/peripheral/cywee/src/main_dml.c | 59 +++++++++++++++---- .../drivers/peripheral/ppg/hx3695/hx3695.c | 15 +++++ .../peripheral/ppg/service/ppg_service.cpp | 6 +- 9 files changed, 79 insertions(+), 23 deletions(-) diff --git a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c index 461471e8f..26dd320c1 100644 --- a/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c +++ b/code/sdk/application/wearable/service/ble_service/bleservice/bleService.c @@ -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); ble_cywee_store_report_handle(result->value_handle); // } + + ble_cywee_store_recv_handle(65) ; } #endif return; diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index 959d55891..079defc50 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -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() diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h index 5a4d01b58..e686ec3de 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h @@ -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); diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_ble_Service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_ble_Service.c index 9cf9f620c..cda7cd4d1 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_ble_Service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_ble_Service.c @@ -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); /*****参考结束****/ } diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c index 2849854a4..9e0d689ac 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c @@ -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; diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index 957803b8a..e637801c3 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -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; } diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index c1e1766f1..12d67443d 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -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; diff --git a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c index a826903cc..41326e17d 100644 --- a/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c +++ b/code/sdk/drivers/peripheral/ppg/hx3695/hx3695.c @@ -128,6 +128,8 @@ int wear_mode_status = -1; static uint8_t hx3695_chip_id = 0; +static int timeout = 0; + //////// spo2 para and switches const uint8_t COUNT_BLOCK_NUM = 25; //delay the block of some single good signal after a series of bad signal const uint8_t SPO2_LOW_XCORR_THRE = 30; //(64*xcorr)'s square below this threshold, means error signal @@ -2820,6 +2822,18 @@ void hx3695_hrs_ppg_Int_handle(void) for(ii=0; ii<*count; ii++) { + if(gsensordata[ii].x == 0.0f && gsensordata[ii].y == 0.0f && gsensordata[ii].z == 0.0f) + { + timeout++; + if(timeout > 20) + { + do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESTART_ACC,NULL); + } + } + else + { + timeout = 0; + } if(ii == 8) { gsen_fifo_x_send[ii] = gsen_fifo_x_send[ii - 1]; @@ -2834,6 +2848,7 @@ void hx3695_hrs_ppg_Int_handle(void) } //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); //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); + 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); } hrs_wear_status = hx3695_hrs_get_wear_status(); diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index cacb6631a..672d27e17 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -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; -- 2.17.1