mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
Merge branch 'feat/support_adv_monitor_for_bluedroid_host_v6.0' into 'release/v6.0'
feat(ble/bluedroid): support adv monitor feature (6.0) See merge request espressif/esp-idf!47038
This commit is contained in:
@@ -1821,6 +1821,98 @@ esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr,
|
||||
|
||||
}
|
||||
|
||||
#if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
esp_err_t esp_ble_gap_add_monitor_adv_list(const esp_ble_gap_add_monitor_adv_params_t *params)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_5_gap_args_t arg;
|
||||
memset(&arg, 0, sizeof(arg));
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (params == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ADD_MONITOR_ADV_LIST;
|
||||
arg.add_monitor_adv_list.addr_type = params->addr_type;
|
||||
memcpy(arg.add_monitor_adv_list.addr, params->addr, sizeof(esp_bd_addr_t));
|
||||
arg.add_monitor_adv_list.rssi_low = params->rssi_low;
|
||||
arg.add_monitor_adv_list.rssi_high = params->rssi_high;
|
||||
arg.add_monitor_adv_list.timeout = params->timeout;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_remove_monitor_adv_list(const esp_ble_gap_remove_monitor_adv_params_t *params)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_5_gap_args_t arg;
|
||||
memset(&arg, 0, sizeof(arg));
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if (params == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_RMV_MONITOR_ADV_LIST;
|
||||
arg.rmv_monitor_adv_list.addr_type = params->addr_type;
|
||||
memcpy(arg.rmv_monitor_adv_list.addr, params->addr, sizeof(esp_bd_addr_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_clear_monitor_adv_list(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
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_CLEAR_MONITOR_ADV_LIST;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_read_monitor_adv_list_size(void)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
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_MONITOR_ADV_LIST_SIZE;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_enable_monitor_adv(bool enable)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_5_gap_args_t arg;
|
||||
memset(&arg, 0, sizeof(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_ENABLE_MONITOR_ADV;
|
||||
arg.enable_monitor_adv.enable = enable ? 1 : 0;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
|
||||
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2015-2026 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -267,6 +267,12 @@ typedef enum {
|
||||
ESP_GAP_BLE_CS_CONFIG_CMPL_EVT, /*!< When CS has completed the Channel Sounding Configuration procedure, the event comes */
|
||||
ESP_GAP_BLE_CS_SUBEVENT_RESULT_EVT, /*!< When CS has results to report for a CS subevent during the CS procedure, the event comes */
|
||||
ESP_GAP_BLE_CS_SUBEVENT_RESULT_CONTINUE_EVT, /*!< When CS has completed a new CS subevent measurement, the event comes */
|
||||
ESP_GAP_BLE_MONITOR_ADV_REPORT_EVT, /*!< When LE monitor advertisement report (RSSI threshold etc), the event comes */
|
||||
ESP_GAP_BLE_ADD_MONITOR_ADV_COMPLETE_EVT, /*!< When add monitor advertiser complete, the event comes */
|
||||
ESP_GAP_BLE_REMOVE_MONITOR_ADV_COMPLETE_EVT, /*!< When remove monitor advertiser complete, the event comes */
|
||||
ESP_GAP_BLE_CLEAR_MONITOR_ADV_COMPLETE_EVT, /*!< When clear monitor advertiser list complete, the event comes */
|
||||
ESP_GAP_BLE_READ_MONITOR_ADV_LIST_SIZE_COMPLETE_EVT, /*!< When read monitor advertiser list size complete, the event comes */
|
||||
ESP_GAP_BLE_ENABLE_MONITOR_ADV_COMPLETE_EVT, /*!< When enable/disable monitor advertising complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
@@ -1212,6 +1218,27 @@ typedef struct {
|
||||
} esp_ble_gap_past_params_t;
|
||||
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
#if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
/**
|
||||
* @brief Parameters for adding a device to the LE Monitor Advertisers list
|
||||
*/
|
||||
typedef struct {
|
||||
esp_ble_addr_type_t addr_type; /*!< Address type of the advertiser */
|
||||
esp_bd_addr_t addr; /*!< Device address of the advertiser to monitor */
|
||||
int8_t rssi_low; /*!< Low threshold of RSSI (dBm). Report when RSSI goes at or below this value */
|
||||
int8_t rssi_high; /*!< High threshold of RSSI (dBm). Report when RSSI goes at or above this value */
|
||||
uint8_t timeout; /*!< Monitor timeout: 0 = no timeout; 1–0xFF = timeout in seconds */
|
||||
} esp_ble_gap_add_monitor_adv_params_t;
|
||||
|
||||
/**
|
||||
* @brief Parameters for removing a device from the LE Monitor Advertisers list
|
||||
*/
|
||||
typedef struct {
|
||||
esp_ble_addr_type_t addr_type; /*!< Address type of the advertiser */
|
||||
esp_bd_addr_t addr; /*!< Device address of the advertiser to remove from the monitor list */
|
||||
} esp_ble_gap_remove_monitor_adv_params_t;
|
||||
#endif // (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
|
||||
typedef enum {
|
||||
ESP_BLE_NETWORK_PRIVACY_MODE = 0X00, /*!< Network Privacy Mode for peer device (default) */
|
||||
ESP_BLE_DEVICE_PRIVACY_MODE = 0X01, /*!< Device Privacy Mode for peer device */
|
||||
@@ -2124,6 +2151,47 @@ typedef union {
|
||||
esp_ble_addr_type_t scan_addr_type; /*!< scanner address type */
|
||||
esp_bd_addr_t scan_addr; /*!< scanner address */
|
||||
} scan_req_received; /*!< Event parameter of ESP_GAP_BLE_SCAN_REQ_RECEIVED_EVT */
|
||||
#if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_MONITOR_ADV_REPORT_EVT
|
||||
*/
|
||||
struct ble_monitor_adv_report_param {
|
||||
esp_ble_addr_type_t addr_type; /*!< address type */
|
||||
esp_bd_addr_t addr; /*!< advertiser address */
|
||||
uint8_t condition; /*!< RSSI threshold condition (e.g. entered/left range) */
|
||||
} monitor_adv_report; /*!< Event parameter of ESP_GAP_BLE_MONITOR_ADV_REPORT_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ADD_MONITOR_ADV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_add_monitor_adv_cmpl_param {
|
||||
esp_bt_status_t status; /*!< Indicate add monitor advertiser operation success status */
|
||||
} add_monitor_adv; /*!< Event parameter of ESP_GAP_BLE_ADD_MONITOR_ADV_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_REMOVE_MONITOR_ADV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_remove_monitor_adv_cmpl_param {
|
||||
esp_bt_status_t status; /*!< Indicate remove monitor advertiser operation success status */
|
||||
} remove_monitor_adv; /*!< Event parameter of ESP_GAP_BLE_REMOVE_MONITOR_ADV_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_CLEAR_MONITOR_ADV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_clear_monitor_adv_cmpl_param {
|
||||
esp_bt_status_t status; /*!< Indicate clear monitor advertiser list operation success status */
|
||||
} clear_monitor_adv; /*!< Event parameter of ESP_GAP_BLE_CLEAR_MONITOR_ADV_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_READ_MONITOR_ADV_LIST_SIZE_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_read_monitor_adv_list_size_cmpl_param {
|
||||
esp_bt_status_t status; /*!< Indicate read monitor advertiser list size operation success status */
|
||||
uint8_t list_size; /*!< Monitor advertiser list capacity */
|
||||
} read_monitor_adv_list_size; /*!< Event parameter of ESP_GAP_BLE_READ_MONITOR_ADV_LIST_SIZE_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_ENABLE_MONITOR_ADV_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_enable_monitor_adv_cmpl_param {
|
||||
esp_bt_status_t status; /*!< Indicate enable/disable monitor advertising operation success status */
|
||||
} enable_monitor_adv; /*!< Event parameter of ESP_GAP_BLE_ENABLE_MONITOR_ADV_COMPLETE_EVT */
|
||||
#endif
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_CHANNEL_SELECT_ALGORITHM_EVT
|
||||
*/
|
||||
@@ -3901,6 +3969,65 @@ 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);
|
||||
|
||||
#if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
/**
|
||||
* @brief This function is used to add a single device to the list of Monitored Advertisers in the Controller.
|
||||
* When the Controller receives advertising that matches the address and meets the RSSI threshold condition,
|
||||
* it will send an LE Monitor Advertising Report event (ESP_GAP_BLE_MONITOR_ADV_REPORT_EVT).
|
||||
*
|
||||
* @param[in] params : Pointer to parameters (addr_type, addr, rssi_low, rssi_high, timeout). Reserved fields allow future extension.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_add_monitor_adv_list(const esp_ble_gap_add_monitor_adv_params_t *params);
|
||||
|
||||
/**
|
||||
* @brief This function is used to remove one device from the list of Monitored Advertisers in the Controller.
|
||||
* Removals take effect immediately.
|
||||
*
|
||||
* @param[in] params : Pointer to parameters (addr_type, addr). Reserved fields allow future extension.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_remove_monitor_adv_list(const esp_ble_gap_remove_monitor_adv_params_t *params);
|
||||
|
||||
/**
|
||||
* @brief This function is used to remove all devices from the list of Monitored Advertisers in the Controller.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_clear_monitor_adv_list(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to read the capacity of the list of Monitored Advertisers in the Controller.
|
||||
* The HCI command is sent asynchronously; the list size is reported via command complete if needed.
|
||||
*
|
||||
* @return - ESP_OK : success (command sent)
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_read_monitor_adv_list_size(void);
|
||||
|
||||
/**
|
||||
* @brief This function is used to enable or disable the reporting of LE Monitor Advertising Report events.
|
||||
* When enabled, the Controller will generate ESP_GAP_BLE_MONITOR_ADV_REPORT_EVT when advertising
|
||||
* from devices in the monitor list meets the configured RSSI threshold condition.
|
||||
*
|
||||
* @param[in] enable : true to enable monitor advertising reports, false to disable
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_enable_monitor_adv(bool enable);
|
||||
#endif // #if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
|
||||
Reference in New Issue
Block a user