From bb16890d0ba39a8dbd00b328cc4eb130ac44a899 Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Wed, 12 Jun 2024 11:35:40 +0800 Subject: [PATCH] =?utf8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4=E6=96=87?= =?utf8?q?=E4=BB=B6=E9=80=9A=E7=94=A8=E6=8E=A5=E5=8F=A3=EF=BC=8C=E4=BC=98?= =?utf8?q?=E5=8C=96=E8=93=9D=E7=89=99=E4=BA=A7=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../factorytest_protocol.c | 142 +++++++++--------- .../peripheral/cywee/service/cywee_service.c | 6 +- .../peripheral/cywee/src/board_yh601s.c | 4 +- .../peripheral/utils/custom_cmd_service.c | 3 +- .../drivers/peripheral/utils/custom_utils.c | 54 +++---- .../drivers/peripheral/utils/custom_utils.h | 3 +- 6 files changed, 106 insertions(+), 106 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 203ad16af..fafe602d6 100644 --- a/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c +++ b/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c @@ -69,6 +69,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_microhone_timer; +static osTimerId_t g_ble_spk_timer; + static uint32_t aging_time = 0; static int CRC16_XMODEM(uint8_t *bytes,uint16_t length) { @@ -205,6 +208,33 @@ void ble_spo2_check_timer_callback(void) } +void ble_microhone_check_timer_callback(void) +{ + 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, + 0x01, + &send_data, + 1); + +} + +void ble_spk_check_timer_callback(void) +{ + 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, + 0x02, + &send_data, + 1); +} + void aging_task(void) { while(aging_t.flag == 0xfdfd0002 && aging_time) @@ -1060,38 +1090,38 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint } else if(testitem == 0x05) { //灰卡测试 - 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); + 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) { @@ -1433,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 28bab83cf..c55ce092d 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); @@ -381,7 +381,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/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