From 6c9456115846a142c2b054cc6eca9883702635ff Mon Sep 17 00:00:00 2001 From: penglei <1624952103@qq.com> Date: Fri, 28 Nov 2025 20:40:20 +0800 Subject: [PATCH] =?utf8?q?=E4=BC=98=E5=8C=96272=E8=93=9D=E7=89=99=E4=BA=A7?= =?utf8?q?=E6=B5=8BHFP=20A2DP=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../src/BluetoothServiceOptionsPresenter.cpp | 4 +- .../factorytest_protocol.c | 94 +++++++++++++++++-- code/sdk/zhihui/utilscpp/custom_utilscpp.cpp | 2 + 3 files changed, 90 insertions(+), 10 deletions(-) diff --git a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp index 810a315e2..73894734b 100644 --- a/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp +++ b/code/sdk/application/wearable/fd272/nativeapp/nativeui/classicbluetooth/src/BluetoothServiceOptionsPresenter.cpp @@ -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); } diff --git a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c index a3471b0bf..7a72beb10 100644 --- a/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c +++ b/code/sdk/zhihui/services/factorytest_service/factorytest_protocol.c @@ -2,7 +2,7 @@ * @Author: penglei 1624952103@qq.com * @Date: 2024-06-17 14:31:08 * @LastEditors: penglei 1624952103@qq.com - * @LastEditTime: 2025-11-19 10:43:10 + * @LastEditTime: 2025-11-28 20:32:34 * @FilePath: /FD230/code/sdk/application/wearable/service/factorytest_service/factorytest_protocol.c * @Description: * @@ -65,6 +65,8 @@ #include "hp4570.h" #endif +#include "ConfigModelC.h" + #ifdef SUPPORT_GNSS #include "gnss_ctl.h" #include "NMEA0183.h" @@ -76,6 +78,9 @@ static char *g_gps_tmp_buffer = NULL; static char *g_gps_time_buffer = NULL; #endif +static osTimerId_t g_bt_conn_timer = NULL; +static uint8_t g_bt_conn_cnt = 0; + #ifdef ENABLE_BN02 #include "bp_ble_service.h" #endif @@ -220,6 +225,49 @@ void ble_acc_check_timer_callback(void) 6); } +static void bt_connect_timer_callback(void *argument) +{ + printf("bt_connect_timer_callback \n"); + if(argument == NULL) + return; + + uint32_t conn_type = (uint32_t)argument; + printf("conn_type : %d\n", conn_type); + + g_bt_conn_cnt++; + if(g_bt_conn_cnt >= 10) + { + g_bt_conn_cnt = 0; + osTimerStop(g_bt_conn_timer); + return; + } + + if(conn_type == 1) + { + printf("uapi_hfp_connect_state:%d\n",uapi_hfp_connect_state()); + if(uapi_hfp_connect_state()) + { + g_bt_conn_cnt = 0; + osTimerStop(g_bt_conn_timer); + return; + } + cm_set_HFP_switch(1); + uapi_hfp_connect(); + } + else if(conn_type == 2) + { + printf("uapi_a2dp_snk_get_device_connect_state:%d\n",uapi_a2dp_snk_get_device_connect_state()); + if(uapi_a2dp_snk_get_device_connect_state()) + { + g_bt_conn_cnt = 0; + osTimerStop(g_bt_conn_timer); + return; + } + cm_set_A2DP_switch(1); + uapi_a2dp_snk_connect(); + } +} + #ifdef SUPPORT_GNSS void gps_test_timer_callback(void) { @@ -756,9 +804,13 @@ void factorytest_protocol_common_decode(uint8_t submode,uint8_t testitem,uint8_t 0x01, &send_data, 1); - uapi_hfp_connect_(); + + cm_set_HFP_switch(1); + cm_set_A2DP_switch(1); + + uapi_hfp_connect(); LOS_Msleep(500); - uapi_a2dp_snk_connect_(); + uapi_a2dp_snk_connect(); } else if (testitem == 0x02) { @@ -2365,15 +2417,41 @@ void factorytest_protocol_soft_test_decode(uint8_t submode,uint8_t testitem,uint 1); } - if (testitem == 0x06) + else if (testitem == 0x06) { uint8_t send_data = 0x00; - uapi_hfp_connect_(); - LOS_Msleep(500); - uapi_a2dp_snk_connect_(); + + if(g_bt_conn_timer == NULL) + { + g_bt_conn_timer = osTimerNew((osTimerFunc_t)bt_connect_timer_callback, osTimerPeriodic, (void *)1, NULL); + } + if(g_bt_conn_timer != NULL) + { + osTimerStart(g_bt_conn_timer, 500); + } + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, - 0x03, + 0x06, + &send_data, + 1); + } + else if (testitem == 0x07) + { + uint8_t send_data = 0x00; + + if(g_bt_conn_timer == NULL) + { + g_bt_conn_timer = osTimerNew((osTimerFunc_t)bt_connect_timer_callback, osTimerPeriodic, (void *)2, NULL); + } + if(g_bt_conn_timer != NULL) + { + osTimerStart(g_bt_conn_timer, 500); + } + + factorytest_protocol_replymsg(BLE_TEST_CMD_MODE_SOFT_TEST, + BLE_TEST_CMD_SOFT_TEST_SUB_MODE_SPEAKER, + 0x07, &send_data, 1); } diff --git a/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp b/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp index 1ca63ea1a..bc7395d6f 100644 --- a/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp +++ b/code/sdk/zhihui/utilscpp/custom_utilscpp.cpp @@ -509,6 +509,8 @@ int custom_play_audio(const char* filePath, float volume) // 不返回错误,音量设置失败不应该阻止播放 } + // player->SetLoop(true); // 设置是否循环播放 + // 开始播放 printf("Starting playback...\n"); if (!player->Play()) { -- 2.17.1