From 4dc175ac7342bcda0d2d6fd657166bdc271dd795 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BD=AD=E7=A3=8A?= <1624952103@qq.com> Date: Wed, 12 Jun 2024 03:41:36 +0000 Subject: [PATCH] Merge #262 into sdk602patch0521 from refs/changes/262/head MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 优化蓝牙产测,解决表盘指南针校准不过的问题 * refs/changes/262/head: (2 commits squashed) - 优化蓝牙产测,解决表盘指南针校准不过的问题 - 添加删除文件通用接口,优化蓝牙产测 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/262 --- .../compass/src/CompassControlView.cpp | 6 +- .../factorytest_protocol.c | 213 ++++++++---------- .../peripheral/cywee/service/cywee_service.c | 6 +- .../peripheral/cywee/src/board_yh601s.c | 4 +- .../peripheral/mag/mmc5603/mmc5603_main.c | 2 +- .../peripheral/mag/service/mag_service.c | 4 +- .../peripheral/utils/custom_cmd_service.c | 3 +- .../drivers/peripheral/utils/custom_utils.c | 54 ++--- .../drivers/peripheral/utils/custom_utils.h | 3 +- 9 files changed, 132 insertions(+), 163 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassControlView.cpp b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassControlView.cpp index 71dcefcae..3121836ba 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassControlView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassControlView.cpp @@ -71,9 +71,9 @@ bool CompassControlView::InitView(void) void CompassControlView::SetCalibrationView(bool flag) { - if (flag == isCalibration) { - return; - } + // if (flag == isCalibration) { + // return; + // } if (flag) { compassCalibrationView->SetVisible(true); 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 af5956d18..fafe602d6 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -68,11 +68,9 @@ static osTimerId_t g_ble_acc_timer; static osTimerId_t g_ble_hrs_timer; static osTimerId_t g_ble_spo2_timer; -static osTimerId_t g_ble_graycard_timer; -static osTimerId_t g_ble_leaklight_timer; -static uint8_t graycard_flag = 0; -static uint8_t leaklight_flag = 0; +static osTimerId_t g_ble_microhone_timer; +static osTimerId_t g_ble_spk_timer; static uint32_t aging_time = 0; @@ -210,91 +208,31 @@ void ble_spo2_check_timer_callback(void) } -void ble_graycard_check_timer_callback(void) +void ble_microhone_check_timer_callback(void) { - if(graycard_flag == 10) - { - graycard_flag = 0; - osTimerStop(g_ble_graycard_timer); - osTimerDelete(g_ble_graycard_timer); - return; - } - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); - FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST); - 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); - databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0); - - databuf[4] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24); - databuf[5] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16); - databuf[6] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8); - databuf[7] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0); - - databuf[8] = (uint8_t)((ft_result.ir_data_final & 0xFF000000) >> 24); - databuf[9] = (uint8_t)((ft_result.ir_data_final & 0x00FF0000) >> 16); - databuf[10] = (uint8_t)((ft_result.ir_data_final & 0x0000FF00) >> 8); - databuf[11] = (uint8_t)((ft_result.ir_data_final & 0x000000FF) >> 0); - - PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n", - databuf[0],databuf[1],databuf[2],databuf[3], - databuf[4],databuf[5],databuf[6],databuf[7], - databuf[8],databuf[9],databuf[10],databuf[11] - ); + uint8_t send_data= 0; + uapi_microhone_switch(0); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, - 0x05, - databuf, - 12); - graycard_flag++; + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, + 0x01, + &send_data, + 1); + } -void ble_leaklight_check_timer_callback(void) +void ble_spk_check_timer_callback(void) { - if(leaklight_flag == 10) - { - leaklight_flag = 0; - osTimerStop(g_ble_leaklight_timer); - osTimerDelete(g_ble_leaklight_timer); - return; - } - send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); - FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST); - 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); - databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16); - databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8); - databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0); - - databuf[4] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24); - databuf[5] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16); - databuf[6] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8); - databuf[7] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0); - - databuf[8] = (uint8_t)((ft_result.ir_data_final & 0xFF000000) >> 24); - databuf[9] = (uint8_t)((ft_result.ir_data_final & 0x00FF0000) >> 16); - databuf[10] = (uint8_t)((ft_result.ir_data_final & 0x0000FF00) >> 8); - databuf[11] = (uint8_t)((ft_result.ir_data_final & 0x000000FF) >> 0); - - PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n", - databuf[0],databuf[1],databuf[2],databuf[3], - databuf[4],databuf[5],databuf[6],databuf[7], - databuf[8],databuf[9],databuf[10],databuf[11] - ); + uint8_t send_data= 0; + + uapi_check_spk(0); factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, - 0x06, - databuf, - 12); - leaklight_flag++; + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, + 0x02, + &send_data, + 1); } void aging_task(void) @@ -1152,14 +1090,73 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x05) { //灰卡测试 - g_ble_graycard_timer = osTimerNew((osTimerFunc_t)ble_graycard_check_timer_callback, osTimerPeriodic, NULL, NULL); - osTimerStart(g_ble_graycard_timer,400); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST); + FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST); + 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); + databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0); + + databuf[4] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24); + databuf[5] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16); + databuf[6] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8); + databuf[7] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0); + + databuf[8] = (uint8_t)((ft_result.ir_data_final & 0xFF000000) >> 24); + databuf[9] = (uint8_t)((ft_result.ir_data_final & 0x00FF0000) >> 16); + databuf[10] = (uint8_t)((ft_result.ir_data_final & 0x0000FF00) >> 8); + databuf[11] = (uint8_t)((ft_result.ir_data_final & 0x000000FF) >> 0); + + PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n", + databuf[0],databuf[1],databuf[2],databuf[3], + databuf[4],databuf[5],databuf[6],databuf[7], + databuf[8],databuf[9],databuf[10],databuf[11] + ); + + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, + 0x05, + databuf, + 12); } else if(testitem == 0x06) { //漏光测试 - g_ble_leaklight_timer = osTimerNew((osTimerFunc_t)ble_leaklight_check_timer_callback, osTimerPeriodic, NULL, NULL); - osTimerStart(g_ble_leaklight_timer,400); + send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST); + FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_TEST); + 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); + databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16); + databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8); + databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0); + + databuf[4] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24); + databuf[5] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16); + databuf[6] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8); + databuf[7] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0); + + databuf[8] = (uint8_t)((ft_result.ir_data_final & 0xFF000000) >> 24); + databuf[9] = (uint8_t)((ft_result.ir_data_final & 0x00FF0000) >> 16); + databuf[10] = (uint8_t)((ft_result.ir_data_final & 0x0000FF00) >> 8); + databuf[11] = (uint8_t)((ft_result.ir_data_final & 0x000000FF) >> 0); + + PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n", + databuf[0],databuf[1],databuf[2],databuf[3], + databuf[4],databuf[5],databuf[6],databuf[7], + databuf[8],databuf[9],databuf[10],databuf[11] + ); + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS, + 0x06, + databuf, + 12); } break; @@ -1466,51 +1463,17 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint case BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER: if(testitem == 0x01) { - uint8_t send_data= 0; - + //开始录音 + g_ble_microhone_timer = osTimerNew((osTimerFunc_t)ble_microhone_check_timer_callback, osTimerPeriodic, NULL, NULL); + osTimerStart(g_ble_microhone_timer,5000); uapi_microhone_switch(1); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x01, - &send_data, - 1); - } else if(testitem == 0x02) - { - uint8_t send_data = 0; - - uapi_microhone_switch(0); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x02, - &send_data, - 1); - } else if(testitem == 0x03) + } else if(testitem == 0x02) { - - uint8_t send_data = 0; - + //播放录音 + g_ble_microhone_timer = osTimerNew((osTimerFunc_t)ble_spk_check_timer_callback, osTimerPeriodic, NULL, NULL); + osTimerStart(g_ble_spk_timer,5000); uapi_check_spk(1); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x03, - &send_data, - 1); - } else if(testitem == 0x04) - { - - uint8_t send_data = 0; - - uapi_check_spk(0); - - factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, - BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x04, - &send_data, - 1); } break; diff --git a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c index a337eab43..32af17bfb 100644 --- a/code/sdk/drivers/peripheral/cywee/service/cywee_service.c +++ b/code/sdk/drivers/peripheral/cywee/service/cywee_service.c @@ -426,6 +426,10 @@ errcode_t uapi_cywee_service_init(void) taskcfg.func = cywee_service_check_task; taskcfg.use_mem = USE_EXTEND_MEM; + // uint8_t buf[200] = {0}; + // uapi_efuse_read_buffer(buf, 0x100, 80); + // PRINT("efuse buf : %s \r\n",buf); + errcode_t ret = uapi_create_osThread_custom(&taskcfg); if (ret != ERRCODE_SUCC) { @@ -433,7 +437,7 @@ errcode_t uapi_cywee_service_init(void) return ERRCODE_FAIL; } - g_cywee_service_timer = osTimerNew((osTimerFunc_t)cywee_service_check_timer_callback, osTimerPeriodic, NULL, NULL); + //g_cywee_service_timer = osTimerNew((osTimerFunc_t)cywee_service_check_timer_callback, osTimerPeriodic, NULL, NULL); cywee_register_msg_callback(cywee_msg_callback); do_cywee_service_check_msg(CYWEE_SERVICE_CMD_START_CHECK, NULL); diff --git a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c index fdee522b7..e57ec0c4b 100644 --- a/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c +++ b/code/sdk/drivers/peripheral/cywee/src/board_yh601s.c @@ -268,7 +268,7 @@ void CWM_OS_saveData(int* data, uint32_t len){ FILE * fp = fopen(CWM_DATA_PATH,"wb"); if(fp==NULL) { - CWM_OS_dbgPrintf("open fail\n"); + CWM_OS_dbgPrintf("%s open fail\n",CWM_DATA_PATH); return; } int ret =fwrite(data,1,len,fp); @@ -404,7 +404,7 @@ void CWM_OS_restoreData(int* data, uint32_t len){ FILE * fp = fopen(CWM_DATA_PATH,"rb"); if(fp==NULL) { - CWM_OS_dbgPrintf("open fail\n"); + CWM_OS_dbgPrintf("%s open fail\n",CWM_DATA_PATH);; return; } int ret =fread(data,1,len,fp); diff --git a/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c b/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c index 3a3751a98..d0b3fed0a 100644 --- a/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c +++ b/code/sdk/drivers/peripheral/mag/mmc5603/mmc5603_main.c @@ -436,7 +436,7 @@ int mag_service_get_iAccuracy(void) int mmc5603_stop(void) { - SavePara_infile(saveData,4); + SavePara_infile(g_MagPara,4); MMC5603_Disable(); return 0; } diff --git a/code/sdk/drivers/peripheral/mag/service/mag_service.c b/code/sdk/drivers/peripheral/mag/service/mag_service.c index 23ed1d94a..ca426e336 100644 --- a/code/sdk/drivers/peripheral/mag/service/mag_service.c +++ b/code/sdk/drivers/peripheral/mag/service/mag_service.c @@ -184,6 +184,8 @@ void create_mag_queue(void) MMC_ERROR("[mag][service] app create mail fail\n"); } } + +#define MAG_BOARD_TASK_SIZE 0x900 errcode_t uapi_mag_service_init(void) { @@ -205,7 +207,7 @@ errcode_t uapi_mag_service_init(void) taskcfg.create_queue_handle = create_mag_queue; taskcfg.attr.name="mag_service"; taskcfg.attr.priority = TASK_PRIORITY_APP; - taskcfg.attr.stack_size = APP_BOARD_TASK_SIZE; + taskcfg.attr.stack_size = MAG_BOARD_TASK_SIZE; taskcfg.func = mag_service_check_task; taskcfg.use_mem = USE_EXTEND_MEM; diff --git a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c index ee0be8ca6..fa390fe95 100644 --- a/code/sdk/drivers/peripheral/utils/custom_cmd_service.c +++ b/code/sdk/drivers/peripheral/utils/custom_cmd_service.c @@ -123,8 +123,7 @@ static void custom_cmd_service_check_task(void const *arg) case CUSTOM_CMD_MSG_TYPE_RESTORE_FACTORY_SETTING: { UnbindSucessCmd(1);//1确认解绑 - uapi_delete_files(); - uapi_reboot_device(); + uapi_restore_factory_setting(); } break; case CUSTOM_CMD_MSG_TYPE_STARTOTA: diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.c b/code/sdk/drivers/peripheral/utils/custom_utils.c index 2fce0a257..18b76087b 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.c +++ b/code/sdk/drivers/peripheral/utils/custom_utils.c @@ -1588,33 +1588,25 @@ int removeFilesInFolder(const char *folderPath) return ret; } -void uapi_delete_files(void) +void uapi_delete_files(const char *file_path) { - char *filebuf[2] = {"/system/ConfigModel.json", - "/user/userdata", - }; - - struct stat s_buf; - int ret = 0; - for(int i = 0; i < 2 ; i++) + + if(access(file_path, F_OK) == -1) { - if(access(filebuf[i], F_OK) == -1) - { - PRINT("%s does not exist!!!\r\n", filebuf[i]); - continue; - } - stat(filebuf[i],&s_buf); - if(S_ISDIR(s_buf.st_mode)) - ret = removeFilesInFolder(filebuf[i]); - else - ret = remove(filebuf[i]); - if(ret != 0) - PRINT("%s remove failed !!! \r\n",filebuf[i]); - else - PRINT("%s remove succeed !!! \r\n",filebuf[i]); + PRINT("%s does not exist!!!\r\n", file_path); + return; } + stat(file_path,&s_buf); + if(S_ISDIR(s_buf.st_mode)) + ret = removeFilesInFolder(file_path); + else + ret = remove(file_path); + if(ret != 0) + PRINT("%s remove failed !!! \r\n",file_path); + else + PRINT("%s remove succeed !!! \r\n",file_path); } int uapi_tar_file(const char *src_path,const char *tar_path,char *tarfilename) @@ -1632,11 +1624,8 @@ int uapi_tar_file(const char *src_path,const char *tar_path,char *tarfilename) if(access(src_path, F_OK) == -1) { - if(ret == -1) - { - PRINT("%s does not exist!!!\r\n", src_path); - return -1; - } + PRINT("%s does not exist!!!\r\n", src_path); + return -1; } dir = opendir(src_path); @@ -1732,6 +1721,17 @@ int uapi_save_exc(void) return uapi_tar_file("/user/exc","/user/tar",str); } +void uapi_restore_factory_setting(void) +{ + char *filebuf[2] = {"/system/ConfigModel.json", + "/user/userdata", + }; + for(int i = 0; i < 2; i++) + uapi_delete_files(filebuf[i]); + uapi_reboot_device(); +} + + #include "driver/calendar.h" uint32_t uapi_calendar_store_date(void) diff --git a/code/sdk/drivers/peripheral/utils/custom_utils.h b/code/sdk/drivers/peripheral/utils/custom_utils.h index 46863f55f..d59511514 100644 --- a/code/sdk/drivers/peripheral/utils/custom_utils.h +++ b/code/sdk/drivers/peripheral/utils/custom_utils.h @@ -177,7 +177,8 @@ uint32_t uapi_calendar_store_date(void); errcode_t uapi_custom_cmd_service_init(void); void do_custom_cmd_service_check_msg(int cmd, void *params, int paramlen); -void uapi_delete_files(void); +void uapi_delete_files(const char *file_path); +void uapi_restore_factory_setting(void); void custom_i2c_reset(void); errcode_t custom_i2c_write_reg(uint16_t slaveAddr, uint16_t reg, int regLength, uint8_t *writeData, int writeDataSize, int busIndex); -- 2.17.1