添加删除文件通用接口,优化蓝牙产测 262/2 262/head
authorpenglei <1624952103@qq.com>
Wed, 12 Jun 2024 03:35:40 +0000 (11:35 +0800)
committerpenglei <1624952103@qq.com>
Wed, 12 Jun 2024 03:35:40 +0000 (11:35 +0800)
code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c
code/sdk/drivers/peripheral/cywee/service/cywee_service.c
code/sdk/drivers/peripheral/cywee/src/board_yh601s.c
code/sdk/drivers/peripheral/utils/custom_cmd_service.c
code/sdk/drivers/peripheral/utils/custom_utils.c
code/sdk/drivers/peripheral/utils/custom_utils.h

index 203ad16..fafe602 100644 (file)
@@ -69,6 +69,9 @@ static osTimerId_t g_ble_acc_timer;
 static osTimerId_t g_ble_hrs_timer;\r
 static osTimerId_t g_ble_spo2_timer;\r
 \r
+static osTimerId_t g_ble_microhone_timer;\r
+static osTimerId_t g_ble_spk_timer;\r
+\r
 static uint32_t aging_time = 0;\r
 \r
 static int CRC16_XMODEM(uint8_t *bytes,uint16_t length) {\r
@@ -205,6 +208,33 @@ void ble_spo2_check_timer_callback(void)
 \r
 }\r
 \r
+void ble_microhone_check_timer_callback(void)\r
+{\r
+    uint8_t send_data= 0;\r
+\r
+    uapi_microhone_switch(0);\r
+\r
+    factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+            BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
+            0x01,\r
+            &send_data,\r
+            1);\r
+\r
+}\r
+\r
+void ble_spk_check_timer_callback(void)\r
+{\r
+    uint8_t send_data= 0;\r
+\r
+    uapi_check_spk(0);\r
+\r
+    factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+            BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
+            0x02,\r
+            &send_data,\r
+            1);\r
+}\r
+\r
 void aging_task(void)\r
 {\r
     while(aging_t.flag == 0xfdfd0002 && aging_time)\r
@@ -1060,38 +1090,38 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             } else if(testitem == 0x05)\r
             {\r
                 //灰卡测试\r
-                    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST);\r
-                    FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST);\r
-                    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST);\r
-                    uint8_t databuf[12] = {0};\r
-\r
-                    databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24);\r
-                    databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16);\r
-                    databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8);\r
-                    databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0);\r
-\r
-                    databuf[4] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24);\r
-                    databuf[5] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16);\r
-                    databuf[6] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8);\r
-                    databuf[7] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0);\r
-\r
-                    databuf[8] = (uint8_t)((ft_result.ir_data_final & 0xFF000000) >> 24);\r
-                    databuf[9] = (uint8_t)((ft_result.ir_data_final & 0x00FF0000) >> 16);\r
-                    databuf[10] = (uint8_t)((ft_result.ir_data_final & 0x0000FF00) >> 8);\r
-                    databuf[11] = (uint8_t)((ft_result.ir_data_final & 0x000000FF) >> 0);\r
-\r
-                    PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n",\r
-                    databuf[0],databuf[1],databuf[2],databuf[3],\r
-                    databuf[4],databuf[5],databuf[6],databuf[7],\r
-                    databuf[8],databuf[9],databuf[10],databuf[11]\r
-                    );\r
-\r
-\r
-                    factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
-                                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS,\r
-                                        0x05,\r
-                                        databuf,\r
-                                        12);\r
+                send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_GRAYCARD_TEST);\r
+                FT_RESULTS_t ft_result = hx3695_factroy_test(GRAY_CARD_TEST);\r
+                send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_STOP_PPG_TEST);\r
+                uint8_t databuf[12] = {0};\r
+\r
+                databuf[0] = (uint8_t)((ft_result.gr_data_final & 0xFF000000) >> 24);\r
+                databuf[1] = (uint8_t)((ft_result.gr_data_final & 0x00FF0000) >> 16);\r
+                databuf[2] = (uint8_t)((ft_result.gr_data_final & 0x0000FF00) >> 8);\r
+                databuf[3] = (uint8_t)((ft_result.gr_data_final & 0x000000FF) >> 0);\r
+\r
+                databuf[4] = (uint8_t)((ft_result.red_data_final & 0xFF000000) >> 24);\r
+                databuf[5] = (uint8_t)((ft_result.red_data_final & 0x00FF0000) >> 16);\r
+                databuf[6] = (uint8_t)((ft_result.red_data_final & 0x0000FF00) >> 8);\r
+                databuf[7] = (uint8_t)((ft_result.red_data_final & 0x000000FF) >> 0);\r
+\r
+                databuf[8] = (uint8_t)((ft_result.ir_data_final & 0xFF000000) >> 24);\r
+                databuf[9] = (uint8_t)((ft_result.ir_data_final & 0x00FF0000) >> 16);\r
+                databuf[10] = (uint8_t)((ft_result.ir_data_final & 0x0000FF00) >> 8);\r
+                databuf[11] = (uint8_t)((ft_result.ir_data_final & 0x000000FF) >> 0);\r
+\r
+                PRINT("%2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X %2X\r\n",\r
+                databuf[0],databuf[1],databuf[2],databuf[3],\r
+                databuf[4],databuf[5],databuf[6],databuf[7],\r
+                databuf[8],databuf[9],databuf[10],databuf[11]\r
+                );\r
+\r
+\r
+                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+                                    BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS,\r
+                                    0x05,\r
+                                    databuf,\r
+                                    12);\r
 \r
             } else if(testitem == 0x06)\r
             {\r
@@ -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:\r
             if(testitem == 0x01)\r
             {\r
-                uint8_t send_data= 0;\r
-\r
+                //开始录音\r
+                g_ble_microhone_timer = osTimerNew((osTimerFunc_t)ble_microhone_check_timer_callback, osTimerPeriodic, NULL, NULL);\r
+                osTimerStart(g_ble_microhone_timer,5000);\r
                 uapi_microhone_switch(1);\r
- \r
-                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
-                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
-                        0x01,\r
-                        &send_data,\r
-                        1);\r
-            } else if(testitem == 0x02)\r
-            {\r
 \r
-                uint8_t send_data = 0;\r
-\r
-                uapi_microhone_switch(0);\r
-                \r
-                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
-                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
-                        0x02,\r
-                        &send_data,\r
-                        1);\r
-            } else if(testitem == 0x03)\r
+            } else if(testitem == 0x02)\r
             {\r
-\r
-                uint8_t send_data = 0;\r
-\r
+                //播放录音\r
+                g_ble_microhone_timer = osTimerNew((osTimerFunc_t)ble_spk_check_timer_callback, osTimerPeriodic, NULL, NULL);\r
+                osTimerStart(g_ble_spk_timer,5000);\r
                 uapi_check_spk(1);\r
-                \r
-                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
-                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
-                        0x03,\r
-                        &send_data,\r
-                        1);\r
-            } else if(testitem == 0x04)\r
-            {\r
-\r
-                uint8_t send_data = 0;\r
-\r
-                uapi_check_spk(0);\r
-                \r
-                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
-                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
-                        0x04,\r
-                        &send_data,\r
-                        1);\r
             }\r
             break;\r
 \r
index a337eab..32af17b 100644 (file)
@@ -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);
index 28bab83..c55ce09 100644 (file)
@@ -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);
index ee0be8c..fa390fe 100644 (file)
@@ -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:
index 2fce0a2..18b7608 100644 (file)
@@ -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)
index 46863f5..d595115 100644 (file)
@@ -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);