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 9f5a1f5853..278b3bd9d1 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -1502,6 +1502,17 @@ esp_err_t esp_ble_gap_periodic_adv_clear_dev(void) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } + +esp_err_t esp_ble_gap_get_periodic_list_size(uint8_t *size) +{ + if (size == NULL) { + return ESP_FAIL; + } + btc_get_periodic_list_size(size); + + return ESP_OK; +} + #endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #if (BLE_50_EXTEND_SCAN_EN == 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 748c34c2ca..59c1e1e9fd 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 @@ -2593,6 +2593,17 @@ esp_err_t esp_ble_gap_periodic_adv_remove_dev_from_list(esp_ble_addr_type_t addr */ esp_err_t esp_ble_gap_periodic_adv_clear_dev(void); +/** + * @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); + /** * @brief This function is used to set aux connection parameters * @@ -2611,7 +2622,6 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, const esp_ble_gap_conn_params_t *phy_1m_conn_params, const esp_ble_gap_conn_params_t *phy_2m_conn_params, const esp_ble_gap_conn_params_t *phy_coded_conn_params); - #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 c4cbdc0a1d..5a54f33b67 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 @@ -1594,6 +1594,13 @@ static void btc_ble_dtm_enhance_rx_start(uint8_t rx_channel, uint8_t phy, uint8_ } #endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) +void btc_get_periodic_list_size(uint8_t *size) +{ + BTM_BleGetPeriodicAdvListSize(size); + return; +} +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == 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 d3829aa2e0..988b234205 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 @@ -463,6 +463,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_EXTEND_SYNC_EN == TRUE) +void btc_get_periodic_list_size(uint8_t *length); +#endif //#if (BLE_50_EXTEND_SYNC_EN == 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 d745bcba0c..ded9356943 100644 --- a/components/bt/host/bluedroid/device/controller.c +++ b/components/bt/host/bluedroid/device/controller.c @@ -86,6 +86,9 @@ typedef struct { #if (BLE_50_EXTEND_ADV_EN == TRUE) uint16_t ble_ext_adv_data_max_len; #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + uint16_t get_ble_periodic_advertiser_list_size; +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) } controller_local_param_t; @@ -283,6 +286,12 @@ static void start_up(void) &controller_param.ble_ext_adv_data_max_len); } #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + response = AWAIT_COMMAND(controller_param.packet_factory->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 // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #endif // (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE) if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) { @@ -525,6 +534,14 @@ static uint16_t ble_get_ext_adv_data_max_len(void) return controller_param.ble_ext_adv_data_max_len; } #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) +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_EXTEND_SYNC_EN == TRUE) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE) static uint8_t get_sco_data_size(void) @@ -587,6 +604,9 @@ static const controller_t interface = { #if (BLE_50_EXTEND_ADV_EN == TRUE) ble_get_ext_adv_data_max_len, #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + get_ble_periodic_adv_list_size, +#endif // (BLE_50_EXTEND_SYNC_EN == TRUE) #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 b515d17f8b..6345d7a9c9 100644 --- a/components/bt/host/bluedroid/device/include/device/controller.h +++ b/components/bt/host/bluedroid/device/include/device/controller.h @@ -84,6 +84,9 @@ typedef struct controller_t { #if (BLE_50_EXTEND_ADV_EN == TRUE) uint16_t (*ble_get_ext_adv_data_max_len)(void); #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + uint8_t (*get_ble_periodic_adv_list_size)(void); +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #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 5b037b0a8e..5649a9f6c1 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_factory.c +++ b/components/bt/host/bluedroid/hci/hci_packet_factory.c @@ -226,6 +226,12 @@ static BT_HDR *make_read_max_adv_data_len(void) return make_command_no_params(HCI_BLE_RD_MAX_ADV_DATA_LEN); } #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) +static BT_HDR *read_periodic_adv_list_size(void) +{ + return make_command_no_params(HCI_BLE_RD_PERIOD_ADV_LIST_SIZE); +} +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) // Internal functions @@ -277,6 +283,9 @@ static const hci_packet_factory_t interface = { #if (BLE_50_EXTEND_ADV_EN == TRUE) make_read_max_adv_data_len, #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + read_periodic_adv_list_size, +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #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 0a39276b6f..58660fddd2 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_parser.c +++ b/components/bt/host/bluedroid/hci/hci_packet_parser.c @@ -222,7 +222,21 @@ static void parse_ble_read_adv_max_len_response( } osi_free(response); } -#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE +#if (BLE_50_EXTEND_SYNC_EN == TRUE) +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_EXTEND_SYNC_EN == TRUE) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) @@ -287,6 +301,9 @@ static const hci_packet_parser_t interface = { #if (BLE_50_EXTEND_ADV_EN == TRUE) parse_ble_read_adv_max_len_response, #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + parse_ble_read_periodic_adv_list_size_response, +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #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 49b9602ee1..4c6e837714 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 @@ -48,6 +48,9 @@ typedef struct { #if (BLE_50_EXTEND_ADV_EN == TRUE) BT_HDR *(*make_read_max_adv_data_len)(void); #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + BT_HDR *(*read_periodic_adv_list_size)(void); +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #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 40d0f4f2f0..bba1ceed48 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 @@ -101,6 +101,12 @@ typedef struct { uint16_t *ble_ext_adv_data_max_len_ptr ); #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) + void (*parse_ble_read_periodic_adv_list_size_response) ( + BT_HDR *response, + uint16_t *periodic_advertiser_list_size + ); +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #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 b241c68238..7f308f3752 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_acl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_acl.c @@ -2222,6 +2222,18 @@ void BTM_BleGetWhiteListSize(uint16_t *length) *length = p_cb->white_list_avail_size; return; } + +#if (BLE_50_EXTEND_SYNC_EN == 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_EXTEND_SYNC_EN == TRUE) + #endif ///BLE_INCLUDED == TRUE #if (BLE_HOST_READ_TX_POWER_EN == 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 a84ca571cb..9d08c042be 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_EXTEND_SYNC_EN == 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_EXTEND_SYNC_EN == TRUE) + /******************************************************************************* ** ** Function btm_ble_add_2_white_list_complete diff --git a/components/bt/host/bluedroid/stack/btm/btm_devctl.c b/components/bt/host/bluedroid/stack/btm/btm_devctl.c index 3125ee775e..95c2baa565 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_devctl.c @@ -199,6 +199,9 @@ static void reset_complete(void) if (controller->supports_ble()) { btm_ble_white_list_init(controller->get_ble_white_list_size()); + #if (BLE_50_EXTEND_SYNC_EN == TRUE) + btm_ble_periodic_adv_list_init(controller->get_ble_periodic_adv_list_size()); + #endif //#if (BLE_50_EXTEND_SYNC_EN == 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 49f9ff8353..91693b1624 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_EXTEND_SYNC_EN == TRUE) + /* periodic list information */ + UINT8 periodic_adv_list_size; +#endif //#if (BLE_50_EXTEND_SYNC_EN == TRUE) tBTM_UPDATE_WHITELIST_CBACK *update_wl_cb; tBTM_BLE_WL_STATE wl_state; @@ -552,6 +556,9 @@ 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); +#if (BLE_50_EXTEND_SYNC_EN == TRUE) +void btm_ble_periodic_adv_list_init(UINT8 periodic_adv_size); +#endif //#if (BLE_50_EXTEND_SYNC_EN == TRUE) #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 8e51118f58..c501fafd70 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_api.h @@ -3049,7 +3049,9 @@ tBTM_STATUS BTM_BleReadAdvTxPower(tBTM_CMPL_CB *p_cb); void BTM_BleGetWhiteListSize(uint16_t *length); - +#if (BLE_50_EXTEND_SYNC_EN == TRUE) +void BTM_BleGetPeriodicAdvListSize(uint8_t *size); +#endif //#if (BLE_50_EXTEND_SYNC_EN == TRUE) /******************************************************************************* ** ** Function BTM_ReadLinkQuality