mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +03:00
feat(ble/bluedroid): add DBAF host support (Core 6.0)
This commit is contained in:
@@ -1957,6 +1957,72 @@ esp_err_t esp_ble_gap_enable_monitor_adv(bool enable)
|
||||
}
|
||||
#endif // #if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
|
||||
#if (BLE_FEAT_DBAF == TRUE)
|
||||
esp_err_t esp_ble_gap_set_decision_data(const esp_ble_gap_set_decision_data_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;
|
||||
}
|
||||
if (params->data_len > ESP_BLE_GAP_DECISION_DATA_MAX_LEN) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (params->data_len > 0 && params->data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_SET_DECISION_DATA;
|
||||
arg.set_decision_data.adv_handle = params->adv_handle;
|
||||
arg.set_decision_data.decision_type_flags = params->decision_type_flags;
|
||||
arg.set_decision_data.data_len = params->data_len;
|
||||
arg.set_decision_data.data = (uint8_t *)params->data;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t),
|
||||
btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_decision_instructions(const esp_ble_gap_set_decision_instructions_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;
|
||||
}
|
||||
if (params->num_tests == 0 || params->num_tests > ESP_BLE_GAP_DECISION_MAX_TESTS) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (params->test_flags == NULL || params->test_fields == NULL || params->test_params == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_SET_DECISION_INSTRUCTIONS;
|
||||
arg.set_decision_instructions.num_tests = params->num_tests;
|
||||
arg.set_decision_instructions.test_flags = (uint8_t *)params->test_flags;
|
||||
arg.set_decision_instructions.test_fields = (uint8_t *)params->test_fields;
|
||||
arg.set_decision_instructions.test_params = (uint8_t *)params->test_params;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t),
|
||||
btc_gap_ble_arg_deep_copy, btc_gap_ble_arg_deep_free)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif // #if (BLE_FEAT_DBAF == TRUE)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
@@ -2608,6 +2674,7 @@ esp_err_t esp_ble_cs_security_enable(uint16_t conn_handle)
|
||||
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_cs_set_default_settings(esp_ble_cs_set_default_settings_params *default_setting_params)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
@@ -273,6 +273,8 @@ typedef enum {
|
||||
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_SET_DECISION_DATA_COMPLETE_EVT, /*!< When set decision data complete, the event comes */
|
||||
ESP_GAP_BLE_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT, /*!< When set decision instructions complete, the event comes */
|
||||
ESP_GAP_BLE_EVT_MAX, /*!< when maximum advertising event complete, the event comes */
|
||||
} esp_gap_ble_cb_event_t;
|
||||
|
||||
@@ -296,6 +298,7 @@ typedef uint8_t esp_gap_ble_channels[ESP_GAP_BLE_CHANNELS_LEN];
|
||||
*
|
||||
* - Advertising interval: unit is 0.625ms (range: 20ms to 10240ms)
|
||||
* - Connection interval: unit is 1.25ms (range: 7.5ms to 4000ms)
|
||||
* - Connection rate interval (Core 6.2 SCI): unit is 125us (range: 375us), see ESP_BLE_GAP_CONN_RATE_*
|
||||
* - Scan interval/window: unit is 0.625ms
|
||||
* - Periodic advertising interval: unit is 1.25ms
|
||||
* - Supervision timeout: unit is 10ms (range: 100ms to 32000ms)
|
||||
@@ -1254,6 +1257,42 @@ typedef struct {
|
||||
} esp_ble_gap_remove_monitor_adv_params_t;
|
||||
#endif // (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
|
||||
#if (BLE_FEAT_DBAF == TRUE)
|
||||
#define ESP_BLE_GAP_DECISION_DATA_MAX_LEN 248
|
||||
#define ESP_BLE_GAP_DECISION_MAX_TESTS 8
|
||||
#define ESP_BLE_GAP_DECISION_TEST_PARAM_LEN 16
|
||||
#define ESP_BLE_GAP_DECISION_TEST_PARAMS_MAX_LEN (ESP_BLE_GAP_DECISION_MAX_TESTS * ESP_BLE_GAP_DECISION_TEST_PARAM_LEN)
|
||||
#define ESP_BLE_GAP_DECISION_TYPE_FLAG_RESOLVABLE_TAG (1 << 0)
|
||||
|
||||
#define ESP_BLE_GAP_DECISION_SCAN_FILTER_NO_DECISIONS 0x00
|
||||
#define ESP_BLE_GAP_DECISION_SCAN_FILTER_ALL_PDUS 0x04
|
||||
#define ESP_BLE_GAP_DECISION_SCAN_FILTER_DECISIONS_ONLY 0x0C
|
||||
|
||||
/**
|
||||
* @brief Parameters for setting decision data for an advertising set (DBAF)
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t adv_handle; /*!< Advertising set handle */
|
||||
uint8_t decision_type_flags; /*!< Decision type flags (e.g. ESP_BLE_GAP_DECISION_TYPE_FLAG_RESOLVABLE_TAG) */
|
||||
uint8_t data_len; /*!< Length of decision data, max: ESP_BLE_GAP_DECISION_DATA_MAX_LEN */
|
||||
const uint8_t *data; /*!< Pointer to decision data */
|
||||
} esp_ble_gap_set_decision_data_params_t;
|
||||
|
||||
/**
|
||||
* @brief Parameters for setting decision instructions for decision-based advertising filtering (DBAF)
|
||||
*/
|
||||
typedef struct {
|
||||
uint8_t num_tests; /*!< Number of decision tests, max: ESP_BLE_GAP_DECISION_MAX_TESTS */
|
||||
const uint8_t *test_flags; /*!< Pointer to test flags array (num_tests octets) */
|
||||
const uint8_t *test_fields; /*!< Pointer to test fields array (num_tests octets) */
|
||||
const uint8_t *test_params; /*!< Pointer to test parameters (num_tests * ESP_BLE_GAP_DECISION_TEST_PARAM_LEN octets) */
|
||||
} esp_ble_gap_set_decision_instructions_params_t;
|
||||
#endif // #if (BLE_FEAT_DBAF == 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 */
|
||||
@@ -1551,6 +1590,7 @@ typedef enum {
|
||||
/** Reflector role is enabled */
|
||||
#define ESP_BLE_CS_REFLECTOR_ROLE_ENABLED (1 << 1)
|
||||
|
||||
|
||||
/**
|
||||
* @brief CS set default settings parameters
|
||||
*/
|
||||
@@ -2207,6 +2247,20 @@ typedef union {
|
||||
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
|
||||
#if (BLE_FEAT_DBAF == TRUE)
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_DECISION_DATA_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_set_decision_data_cmpl_param {
|
||||
esp_bt_status_t status; /*!< Indicate set decision data operation success status */
|
||||
} set_decision_data; /*!< Event parameter of ESP_GAP_BLE_SET_DECISION_DATA_COMPLETE_EVT */
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT
|
||||
*/
|
||||
struct ble_set_decision_instructions_cmpl_param {
|
||||
esp_bt_status_t status; /*!< Indicate set decision instructions operation success status */
|
||||
} set_decision_instructions; /*!< Event parameter of ESP_GAP_BLE_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT */
|
||||
#endif // #if (BLE_FEAT_DBAF == TRUE)
|
||||
/**
|
||||
* @brief ESP_GAP_BLE_CHANNEL_SELECT_ALGORITHM_EVT
|
||||
*/
|
||||
@@ -4068,6 +4122,34 @@ esp_err_t esp_ble_gap_read_monitor_adv_list_size(void);
|
||||
*/
|
||||
esp_err_t esp_ble_gap_enable_monitor_adv(bool enable);
|
||||
#endif // #if (BLE_FEAT_ADV_MONITOR == TRUE)
|
||||
|
||||
#if (BLE_FEAT_DBAF == TRUE)
|
||||
/**
|
||||
* @brief Set decision data for an advertising set (DBAF).
|
||||
*
|
||||
* @param[in] params : Pointer to decision data parameters.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_decision_data(const esp_ble_gap_set_decision_data_params_t *params);
|
||||
|
||||
/**
|
||||
* @brief Set decision instructions for decision-based advertising filtering (DBAF).
|
||||
*
|
||||
* @param[in] params : Pointer to decision instructions parameters.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gap_set_decision_instructions(const esp_ble_gap_set_decision_instructions_params_t *params);
|
||||
#endif // #if (BLE_FEAT_DBAF == TRUE)
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
@@ -4425,11 +4507,17 @@ esp_err_t esp_ble_gap_set_default_subrate(esp_ble_default_subrate_param_t *defau
|
||||
*/
|
||||
esp_err_t esp_ble_gap_subrate_request(esp_ble_subrate_req_param_t *subrate_req_params);
|
||||
|
||||
/** Host Feature Set bit position: Channel Sounding Host Support (Bluetooth Core, bit 47) */
|
||||
#define ESP_BLE_HOST_FEATURE_CS_HOST_SUPPORT 47
|
||||
|
||||
/**
|
||||
* @brief This function is called to set host feature.
|
||||
*
|
||||
* @param[in] bit_num: the bit position in the FeatureSet.
|
||||
* @param[in] bit_val: the feature is enabled or disabled
|
||||
* @param[in] bit_num: the bit position in the FeatureSet (e.g. ESP_BLE_HOST_FEATURE_CS_HOST_SUPPORT).
|
||||
* @param[in] bit_val: 0x00 to disable, 0x01 to enable Host support for the feature
|
||||
*
|
||||
* @note Channel Sounding Host APIs require CS Host Support enabled first:
|
||||
* esp_ble_gap_set_host_feature(ESP_BLE_HOST_FEATURE_CS_HOST_SUPPORT, 1).
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK : success
|
||||
@@ -4533,6 +4621,7 @@ esp_err_t esp_ble_cs_write_cached_remote_supported_capabilities(esp_ble_cs_write
|
||||
*/
|
||||
esp_err_t esp_ble_cs_security_enable(uint16_t conn_handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is used to set default CS settings in the local Controller
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user