change(bt/bluedroid): optimized the HFP example workflow to improve audio quality

Disabled inquiry scan and page scan after SCO connection establishment
to reduce over-the-air bandwidth usage and improve audio quality by
prevent scan activities from interrupting SCO traffic.
This commit is contained in:
Jin Cheng
2026-07-30 14:58:21 +08:00
parent c80598ef7f
commit 57963a826d
2 changed files with 8 additions and 0 deletions

View File

@@ -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;

View File

@@ -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 ||