Merge #262 into sdk602patch0521 from refs/changes/262/head 263/target/1
author彭磊 <1624952103@qq.com>
Wed, 12 Jun 2024 03:41:36 +0000 (03:41 +0000)
committersnickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Wed, 12 Jun 2024 03:41:36 +0000 (03:41 +0000)
优化蓝牙产测,解决表盘指南针校准不过的问题

* refs/changes/262/head: (2 commits squashed)

  - 优化蓝牙产测,解决表盘指南针校准不过的问题

  - 添加删除文件通用接口,优化蓝牙产测

Signed-off-by: aliyun6865282430 <1624952103@qq.com>
Reviewed-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
Merged-by: snickersun@163.com <accounts_62b90f7fcf51ade33b6f628e@mail.teambition.com>
link: https://codeup.aliyun.com/64191456b9581d62e8f81ac0/FD230/change/262
code/sdk/application/wearable/fd230app/nativeui/compass/src/CompassControlView.cpp
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/mag/mmc5603/mmc5603_main.c
code/sdk/drivers/peripheral/mag/service/mag_service.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 71dcefc..3121836 100644 (file)
@@ -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);
index af5956d..fafe602 100644 (file)
@@ -68,11 +68,9 @@ static osTimerId_t g_ble_acc_timer;
 \r
 static osTimerId_t g_ble_hrs_timer;\r
 static osTimerId_t g_ble_spo2_timer;\r
-static osTimerId_t g_ble_graycard_timer;\r
-static osTimerId_t g_ble_leaklight_timer;\r
 \r
-static uint8_t graycard_flag = 0;\r
-static uint8_t leaklight_flag = 0;\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
@@ -210,91 +208,31 @@ void ble_spo2_check_timer_callback(void)
 \r
 }\r
 \r
-void ble_graycard_check_timer_callback(void)\r
+void ble_microhone_check_timer_callback(void)\r
 {\r
-    if(graycard_flag == 10)\r
-    {\r
-        graycard_flag = 0;\r
-        osTimerStop(g_ble_graycard_timer);\r
-        osTimerDelete(g_ble_graycard_timer);\r
-        return;\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
+    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_HRS,\r
-                        0x05,\r
-                        databuf,\r
-                        12);\r
-    graycard_flag++;\r
+            BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
+            0x01,\r
+            &send_data,\r
+            1);\r
+\r
 }\r
 \r
-void ble_leaklight_check_timer_callback(void)\r
+void ble_spk_check_timer_callback(void)\r
 {\r
-    if(leaklight_flag == 10)\r
-    {\r
-        leaklight_flag = 0;\r
-        osTimerStop(g_ble_leaklight_timer);\r
-        osTimerDelete(g_ble_leaklight_timer);\r
-        return;\r
-    }\r
-    send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST);\r
-    FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_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
+    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_HRS,\r
-                        0x06,\r
-                        databuf,\r
-                        12);\r
-    leaklight_flag++;\r
+            BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
+            0x02,\r
+            &send_data,\r
+            1);\r
 }\r
 \r
 void aging_task(void)\r
@@ -1152,14 +1090,73 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
             } else if(testitem == 0x05)\r
             {\r
                 //灰卡测试\r
-                g_ble_graycard_timer = osTimerNew((osTimerFunc_t)ble_graycard_check_timer_callback, osTimerPeriodic, NULL, NULL);\r
-                osTimerStart(g_ble_graycard_timer,400);\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
                 //漏光测试\r
-                g_ble_leaklight_timer = osTimerNew((osTimerFunc_t)ble_leaklight_check_timer_callback, osTimerPeriodic, NULL, NULL);\r
-                osTimerStart(g_ble_leaklight_timer,400);\r
+                send_ppg_cmd_msg(PPG_SERVICE_CMD_TYPE_DO_LEAKLIGHT_TEST);\r
+                FT_RESULTS_t ft_result = hx3695_factroy_test(LEAK_LIGHT_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
+                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+                                    BLE_TEST_CMD_SOFT_TEST_SUB_MODE_HRS,\r
+                                    0x06,\r
+                                    databuf,\r
+                                    12);\r
 \r
             }\r
             break;\r
@@ -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:\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 fdee522..e57ec0c 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);
@@ -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);
index 3a3751a..d0b3fed 100644 (file)
@@ -436,7 +436,7 @@ int mag_service_get_iAccuracy(void)
 \r
 int mmc5603_stop(void)\r
 {\r
-       SavePara_infile(saveData,4);\r
+       SavePara_infile(g_MagPara,4);\r
        MMC5603_Disable();\r
        return 0;\r
 }\r
index 23ed1d9..ca426e3 100644 (file)
@@ -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;
     
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);