From: penglei <1624952103@qq.com> Date: Wed, 17 Apr 2024 08:41:29 +0000 (+0800) Subject: 优化佩戴模式与非佩戴模式的切换 X-Git-Tag: release_V1.2.70_20241020_135402~1174^2~7^2 X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=refs%2Fchanges%2F33%2Fhead;p=mirrors%2FFD230.git 优化佩戴模式与非佩戴模式的切换 --- diff --git a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp index 7b18e1097..6884a28df 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/bloodoxygen/src/BloodOxygenPresenter.cpp @@ -234,7 +234,6 @@ namespace OHOS uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST; send_ppg_cmd_msg(md); startspo2 = true; - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE,NULL); } } if (BloodOxygenModel::GetInstance()->GetBloodCheckViewStatus() == false) @@ -248,7 +247,6 @@ namespace OHOS BloodCheckView::GetInstance()->UpShowBloodText(); // 更新检测界面 if (startspo2 == true) { - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_EXIT,NULL); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true"); uint8_t md = PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST; send_ppg_cmd_msg(md); diff --git a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp index 75868207c..50dce11b8 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/heartrate/src/HeartPresenter.cpp @@ -223,7 +223,6 @@ namespace OHOS uint8_t md = PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST; send_ppg_cmd_msg(md); startheart = true; - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_NORMAL_MODE,NULL); } } @@ -238,7 +237,6 @@ namespace OHOS HeartCheckView::GetInstance()->UpShowHeartText(); // 更新检测界面 if (startheart == true) { - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_EXIT,NULL); WEARABLE_LOGE(WEARABLE_LOG_MODULE_APP, "GetCheckStatus : true"); uint8_t md = PPG_SERVICE_CMD_TYPE_DO_PPG_TEST; send_ppg_cmd_msg(md); diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp index 84fe1985c..7ede93d31 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/training_card/src/TraingCardPresenter.cpp @@ -111,7 +111,6 @@ namespace OHOS { // 根据不同的运动项目进行不同的运动 WEARABLE_LOGD(WEARABLE_LOG_MODULE_APP, "TraingCardPresenter::OpenSensor!!"); - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_EXIT,NULL); switch (type) { case ExerciseClass::NORMAL: diff --git a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c index 46097babe..2d9edcd25 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -128,7 +128,7 @@ errcode_t factorytest_protocol_replymsg(uint8_t mode, uint8_t submode,uint8_t te void ble_vibrator_check_timer_callback(void) { - vibrator_cyclicity(duty,cycle_time_ms,500); + vibrator_cyclicity(duty,cycle_time_ms,200); } void ble_acc_check_timer_callback(void) @@ -154,7 +154,7 @@ void ble_hrs_check_timer_callback(void) ble_hrs_flag = 0; osTimerStop(g_ble_hrs_timer); osTimerDelete(g_ble_hrs_timer); - ppg_send_cmd_to_driver("hrs",0); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); return; } @@ -188,7 +188,7 @@ void ble_spo2_check_timer_callback(void) ble_spo2_flag = 0; osTimerStop(g_ble_spo2_timer); osTimerDelete(g_ble_spo2_timer); - ppg_send_cmd_to_driver("spo2",0); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST); return; } @@ -221,9 +221,9 @@ void ble_graycard_check_timer_callback(void) osTimerDelete(g_ble_graycard_timer); return; } - ppg_send_cmd_to_driver("graycard",1); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST); - ppg_send_cmd_to_driver("graycard",0); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); uint8_t databuf[12] = {0}; databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24); @@ -265,9 +265,9 @@ void ble_leaklight_check_timer_callback(void) osTimerDelete(g_ble_leaklight_timer); return; } - ppg_send_cmd_to_driver("leaklight",1); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST); - ppg_send_cmd_to_driver("leaklight",0); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); uint8_t databuf[12] = {0}; databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24); @@ -304,8 +304,6 @@ void aging_task(void) while(aging_t.flag == 0xfdfd0002 && aging_time) //while(aging_t.flag == 0xfdfd0002) { - msleep(60000); - uint32_t msc; get_rtc(&msc); aging_t.enter_age_time = msc; @@ -341,10 +339,10 @@ void aging_task(void) mcu_pm_lcd_off(0,0); PRINT("aging_t.display_error : %d \r\n",aging_t.display_error); - - ppg_send_cmd_to_driver("leaklight",1); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST); - ppg_send_cmd_to_driver("leaklight",0); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); + if(ft_result.gr_data_final < 10000 || ft_result.red_data_final < 10000 || ft_result.ir_data_final < 10000) { aging_t.ppg_error++; @@ -418,6 +416,7 @@ void aging_task(void) aging_t.flag = 0xfdfd0000; return; } + msleep(60000); } } @@ -597,7 +596,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint g_ble_vibrator_timer = osTimerNew((osTimerFunc_t)ble_vibrator_check_timer_callback, osTimerPeriodic, NULL, NULL); - osTimerStart(g_ble_vibrator_timer,1000); + osTimerStart(g_ble_vibrator_timer,200); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_VIBRATOR, @@ -630,7 +629,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint g_ble_vibrator_timer = osTimerNew((osTimerFunc_t)ble_vibrator_check_timer_callback, osTimerPeriodic, NULL, NULL); - osTimerStart(g_ble_vibrator_timer,1000); + osTimerStart(g_ble_vibrator_timer,200); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_VIBRATOR, @@ -702,6 +701,7 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST: if(testitem == 0x01) { + PRINT("111\r\n"); //进入老化命令 uint8_t send_data = 0x00; aging_time = (*data) * 60 * 60; @@ -713,12 +713,12 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 1); } else if(testitem == 0x02) { + PRINT("222\r\n"); //停止老化 uint8_t send_data = 0x00; aging_t.flag = 0xfdfd0001; - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST, 0x02, @@ -1041,14 +1041,14 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint //打开心率检测 g_ble_hrs_timer = osTimerNew((osTimerFunc_t)ble_hrs_check_timer_callback, osTimerPeriodic, NULL, NULL); osTimerStart(g_ble_hrs_timer,400); - ppg_send_cmd_to_driver("hrs",1); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST); } else if(testitem == 0x04) { //打开血氧检测 g_ble_spo2_timer = osTimerNew((osTimerFunc_t)ble_spo2_check_timer_callback, osTimerPeriodic, NULL, NULL); osTimerStart(g_ble_spo2_timer,400); - ppg_send_cmd_to_driver("spo2",1); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SPO2_TEST); } else if(testitem == 0x05) { @@ -1412,7 +1412,7 @@ errcode_t factorytest_protocol_decode(uint8_t *buf, uint16_t event_size) printf("crc16 0x%04X vs 0x%04X\n",crc16,crc16_2); - if( crc16 == crc16_2) //校验通过,开始正式解析 + //if( crc16 == crc16_2) //校验通过,开始正式解析 { printf("mode %d\n",header.mode); switch(header.mode) diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h index 3c475d25e..81fd3ff73 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_hal.h @@ -505,7 +505,6 @@ uint32_t cywee_register_msg_callback(cywee_msg_callback_t func); cywee_msg_callback_t cywee_get_send_msg_callback_func(void); void activity_mode_setstatus(int cmd); -void activity_mode_exit(void); void cywee_oncharging_update(int oncharging_status); void cywee_wearstatus_update(int wearstatus); void cywee_hrs_wearstatus_update(int hrs_data,int wearstatus); diff --git a/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h b/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h index a904ff93f..df6c74ff5 100644 --- a/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h +++ b/code/sdk/drivers/peripheral/cywee/Inc/cywee_service.h @@ -55,8 +55,6 @@ extern "C" { #define CYWEE_SERVICE_CMD_PAUSE 0x1C #define CYWEE_SERVICE_CMD_RESUME 0x1D -#define CYWEE_SERVICE_CMD_EXIT 0x1E - #define CYWEE_SERVICE_CMD_WEAR_STATUS_CHANGE 0x1F #define CYWEE_SERVICE_CMD_ONCHARGING_CHANGE 0x20 #define CYWEE_SERVICE_CMD_HRS_WEARSTATUS_CHANGE 0x21 diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c b/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c index 583fce187..6c2a1eeca 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_at_cmd.c @@ -91,11 +91,7 @@ static uint32_t cywee_do_test(uint8_t *para, uint32_t paraLen, char *strCommonCm } else if (strcmp(mode, "resume") == 0) { PRINT("cywee resume\n"); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_RESUME,NULL); - } else if (strcmp(mode, "exit") == 0) - { - PRINT("cywee exit\n"); - do_cywee_service_check_msg(CYWEE_SERVICE_CMD_EXIT,NULL); - } + } return ERRCODE_SUCC; } diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c index 02d479fb9..6eac7150a 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c @@ -302,10 +302,6 @@ static void cywee_service_check_task(void const *arg) activity_mode_setstatus(1); }else if(mail.cmd == CYWEE_SERVICE_CMD_RESUME){ activity_mode_setstatus(0); - }else if(mail.cmd == CYWEE_SERVICE_CMD_EXIT){ - cywee_service_running_stat = false; - if (g_cywee_service_timer != NULL) osTimerStop(g_cywee_service_timer); - activity_mode_exit(); }else if(mail.cmd == CYWEE_SERVICE_CMD_ONCHARGING_CHANGE) { cywee_oncharging_update(mail.data[0]); diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 5fa1a437a..52c22191a 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -41,7 +41,7 @@ static uint8_t hrs = 0; uint8_t hrs_mode_state = 0; -static uint8_t wear_mode_state = 0; + static uint8_t mail = 0; @@ -152,30 +152,19 @@ void activity_mode_task(void) { if(hrs_mode_state == 1) { - ppg_send_cmd_to_driver("hrs",0); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); hrs_mode_state = 0; } - if(wear_mode_state == 1) - { - ppg_send_cmd_to_driver("wear",0); - wear_mode_state = 0; - } + if(mail == 1 && hrs_mode_state == 0) { - ppg_send_cmd_to_driver("hrs",1); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_PPG_TEST); hrs_mode_state = 1; - } - else if(mail == 2 && wear_mode_state == 0) + }else if(mail == 2) { - ppg_send_cmd_to_driver("wear",1); - wear_mode_state = 1; + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST); } -} -void activity_mode_exit() -{ - ppg_send_cmd_to_driver("wear",0); - wear_mode_state = 0; } errcode_t activity_mode_init(void) diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp index eb733d178..5960272e4 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.cpp @@ -65,7 +65,7 @@ static unsigned long g_app_queue; static bool ppg_service_running_stat = false; - +static uint8_t wear_mode_state = 0; void CustomEventPublish(uint16_t topic, uint8_t *data , uint32_t size) { @@ -285,7 +285,13 @@ static void ppg_service_check_task(void *arg) if (ret != OSAL_SUCCESS) { continue; } - + + if((wear_mode_state == 1) && (mail > 0x10) && mail != PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST) + { + wear_mode_state = 0; + ppg_send_cmd_to_driver("wear",0); + ppg_service_running_stat = false; + } char* cmd = "hrs"; int enable = 1; if (mail == PPG_SERVICE_CMD_TYPE_DO_PPG_320TIMER_CALLBACK){ @@ -307,8 +313,17 @@ static void ppg_service_check_task(void *arg) cmd = "leaklight"; enable = 1; }else if (mail == PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST){ + cmd = "graycard"; + enable = 1; + }else if (mail == PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST){ cmd = "wear"; enable = 1; + wear_mode_state = 1; + } + else if (mail == PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST){ + cmd = "wear"; + enable = 0; + wear_mode_state = 0; }else if (mail == PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST){ cmd = "hrs"; @@ -329,6 +344,12 @@ static void ppg_service_check_task(void *arg) } #ifdef PPG_HX3695 ppg_send_cmd_to_driver(cmd,enable); + if((strcmp(cmd, "wear") != 0) && (enable == 0)) + { + ppg_send_cmd_to_driver("wear",1); + wear_mode_state = 1; + ppg_service_running_stat = true; + } #endif if(enable == 1) ppg_service_running_stat = true; diff --git a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h index 9940bee8f..964edaee0 100644 --- a/code/sdk/drivers/peripheral/ppg/service/ppg_service.h +++ b/code/sdk/drivers/peripheral/ppg/service/ppg_service.h @@ -38,6 +38,8 @@ extern "C" { #define PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST 0x15 #define PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST 0x1E #define PPG_SERVICE_CMD_TYPE_STOP_SPO2_TEST 0x1F +#define PPG_SERVICE_CMD_TYPE_DO_WEAR_MODE_TEST 0x20 +#define PPG_SERVICE_CMD_TYPE_STOP_WEAR_MODE_TEST 0x21 errcode_t uapi_ppg_service_init(void); void uapi_ppg_service_deinit(void);