diff --git a/components/bt/host/bluedroid/api/esp_gap_ble_api.c b/components/bt/host/bluedroid/api/esp_gap_ble_api.c index fa5d3c1a1d..435148b203 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1620,6 +1620,18 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, } +esp_err_t esp_ble_gap_get_periodic_list_size(uint8_t *size) +{ + if (size == NULL) { + return ESP_FAIL; + } + + ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED); + + btc_get_periodic_list_size(size); + + return ESP_OK; +} #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) diff --git a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h index f51aad1223..69d1ca59f3 100644 --- a/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h +++ b/components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h @@ -2610,6 +2610,17 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, const esp_ble_gap_conn_params_t *phy_2m_conn_params, const esp_ble_gap_conn_params_t *phy_coded_conn_params); +/** + * @brief Retrieve the capacity of the periodic advertiser list in the controller. + * + * @param[out] size: Pointer to a variable where the capacity of the periodic advertiser list will be stored. + * + * @return + * - ESP_OK : Success + * - Others : Failure + */ +esp_err_t esp_ble_gap_get_periodic_list_size(uint8_t *size); + #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) diff --git a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c index c412f44b33..c937be9f14 100644 --- a/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c +++ b/components/bt/host/bluedroid/btc/profile/std/gap/btc_gap_ble.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1584,6 +1584,13 @@ static void btc_ble_dtm_enhance_rx_start(uint8_t rx_channel, uint8_t phy, uint8_ BTA_DmBleDtmEnhRxStart(rx_channel, phy, modulation_index, p_dtm_cmpl_cback); } + +void btc_get_periodic_list_size(uint8_t *size) +{ + BTM_BleGetPeriodicAdvListSize(size); + return; +} + #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) static void btc_ble_dtm_stop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) diff --git a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h index aa279657cb..55209e0e45 100644 --- a/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h +++ b/components/bt/host/bluedroid/btc/profile/std/include/btc_gap_ble.h @@ -446,6 +446,9 @@ typedef union { void btc_gap_ble_call_handler(btc_msg_t *msg); void btc_gap_ble_cb_handler(btc_msg_t *msg); void btc_get_whitelist_size(uint16_t *length); +#if (BLE_50_FEATURE_SUPPORT == TRUE) +void btc_get_periodic_list_size(uint8_t *length); +#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src); void btc_gap_ble_arg_deep_free(btc_msg_t *msg); void btc_gap_ble_cb_deep_free(btc_msg_t *msg); diff --git a/components/bt/host/bluedroid/device/controller.c b/components/bt/host/bluedroid/device/controller.c index 70e528fe8c..2e4fd9d3ba 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -83,6 +83,7 @@ typedef struct { bool secure_connections_supported; #if (BLE_50_FEATURE_SUPPORT == TRUE) uint16_t ble_ext_adv_data_max_len; + uint16_t get_ble_periodic_advertiser_list_size; #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) } controller_local_param_t; @@ -277,6 +278,10 @@ static void start_up(void) response, &controller_param.ble_ext_adv_data_max_len); } + response = AWAIT_COMMAND(controller_param.packet_factory->make_read_periodic_adv_list_size()); + controller_param.packet_parser->parse_ble_read_periodic_adv_list_size_response( + response, + &controller_param.get_ble_periodic_advertiser_list_size); #endif // (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE) if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) { @@ -517,6 +522,12 @@ static uint16_t ble_get_ext_adv_data_max_len(void) return controller_param.ble_ext_adv_data_max_len; } +static uint8_t get_ble_periodic_adv_list_size(void) +{ + assert(controller_param.readable); + assert(controller_param.ble_supported); + return controller_param.get_ble_periodic_advertiser_list_size; +} #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE) static uint8_t get_sco_data_size(void) @@ -577,6 +588,7 @@ static const controller_t interface = { set_ble_resolving_list_max_size, #if (BLE_50_FEATURE_SUPPORT == TRUE) ble_get_ext_adv_data_max_len, + get_ble_periodic_adv_list_size, #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE) get_sco_data_size, diff --git a/components/bt/host/bluedroid/device/include/device/controller.h b/components/bt/host/bluedroid/device/include/device/controller.h index 6fc766f305..93d0cd5e4b 100644 --- a/components/bt/host/bluedroid/device/include/device/controller.h +++ b/components/bt/host/bluedroid/device/include/device/controller.h @@ -82,6 +82,7 @@ typedef struct controller_t { #if (BLE_50_FEATURE_SUPPORT == TRUE) uint16_t (*ble_get_ext_adv_data_max_len)(void); + uint8_t (*get_ble_periodic_adv_list_size)(void); #endif // BLE_50_FEATURE_SUPPORT #if (BTM_SCO_HCI_INCLUDED == TRUE) diff --git a/components/bt/host/bluedroid/hci/hci_packet_factory.c b/components/bt/host/bluedroid/hci/hci_packet_factory.c index 5010e99d2f..f4a3da9d46 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_factory.c +++ b/components/bt/host/bluedroid/hci/hci_packet_factory.c @@ -223,6 +223,12 @@ static BT_HDR *make_read_max_adv_data_len(void) { return make_command_no_params(HCI_BLE_RD_MAX_ADV_DATA_LEN); } + +static BT_HDR *make_read_periodic_adv_list_size(void) +{ + return make_command_no_params(HCI_BLE_RD_PERIOD_ADV_LIST_SIZE); +} + #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) // Internal functions @@ -270,6 +276,7 @@ static const hci_packet_factory_t interface = { make_ble_read_resolving_list_size, #if (BLE_50_FEATURE_SUPPORT == TRUE) make_read_max_adv_data_len, + make_read_periodic_adv_list_size, #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) make_ble_read_suggested_default_data_length, make_ble_write_suggested_default_data_length, diff --git a/components/bt/host/bluedroid/hci/hci_packet_parser.c b/components/bt/host/bluedroid/hci/hci_packet_parser.c index d25caf3506..990dde4756 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_parser.c +++ b/components/bt/host/bluedroid/hci/hci_packet_parser.c @@ -221,6 +221,19 @@ static void parse_ble_read_adv_max_len_response( } osi_free(response); } + +static void parse_ble_read_periodic_adv_list_size_response( + BT_HDR *response, + uint16_t *periodic_adv_list_size_ptr) +{ + + uint8_t *stream = read_command_complete_header(response, HCI_BLE_RD_PERIOD_ADV_LIST_SIZE, 1 /* bytes after */); + if (stream) { + // Size: 1 Octets ; Value: 0x01 to 0xFF ; Total number of Periodic Advertiser list entries that can be stored in the Controller + STREAM_TO_UINT8(*periodic_adv_list_size_ptr, stream); + } + osi_free(response); +} #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) @@ -283,6 +296,7 @@ static const hci_packet_parser_t interface = { parse_ble_read_resolving_list_size_response, #if (BLE_50_FEATURE_SUPPORT == TRUE) parse_ble_read_adv_max_len_response, + parse_ble_read_periodic_adv_list_size_response, #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) parse_ble_read_suggested_default_data_length_response }; diff --git a/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h b/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h index c1580fd85c..aebabbf4f8 100644 --- a/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h +++ b/components/bt/host/bluedroid/hci/include/hci/hci_packet_factory.h @@ -44,6 +44,7 @@ typedef struct { BT_HDR *(*make_ble_read_resolving_list_size)(void); #if (BLE_50_FEATURE_SUPPORT == TRUE) BT_HDR *(*make_read_max_adv_data_len)(void); + BT_HDR *(*make_read_periodic_adv_list_size)(void); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) BT_HDR *(*make_ble_read_suggested_default_data_length)(void); BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime); diff --git a/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h b/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h index e46acc174a..0d54b75f76 100644 --- a/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h +++ b/components/bt/host/bluedroid/hci/include/hci/hci_packet_parser.h @@ -96,9 +96,13 @@ typedef struct { ); #if (BLE_50_FEATURE_SUPPORT == TRUE) void (*parse_ble_read_adv_max_len_response) ( - BT_HDR *respone, + BT_HDR *response, uint16_t *ble_ext_adv_data_max_len_ptr ); + void (*parse_ble_read_periodic_adv_list_size_response) ( + BT_HDR *response, + uint16_t *periodic_advertiser_list_size + ); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) void (*parse_ble_read_suggested_default_data_length_response)( BT_HDR *response, diff --git a/components/bt/host/bluedroid/stack/btm/btm_acl.c b/components/bt/host/bluedroid/stack/btm/btm_acl.c index 93ca1062fa..1ecfc1ec65 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_acl.c @@ -2218,6 +2218,18 @@ void BTM_BleGetWhiteListSize(uint16_t *length) *length = p_cb->white_list_avail_size; return; } + +#if (BLE_50_FEATURE_SUPPORT == TRUE) +void BTM_BleGetPeriodicAdvListSize(uint8_t *size) +{ + tBTM_BLE_CB *p_cb = &btm_cb.ble_ctr_cb; + if (p_cb->periodic_adv_list_size == 0) { + BTM_TRACE_WARNING("%s Periodic Adv list is full.", __func__); + } + *size = p_cb->periodic_adv_list_size; +} +#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) + #endif ///BLE_INCLUDED == TRUE /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c index 4cb282b79a..1c356c0ac4 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -423,6 +423,23 @@ void btm_ble_white_list_init(UINT8 white_list_size) btm_cb.ble_ctr_cb.white_list_avail_size = white_list_size; } +#if (BLE_50_FEATURE_SUPPORT == TRUE) +/******************************************************************************* +** +** Function btm_ble_periodic_adv_list_init +** +** Description Initialize the periodic advertiser list size. +** +** Parameters periodic_adv_size: The size of the periodic advertiser list to be initialized. +** +*******************************************************************************/ +void btm_ble_periodic_adv_list_init(UINT8 periodic_adv_size) +{ + BTM_TRACE_DEBUG("%s white_list_size = %d", __func__, periodic_adv_size); + btm_cb.ble_ctr_cb.periodic_adv_list_size = periodic_adv_size; +} +#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) + /******************************************************************************* ** ** Function btm_ble_add_2_white_list_complete @@ -724,7 +741,7 @@ void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state) static void btm_wl_update_to_controller(void) { /* whitelist will be added in the btm_ble_resume_bg_conn(), we do not - support background connection now, so we nedd to use btm_execute_wl_dev_operation + support background connection now, so we need to use btm_execute_wl_dev_operation to add whitelist directly ,if we support background connection in the future, please delete btm_execute_wl_dev_operation(). */ btm_execute_wl_dev_operation(); diff --git a/components/bt/host/bluedroid/stack/btm/btm_devctl.c b/components/bt/host/bluedroid/stack/btm/btm_devctl.c index 5b1d93fb5b..04308378ec 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_devctl.c @@ -191,6 +191,9 @@ static void reset_complete(void) if (controller->supports_ble()) { btm_ble_white_list_init(controller->get_ble_white_list_size()); + #if (BLE_50_FEATURE_SUPPORT == TRUE) + btm_ble_periodic_adv_list_init(controller->get_ble_periodic_adv_list_size()); + #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) l2c_link_processs_ble_num_bufs(controller->get_acl_buffer_count_ble()); } #endif diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h index 7defaeba79..92ce47b2f0 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_ble_int.h @@ -353,6 +353,10 @@ typedef struct { tBTM_BLE_SEL_CBACK *p_select_cback; /* white list information */ UINT8 white_list_avail_size; +#if (BLE_50_FEATURE_SUPPORT == TRUE) + /* periodic list information */ + UINT8 periodic_adv_list_size; +#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb; tBTM_BLE_WL_STATE wl_state; @@ -541,6 +545,7 @@ void btm_ble_channel_select_algorithm_evt(tBTM_BLE_CHANNEL_SEL_ALG *params); void btm_ble_periodic_adv_report_evt(tBTM_PERIOD_ADV_REPORT *params); void btm_ble_periodic_adv_sync_lost_evt(tBTM_BLE_PERIOD_ADV_SYNC_LOST *params); void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *params); +void btm_ble_periodic_adv_list_init(UINT8 periodic_adv_size); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_api.h index bc040dc4c1..4d2a9ab4f3 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_api.h @@ -2949,7 +2949,9 @@ tBTM_STATUS BTM_BleReadAdvTxPower(tBTM_CMPL_CB *p_cb); void BTM_BleGetWhiteListSize(uint16_t *length); - +#if (BLE_50_FEATURE_SUPPORT == TRUE) +void BTM_BleGetPeriodicAdvListSize(uint8_t *size); +#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) /******************************************************************************* ** ** Function BTM_ReadLinkQuality