diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/bt_app_hf.c b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/bt_app_hf.c index 07ee4b07916..b70af4cbcd0 100644 --- a/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/bt_app_hf.c +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_ag/main/bt_app_hf.c @@ -326,11 +326,15 @@ void bt_app_hf_cb(esp_hf_cb_event_t event, esp_hf_cb_param_t *param) } s_time_old = esp_timer_get_time(); esp_hf_ag_register_data_callback(bt_app_hf_incoming_cb, bt_app_hf_outgoing_cb); + /* Disable connectable and discoverable mode to save the over-the-air bandwidth and ensure audio quality */ + esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE); /* Begin send esco data task */ bt_app_send_data(); } else if (param->audio_stat.state == ESP_HF_AUDIO_STATE_DISCONNECTED) { ESP_LOGI(BT_HF_TAG, "--ESP AG Audio Connection Disconnected."); bt_app_send_data_shut_down(); + /* Resume connectable and discoverable mode */ + esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); } #endif /* #if CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI */ break; diff --git a/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/bt_app_hf.c b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/bt_app_hf.c index b023fee78fe..570c51d45cb 100644 --- a/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/bt_app_hf.c +++ b/examples/bluetooth/bluedroid/classic_bt/hfp_hf/main/bt_app_hf.c @@ -332,6 +332,8 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ s_sync_conn_hdl = param->audio_stat.sync_conn_handle; s_audio_buff_queue = xQueueCreate(50, sizeof(esp_hf_audio_buff_t*)); esp_hf_client_register_audio_data_callback(bt_app_hf_client_audio_data_cb); + /* Disable connectable and discoverable mode to save the over-the-air bandwidth and ensure audio quality */ + esp_bt_gap_set_scan_mode(ESP_BT_NON_CONNECTABLE, ESP_BT_NON_DISCOVERABLE); } else if (param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_DISCONNECTED) { s_sync_conn_hdl = 0; s_msbc_air_mode = false; @@ -344,6 +346,8 @@ void bt_app_hf_client_cb(esp_hf_client_cb_event_t event, esp_hf_client_cb_param_ s_audio_buff_queue = NULL; } s_audio_buff_cnt = 0; + /* Resume connectable and discoverable mode */ + esp_bt_gap_set_scan_mode(ESP_BT_CONNECTABLE, ESP_BT_GENERAL_DISCOVERABLE); } #else if (param->audio_stat.state == ESP_HF_CLIENT_AUDIO_STATE_CONNECTED ||