Bluetooth Classic
Bluedroid
The following Bluedroid APIs have been changed:
/bt/host/bluedroid/api/include/api/esp_hf_defs.h
Type
esp_hf_wbs_config_tis replaced byesp_hf_codec_mode_t. The new type identifies the negotiated codec (CVSD, mSBC, or LC3-SWB), not a Wideband Speech on/off flag.esp_hf_wbs_config_tis kept as a deprecated alias ofesp_hf_codec_mode_t.Enumerators are renamed. Numeric values 0 / 1 / 2 are unchanged. The old
ESP_HF_WBS_*names remain as macros that alias the new enumerators:
Old enumerator
New enumerator
Value
ESP_HF_WBS_NONE
ESP_HF_CODEC_NONE0
ESP_HF_WBS_NO
ESP_HF_CODEC_CVSD1
ESP_HF_WBS_YES
ESP_HF_CODEC_MSBC2
—
ESP_HF_CODEC_LC33
Existing
switchstatements and comparisons that useESP_HF_WBS_NOorESP_HF_WBS_YESstill compile. Prefer the new names in new code.
ESP_HF_CODEC_NONEmeans no codec has been negotiated, or the preference is reset to the stack default. It does not mean that CVSD is unavailable.ESP_HF_CODEC_CVSDis the selected narrowband codec, whether Wideband Speech is unsupported, disabled, or the link fell back from mSBC / LC3.
ESP_HF_CODEC_LC3is new. Code that indexes a three-entry table with the codec value must add an LC3 entry or a default branch.Do not use
esp_hf_codec_mode_tas a capability bitmap. Peer codec capabilities are reported separately asESP_HF_CODEC_CAP_CVSD/ESP_HF_CODEC_CAP_MSBC/ESP_HF_CODEC_CAP_LC3inESP_HF_BAC_RESPONSE_EVT.Audio connection state
ESP_HF_AUDIO_STATE_CONNECTED_LC3is added for an established LC3-SWB link, alongside the existingESP_HF_AUDIO_STATE_CONNECTED(CVSD) andESP_HF_AUDIO_STATE_CONNECTED_MSBCvalues./bt/host/bluedroid/api/include/api/esp_hf_ag_api.h
esp_hf_ag_set_codec()now takesesp_hf_codec_mode_t. PassESP_HF_CODEC_CVSD,ESP_HF_CODEC_MSBC,ESP_HF_CODEC_LC3, orESP_HF_CODEC_NONEto restore the stack default.
ESP_HF_WBS_RESPONSE_EVT(wbs_rep): fieldcodecis nowesp_hf_codec_mode_t. The field namecodecis unchanged. Astatusfield (esp_bt_status_t) is added to report whether the request succeeded.
ESP_HF_BCS_RESPONSE_EVT(bcs_rep): fieldmodeis nowesp_hf_codec_mode_t. The field namemodeis unchanged.
esp_hf_ag_init()is deprecated. Useesp_hf_ag_init_with_cfg(). The old function still registers both HFP and HSP, which is the same asESP_HF_AG_INIT_CONFIG_DEFAULT().Set
service_masktoESP_HF_AG_SERVICE_HSPto register HSP only, orESP_HF_AG_SERVICE_HFPto register HFP only. A zero mask or any unknown bit returnsESP_ERR_INVALID_ARG. An HSP-only AG advertises Headset Audio Gateway (UUID0x1112). The peer must be an HSP Headset. The Bluedroid HF Client and thehfp_hfexample search only for Hands-Free AG (UUID0x111F) and will not connect.
ESP_HF_CONNECTION_STATE_EVT(conn_stat) addspeer_service. It isESP_HF_AG_SERVICE_HFPorESP_HF_AG_SERVICE_HSPfor the service that opened, and is reported again on SLC connected and disconnect. It is 0 when the open fails. When both services are registered, an outgoing connection can fall back from HFP to HSP, so the initialized mask does not identify the connected service.Call setup, call answer, call reject, call end, volume control, and audio connect or disconnect still apply on an HSP link. While handling those calls the stack may still submit HFP-only results such as indicator reports. Those results are dropped and a warning is logged. Ring and the SCO connection are unchanged.
The following calls apply to an HFP link only. On an HSP link the request is ignored and a warning is logged:
esp_hf_ag_ciev_report(),esp_hf_ag_cind_response(),esp_hf_ag_cops_response(),esp_hf_ag_clcc_response(), andesp_hf_ag_cnum_response().esp_hf_ag_set_codec()is also HFP only. On HSP,ESP_HF_WBS_RESPONSE_EVTreports failure.esp_hf_ag_vra_control()does not send+BVRAon an HSP link or when the peer does not support voice recognition, and a warning is logged. Audio is still connected or disconnected according to the requested state./bt/host/bluedroid/api/include/api/esp_a2dp_api.h
ESP_A2D_MEDIA_CTRL_ACK_EVT(media_ctrl_stat) now includesconn_hdl, the A2DP connection handle of the command being acknowledged.Disconnect and media control can target a connection by handle. The handle is the
conn_hdlreported inESP_A2D_CONNECTION_STATE_EVT. The previous address-based and handle-less APIs remain, and are deprecated:
Deprecated API
Replacement
esp_a2d_sink_disconnect()
esp_a2d_sink_disconnect_by_handle()
esp_a2d_source_disconnect()
esp_a2d_source_disconnect_by_handle()
esp_a2d_media_ctrl()
esp_a2d_media_ctrl_by_handle()A handle that does not match the active A2DP connection is not applied. Media control reports
ESP_A2D_MEDIA_CTRL_ACK_FAILURE. Disconnect is ignored./bt/host/bluedroid/api/include/api/esp_avrc_api.h
The
*_by_handleAVRCP Controller send APIs accept transaction labels0throughESP_USER_AVRC_TRANS_LABEL_MAX(13). Labels14and15are reserved for the stack (A2DP sink active-device Play/Pause). Passing 14 or 15 to those APIs returnsESP_ERR_INVALID_ARG. The deprecated send APIs still accept0throughESP_AVRC_TRANS_LABEL_MAX(15).Suggested replacements:
// Before esp_hf_ag_set_codec(bda, ESP_HF_WBS_YES); if (param->bcs_rep.mode == ESP_HF_WBS_NO) { /* CVSD */ } // After esp_hf_ag_set_codec(bda, ESP_HF_CODEC_MSBC); if (param->bcs_rep.mode == ESP_HF_CODEC_CVSD) { /* CVSD */ } else if (param->bcs_rep.mode == ESP_HF_CODEC_LC3) { /* LC3-SWB */ } // Before esp_hf_ag_init(); // After: both services, same as the deprecated function esp_hf_ag_cfg_t cfg = ESP_HF_AG_INIT_CONFIG_DEFAULT(); esp_hf_ag_init_with_cfg(&cfg); // After: HSP only cfg.service_mask = ESP_HF_AG_SERVICE_HSP; esp_hf_ag_init_with_cfg(&cfg);