Merge branch 'feat/support_read_periodic_adv_size' into 'master'

feat(ble/bluedroid): Support read periodic advertiser list size command

Closes IDF-11793

See merge request espressif/esp-idf!36751
This commit is contained in:
Island 2025-03-05 15:07:32 +08:00
commit bcea8c9881
15 changed files with 133 additions and 3 deletions

View File

@ -1502,6 +1502,17 @@ esp_err_t esp_ble_gap_periodic_adv_clear_dev(void)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); == 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) #endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE)
#if (BLE_50_EXTEND_SCAN_EN == TRUE) #if (BLE_50_EXTEND_SCAN_EN == TRUE)

View File

@ -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); 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 * @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_1m_conn_params,
const esp_ble_gap_conn_params_t *phy_2m_conn_params, const esp_ble_gap_conn_params_t *phy_2m_conn_params,
const esp_ble_gap_conn_params_t *phy_coded_conn_params); const esp_ble_gap_conn_params_t *phy_coded_conn_params);
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE) #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

View File

@ -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) #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)) #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) static void btc_ble_dtm_stop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback)
{ {

View File

@ -463,6 +463,9 @@ typedef union {
void btc_gap_ble_call_handler(btc_msg_t *msg); void btc_gap_ble_call_handler(btc_msg_t *msg);
void btc_gap_ble_cb_handler(btc_msg_t *msg); void btc_gap_ble_cb_handler(btc_msg_t *msg);
void btc_get_whitelist_size(uint16_t *length); 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_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_arg_deep_free(btc_msg_t *msg);
void btc_gap_ble_cb_deep_free(btc_msg_t *msg); void btc_gap_ble_cb_deep_free(btc_msg_t *msg);

View File

@ -86,6 +86,9 @@ typedef struct {
#if (BLE_50_EXTEND_ADV_EN == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE)
uint16_t ble_ext_adv_data_max_len; uint16_t ble_ext_adv_data_max_len;
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
} controller_local_param_t; } controller_local_param_t;
@ -283,6 +286,12 @@ static void start_up(void)
&controller_param.ble_ext_adv_data_max_len); &controller_param.ble_ext_adv_data_max_len);
} }
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // (BLE_50_FEATURE_SUPPORT == TRUE && BLE_42_FEATURE_SUPPORT == FALSE)
if (HCI_LE_DATA_LEN_EXT_SUPPORTED(controller_param.features_ble.as_array)) { 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; return controller_param.ble_ext_adv_data_max_len;
} }
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
static uint8_t get_sco_data_size(void) static uint8_t get_sco_data_size(void)
@ -587,6 +604,9 @@ static const controller_t interface = {
#if (BLE_50_EXTEND_ADV_EN == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE)
ble_get_ext_adv_data_max_len, ble_get_ext_adv_data_max_len,
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)
get_sco_data_size, get_sco_data_size,

View File

@ -84,6 +84,9 @@ typedef struct controller_t {
#if (BLE_50_EXTEND_ADV_EN == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE)
uint16_t (*ble_get_ext_adv_data_max_len)(void); uint16_t (*ble_get_ext_adv_data_max_len)(void);
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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 #endif // BLE_50_FEATURE_SUPPORT
#if (BTM_SCO_HCI_INCLUDED == TRUE) #if (BTM_SCO_HCI_INCLUDED == TRUE)

View File

@ -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); return make_command_no_params(HCI_BLE_RD_MAX_ADV_DATA_LEN);
} }
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
// Internal functions // Internal functions
@ -277,6 +283,9 @@ static const hci_packet_factory_t interface = {
#if (BLE_50_EXTEND_ADV_EN == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE)
make_read_max_adv_data_len, make_read_max_adv_data_len,
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
make_ble_read_suggested_default_data_length, make_ble_read_suggested_default_data_length,
make_ble_write_suggested_default_data_length, make_ble_write_suggested_default_data_length,

View File

@ -222,7 +222,21 @@ static void parse_ble_read_adv_max_len_response(
} }
osi_free(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) #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) #if (BLE_50_EXTEND_ADV_EN == TRUE)
parse_ble_read_adv_max_len_response, parse_ble_read_adv_max_len_response,
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
parse_ble_read_suggested_default_data_length_response parse_ble_read_suggested_default_data_length_response
}; };

View File

@ -48,6 +48,9 @@ typedef struct {
#if (BLE_50_EXTEND_ADV_EN == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE)
BT_HDR *(*make_read_max_adv_data_len)(void); BT_HDR *(*make_read_max_adv_data_len)(void);
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
BT_HDR *(*make_ble_read_suggested_default_data_length)(void); 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); BT_HDR *(*make_ble_write_suggested_default_data_length)(uint16_t SuggestedMaxTxOctets, uint16_t SuggestedMaxTxTime);

View File

@ -101,6 +101,12 @@ typedef struct {
uint16_t *ble_ext_adv_data_max_len_ptr uint16_t *ble_ext_adv_data_max_len_ptr
); );
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
void (*parse_ble_read_suggested_default_data_length_response)( void (*parse_ble_read_suggested_default_data_length_response)(
BT_HDR *response, BT_HDR *response,

View File

@ -2222,6 +2222,18 @@ void BTM_BleGetWhiteListSize(uint16_t *length)
*length = p_cb->white_list_avail_size; *length = p_cb->white_list_avail_size;
return; 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 #endif ///BLE_INCLUDED == TRUE
#if (BLE_HOST_READ_TX_POWER_EN == TRUE) #if (BLE_HOST_READ_TX_POWER_EN == TRUE)

View File

@ -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; 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 ** Function btm_ble_add_2_white_list_complete

View File

@ -199,6 +199,9 @@ static void reset_complete(void)
if (controller->supports_ble()) { if (controller->supports_ble()) {
btm_ble_white_list_init(controller->get_ble_white_list_size()); 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()); l2c_link_processs_ble_num_bufs(controller->get_acl_buffer_count_ble());
} }
#endif #endif

View File

@ -353,6 +353,10 @@ typedef struct {
tBTM_BLE_SEL_CBACK *p_select_cback; tBTM_BLE_SEL_CBACK *p_select_cback;
/* white list information */ /* white list information */
UINT8 white_list_avail_size; 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_UPDATE_WHITELIST_CBACK *update_wl_cb;
tBTM_BLE_WL_STATE wl_state; 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_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_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_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) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)

View File

@ -3049,7 +3049,9 @@ tBTM_STATUS BTM_BleReadAdvTxPower(tBTM_CMPL_CB *p_cb);
void BTM_BleGetWhiteListSize(uint16_t *length); 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 ** Function BTM_ReadLinkQuality