diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index 957abd0aefc..36c7e2d499c 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -1517,7 +1517,6 @@ config BT_BLE_FEAT_CHANNEL_SOUNDING default n help Enable BLE channel sounding - config BT_BLE_FEAT_ADV_MONITOR bool "Enable BLE Advertising Monitor (LE Monitor Advertisement)" depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_ADV_MONITOR_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR @@ -1527,6 +1526,14 @@ config BT_BLE_FEAT_ADV_MONITOR Allows the host to add devices to a monitor list and receive reports when the controller detects advertising from those devices (e.g. RSSI threshold). +config BT_BLE_FEAT_DBAF + bool "Enable BLE Decision-Based Advertising Filtering (DBAF)" + depends on (BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_BLE_DBAF_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR + default n + help + Enable Decision-Based Advertising Filtering (Bluetooth Core 6.0). + Supports LE Set Decision Data and LE Set Decision Instructions HCI commands. + menuconfig BT_BLE_42_FEATURES_SUPPORTED bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)" depends on BT_BLE_ENABLED 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 9ac5a99b3bc..c818357b1ff 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -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}; 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 3b4e10f9847..2ffa4ad4341 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 @@ -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 * diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c index 3f3308c1757..78f7ad41f42 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -5984,6 +5984,28 @@ void bta_dm_ble_gap_enable_monitor_adv(tBTA_DM_MSG *p_data) } #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +void bta_dm_ble_gap_set_decision_data(tBTA_DM_MSG *p_data) +{ + BTM_BleSetDecisionData(p_data->ble_set_decision_data.adv_handle, + p_data->ble_set_decision_data.decision_type_flags, + p_data->ble_set_decision_data.data_len, + p_data->ble_set_decision_data.data); +} + +void bta_dm_ble_gap_set_decision_instructions(tBTA_DM_MSG *p_data) +{ + BTM_BleSetDecisionInstructions(p_data->ble_set_decision_instructions.num_tests, + p_data->ble_set_decision_instructions.test_flags, + p_data->ble_set_decision_instructions.test_fields, + p_data->ble_set_decision_instructions.test_params); +} +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + #if (BLE_FEAT_ISO_EN == TRUE) #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE) void bta_dm_ble_big_create(tBTA_DM_MSG *p_data) @@ -6316,6 +6338,7 @@ void bta_dm_api_cs_procedure_enable(tBTA_DM_MSG *p_data) } #endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE) && SDP_INCLUDED == TRUE) #ifndef BTA_DM_GATT_CLOSE_DELAY_TOUT #define BTA_DM_GATT_CLOSE_DELAY_TOUT 1000 diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c index d9eba75854f..171a5db2b0a 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -2647,6 +2647,7 @@ void BTA_DmBleGapCsProcEnable(uint16_t conn_handle, uint8_t config_id, uint8_t e #endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + /******************************************************************************* ** ** Function BTA_VendorInit @@ -3258,6 +3259,57 @@ void BTA_DmBleGapEnableMonitorAdv(UINT8 enable) } #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +void BTA_DmBleGapSetDecisionData(UINT8 adv_handle, UINT8 decision_type_flags, + UINT8 data_len, const UINT8 *p_data) +{ + tBTA_DM_API_SET_DECISION_DATA *p_msg; + APPL_TRACE_API("%s", __func__); + if ((p_msg = (tBTA_DM_API_SET_DECISION_DATA *) osi_malloc(sizeof(tBTA_DM_API_SET_DECISION_DATA))) != NULL) { + memset(p_msg, 0, sizeof(tBTA_DM_API_SET_DECISION_DATA)); + p_msg->hdr.event = BTA_DM_API_SET_DECISION_DATA_EVT; + p_msg->adv_handle = adv_handle; + p_msg->decision_type_flags = decision_type_flags; + p_msg->data_len = data_len; + if (data_len > 0 && p_data != NULL) { + memcpy(p_msg->data, p_data, data_len); + } + bta_sys_sendmsg(p_msg); + } else { + APPL_TRACE_ERROR("%s malloc failed", __func__); + } +} + +void BTA_DmBleGapSetDecisionInstructions(UINT8 num_tests, const UINT8 *test_flags, + const UINT8 *test_fields, const UINT8 *test_params) +{ + tBTA_DM_API_SET_DECISION_INSTRUCTIONS *p_msg; + APPL_TRACE_API("%s", __func__); + if ((p_msg = (tBTA_DM_API_SET_DECISION_INSTRUCTIONS *) osi_malloc(sizeof(tBTA_DM_API_SET_DECISION_INSTRUCTIONS))) != NULL) { + memset(p_msg, 0, sizeof(tBTA_DM_API_SET_DECISION_INSTRUCTIONS)); + p_msg->hdr.event = BTA_DM_API_SET_DECISION_INSTRUCTIONS_EVT; + p_msg->num_tests = num_tests; + if (num_tests > 0 && test_flags != NULL) { + memcpy(p_msg->test_flags, test_flags, num_tests); + } + if (num_tests > 0 && test_fields != NULL) { + memcpy(p_msg->test_fields, test_fields, num_tests); + } + if (num_tests > 0 && test_params != NULL) { + memcpy(p_msg->test_params, test_params, num_tests * BLE_DECISION_TEST_PARAM_LEN); + } + bta_sys_sendmsg(p_msg); + } else { + APPL_TRACE_ERROR("%s malloc failed", __func__); + } +} +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + + #if (BLE_FEAT_ISO_EN == TRUE) #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE) void BTA_DmBleGapIsoBigCreate(tBTA_DM_BLE_BIG_CREATE_PARAMS *p_big_creat_param) diff --git a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c index 5b7461120df..d78523e76de 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -328,6 +328,10 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_api_cs_set_procedure_params, /* BTA_DM_API_CS_SET_PROCEDURE_PARAMS */ bta_dm_api_cs_procedure_enable, /* BTA_DM_API_CS_PROCEDURE_ENABLE */ #endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + bta_dm_ble_gap_set_decision_data, /* BTA_DM_API_SET_DECISION_DATA_EVT */ + bta_dm_ble_gap_set_decision_instructions, /* BTA_DM_API_SET_DECISION_INSTRUCTIONS_EVT */ +#endif // #if (BLE_FEAT_DBAF == TRUE) }; diff --git a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h index 5a759a7417a..cc77f834a84 100644 --- a/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h +++ b/components/bt/host/bluedroid/bta/dm/include/bta_dm_int.h @@ -322,6 +322,10 @@ enum { BTA_DM_API_CS_SET_PROCEDURE_PARAMS, BTA_DM_API_CS_PROCEDURE_ENABLE, #endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + BTA_DM_API_SET_DECISION_DATA_EVT, + BTA_DM_API_SET_DECISION_INSTRUCTIONS_EVT, +#endif // #if (BLE_FEAT_DBAF == TRUE) BTA_DM_MAX_EVT }; @@ -1204,6 +1208,7 @@ typedef struct { UINT8 config_id; UINT8 enable; } tBTA_DM_API_CS_PROC_ENABLE_PARAMS; + #endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) #endif /* BLE_INCLUDED */ @@ -1377,6 +1382,28 @@ typedef struct { } tBTA_DM_API_ENABLE_MONITOR_ADV; #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +typedef struct { + BT_HDR hdr; + UINT8 adv_handle; + UINT8 decision_type_flags; + UINT8 data_len; + UINT8 data[BLE_DECISION_DATA_MAX_LEN]; +} tBTA_DM_API_SET_DECISION_DATA; + +typedef struct { + BT_HDR hdr; + UINT8 num_tests; + UINT8 test_flags[BLE_DECISION_MAX_TESTS]; + UINT8 test_fields[BLE_DECISION_MAX_TESTS]; + UINT8 test_params[BLE_DECISION_TEST_PARAMS_MAX_LEN]; +} tBTA_DM_API_SET_DECISION_INSTRUCTIONS; +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + typedef struct { BT_HDR hdr; tBTA_DM_BLE_EXT_SCAN_PARAMS params; @@ -1813,6 +1840,10 @@ typedef union { tBTA_DM_API_READ_MONITOR_ADV_LIST_SIZE ble_read_monitor_adv_list_size; tBTA_DM_API_ENABLE_MONITOR_ADV ble_enable_monitor_adv; #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + tBTA_DM_API_SET_DECISION_DATA ble_set_decision_data; + tBTA_DM_API_SET_DECISION_INSTRUCTIONS ble_set_decision_instructions; +#endif // #if (BLE_FEAT_DBAF == TRUE) #if (BLE_42_DTM_TEST_EN == TRUE) tBTA_DM_API_BLE_DTM_TX_START dtm_tx_start; tBTA_DM_API_BLE_DTM_RX_START dtm_rx_start; @@ -2492,6 +2523,15 @@ extern void bta_dm_ble_gap_read_monitor_adv_list_size(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_enable_monitor_adv(tBTA_DM_MSG *p_data); #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +extern void bta_dm_ble_gap_set_decision_data(tBTA_DM_MSG *p_data); +extern void bta_dm_ble_gap_set_decision_instructions(tBTA_DM_MSG *p_data); +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + #if (BLE_FEAT_ISO_EN == TRUE) #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE) extern void bta_dm_ble_big_create(tBTA_DM_MSG *p_data); diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_api.h index 370ccb79a4a..fa19e68c505 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -1605,6 +1605,15 @@ typedef struct { #define BTA_DM_BLE_5_GAP_ENABLE_MONITOR_ADV_COMPLETE_EVT BTM_BLE_5_GAP_ENABLE_MONITOR_ADV_COMPLETE_EVT #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +#define BTA_DM_BLE_5_GAP_SET_DECISION_DATA_COMPLETE_EVT BTM_BLE_5_GAP_SET_DECISION_DATA_COMPLETE_EVT +#define BTA_DM_BLE_5_GAP_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT BTM_BLE_5_GAP_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + #if (BT_BLE_FEAT_PAWR_EN == TRUE) #define BTA_BLE_GAP_SET_PERIODIC_ADV_SUBEVT_DATA_EVT BTM_BLE_GAP_SET_PERIODIC_ADV_SUBEVT_DATA_EVT #define BTA_BLE_GAP_SET_PERIODIC_ADV_RESPONSE_DATA_EVT BTM_BLE_GAP_SET_PERIODIC_ADV_RESPONSE_DATA_EVT @@ -3059,6 +3068,18 @@ extern void BTA_DmBleGapReadMonitorAdvListSize(void); extern void BTA_DmBleGapEnableMonitorAdv(UINT8 enable); #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +extern void BTA_DmBleGapSetDecisionData(UINT8 adv_handle, UINT8 decision_type_flags, + UINT8 data_len, const UINT8 *p_data); +extern void BTA_DmBleGapSetDecisionInstructions(UINT8 num_tests, const UINT8 *test_flags, + const UINT8 *test_fields, UINT8 test_params_len, + const UINT8 *test_params); +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + #if (BLE_FEAT_ISO_EN == TRUE) #if (BLE_FEAT_ISO_BIG_BROADCASTER_EN == TRUE) extern void BTA_DmBleGapIsoBigCreate(tBTA_DM_BLE_BIG_CREATE_PARAMS *p_big_creat_param); 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 568818c3942..9e7a1f2cdbb 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 @@ -1283,6 +1283,18 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, break; } #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + case BTA_DM_BLE_5_GAP_SET_DECISION_DATA_COMPLETE_EVT: { + msg.act = ESP_GAP_BLE_SET_DECISION_DATA_COMPLETE_EVT; + param.set_decision_data.status = btc_btm_status_to_esp_status(params->status); + break; + } + case BTA_DM_BLE_5_GAP_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT: { + msg.act = ESP_GAP_BLE_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT; + param.set_decision_instructions.status = btc_btm_status_to_esp_status(params->status); + break; + } +#endif // #if (BLE_FEAT_DBAF == TRUE) #if (BLE_50_EXTEND_ADV_EN == TRUE) case BTA_DM_BLE_5_GAP_ADV_TERMINATED_EVT: { param.adv_terminate.status = params->adv_term.status; @@ -2477,6 +2489,84 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) break; } #endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + case BTC_GAP_BLE_SET_DECISION_DATA: { + btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src; + btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest; + + dst->set_decision_data.data = NULL; + if (src->set_decision_data.data_len > 0 && src->set_decision_data.data) { + dst->set_decision_data.data = osi_malloc(src->set_decision_data.data_len); + if (dst->set_decision_data.data) { + memcpy(dst->set_decision_data.data, src->set_decision_data.data, + src->set_decision_data.data_len); + } else { + BTC_TRACE_WARNING("%s no mem, decision data drop %u", __func__, src->set_decision_data.data_len); + dst->set_decision_data.data_len = 0; + } + } + break; + } + case BTC_GAP_BLE_SET_DECISION_INSTRUCTIONS: { + btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src; + btc_ble_5_gap_args_t *dst = (btc_ble_5_gap_args_t *)p_dest; + bool oom = false; + + dst->set_decision_instructions.test_flags = NULL; + dst->set_decision_instructions.test_fields = NULL; + dst->set_decision_instructions.test_params = NULL; + if (src->set_decision_instructions.num_tests > ESP_BLE_GAP_DECISION_MAX_TESTS) { + BTC_TRACE_WARNING("%s invalid num_tests %u", __func__, + src->set_decision_instructions.num_tests); + oom = true; + } + if (!oom && src->set_decision_instructions.num_tests > 0) { + if (src->set_decision_instructions.test_flags) { + dst->set_decision_instructions.test_flags = osi_malloc(src->set_decision_instructions.num_tests); + if (dst->set_decision_instructions.test_flags) { + memcpy(dst->set_decision_instructions.test_flags, src->set_decision_instructions.test_flags, + src->set_decision_instructions.num_tests); + } else { + oom = true; + } + } + if (!oom && src->set_decision_instructions.test_fields) { + dst->set_decision_instructions.test_fields = osi_malloc(src->set_decision_instructions.num_tests); + if (dst->set_decision_instructions.test_fields) { + memcpy(dst->set_decision_instructions.test_fields, src->set_decision_instructions.test_fields, + src->set_decision_instructions.num_tests); + } else { + oom = true; + } + } + } + if (!oom && src->set_decision_instructions.num_tests > 0 && + src->set_decision_instructions.test_params) { + size_t test_params_len = (size_t)src->set_decision_instructions.num_tests * + ESP_BLE_GAP_DECISION_TEST_PARAM_LEN; + dst->set_decision_instructions.test_params = osi_malloc(test_params_len); + if (dst->set_decision_instructions.test_params) { + memcpy(dst->set_decision_instructions.test_params, src->set_decision_instructions.test_params, + test_params_len); + } else { + oom = true; + } + } + if (oom) { + BTC_TRACE_WARNING("%s no mem, decision instructions drop", __func__); + if (dst->set_decision_instructions.test_flags) { + osi_free(dst->set_decision_instructions.test_flags); + dst->set_decision_instructions.test_flags = NULL; + } + if (dst->set_decision_instructions.test_fields) { + osi_free(dst->set_decision_instructions.test_fields); + dst->set_decision_instructions.test_fields = NULL; + } + dst->set_decision_instructions.num_tests = 0; + } + break; + } +#endif // #if (BLE_FEAT_DBAF == TRUE) default: BTC_TRACE_ERROR("Unhandled deep copy %d\n", msg->act); break; @@ -2759,6 +2849,28 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) break; } #endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + case BTC_GAP_BLE_SET_DECISION_DATA: { + uint8_t *data = ((btc_ble_5_gap_args_t *)msg->arg)->set_decision_data.data; + if (data) { + osi_free(data); + } + break; + } + case BTC_GAP_BLE_SET_DECISION_INSTRUCTIONS: { + btc_ble_5_gap_args_t *args = (btc_ble_5_gap_args_t *)msg->arg; + if (args->set_decision_instructions.test_flags) { + osi_free(args->set_decision_instructions.test_flags); + } + if (args->set_decision_instructions.test_fields) { + osi_free(args->set_decision_instructions.test_fields); + } + if (args->set_decision_instructions.test_params) { + osi_free(args->set_decision_instructions.test_params); + } + break; + } +#endif // #if (BLE_FEAT_DBAF == TRUE) default: BTC_TRACE_DEBUG("Unhandled deep free %d\n", msg->act); break; @@ -3419,6 +3531,20 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTA_DmBleGapEnableMonitorAdv(arg_5->enable_monitor_adv.enable); break; #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + case BTC_GAP_BLE_SET_DECISION_DATA: + BTA_DmBleGapSetDecisionData(arg_5->set_decision_data.adv_handle, + arg_5->set_decision_data.decision_type_flags, + arg_5->set_decision_data.data_len, + arg_5->set_decision_data.data); + break; + case BTC_GAP_BLE_SET_DECISION_INSTRUCTIONS: + BTA_DmBleGapSetDecisionInstructions(arg_5->set_decision_instructions.num_tests, + arg_5->set_decision_instructions.test_flags, + arg_5->set_decision_instructions.test_fields, + arg_5->set_decision_instructions.test_params); + break; +#endif // #if (BLE_FEAT_DBAF == TRUE) #if (BT_BLE_FEAT_PAWR_EN == TRUE) case BTC_GAP_BLE_SET_PA_SUBEVT_DATA: BTA_DmBleGapSetPASubevtData(arg_5->per_adv_subevent_data_params.adv_handle, arg_5->per_adv_subevent_data_params.num_subevents_with_data, (uint8_t *)(arg_5->per_adv_subevent_data_params.subevent_params)); 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 306adb09a14..99e41df2d67 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 @@ -147,6 +147,10 @@ typedef enum { BTC_GAP_BLE_READ_MONITOR_ADV_LIST_SIZE, BTC_GAP_BLE_ENABLE_MONITOR_ADV, #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + BTC_GAP_BLE_SET_DECISION_DATA, + BTC_GAP_BLE_SET_DECISION_INSTRUCTIONS, +#endif // #if (BLE_FEAT_DBAF == TRUE) BTC_GAP_BLE_READ_CHANNEL_MAP, #if (BT_BLE_FEAT_PAWR_EN == TRUE) BTC_GAP_BLE_SET_PA_SUBEVT_DATA, @@ -588,6 +592,20 @@ typedef union { uint8_t enable; } enable_monitor_adv; #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) + struct set_decision_data_args { + uint8_t adv_handle; + uint8_t decision_type_flags; + uint8_t data_len; + uint8_t *data; + } set_decision_data; + struct set_decision_instructions_args { + uint8_t num_tests; + uint8_t *test_flags; + uint8_t *test_fields; + uint8_t *test_params; + } set_decision_instructions; +#endif // #if (BLE_FEAT_DBAF == TRUE) #if (BT_BLE_FEAT_PAWR_EN == TRUE) // BTC_GAP_BLE_SET_PA_SUBEVT_DATA struct per_adv_subevent_data_params_args { diff --git a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h index c2aefabbe48..6c9dd987a47 100644 --- a/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h +++ b/components/bt/host/bluedroid/common/include/common/bluedroid_user_config.h @@ -343,12 +343,23 @@ #define UC_BT_BLE_FEAT_CHANNEL_SOUNDING FALSE #endif + #ifdef CONFIG_BT_BLE_FEAT_ADV_MONITOR #define UC_BT_BLE_FEAT_ADV_MONITOR CONFIG_BT_BLE_FEAT_ADV_MONITOR #else #define UC_BT_BLE_FEAT_ADV_MONITOR FALSE #endif +#ifdef CONFIG_BT_BLE_FEAT_DBAF +#define UC_BT_BLE_FEAT_DBAF CONFIG_BT_BLE_FEAT_DBAF +#else +#define UC_BT_BLE_FEAT_DBAF FALSE +#endif + + + + + #ifdef CONFIG_BT_BLE_VENDOR_HCI_EN #define UC_BT_BLE_VENDOR_HCI_EN CONFIG_BT_BLE_VENDOR_HCI_EN #else diff --git a/components/bt/host/bluedroid/common/include/common/bt_target.h b/components/bt/host/bluedroid/common/include/common/bt_target.h index def71e9c753..7e015e8a2f5 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -405,6 +405,7 @@ #define BT_BLE_FEAT_CHANNEL_SOUNDING FALSE #endif + /* LE Monitor Advertisement (Bluetooth Core 6.0) */ #if (BLE_50_FEATURE_SUPPORT == TRUE) && (defined UC_BT_BLE_FEAT_ADV_MONITOR) && (UC_BT_BLE_FEAT_ADV_MONITOR == TRUE) #define BLE_FEAT_ADV_MONITOR TRUE @@ -412,6 +413,16 @@ #define BLE_FEAT_ADV_MONITOR FALSE #endif +#if (BLE_50_FEATURE_SUPPORT == TRUE) && (UC_BT_BLE_FEAT_DBAF == TRUE) +#define BLE_FEAT_DBAF TRUE +#else +#define BLE_FEAT_DBAF FALSE +#endif + + + + + #if (UC_BT_BLE_VENDOR_HCI_EN == TRUE) #define BLE_VENDOR_HCI_EN TRUE #else diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c index 8be15ba602d..6d36774ae33 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_5_gap.c @@ -17,6 +17,15 @@ tBTM_BLE_EXTENDED_CB extend_adv_cb; tBTM_BLE_5_HCI_CBACK ble_5_hci_cb; +#if (BLE_FEAT_LL_EXT_FEAT == TRUE) +static UINT8 btm_ble_local_supp_le_features[BLE_LL_EXT_FEAT_DATA_LEN]; +static UINT8 btm_ble_remote_supp_le_features[BLE_LL_EXT_FEAT_DATA_LEN]; +#endif // #if (BLE_FEAT_LL_EXT_FEAT == TRUE) + +#if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE) +static tBTM_BLE_MIN_CONN_INTERVAL_GROUP btm_ble_min_conn_interval_groups[BTM_BLE_MAX_CONN_INTERVAL_GROUPS]; +#endif // #if (BLE_FEAT_SHORTER_CONN_INTERVALS == TRUE) + #define INVALID_VALUE_8BIT 0XFF #define INVALID_VALUE_16BIT 0XFFFF #define INVALID_VALUE_32BIT 0XFFFFFFFF @@ -1411,6 +1420,47 @@ tBTM_STATUS BTM_BleEnableMonitorAdv(UINT8 enable) } #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +tBTM_STATUS BTM_BleSetDecisionData(UINT8 adv_handle, UINT8 decision_type_flags, + UINT8 data_len, const UINT8 *p_data) +{ + tHCI_STATUS err; + tBTM_STATUS status = BTM_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_set_decision_data(adv_handle, decision_type_flags, data_len, p_data)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("LE SetDecisionData: cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } + + cb_params.status = status; + BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SET_DECISION_DATA_COMPLETE_EVT, &cb_params); + return status; +} + +tBTM_STATUS BTM_BleSetDecisionInstructions(UINT8 num_tests, const UINT8 *test_flags, + const UINT8 *test_fields, const UINT8 *test_params) +{ + tHCI_STATUS err; + tBTM_STATUS status = BTM_SUCCESS; + tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; + + if ((err = btsnd_hcic_ble_set_decision_instructions(num_tests, test_flags, test_fields, + test_params)) != HCI_SUCCESS) { + BTM_TRACE_ERROR("LE SetDecisionInstructions: cmd err=0x%x", err); + status = BTM_HCI_ERROR | err; + } + + cb_params.status = status; + BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT, &cb_params); + return status; +} +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + #if (BLE_50_EXTEND_ADV_EN == TRUE) void btm_ble_scan_req_received_evt(tBTM_BLE_SCAN_REQ_RECEIVED *params) { diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index f0a275f23b6..a6939e41fe2 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -1201,6 +1201,7 @@ void btm_read_remote_trans_pwr_level_cmpl(UINT8 status); void btm_subrate_req_cmd_status(UINT8 status); #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + #if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) void btm_ble_cs_read_local_supp_caps_cmpl_evt(UINT8 *p); void btm_ble_cs_read_remote_supp_caps_cmd_status(UINT8 status); diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index d9e34dcd10d..5a16e31adbf 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -2660,6 +2660,8 @@ static void btu_ble_monitor_adv_report_evt(UINT8 *p) } #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) + + #if (BLE_50_EXTEND_SYNC_EN == TRUE) static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p, bool v2_evt) { @@ -3334,6 +3336,8 @@ static void btu_ble_subrate_change_evt(UINT8 *p) } #endif // #if (BLE_FEAT_CONN_SUBRATING == TRUE) + + #if (BT_BLE_FEAT_PAWR_EN == TRUE) static void btu_ble_pa_subevt_data_request_evt(UINT8 *p) { diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index 8c5494b7f04..629ea14042e 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -3054,6 +3054,79 @@ UINT8 btsnd_hcic_ble_enable_monitor_adv(UINT8 enable) } #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +UINT8 btsnd_hcic_ble_set_decision_data(UINT8 adv_handle, UINT8 decision_type_flags, + UINT8 data_len, const UINT8 *p_data) +{ + BT_HDR *p; + UINT8 *pp; + UINT8 param_len; + + if (data_len > BLE_DECISION_DATA_MAX_LEN) { + return HCI_ERR_ILLEGAL_PARAMETER_FMT; + } + if (data_len > 0 && p_data == NULL) { + return HCI_ERR_ILLEGAL_PARAMETER_FMT; + } + + param_len = HCIC_PARAM_SIZE_SET_DECISION_DATA_HDR + data_len; + if (param_len > HCIC_PARAM_SIZE_SET_DECISION_DATA_MAX) { + return HCI_ERR_ILLEGAL_PARAMETER_FMT; + } + + HCIC_BLE_CMD_CREATED_U8(p, pp, param_len); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_DECISION_DATA); + UINT8_TO_STREAM(pp, param_len); + UINT8_TO_STREAM(pp, adv_handle); + UINT8_TO_STREAM(pp, decision_type_flags); + UINT8_TO_STREAM(pp, data_len); + if (data_len > 0) { + ARRAY_TO_STREAM(pp, p_data, data_len); + } + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} + +UINT8 btsnd_hcic_ble_set_decision_instructions(UINT8 num_tests, const UINT8 *test_flags, + const UINT8 *test_fields, const UINT8 *test_params) +{ + BT_HDR *p; + UINT8 *pp; + UINT8 param_len; + + if (num_tests == 0 || num_tests > BLE_DECISION_MAX_TESTS) { + return HCI_ERR_ILLEGAL_PARAMETER_FMT; + } + if (test_flags == NULL || test_fields == NULL || test_params == NULL) { + return HCI_ERR_ILLEGAL_PARAMETER_FMT; + } + + param_len = HCIC_PARAM_SIZE_SET_DECISION_INSTRUCTIONS(num_tests); + if (param_len > HCIC_PARAM_SIZE_SET_DECISION_INSTRUCTIONS_MAX) { + return HCI_ERR_ILLEGAL_PARAMETER_FMT; + } + + HCIC_BLE_CMD_CREATED_U8(p, pp, param_len); + + UINT16_TO_STREAM(pp, HCI_BLE_SET_DECISION_INSTRUCTIONS); + UINT8_TO_STREAM(pp, param_len); + UINT8_TO_STREAM(pp, num_tests); + for (UINT8 i = 0; i < num_tests; i++) { + UINT8_TO_STREAM(pp, test_flags[i]); + UINT8_TO_STREAM(pp, test_fields[i]); + ARRAY_TO_STREAM(pp, test_params + i * BLE_DECISION_TEST_PARAM_LEN, + BLE_DECISION_TEST_PARAM_LEN); + } + + return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); +} +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + #if (BT_BLE_FEAT_PAWR_EN == TRUE) UINT8 btsnd_hcic_ble_set_periodic_adv_subevt_data(UINT8 adv_handle, UINT8 num_subevents_with_data, ble_subevent_params *subevent_params) { diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h index 6e153c66a3c..e0ffbe8890f 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_ble_api.h @@ -990,7 +990,11 @@ typedef void (tBTM_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK) (tBTM_STATUS st #define BTM_BLE_5_GAP_READ_MONITOR_ADV_LIST_SIZE_COMPLETE_EVT 74 #define BTM_BLE_5_GAP_ENABLE_MONITOR_ADV_COMPLETE_EVT 75 #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) -#define BTM_BLE_5_GAP_UNKNOWN_EVT 76 +#if (BLE_FEAT_DBAF == TRUE) +#define BTM_BLE_5_GAP_SET_DECISION_DATA_COMPLETE_EVT 79 +#define BTM_BLE_5_GAP_SET_DECISION_INSTRUCTIONS_COMPLETE_EVT 80 +#endif // #if (BLE_FEAT_DBAF == TRUE) +#define BTM_BLE_5_GAP_UNKNOWN_EVT 91 typedef UINT8 tBTM_BLE_5_GAP_EVENT; #if (BLE_FEAT_ISO_EN == TRUE) @@ -1240,6 +1244,10 @@ typedef struct { } tBTM_BLE_MONITOR_ADV_LIST_SIZE; #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) + + + + typedef struct { UINT16 sync_handle; UINT8 tx_power; @@ -1463,6 +1471,7 @@ typedef struct { UINT16 conn_handle; } tBTM_BLE_CS_SEC_ENABLE_CMPL_EVT; + typedef struct { UINT8 status; UINT16 conn_handle; @@ -3109,6 +3118,18 @@ tBTM_STATUS BTM_BleClearMonitorAdvList(void); tBTM_STATUS BTM_BleReadMonitorAdvListSize(void); tBTM_STATUS BTM_BleEnableMonitorAdv(UINT8 enable); #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) + +#if (BLE_FEAT_DBAF == TRUE) +tBTM_STATUS BTM_BleSetDecisionData(UINT8 adv_handle, UINT8 decision_type_flags, + UINT8 data_len, const UINT8 *p_data); +tBTM_STATUS BTM_BleSetDecisionInstructions(UINT8 num_tests, const UINT8 *test_flags, + const UINT8 *test_fields, UINT8 test_params_len, + const UINT8 *test_params); +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_50_DTM_TEST_EN == TRUE) diff --git a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h index 43eb352bb11..ff39bb22ae4 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h @@ -439,6 +439,7 @@ #define HCI_BLE_ENABLE_MONITOR_ADV (0x009C | HCI_GRP_BLE_CMDS) #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) + #if (BLE_FEAT_POWER_CONTROL_EN == TRUE) #define HCI_BLE_ENH_READ_TRANS_POWER_LEVEL (0x0076 | HCI_GRP_BLE_CMDS) #define HCI_BLE_READ_REMOTE_TRANS_POWER_LEVEL (0x0077 | HCI_GRP_BLE_CMDS) @@ -464,6 +465,12 @@ #define HCI_BLE_SET_PERIOD_ADV_PARAMS_V2 (0x0086 | HCI_GRP_BLE_CMDS) #endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + +#if (BLE_FEAT_DBAF == TRUE) +#define HCI_BLE_SET_DECISION_DATA (0x0080 | HCI_GRP_BLE_CMDS) +#define HCI_BLE_SET_DECISION_INSTRUCTIONS (0x0081 | HCI_GRP_BLE_CMDS) +#endif // #if (BLE_FEAT_DBAF == TRUE) + #if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) #define HCI_BLE_CS_READ_LOCAL_SUPP_CAPS (0x0089 | HCI_GRP_BLE_CMDS) #define HCI_BLE_CS_READ_REMOTE_SUPP_CAPS (0x008A | HCI_GRP_BLE_CMDS) @@ -479,6 +486,9 @@ #define HCI_BLE_CS_SET_PROCEDURE_ENABLE (0x0094 | HCI_GRP_BLE_CMDS) #endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + + + // Vendor OGF define #define HCI_VENDOR_OGF 0x3F @@ -970,10 +980,14 @@ #define HCI_BLE_PA_RESPONSE_REPORT_EVT 0x28 #endif // #if (BT_BLE_FEAT_PAWR_EN == TRUE) + #if (BLE_FEAT_ADV_MONITOR == TRUE) #define HCI_BLE_MONITOR_ADV_REPORT_EVT 0x34 #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) + + + #if (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) #define HCI_BLE_CS_READ_REMOTE_SUPP_CAPS_CMPL_EVT 0x2C #define HCI_BLE_CS_READ_REMOTE_FAE_TAB_CMPL_EVT 0x2D diff --git a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h index 897d0f636e7..3dfc7bc9a1d 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -825,6 +825,26 @@ BOOLEAN btsnd_hcic_ble_read_monitor_adv_list_size(void); UINT8 btsnd_hcic_ble_enable_monitor_adv(UINT8 enable); #endif // #if (BLE_FEAT_ADV_MONITOR == TRUE) +#if (BLE_FEAT_DBAF == TRUE) +#define HCIC_PARAM_SIZE_SET_DECISION_DATA_HDR 3 +#define HCIC_PARAM_SIZE_SET_DECISION_DATA_MAX 251 +#define HCIC_PARAM_SIZE_SET_DECISION_INSTRUCTIONS_HDR 1 +#define HCIC_PARAM_SIZE_SET_DECISION_INSTRUCTIONS_MAX 251 +#define BLE_DECISION_DATA_MAX_LEN 248 +#define BLE_DECISION_MAX_TESTS 8 +#define BLE_DECISION_TEST_PARAMS_MAX_LEN 229 + +UINT8 btsnd_hcic_ble_set_decision_data(UINT8 adv_handle, UINT8 decision_type_flags, + UINT8 data_len, const UINT8 *p_data); +UINT8 btsnd_hcic_ble_set_decision_instructions(UINT8 num_tests, const UINT8 *test_flags, + const UINT8 *test_fields, UINT8 test_params_len, + const UINT8 *test_params); +#endif // #if (BLE_FEAT_DBAF == TRUE) + + + + + /* ULP HCI command */ BOOLEAN btsnd_hcic_ble_set_evt_mask (BT_EVENT_MASK event_mask); @@ -1355,4 +1375,5 @@ UINT8 btsnd_hcic_ble_cs_set_procedure_params(UINT16 conn_handle, UINT8 config_id UINT8 btsnd_hcic_ble_cs_procedure_enable(UINT16 conn_handle, UINT8 config_id, UINT8 enable); #endif // (BT_BLE_FEAT_CHANNEL_SOUNDING == TRUE) + #endif