feat(ble/bluedroid): Implement BLE channel map reading API

(cherry picked from commit 55043e280a)

Co-authored-by: zhanghaipeng <zhanghaipeng@espressif.com>
This commit is contained in:
Zhang Hai Peng
2025-04-07 21:14:23 +08:00
parent d47d3230cd
commit 20910df9d6
13 changed files with 242 additions and 1 deletions
@@ -581,6 +581,7 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
#if (BLE_42_FEATURE_SUPPORT == TRUE)
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
{
@@ -929,6 +930,26 @@ esp_err_t esp_gap_ble_set_channels(esp_gap_ble_channels channels)
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_ble_gap_read_channel_map(esp_bd_addr_t bd_addr)
{
if (!bd_addr) {
return ESP_ERR_INVALID_ARG;
}
btc_msg_t msg;
btc_ble_gap_args_t arg;
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_GAP_BLE;
msg.act = BTC_GAP_BLE_READ_CHANNEL_MAP;
memcpy(arg.read_channel_map.bd_addr, bd_addr, ESP_BD_ADDR_LEN);
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL)
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
}
esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize)
{
if (!bd_addr) {
@@ -245,6 +245,7 @@ typedef enum {
ESP_GAP_BLE_SUBRATE_REQUEST_COMPLETE_EVT, /*!< when subrate request command complete, the event comes */
ESP_GAP_BLE_SUBRATE_CHANGE_EVT, /*!< when Connection Subrate Update procedure has completed and some parameters of the specified connection have changed, the event comes */
ESP_GAP_BLE_SET_HOST_FEATURE_CMPL_EVT, /*!< When host feature set complete, the event comes */
ESP_GAP_BLE_READ_CHANNEL_MAP_COMPLETE_EVT, /*!< When BLE channel map result is received, the event comes */
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
} esp_gap_ble_cb_event_t;
@@ -1324,6 +1325,14 @@ typedef union {
if the RSSI cannot be read, the RSSI metric shall be set to 127. */
esp_bd_addr_t remote_addr; /*!< The remote device address */
} read_rssi_cmpl; /*!< Event parameter of ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_READ_CHANNEL_MAP_COMPLETE_EVT
*/
struct ble_read_ble_channel_map_cmpl_evt_param {
esp_bt_status_t status; /*!< Status of the read channel map operation */
uint8_t channel_map[ESP_GAP_BLE_CHANNELS_LEN]; /*!< The BLE channel map, represented as a 5-byte array */
esp_bd_addr_t remote_addr; /*!< The remote device address */
} read_ble_channel_map_cmpl; /*!< Event parameter of ESP_GAP_BLE_READ_CHANNEL_MAP_COMPLETE_EVT */
/**
* @brief ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT
*/
@@ -2194,6 +2203,7 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d
* - other : failed
*/
esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr);
#if (BLE_42_FEATURE_SUPPORT == TRUE)
/**
* @brief This function is called to add a device info into the duplicate scan exceptional list.
@@ -2441,6 +2451,18 @@ esp_err_t esp_ble_get_current_conn_params(esp_bd_addr_t bd_addr, esp_gap_conn_pa
*/
esp_err_t esp_gap_ble_set_channels(esp_gap_ble_channels channels);
/**
* @brief This function is used to read the current channel map
* for the connection identified by remote address.
*
* @param[in] bd_addr : BD address of the peer device
*
* @return - ESP_OK : success
* - other : failed
*
*/
esp_err_t esp_ble_gap_read_channel_map(esp_bd_addr_t bd_addr);
/**
* @brief This function is called to authorized a link after Authentication(MITM protection)
*