优化272蓝牙产测HFP A2DP测试 2819/target/2 2822/1 2822/head
authorpenglei <1624952103@qq.com>
Fri, 28 Nov 2025 12:40:20 +0000 (20:40 +0800)
committerpenglei <1624952103@qq.com>
Fri, 28 Nov 2025 12:40:20 +0000 (20:40 +0800)
code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp
code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c
code/sdk/zhihui/utilscpp/custom_utilscpp.cpp

index 810a315..7389473 100644 (file)
@@ -84,9 +84,9 @@ namespace OHOS
                 {
                     if (it->second == "HFP")
                     {
-                        ConfigModel::GetInstance()->SetHFPState(true);
+                        ConfigModel::GetInstance()->SetHFPState(true);//需要同时开启
 #ifdef CUSTOM_ZHIHUI
-                        uapi_hfp_connect();
+                        uapi_hfp_connect();//需要同时开启
 #endif
                         classicBlueToothView->init_connect_timer(BluetoothServiceOptionsView::CONNECT_HFP);
                     }
index a3471b0..7a72beb 100644 (file)
@@ -2,7 +2,7 @@
  * @Author: penglei 1624952103@qq.com\r
  * @Date: 2024-06-17 14:31:08\r
  * @LastEditors: penglei 1624952103@qq.com\r
- * @LastEditTime: 2025-11-19 10:43:10\r
+ * @LastEditTime: 2025-11-28 20:32:34\r
  * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c\r
  * @Description: \r
  * \r
@@ -65,6 +65,8 @@
 #include "hp4570.h"\r
 #endif\r
 \r
+#include "ConfigModelC.h"\r
+\r
 #ifdef SUPPORT_GNSS\r
 #include "gnss_ctl.h"\r
 #include "NMEA0183.h"\r
@@ -76,6 +78,9 @@ static char *g_gps_tmp_buffer = NULL;
 static char *g_gps_time_buffer = NULL;\r
 #endif\r
 \r
+static osTimerId_t g_bt_conn_timer = NULL;\r
+static uint8_t g_bt_conn_cnt = 0;\r
+\r
 #ifdef ENABLE_BN02\r
 #include "bp_ble_service.h"\r
 #endif\r
@@ -220,6 +225,49 @@ void ble_acc_check_timer_callback(void)
             6);\r
 }\r
 \r
+static void bt_connect_timer_callback(void *argument)\r
+{\r
+    printf("bt_connect_timer_callback \n");\r
+    if(argument == NULL)\r
+        return;\r
+\r
+    uint32_t conn_type = (uint32_t)argument;\r
+    printf("conn_type : %d\n", conn_type);\r
+\r
+    g_bt_conn_cnt++;\r
+    if(g_bt_conn_cnt >= 10)\r
+    {\r
+        g_bt_conn_cnt = 0;\r
+        osTimerStop(g_bt_conn_timer);\r
+        return;\r
+    }\r
+\r
+    if(conn_type == 1) \r
+    {\r
+        printf("uapi_hfp_connect_state:%d\n",uapi_hfp_connect_state());\r
+        if(uapi_hfp_connect_state())\r
+        {\r
+            g_bt_conn_cnt = 0;\r
+            osTimerStop(g_bt_conn_timer);\r
+            return;\r
+        }\r
+        cm_set_HFP_switch(1);\r
+        uapi_hfp_connect();\r
+    }\r
+    else if(conn_type == 2)\r
+    {\r
+        printf("uapi_a2dp_snk_get_device_connect_state:%d\n",uapi_a2dp_snk_get_device_connect_state());\r
+        if(uapi_a2dp_snk_get_device_connect_state())\r
+        {\r
+            g_bt_conn_cnt = 0;\r
+            osTimerStop(g_bt_conn_timer);\r
+            return;\r
+        }\r
+        cm_set_A2DP_switch(1);\r
+        uapi_a2dp_snk_connect();\r
+    }\r
+}\r
+\r
 #ifdef SUPPORT_GNSS\r
 void gps_test_timer_callback(void)\r
 {\r
@@ -756,9 +804,13 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t
                 0x01,\r
                 &send_data,\r
                 1);\r
-                uapi_hfp_connect_();\r
+\r
+                cm_set_HFP_switch(1);\r
+                cm_set_A2DP_switch(1);\r
+\r
+                uapi_hfp_connect();\r
                 LOS_Msleep(500);\r
-                uapi_a2dp_snk_connect_();\r
+                uapi_a2dp_snk_connect();\r
             } else if (testitem == 0x02)\r
             {\r
     \r
@@ -2365,15 +2417,41 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint
                         1);\r
             }\r
 \r
-            if (testitem == 0x06)\r
+            else if (testitem == 0x06)\r
             {\r
                 uint8_t send_data = 0x00;\r
-                uapi_hfp_connect_();\r
-                LOS_Msleep(500);\r
-                uapi_a2dp_snk_connect_();\r
+\r
+                if(g_bt_conn_timer == NULL)\r
+                {\r
+                    g_bt_conn_timer = osTimerNew((osTimerFunc_t)bt_connect_timer_callback, osTimerPeriodic, (void *)1, NULL);\r
+                }\r
+                if(g_bt_conn_timer != NULL)\r
+                {\r
+                    osTimerStart(g_bt_conn_timer, 500);\r
+                }\r
+\r
                 factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
                         BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
-                        0x03,\r
+                        0x06,\r
+                        &send_data,\r
+                        1);\r
+            }\r
+            else if (testitem == 0x07)\r
+            {\r
+                uint8_t send_data = 0x00;\r
+\r
+                if(g_bt_conn_timer == NULL)\r
+                {\r
+                    g_bt_conn_timer = osTimerNew((osTimerFunc_t)bt_connect_timer_callback, osTimerPeriodic, (void *)2, NULL);\r
+                }\r
+                if(g_bt_conn_timer != NULL)\r
+                {\r
+                    osTimerStart(g_bt_conn_timer, 500);\r
+                }\r
+\r
+                factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST,\r
+                        BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER,\r
+                        0x07,\r
                         &send_data,\r
                         1);\r
             }\r
index 1ca63ea..bc7395d 100644 (file)
@@ -509,6 +509,8 @@ int custom_play_audio(const char* filePath, float volume)
         // 不返回错误,音量设置失败不应该阻止播放
     }
     
+    // player->SetLoop(true); // 设置是否循环播放
+
     // 开始播放
     printf("Starting playback...\n");
     if (!player->Play()) {