From f9b2d9780113bf2406dc2c12d39826690bea256b Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BD=AD=E7=A3=8A?= <1624952103@qq.com> Date: Tue, 22 Oct 2024 09:57:57 +0000 Subject: [PATCH] Merge #1240 into sdk602patch0911 from refs/changes/1240/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Code review from 彭磊 * refs/changes/1240/head: (3 commits squashed) - 优化睡眠存储,增加佩戴状态runtime - 优化产测老化测试 - Merge branch 'sdk602patch0911' of https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230 into sdk602patch0911 Signed-off-by: aliyun6865282430 <1624952103@qq.com> Reviewed-by: snickersun@163.com Merged-by: snickersun@163.com CR-link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/1240 --- .../factorytest_protocol.c | 232 ++++++++++-------- .../debug_output_notification.cpp | 5 +- .../drivers/peripheral/cywee/src/main_dml.c | 31 ++- .../drivers/peripheral/utils/custom_runtime.c | 13 +- .../drivers/peripheral/utils/custom_runtime.h | 5 + 5 files changed, 172 insertions(+), 114 deletions(-) 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 489c04daf..51509ad74 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2024-10-20 18:54:23 + * @LastEditTime: 2024-10-22 16:21:43 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -56,31 +56,27 @@ typedef struct factorytest_cmd_header_t typedef struct { - uint8_t send_data;//填充字节 uint32_t flag; //老化测试状态 (完成 - 0xfdfd0000, 停止 - 0xfdfd0001, 开始-0xfdfd0002, 结束-0xfdfd0003) + uint32_t target_time; //目标时间 + uint32_t left_time; //剩余时间 uint32_t executions_num;//执行次数 - uint32_t target_num; //目标次数 - uint32_t fail_num; //失败次数 - uint32_t enter_age_time; //进入老化时间 - uint32_t age_time; //每轮老化结束时间 - uint16_t restart_num; //老化重启次数 - - uint32_t display_error; //屏失败次数 + uint32_t fail_num; //总失败次数 + uint32_t display_error; //LCD失败次数 uint32_t tp_error; //tp失败次数 - uint32_t gsensor_error; //A+G sensor失败次数 + uint32_t gsensor_error; //gsensor失败次数 uint32_t ppg_error; //ppg失败次数 - uint32_t mag_error; //magnetic 失败次数 - uint32_t motor_error; //motor失败次数 - uint32_t speaker_error; //speaker失败次数 - uint32_t flash_res_error; //片外资源失败次数 - uint16_t flash_bad_block_num; //老化前后flash的坏块数量差值 + uint32_t mag_error; //磁力计失败次数 + uint32_t motor_error; //马达失败次数 + uint32_t mic_error; //mic失败次数 + uint32_t speaker_error; //spk失败次数 + uint32_t charge_error; //充电失败次数 }ble_aging_t; #pragma pack() static int factorytest_mode_flag = 0; -ble_aging_t aging_t; +ble_aging_t aging_t = {0}; static osTimerId_t g_ble_vibrator_timer = NULL; @@ -168,35 +164,34 @@ void ble_acc_check_timer_callback(void) 6); } + + uint32_t executions_num;//执行次数 + uint32_t fail_num; //失败次数 + uint32_t target_hour; //目标时间 + uint32_t enter_age_time; //进入老化时间 + uint32_t age_time; //每轮老化结束时间 + + void aging_task(void) { + errcode_t ret = 0; + uint32_t enter_age_time = 0; + uint32_t exit_age_time = 0; + int cmd = 0; while(aging_t.flag == 0xfdfd0002 && aging_time) //while(aging_t.flag == 0xfdfd0002) { - int cmd = 0; - uint32_t msc; - uapi_get_timestampe_ss(&msc); - aging_t.enter_age_time = msc; - PRINT("aging_t.enter_age_time : %d \r\n",aging_t.enter_age_time); + + uapi_get_timestampe_ss(&enter_age_time); + PRINT("老化目标时间 : %d \r\n",aging_t.target_time); + PRINT("老化剩余时间 : %d \r\n",aging_t.left_time); + + + aging_t.executions_num++; - PRINT("aging_t.executions_num : %d \r\n",aging_t.executions_num); - aging_t.target_num = msc/60; - PRINT("aging_t.target_num : %d \r\n",aging_t.target_num); - aging_t.fail_num = 0; - PRINT("aging_t.fail_num : %d \r\n",aging_t.fail_num); - aging_t.restart_num = 0; - PRINT("aging_t.restart_num : %d \r\n",aging_t.restart_num); - - uint16_t before_block_num = 0; - struct nand_driver_struct *nandflash_driver; - nandflash_driver = get_nand_flash(); - for (uint32_t i = 0; i < nandflash_driver->total_block; i++) - { - if (nandflash_driver->check_bad_block(i) == 1) - { - before_block_num++; - } - } + PRINT("老化执行次数 : %d \r\n",aging_t.executions_num); + PRINT("总失败次数 : %d \r\n",aging_t.fail_num); + /*********************LCD 老化测试*****************************/ @@ -208,12 +203,12 @@ void aging_task(void) aging_t.display_error++; aging_t.fail_num++; } - PRINT("aging_t.display_error : %d \r\n",aging_t.display_error); + PRINT("LCD 失败次数 : %d \r\n",aging_t.display_error); - //单色屏测试 + //单色屏测试 2min cmd = 1; do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_LCD_TEST,&cmd,sizeof(cmd)); - for(cmd = 1; cmd < 6 ; cmd++) + for(cmd = 1; cmd < 120 ; cmd++) { do_custom_cmd_service_check_msg(CUSTOM_CMD_MSG_TYPE_LCD_COLOR_TEST,&cmd,sizeof(cmd)); LOS_Msleep(1000); @@ -228,89 +223,128 @@ void aging_task(void) aging_t.tp_error++; aging_t.fail_num++; } - PRINT("aging_t.tp_error : %d \r\n",aging_t.tp_error); + PRINT("TP 失败次数 : %d \r\n",aging_t.tp_error); /********************* 马达 老化测试*****************************/ - //震6秒 - for(cmd = 0; cmd < 2 ; cmd++) + //2min 震2s 停2s + uint32_t total_time = 2 * 60; + uint32_t enter_time = 0; + uint32_t age_time = 0; + while(total_time) { - // ui_api_vibrate_once_func(3); - ui_api_vibrate_once_func(); - LOS_Msleep(1000); + uapi_get_timestampe_ss(&enter_time); + custom_VibratorFunc_int(4); + LOS_Msleep(4000); + uapi_get_timestampe_ss(&age_time); + total_time -= (age_time - enter_time); + PRINT("total_time[%d]\n",total_time); } - PRINT("aging_t.motor_error : %d \r\n",aging_t.motor_error); -/********************* spk 老化测试*****************************/ - uapi_check_spk(1); - LOS_Msleep(2000); - uapi_check_spk(0); - aging_t.speaker_error = 0; - PRINT("aging_t.speaker_error : %d \r\n",aging_t.speaker_error); -/*********************ppg 老化测试*****************************/ - //漏光测试 - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); - FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST); - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); - - if(ft_result.gr_data_final > 5000 || ft_result.red_data_final > 5000 || ft_result.ir_data_final > 5000) + uapi_vibrator_test(); + PRINT("马达失败次数 : %d \r\n",aging_t.motor_error); + +/********************* mic 老化测试*****************************/ + ret = uapi_microhone_switch(1); + LOS_Msleep(2000 * 60); + ret = uapi_microhone_switch(0); + if(ret != 0) { - aging_t.ppg_error++; + aging_t.mic_error++; aging_t.fail_num++; } - PRINT("aging_t.ppg_error : %d \r\n",aging_t.ppg_error); - -/*********************gsensor 老化测试*****************************/ - gsenson_t g; - get_gsonsen_xyz(&g); - if(g.x == 0 && g.y == 0 && g.z == 0) + PRINT("mic失败次数 : %d \r\n",aging_t.mic_error); +/********************* spk 老化测试*****************************/ + total_time = 2 * 60; + enter_time = 0; + age_time = 0; + while(total_time) { - aging_t.gsensor_error++; - aging_t.fail_num++; + uapi_get_timestampe_ss(&enter_time); + uapi_check_spk(1); + LOS_Msleep(2000); + uapi_check_spk(0); + aging_t.speaker_error = 0; + uapi_get_timestampe_ss(&age_time); + total_time -= (age_time - enter_time); + PRINT("total_time[%d]\n",total_time); } - PRINT("aging_t.gsensor_error : %d \r\n",aging_t.gsensor_error); + PRINT("spk失败次数 : %d \r\n",aging_t.speaker_error); +/*********************ppg 老化测试*****************************/ -/*********************磁力计 老化测试*****************************/ - float fAzimuth,fPitch,fRoll; - mmc5603_getdata(&fAzimuth,&fPitch,&fRoll); - if(fAzimuth < 0) + total_time = 2 * 60; + enter_time = 0; + age_time = 0; + while(total_time) { - aging_t.mag_error++; - aging_t.fail_num++; + uapi_get_timestampe_ss(&enter_time); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_SINGLE_CHECK_MODE_TEST); + LOS_Msleep(200); + FT_RESULTS_t ft_result = hx3695_factroy_test(SINGLE_CHECK_TEST); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST); + PRINT("ft_result.gr_data_final : %d , ft_result.red_data_final : %d , ft_result.ir_data_final : %d\r\n",ft_result.gr_data_final,ft_result.red_data_final,ft_result.ir_data_final); + uapi_get_timestampe_ss(&age_time); + total_time -= (age_time - enter_time); + PRINT("total_time[%d]\n",total_time); } - PRINT("aging_t.mag_error : %d \r\n",aging_t.mag_error); - uint32_t flash_id; - flash_getid(&flash_id); - if(flash_id == 0) + // if(ft_result.gr_data_final > 5000 || ft_result.red_data_final > 5000 || ft_result.ir_data_final > 5000) + // { + // aging_t.ppg_error++; + // aging_t.fail_num++; + // } + // PRINT("aging_t.ppg_error : %d \r\n",aging_t.ppg_error); + +/*********************gsensor 老化测试*****************************/ + gsenson_t g; + total_time = 2 * 60; + enter_time = 0; + age_time = 0; + while(total_time) { - aging_t.flash_res_error++; - aging_t.fail_num++; + uapi_get_timestampe_ss(&enter_time); + get_gsonsen_xyz(&g); + if(g.x == 0 && g.y == 0 && g.z == 0) + { + aging_t.gsensor_error++; + aging_t.fail_num++; + } + uapi_get_timestampe_ss(&age_time); + total_time -= (age_time - enter_time); + PRINT("total_time[%d]\n",total_time); + LOS_Msleep(1000); } - PRINT("aging_t.flash_res_error : %d \r\n",aging_t.flash_res_error); + PRINT("gsensor失败次数 : %d \r\n",aging_t.gsensor_error); - uint16_t after_block_num = 0; - nandflash_driver = get_nand_flash(); - for (uint32_t i = 0; i < nandflash_driver->total_block; i++) +/*********************磁力计 老化测试*****************************/ + float fAzimuth,fPitch,fRoll; + + total_time = 2 * 60; + enter_time = 0; + age_time = 0; + while(total_time) { - if (nandflash_driver->check_bad_block(i) == 1) + uapi_get_timestampe_ss(&enter_time); + mmc5603_getdata(&fAzimuth,&fPitch,&fRoll); + if(fAzimuth < 0) { - after_block_num++; + aging_t.mag_error++; + aging_t.fail_num++; } + uapi_get_timestampe_ss(&age_time); + total_time -= (age_time - enter_time); + PRINT("total_time[%d]\n",total_time); + LOS_Msleep(1000); } - aging_t.flash_bad_block_num = after_block_num - before_block_num; + PRINT("磁力计失败次数 : %d \r\n",aging_t.mag_error); - uapi_get_timestampe_ss(&msc); - aging_t.age_time = msc; - PRINT("aging_t.age_time : %d \r\n",aging_t.age_time); - aging_time -= (aging_t.age_time - aging_t.enter_age_time); - PRINT("aging_time : %d \r\n",aging_time); + uapi_get_timestampe_ss(&exit_age_time); + aging_time -= (exit_age_time - enter_age_time); if(aging_time == 0) { aging_t.flag = 0xfdfd0000; return; } - msleep(60000); } } @@ -357,6 +391,7 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t factorytest_mode_flag = 1; ChargerEventPublish(TOPIC_EVENT_CHARGE_UNPLUG,0); //进入产测模式 关闭充电弹窗 uapi_dev_runtime_set_factory_test_status(1); //设置产测模式runtime + svr_ble_adv_factory_test_start_param(); //设置蓝牙广播 避免出现连接问题 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_COMMON, BLE_TEST_CMD_COMMON_SUB_MODE_SWITCH_MODE, 0x01, @@ -814,7 +849,8 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint { //进入老化命令 uint8_t send_data = 0x00; - aging_time = (*data) * 60 * 60; + aging_t.target_time = 6 * 60 * 60; //老化时间6小时 + aging_time = aging_t.target_time; aging_test_init(); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_AGING_TEST, diff --git a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp index 2fd20d220..fae1fe150 100644 --- a/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp +++ b/code/sdk/application/wearable/service/msg_center/src/notify/debug_output_notification/debug_output_notification.cpp @@ -247,6 +247,7 @@ namespace OHOS result += "nap_status:" + std::to_string(uapi_dev_runtime_get_nap_status()) + " "; result += "nap_monitoring_status:" + std::to_string(uapi_dev_runtime_get_nap_monitoring_status()) + " "; result += "sedentary_status:" + std::to_string(uapi_dev_runtime_get_sedentary_status()) + " "; + result += "wear_status:" + std::to_string(uapi_dev_runtime_get_wear_status_flag()) + " "; result += "drinkremind_status:" + std::to_string(uapi_dev_runtime_get_drinkremind_status()) + " "; result += "train_status:" + std::to_string(uapi_dev_runtime_get_train_status()) + " "; result += "saveele_status:" + std::to_string(uapi_dev_runtime_get_saveele_status()) + " "; @@ -263,10 +264,6 @@ namespace OHOS result += "lock_flag_heartrate:" + std::to_string(uapi_dev_runtime_get_heartrate_storage_status()) + " "; result += "lock_flag_blood:" + std::to_string(uapi_dev_runtime_get_bloodoxygen_storage_status()) + " "; result += "lock_flag_sleep:" + std::to_string(uapi_dev_runtime_get_sleep_storage_status()) + " "; - result += "nap_monitoring_status:" + std::to_string(uapi_dev_runtime_get_nap_monitoring_status()) + " "; - result += "nap_status:" + std::to_string(uapi_dev_runtime_get_nap_status()) + " "; - result += "sleep_monitoring_status:" + std::to_string(uapi_dev_runtime_get_sleep_monitoring_status()) + " "; - result += "sleep_status:" + std::to_string(uapi_dev_runtime_get_sleep_status()) + " "; result += "lock_flag_goal:" + std::to_string(uapi_dev_runtime_get_goal_storage_status()) + " "; result += "respiratory_training_status:" + std::to_string(uapi_dev_runtime_get_respiratory_training_status()) + " "; result += "heartrate_detect_status:" + std::to_string(uapi_dev_runtime_get_heartrate_detect_status()) + " "; diff --git a/code/sdk/drivers/peripheral/cywee/src/main_dml.c b/code/sdk/drivers/peripheral/cywee/src/main_dml.c index 5bee5e31a..c56f8f420 100644 --- a/code/sdk/drivers/peripheral/cywee/src/main_dml.c +++ b/code/sdk/drivers/peripheral/cywee/src/main_dml.c @@ -116,6 +116,9 @@ static char nap_file_path[64] = {0}; static char day[12] = {0}; static char dir_path[64] = {0}; +static uint8_t ephemeral_flag = 0; //临时数据 + +static uint8_t wear_status = 0;//佩戴状态 #ifdef CYWEE_MAC_ACTIVE int cm__hs1__mac_c1_init(void); @@ -208,8 +211,6 @@ void cywee_set_sleep_time_data(cywee_inactivity_accumulate_time_t *sleep_data) void cywee_save_sleep_time_data(cywee_inactivity_accumulate_time_t sleep_time) { - uint8_t flag = 0; //临时数据标志 - if (access(time_file_path, 0) == -1) { memset(time_file_path, 0, sizeof(time_file_path)); @@ -232,7 +233,6 @@ void cywee_save_sleep_time_data(cywee_inactivity_accumulate_time_t sleep_time) if (wake_up_timestamp == 0) { uapi_get_timestampe_ss(&wake_up_timestamp); - flag = 1; } fwrite(&wake_up_timestamp, 1, 4, fp); @@ -275,17 +275,21 @@ void cywee_save_sleep_time_data(cywee_inactivity_accumulate_time_t sleep_time) total_time_minute = (total_wake_time % 60); fwrite(&total_time_minute, 1, 1, fp); - - CWM_OS_dbgPrintf("total_time[%d], total_deep_sleep_time[%d], total_mild_sleep_time[%d], total_rem_sleep_time[%d], total_wake_time[%d] \n", - total_time,total_deep_sleep_time,total_mild_sleep_time,total_rem_sleep_time,total_wake_time); fclose(fp); - if (flag) // 临时数据清掉 + if (ephemeral_flag) // 临时数据清掉 { - total_deep_sleep_time -= sleep_time.total_deep_sleep_time; - total_mild_sleep_time -= sleep_time.total_mild_sleep_time; - total_rem_sleep_time -= sleep_time.total_rem_sleep_time; + total_deep_sleep_time -= sleep_time.total_deep_sleep_time; + total_mild_sleep_time -= sleep_time.total_mild_sleep_time; + total_rem_sleep_time -= sleep_time.total_rem_sleep_time; + ephemeral_flag = 0; } + + CWM_OS_dbgPrintf("wake_up_timestamp : %d ,fall_asleep_timestamp : %d \n",wake_up_timestamp,fall_asleep_timestamp); + CWM_OS_dbgPrintf("total_time[%d], total_deep_sleep_time[%d], total_mild_sleep_time[%d], total_rem_sleep_time[%d], total_wake_time[%d] \n", + total_time,total_deep_sleep_time,total_mild_sleep_time,total_rem_sleep_time,total_wake_time); + + } void cywee_save_sleep_stat_data(void) @@ -789,6 +793,7 @@ void cywee_oncharging_update(int oncharging_status) void cywee_wearstatus_update(int wearstatus) { #if 1 + uapi_dev_runtime_set_wear_status(wearstatus); memset(&csd, 0, sizeof(CUSTOM_OFFBODY_DETECT)); csd.sensorType = CUSTOM_OFFBODY_DETECT; csd.fData[0] = wearstatus; @@ -1175,7 +1180,7 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { // sleep_flag_t.stat = c_inactivity_result_t.status; // // uapi_save_sleep_flag(&sleep_flag_t,sizeof(SLEEP_FLAG_T)); // } - + CWM_OS_dbgPrintf("c_inactivity_result_t.status : %d \n", c_inactivity_result_t.status); //0进入睡眠 1潜睡 2深睡 3清醒 4结束睡眠 6入睡 7出睡最后一笔输出 9未出睡最后一笔输出 12快速动眼 13取消入睡 if(c_inactivity_result_t.status >= 6 && c_inactivity_result_t.status <= 9) { @@ -1184,6 +1189,10 @@ void CWM_AP_SensorListen(pSensorEVT_t sensorEVT) { uapi_dev_runtime_set_sleep_status(1); uapi_get_timestampe_ss(&asleep_timestampe); } + else if(c_inactivity_result_t.status == 9) + { + ephemeral_flag = 1; //临时数据 + } break; //只要是通知都不发消息,直接退出 } else if(c_inactivity_result_t.status == 4 || c_inactivity_result_t.status == 13) diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.c b/code/sdk/drivers/peripheral/utils/custom_runtime.c index 4a8c2315f..d2315e4b4 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.c +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.c @@ -100,7 +100,7 @@ typedef struct uint8_t heartrate_detect_status;//主动检测心率状态 uint8_t factory_test_status;//产测模式状态 uint8_t screen_always_on_status;//屏幕是否常亮状态 - + uint8_t wear_status; } runtime_status_t; @@ -594,3 +594,14 @@ uint8_t uapi_dev_runtime_get_factory_test_status_flag(void) { return g_runtime.factory_test_status; } + +// 设置是否为佩戴状态 +void uapi_dev_runtime_set_wear_status(uint8_t status) +{ + g_runtime.wear_status = status; +} +// 获取是否为佩戴状态 +uint8_t uapi_dev_runtime_get_wear_status_flag(void) +{ + return g_runtime.wear_status; +} diff --git a/code/sdk/drivers/peripheral/utils/custom_runtime.h b/code/sdk/drivers/peripheral/utils/custom_runtime.h index 39ef46455..00ae3b7c5 100644 --- a/code/sdk/drivers/peripheral/utils/custom_runtime.h +++ b/code/sdk/drivers/peripheral/utils/custom_runtime.h @@ -295,6 +295,11 @@ void uapi_dev_runtime_set_factory_test_status(uint8_t status); // 获取是否为产测模式 uint8_t uapi_dev_runtime_get_factory_test_status_flag(void); +// 设置是否为佩戴状态 +void uapi_dev_runtime_set_wear_status(uint8_t status); +// 获取是否为佩戴状态 +uint8_t uapi_dev_runtime_get_wear_status_flag(void); + #ifdef __cplusplus #if __cplusplus } -- 2.17.1