diff --git a/components/bt/common/btc/core/btc_task.c b/components/bt/common/btc/core/btc_task.c index 877b36e5bf..bbc713ad8f 100644 --- a/components/bt/common/btc/core/btc_task.c +++ b/components/bt/common/btc/core/btc_task.c @@ -389,6 +389,7 @@ static void btc_deinit_mem(void) { } #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) if (gl_bta_adv_data_ptr) { osi_free(gl_bta_adv_data_ptr); gl_bta_adv_data_ptr = NULL; @@ -398,6 +399,7 @@ static void btc_deinit_mem(void) { osi_free(gl_bta_scan_rsp_data_ptr); gl_bta_scan_rsp_data_ptr = NULL; } +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // BLE_42_FEATURE_SUPPORT #if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE @@ -452,6 +454,7 @@ static bt_status_t btc_init_mem(void) { #if BTC_DYNAMIC_MEMORY == TRUE #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) if ((gl_bta_adv_data_ptr = (tBTA_BLE_ADV_DATA *)osi_malloc(sizeof(tBTA_BLE_ADV_DATA))) == NULL) { goto error_exit; } @@ -461,6 +464,7 @@ static bt_status_t btc_init_mem(void) { goto error_exit; } memset((void *)gl_bta_scan_rsp_data_ptr, 0, sizeof(tBTA_BLE_ADV_DATA)); +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // (BLE_42_FEATURE_SUPPORT == TRUE) #endif // BTC_DYNAMIC_MEMORY == TRUE diff --git a/components/bt/host/bluedroid/Kconfig.in b/components/bt/host/bluedroid/Kconfig.in index df307a875a..a4659e9666 100644 --- a/components/bt/host/bluedroid/Kconfig.in +++ b/components/bt/host/bluedroid/Kconfig.in @@ -229,7 +229,7 @@ config BT_BLE_ENABLED help This enables Bluetooth Low Energy -config BT_GATTS_ENABLE +menuconfig BT_GATTS_ENABLE bool "Include GATT server module(GATTS)" depends on BT_BLE_ENABLED default y @@ -319,7 +319,7 @@ config BT_GATTS_APPEARANCE_WRITABLE help Enabling this option allows remote GATT clients to write appearance -config BT_GATTC_ENABLE +menuconfig BT_GATTC_ENABLE bool "Include GATT client module(GATTC)" depends on BT_BLE_ENABLED default y @@ -357,7 +357,16 @@ config BT_GATTC_CONNECT_RETRY_COUNT help The number of attempts to reconnect if the connection establishment failed -config BT_BLE_SMP_ENABLE +config BT_BLE_ESTAB_LINK_CONN_TOUT + int "Timeout of BLE connection establishment" + depends on BT_GATTC_ENABLE + range 1 60 + default 30 + help + Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection + establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered. + +menuconfig BT_BLE_SMP_ENABLE bool "Include BLE security module(SMP)" depends on BT_BLE_ENABLED default y @@ -390,6 +399,23 @@ config BT_BLE_SMP_BOND_NVS_FLASH help This select can save SMP bonding keys to nvs flash +config BT_BLE_RPA_SUPPORTED + bool "Update RPA to Controller" + depends on (BT_BLE_SMP_ENABLE && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR + default n if (BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) + default y if BT_CONTROLLER_DISABLED + help + This enables controller RPA list function. + For ESP32, ESP32 only support network privacy mode. If this option is enabled, ESP32 will only accept + advertising packets from peer devices that contain private address, HW will not receive the advertising + packets contain identity address after IRK changed. If this option is disabled, address resolution will + be performed in the host, so the functions that require controller to resolve address in the white list + cannot be used. This option is disabled by default on ESP32, please enable or disable this option according + to your own needs. + + For other BLE chips, devices support network privacy mode and device privacy mode, + users can switch the two modes according to their own needs. So this option is enabled by default. + config BT_STACK_NO_LOG bool "Disable BT debug logs (minimize bin size)" depends on BT_BLUEDROID_ENABLED @@ -1194,15 +1220,6 @@ config BT_BLE_ACT_SCAN_REP_ADV_SCAN # Memory reserved at start of DRAM for Bluetooth stack -config BT_BLE_ESTAB_LINK_CONN_TOUT - int "Timeout of BLE connection establishment" - depends on BT_BLE_ENABLED - range 1 60 - default 30 - help - Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection - establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered. - config BT_MAX_DEVICE_NAME_LEN int "length of bluetooth device name" depends on BT_BLUEDROID_ENABLED @@ -1213,23 +1230,6 @@ config BT_MAX_DEVICE_NAME_LEN the complete device name, then only the shortname will be displayed, the rest parts that can't fit in will be truncated. -config BT_BLE_RPA_SUPPORTED - bool "Update RPA to Controller" - depends on (BT_BLUEDROID_ENABLED && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR - default n if (BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) - default y if BT_CONTROLLER_DISABLED - help - This enables controller RPA list function. - For ESP32, ESP32 only support network privacy mode. If this option is enabled, ESP32 will only accept - advertising packets from peer devices that contain private address, HW will not receive the advertising - packets contain identity address after IRK changed. If this option is disabled, address resolution will - be performed in the host, so the functions that require controller to resolve address in the white list - cannot be used. This option is disabled by default on ESP32, please enable or disable this option according - to your own needs. - - For other BLE chips, devices support network privacy mode and device privacy mode, - users can switch the two modes according to their own needs. So this option is enabled by default. - config BT_BLE_RPA_TIMEOUT int "Timeout of resolvable private address" depends on BT_BLE_ENABLED @@ -1239,7 +1239,7 @@ config BT_BLE_RPA_TIMEOUT This set RPA timeout of Controller and Host. Default is 900 s (15 minutes). Range is 1 s to 1 hour (3600 s). -config BT_BLE_50_FEATURES_SUPPORTED +menuconfig BT_BLE_50_FEATURES_SUPPORTED bool "Enable BLE 5.0 features(please disable BLE 4.2 if enable BLE 5.0)" depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED)) default y @@ -1248,6 +1248,41 @@ config BT_BLE_50_FEATURES_SUPPORTED This option is universally supported in chips that support BLE, except for ESP32. BLE 4.2 and BLE 5.0 cannot be used simultaneously. +config BT_BLE_50_EXTEND_ADV_EN + bool "Enable BLE extend advertising" + depends on BT_BLE_50_FEATURES_SUPPORTED + default y + help + This enables BLE extend advertising + +config BT_BLE_50_PERIODIC_ADV_EN + bool "Enable BLE periodic advertising" + depends on BT_BLE_50_FEATURES_SUPPORTED + default y + help + This enables BLE periodic advertising + +config BT_BLE_50_EXTEND_SCAN_EN + bool "Enable BLE extend scan" + depends on BT_BLE_50_FEATURES_SUPPORTED + default y + help + This enables BLE extend scan + +config BT_BLE_50_EXTEND_SYNC_EN + bool "Enable BLE periodic advertising sync" + depends on BT_BLE_50_FEATURES_SUPPORTED + default y + help + This enables BLE periodic advertising sync + +config BT_BLE_50_DTM_TEST_EN + bool "Enable BLE 5.0 DTM test" + depends on BT_BLE_50_FEATURES_SUPPORTED + default y + help + This enables BLE 5.0 direct test mode + config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER bool "Enable BLE periodic advertising sync transfer feature" depends on (BT_BLUEDROID_ENABLED && BT_BLE_50_FEATURES_SUPPORTED && ((BT_CONTROLLER_ENABLED && SOC_ESP_NIMBLE_CONTROLLER) || BT_CONTROLLER_DISABLED)) # NOERROR @@ -1269,15 +1304,37 @@ config BT_BLE_FEAT_CREATE_SYNC_ENH help Enable the create sync enhancements -config BT_BLE_42_FEATURES_SUPPORTED +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 && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED)) + depends on BT_BLE_ENABLED + default y if IDF_TARGET_ESP32 default n help This enables BLE 4.2 features. This option is universally supported by all ESP chips with BLE capabilities. BLE 4.2 and BLE 5.0 cannot be used simultaneously. +config BT_BLE_42_DTM_TEST_EN + bool "Enable BLE 4.2 DTM test" + depends on BT_BLE_42_FEATURES_SUPPORTED + default y + help + This enables BLE 4.2 direct test mode + +config BT_BLE_42_ADV_EN + bool "Enable BLE 4.2 advertising" + depends on BT_BLE_42_FEATURES_SUPPORTED + default y + help + This enables BLE v4.2 advertising + +config BT_BLE_42_SCAN_EN + bool "Enable BLE 4.2 scan" + depends on BT_BLE_42_FEATURES_SUPPORTED + default y + help + This enables BLE v4.2 scan + config BT_BLE_HIGH_DUTY_ADV_INTERVAL bool "Enable BLE high duty advertising interval feature" 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 a412252979..6cef5e32da 100644 --- a/components/bt/host/bluedroid/api/esp_gap_ble_api.c +++ b/components/bt/host/bluedroid/api/esp_gap_ble_api.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -28,6 +28,7 @@ esp_gap_ble_cb_t esp_ble_gap_get_callback(void) } #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data) { btc_msg_t msg = {0}; @@ -51,8 +52,9 @@ esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_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_42_ADV_EN == TRUE) - +#if (BLE_42_SCAN_EN == TRUE) esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params) { btc_msg_t msg = {0}; @@ -99,7 +101,9 @@ esp_err_t esp_ble_gap_stop_scanning(void) msg.act = BTC_GAP_BLE_ACT_STOP_SCAN; return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_42_ADV_EN == TRUE) esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params) { btc_msg_t msg = {0}; @@ -140,6 +144,7 @@ esp_err_t esp_ble_gap_clear_advertising(void) return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params) @@ -536,6 +541,7 @@ uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *len } #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len) { btc_msg_t msg = {0}; @@ -557,6 +563,7 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr) { @@ -933,7 +940,7 @@ esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize) return ESP_FAIL; } -#if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_DTM_TEST_EN == TRUE) esp_err_t esp_ble_dtm_tx_start(const esp_ble_dtm_tx_t *tx_params) { btc_msg_t msg = {0}; @@ -973,9 +980,9 @@ esp_err_t esp_ble_dtm_rx_start(const esp_ble_dtm_rx_t *rx_params) return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } -#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) -#if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) esp_err_t esp_ble_dtm_enh_tx_start(const esp_ble_dtm_enh_tx_t *tx_params) { btc_msg_t msg = {0}; @@ -1015,8 +1022,9 @@ esp_err_t esp_ble_dtm_enh_rx_start(const esp_ble_dtm_enh_rx_t *rx_params) 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_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) esp_err_t esp_ble_dtm_stop(void) { btc_msg_t msg = {0}; @@ -1029,6 +1037,7 @@ esp_err_t esp_ble_dtm_stop(void) return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) esp_err_t esp_ble_gap_set_privacy_mode(esp_ble_addr_type_t addr_type, esp_bd_addr_t addr, esp_ble_privacy_mode_t mode) { @@ -1125,6 +1134,7 @@ esp_err_t esp_ble_gap_set_preferred_phy(esp_bd_addr_t bd_addr, == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#if (BLE_50_EXTEND_ADV_EN == TRUE) esp_err_t esp_ble_gap_ext_adv_set_rand_addr(uint8_t instance, esp_bd_addr_t rand_addr) { btc_msg_t msg; @@ -1280,7 +1290,9 @@ esp_err_t esp_ble_gap_ext_adv_set_clear(void) return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) esp_err_t esp_ble_gap_periodic_adv_set_params(uint8_t instance, const esp_ble_gap_periodic_adv_params_t *params) { btc_msg_t msg; @@ -1375,7 +1387,9 @@ esp_err_t esp_ble_gap_periodic_adv_stop(uint8_t instance) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) esp_err_t esp_ble_gap_periodic_adv_create_sync(const esp_ble_gap_periodic_adv_sync_params_t *params) { btc_msg_t msg; @@ -1488,7 +1502,9 @@ esp_err_t esp_ble_gap_periodic_adv_clear_dev(void) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) esp_err_t esp_ble_gap_set_ext_scan_params(const esp_ble_ext_scan_params_t *params) { btc_msg_t msg; @@ -1540,6 +1556,7 @@ esp_err_t esp_ble_gap_stop_ext_scan(void) return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL); } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr, esp_ble_gap_phy_mask_t phy_mask, 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 bc096abef7..9e328bfde6 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 @@ -1291,6 +1291,7 @@ typedef union { struct ble_set_perf_phy_cmpl_evt_param { esp_bt_status_t status; /*!< Indicate perf phy set status */ } set_perf_phy; /*!< Event parameter of ESP_GAP_BLE_SET_PREFERRED_PHY_COMPLETE_EVT */ +#if (BLE_50_EXTEND_ADV_EN == TRUE) /** * @brief ESP_GAP_BLE_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT */ @@ -1349,6 +1350,7 @@ typedef union { esp_bt_status_t status; /*!< Indicate advertising stop operation success status */ uint8_t instance; /*!< extend advertising handle */ } ext_adv_clear; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_SET_CLEAR_COMPLETE_EVT */ +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) /** * @brief ESP_GAP_BLE_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT */ 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 d33696e319..d3e9336824 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_act.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_act.c @@ -5192,6 +5192,7 @@ void bta_dm_ble_set_scan_params(tBTA_DM_MSG *p_data) p_data->ble_set_scan_params.scan_param_setup_cback); } +#if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** ** Function bta_dm_ble_set_scan_fil_params @@ -5223,7 +5224,7 @@ void bta_dm_ble_set_scan_fil_params(tBTA_DM_MSG *p_data) } } - +#endif // #if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** @@ -5319,8 +5320,9 @@ void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data) if (p_data->hdr.event != BTA_DM_API_BLE_STOP_ADV_EVT) { APPL_TRACE_ERROR("Invalid BTA event,can't stop the BLE adverting\n"); } - +#if (BLE_42_ADV_EN == TRUE) btm_ble_stop_adv(); +#endif // #if (BLE_42_ADV_EN == TRUE) } @@ -5438,23 +5440,7 @@ void bta_dm_ble_scan (tBTA_DM_MSG *p_data) } } -/******************************************************************************* -** -** Function bta_dm_ble_set_adv_params -** -** Description This function set the adv parameters. -** -** Parameters: -** -*******************************************************************************/ -void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data) -{ - BTM_BleSetAdvParams(p_data->ble_set_adv_params.adv_int_min, - p_data->ble_set_adv_params.adv_int_max, - p_data->ble_set_adv_params.p_dir_bda, - BTA_DM_BLE_ADV_CHNL_MAP); -} - +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function bta_dm_ble_set_adv_params_all @@ -5492,6 +5478,7 @@ void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data) (*p_data->ble_set_adv_params_all.p_start_adv_cback)(status); } } +#endif // #if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** @@ -5509,6 +5496,7 @@ void bta_dm_ble_update_duplicate_exceptional_list(tBTA_DM_MSG *p_data) p_data->ble_duplicate_exceptional_list.exceptional_list_cb); } +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function bta_dm_ble_set_adv_config @@ -5532,29 +5520,6 @@ void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data) } } -/******************************************************************************* -** -** Function bta_dm_ble_set_long_adv -** -** Description This function set the long ADV data -** -** Parameters: -** -*******************************************************************************/ -void bta_dm_ble_set_long_adv (tBTA_DM_MSG *p_data) -{ - tBTA_STATUS status = BTA_FAILURE; - - if (BTM_BleWriteLongAdvData(p_data->ble_set_long_adv_data.adv_data, - p_data->ble_set_long_adv_data.adv_data_len) == BTM_SUCCESS) { - status = BTA_SUCCESS; - } - - if (p_data->ble_set_adv_data.p_adv_data_cback) { - (*p_data->ble_set_adv_data.p_adv_data_cback)(status); - } -} - /******************************************************************************* ** ** Function bta_dm_ble_set_adv_config_raw @@ -5578,7 +5543,6 @@ void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data) } } - /******************************************************************************* ** ** Function bta_dm_ble_set_scan_rsp @@ -5624,7 +5588,7 @@ void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data) (*p_data->ble_set_adv_data_raw.p_adv_data_cback)(status); } } - +#endif // #if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function bta_dm_ble_set_data_length @@ -5681,6 +5645,7 @@ void bta_dm_ble_set_data_length(tBTA_DM_MSG *p_data) } +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function bta_dm_ble_broadcast @@ -5706,6 +5671,7 @@ void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data) } } +#endif // #if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** @@ -5815,6 +5781,7 @@ void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data) } } +#if (BLE_42_DTM_TEST_EN == TRUE) void bta_dm_ble_gap_dtm_tx_start(tBTA_DM_MSG *p_data) { BTM_BleTransmitterTest(p_data->dtm_tx_start.tx_channel, p_data->dtm_tx_start.len_of_data, p_data->dtm_tx_start.pkt_payload, p_data->dtm_tx_start.p_dtm_cmpl_cback); @@ -5824,11 +5791,14 @@ void bta_dm_ble_gap_dtm_rx_start(tBTA_DM_MSG *p_data) { BTM_BleReceiverTest(p_data->dtm_rx_start.rx_channel, p_data->dtm_rx_start.p_dtm_cmpl_cback); } +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) void bta_dm_ble_gap_dtm_stop(tBTA_DM_MSG *p_data) { BTM_BleTestEnd(p_data->dtm_stop.p_dtm_cmpl_cback); } +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data) { @@ -5867,7 +5837,8 @@ void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data) BTM_BleSetCsaSupport(p_data->ble_set_csa_support.csa_select, p_data->ble_set_csa_support.p_cback); } -#if (BLE_50_FEATURE_SUPPORT == TRUE) + +#if (BLE_50_DTM_TEST_EN == TRUE) void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data) { BTM_BleEnhancedTransmitterTest(p_data->dtm_enh_tx_start.tx_channel, p_data->dtm_enh_tx_start.len_of_data, @@ -5879,7 +5850,8 @@ void bta_dm_ble_gap_dtm_enhance_rx_start(tBTA_DM_MSG *p_data) BTM_BleEnhancedReceiverTest(p_data->dtm_enh_rx_start.rx_channel, p_data->dtm_enh_rx_start.phy, p_data->dtm_enh_rx_start.modulation_index, p_data->dtm_enh_rx_start.p_dtm_cmpl_cback); } - +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_FEATURE_SUPPORT == TRUE) void bta_dm_ble_gap_read_phy(tBTA_DM_MSG *p_data) { //tBTM_STATUS btm_status = 0; @@ -5905,6 +5877,7 @@ void bta_dm_ble_gap_set_prefer_phy(tBTA_DM_MSG *p_data) p_data->ble_set_per_phy.phy_options); } +#if (BLE_50_EXTEND_ADV_EN == TRUE) void bta_dm_ble_gap_ext_adv_set_rand_addr(tBTA_DM_MSG *p_data) { BTM_BleSetExtendedAdvRandaddr(p_data->ble_set_ext_adv_rand_addr.instance, p_data->ble_set_ext_adv_rand_addr.rand_addr); @@ -5945,7 +5918,9 @@ void bta_dm_ble_gap_ext_adv_set_clear(tBTA_DM_MSG *p_data) { BTM_BleExtAdvSetClear(); } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) void bta_dm_ble_gap_periodic_adv_set_params(tBTA_DM_MSG *p_data) { APPL_TRACE_API("%s, instance = %d", __func__, p_data->ble_set_periodic_adv_params.instance); @@ -5972,7 +5947,9 @@ void bta_dm_ble_gap_periodic_adv_enable(tBTA_DM_MSG *p_data) BTM_BlePeriodicAdvEnable(p_data->ble_enable_periodic_adv.instance, p_data->ble_enable_periodic_adv.enable); } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) void bta_dm_ble_gap_periodic_adv_create_sync(tBTA_DM_MSG *p_data) { APPL_TRACE_API("%s", __func__); @@ -6017,8 +5994,9 @@ void bta_dm_ble_gap_periodic_adv_clear_dev(tBTA_DM_MSG *p_data) APPL_TRACE_API("%s", __func__); BTM_BlePeriodicAdvClearDev(); } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) - +#if (BLE_50_EXTEND_SCAN_EN == TRUE) void bta_dm_ble_gap_set_ext_scan_params(tBTA_DM_MSG *p_data) { APPL_TRACE_API("%s", __func__); @@ -6032,14 +6010,14 @@ void bta_dm_ble_gap_ext_scan(tBTA_DM_MSG *p_data) BTM_BleExtendedScan(p_data->ble_ext_scan.start, p_data->ble_ext_scan.duration, p_data->ble_ext_scan.period); } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) void bta_dm_ble_gap_set_prefer_ext_conn_params(tBTA_DM_MSG *p_data) { tBTM_EXT_CONN_PARAMS conn_params; conn_params.phy_mask = p_data->ble_set_per_ext_conn_params.phy_mask; - APPL_TRACE_API("%s, start = %d, duration = %d, period = %d", __func__, p_data->ble_ext_scan.start, p_data->ble_ext_scan.duration, - p_data->ble_ext_scan.period); + APPL_TRACE_API("%s, phy_mask %d", __func__, p_data->ble_set_per_ext_conn_params.phy_mask); if (conn_params.phy_mask & BTA_PHY_1M_MASK) { memcpy(&conn_params.phy_1m_conn_params, &p_data->ble_set_per_ext_conn_params.phy_1m_conn_params, 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 7155524637..2eb9d74176 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_api.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_api.c @@ -1440,7 +1440,7 @@ void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval, } } - +#if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** ** Function BTA_DmSetBleScanFilterParams @@ -1480,46 +1480,9 @@ void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, } +#endif // #if (BLE_42_SCAN_EN == TRUE) -/******************************************************************************* -** -** Function BTA_DmSetBleAdvParams -** -** Description This function sets the advertising parameters BLE functionality. -** It is to be called when device act in peripheral or broadcaster -** role. -** -** -** Returns void -** -*******************************************************************************/ -void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max, - tBLE_BD_ADDR *p_dir_bda) -{ -#if BLE_INCLUDED == TRUE - tBTA_DM_API_BLE_ADV_PARAMS *p_msg; - - APPL_TRACE_API ("BTA_DmSetBleAdvParam: %d, %d\n", adv_int_min, adv_int_max); - - if ((p_msg = (tBTA_DM_API_BLE_ADV_PARAMS *) osi_malloc(sizeof(tBTA_DM_API_BLE_ADV_PARAMS) - + sizeof(tBLE_BD_ADDR))) != NULL) { - memset(p_msg, 0, sizeof(tBTA_DM_API_BLE_ADV_PARAMS) + sizeof(tBLE_BD_ADDR)); - - p_msg->hdr.event = BTA_DM_API_BLE_ADV_PARAM_EVT; - - p_msg->adv_int_min = adv_int_min; - p_msg->adv_int_max = adv_int_max; - - if (p_dir_bda != NULL) { - p_msg->p_dir_bda = (tBLE_BD_ADDR *)(p_msg + 1); - memcpy(p_msg->p_dir_bda, p_dir_bda, sizeof(tBLE_BD_ADDR)); - } - - bta_sys_sendmsg(p_msg); - } -#endif -} - +#if (BLE_42_ADV_EN == TRUE) void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own, tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol, @@ -1553,6 +1516,8 @@ void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, } #endif } +#endif // #if (BLE_42_ADV_EN == TRUE) + #endif ///BLE_INCLUDED == TRUE @@ -1561,6 +1526,7 @@ void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, ********************************************************************************/ #if BLE_INCLUDED == TRUE +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function BTA_DmBleSetAdvConfig @@ -1622,35 +1588,6 @@ void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len, } } -/******************************************************************************* -** -** Function BTA_DmBleSetLongAdv -** -** Description This function is called to set long Advertising data -** -** Parameters adv_data : long advertising data. -** adv_data_len : long advertising data length. -** p_adv_data_cback : set long adv data complete callback. -** -** Returns None -** -*******************************************************************************/ -void BTA_DmBleSetLongAdv (UINT8 *adv_data, UINT32 adv_data_len, - tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback) -{ - tBTA_DM_API_SET_LONG_ADV *p_msg; - - if ((p_msg = (tBTA_DM_API_SET_LONG_ADV *) - osi_malloc(sizeof(tBTA_DM_API_SET_LONG_ADV))) != NULL) { - p_msg->hdr.event = BTA_DM_API_BLE_SET_LONG_ADV_EVT; - p_msg->p_adv_data_cback = p_adv_data_cback; - p_msg->adv_data = adv_data; - p_msg->adv_data_len = adv_data_len; - - bta_sys_sendmsg(p_msg); - } -} - /******************************************************************************* ** ** Function BTA_DmBleSetScanRsp @@ -1707,6 +1644,7 @@ void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_len, bta_sys_sendmsg(p_msg); } } +#endif // #if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** @@ -1894,7 +1832,7 @@ extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value, ** BLE ADV data management API ********************************************************************************/ #if BLE_INCLUDED == TRUE - +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function BTA_DmBleBroadcast @@ -1948,6 +1886,8 @@ void BTA_DmBleClearAdv (tBTA_CLEAR_ADV_CMPL_CBACK *p_clear_adv_cback) bta_sys_sendmsg(p_msg); } } +#endif // #if (BLE_42_ADV_EN == TRUE) + #endif /******************************************************************************* ** @@ -2682,6 +2622,7 @@ void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_S } } +#if (BLE_42_DTM_TEST_EN == TRUE) void BTA_DmBleDtmTxStart(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) { tBTA_DM_API_BLE_DTM_TX_START *p_msg; @@ -2711,7 +2652,9 @@ void BTA_DmBleDtmRxStart(uint8_t rx_channel, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl bta_sys_sendmsg(p_msg); } } +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) { tBTA_DM_API_BLE_DTM_STOP *p_msg; @@ -2724,6 +2667,7 @@ void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) bta_sys_sendmsg(p_msg); } } +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) void BTA_DmBleSetPrivacyMode(uint8_t addr_type, BD_ADDR addr, uint8_t privacy_mode, tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback) { @@ -2859,7 +2803,7 @@ extern void BTA_DmBleObserve(BOOLEAN start, UINT32 duration, bta_sys_sendmsg(p_msg); } } - +#if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** ** Function BTA_DmBleScan @@ -2900,6 +2844,7 @@ extern void BTA_DmBleScan(BOOLEAN start, UINT32 duration, bta_sys_sendmsg(p_msg); } } +#endif // #if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** @@ -3141,7 +3086,7 @@ void BTA_DmBleGapSetPreferedPHY(BD_ADDR addr, APPL_TRACE_ERROR("%s malloc failed", __func__); } } - +#if (BLE_50_EXTEND_ADV_EN == TRUE) void BTA_DmBleGapExtAdvSetRandaddr(UINT16 instance, BD_ADDR addr) { tBTA_DM_API_EXT_ADV_SET_RAND_ADDR *p_msg; @@ -3247,7 +3192,9 @@ void BTA_DmBleGapExtAdvSetClear(void) APPL_TRACE_ERROR("%s malloc failed", __func__); } } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) void BTA_DmBleGapPeriodicAdvSetParams(UINT8 instance, tBTA_DM_BLE_Periodic_Adv_Params *params) { @@ -3304,7 +3251,9 @@ void BTA_DmBleGapPeriodicAdvEnable(UINT8 enable, UINT8 instance) } } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) void BTA_DmBleGapPeriodicAdvCreateSync(tBTA_DM_BLE_Periodic_Sync_Params *params) { tBTA_DM_API_PERIODIC_ADV_SYNC *p_msg; @@ -3406,7 +3355,9 @@ void BTA_DmBleGapPeriodicAdvClearDev(void) } } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) void BTA_DmBleGapSetExtScanParams(tBTA_DM_BLE_EXT_SCAN_PARAMS *params) { tBTA_DM_API_SET_EXT_SCAN_PARAMS *p_msg; @@ -3440,6 +3391,7 @@ void BTA_DmBleGapExtScan(BOOLEAN start, UINT32 duration, UINT16 period) } } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr, UINT8 phy_mask, @@ -3493,7 +3445,9 @@ void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_add } } +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) void BTA_DmBleDtmEnhTxStart(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, uint8_t phy, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) { tBTA_DM_API_BLE_DTM_ENH_TX_START *p_msg; @@ -3526,8 +3480,7 @@ void BTA_DmBleDtmEnhRxStart(uint8_t rx_channel, uint8_t phy, uint8_t modulation_ bta_sys_sendmsg(p_msg); } } - -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) void BTA_DmBleGapPeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable) 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 2d747f5b07..f944398634 100644 --- a/components/bt/host/bluedroid/bta/dm/bta_dm_main.c +++ b/components/bt/host/bluedroid/bta/dm/bta_dm_main.c @@ -132,9 +132,13 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */ bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */ bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */ +#if (BLE_42_SCAN_EN == TRUE) bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */ +#endif // #if (BLE_42_SCAN_EN == TRUE) bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT */ +#if (BLE_42_SCAN_EN == TRUE) bta_dm_ble_scan, /* BTA_DM_API_BLE_SCAN_EVT */ +#endif // #if (BLE_42_SCAN_EN == TRUE) bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */ /* This handler function added by Yulong at 2016/9/9 to support the @@ -150,7 +154,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */ #endif bta_dm_ble_config_local_icon, /* BTA_DM_API_LOCAL_ICON_EVT */ - bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */ +#if (BLE_42_ADV_EN == TRUE) bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */ bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */ /* New function to allow set raw adv @@ -161,8 +165,8 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { response data to HCI */ bta_dm_ble_set_scan_rsp_raw, /* BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT */ bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */ +#endif // #if (BLE_42_ADV_EN == TRUE) bta_dm_ble_set_data_length, /* BTA_DM_API_SET_DATA_LENGTH_EVT */ - bta_dm_ble_set_long_adv, /* BTA_DM_API_BLE_SET_LONG_ADV_EVT */ #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */ bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */ @@ -199,28 +203,38 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_ble_gap_read_phy, /* BTA_DM_API_READ_PHY_EVT */ bta_dm_ble_gap_set_prefer_default_phy, /* BTA_DM_API_SET_PER_DEF_PHY_EVT */ bta_dm_ble_gap_set_prefer_phy, /* BTA_DM_API_SET_PER_PHY_EVT */ +#if (BLE_50_EXTEND_ADV_EN == TRUE) bta_dm_ble_gap_ext_adv_set_rand_addr, /* BTA_DM_API_SET_EXT_ADV_RAND_ADDR_EVT */ bta_dm_ble_gap_ext_adv_set_params, /* BTA_DM_API_SET_EXT_ADV_PARAMS_EVT */ bta_dm_ble_gap_config_ext_adv_data_raw, /* BTA_DM_API_CFG_ADV_DATA_RAW_EVT */ bta_dm_ble_gap_start_ext_adv, /* BTA_DM_API_EXT_ADV_ENABLE_EVT */ bta_dm_ble_gap_ext_adv_set_remove, /* BTA_DM_API_EXT_ADV_SET_REMOVE_EVT */ bta_dm_ble_gap_ext_adv_set_clear, /* BTA_DM_API_EXT_ADV_SET_CLEAR_EVT */ +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) bta_dm_ble_gap_periodic_adv_set_params, /* BTA_DM_API_PERIODIC_ADV_SET_PARAMS_EVT */ bta_dm_ble_gap_periodic_adv_cfg_data_raw, /* BTA_DM_API_PERIODIC_ADV_CFG_DATA_EVT */ bta_dm_ble_gap_periodic_adv_enable, /* BTA_DM_API_PERIODIC_ADV_ENABLE_EVT */ +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) bta_dm_ble_gap_periodic_adv_create_sync, /* BTA_DM_API_PERIODIC_ADV_SYNC_EVT */ bta_dm_ble_gap_periodic_adv_sync_cancel, /* BTA_DM_API_PERIODIC_ADV_SYNC_CANCEL_EVT */ bta_dm_ble_gap_periodic_adv_sync_terminate, /* BTA_DM_API_PERIODIC_ADV_SYNC_TERMINATE_EVT */ bta_dm_ble_gap_periodic_adv_add_dev_to_list, /* BTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LSIT_EVT */ bta_dm_ble_gap_periodic_adv_remove_dev_from_list, /* BTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LSIT_EVT */ bta_dm_ble_gap_periodic_adv_clear_dev, /* BTA_DM_API_PERIODIC_ADV_CLEAR_DEV_EVT */ +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) bta_dm_ble_gap_set_ext_scan_params, /* BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT */ bta_dm_ble_gap_ext_scan, /* BTA_DM_API_START_EXT_SCAN_EVT */ +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) bta_dm_ble_gap_set_prefer_ext_conn_params, /* BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT */ NULL, /* BTA_DM_API_EXT_CONN_EVT */ +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) bta_dm_ble_gap_dtm_enhance_tx_start, /* BTA_DM_API_DTM_ENH_TX_START_EVT */ bta_dm_ble_gap_dtm_enhance_rx_start, /* BTA_DM_API_DTM_ENH_RX_START_EVT */ -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) bta_dm_ble_gap_periodic_adv_recv_enable, /* BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT */ bta_dm_ble_gap_periodic_adv_sync_trans, /* BTA_DM_API_PERIODIC_ADV_SYNC_TRANS_EVT */ @@ -228,10 +242,16 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = { bta_dm_ble_gap_set_periodic_adv_sync_trans_params, /* BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT */ #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #if BLE_INCLUDED == TRUE +#if (BLE_42_DTM_TEST_EN == TRUE) bta_dm_ble_gap_dtm_tx_start, /* BTA_DM_API_DTM_TX_START_EVT */ bta_dm_ble_gap_dtm_rx_start, /* BTA_DM_API_DTM_RX_START_EVT */ +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) bta_dm_ble_gap_dtm_stop, /* BTA_DM_API_DTM_STOP_EVT */ +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) +#if (BLE_42_ADV_EN == TRUE) bta_dm_ble_gap_clear_adv, /* BTA_DM_API_BLE_CLEAR_ADV_EVT */ +#endif // #if (BLE_42_ADV_EN == TRUE) bta_dm_ble_gap_set_rpa_timeout, /* BTA_DM_API_SET_RPA_TIMEOUT_EVT */ bta_dm_ble_gap_add_dev_to_resolving_list, /* BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT */ bta_dm_ble_gap_set_privacy_mode, /* BTA_DM_API_SET_PRIVACY_MODE_EVT */ 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 627ab78ff5..920b19a447 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 @@ -125,9 +125,13 @@ enum { BTA_DM_API_BLE_SCAN_PARAM_EVT, /*******This event added by Yulong at 2016/10/25 to support the scan filter setting for the APP******/ +#if (BLE_42_SCAN_EN == TRUE) BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT, +#endif // #if (BLE_42_SCAN_EN == TRUE) BTA_DM_API_BLE_OBSERVE_EVT, +#if (BLE_42_SCAN_EN == TRUE) BTA_DM_API_BLE_SCAN_EVT, +#endif // #if (BLE_42_SCAN_EN == TRUE) BTA_DM_API_UPDATE_CONN_PARAM_EVT, /*******This event added by Yulong at 2016/9/9 to support the random address setting for the APP******/ @@ -140,10 +144,10 @@ enum { BTA_DM_API_LOCAL_PRIVACY_EVT, #endif BTA_DM_API_LOCAL_ICON_EVT, - BTA_DM_API_BLE_ADV_PARAM_EVT, /*******This event added by Yulong at 2016/10/20 to support setting the ble advertising param by the APP******/ +#if (BLE_42_ADV_EN == TRUE) BTA_DM_API_BLE_ADV_PARAM_All_EVT, BTA_DM_API_BLE_SET_ADV_CONFIG_EVT, /* Add for set raw advertising data */ @@ -152,8 +156,8 @@ enum { /* Add for set raw scan response data */ BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT, BTA_DM_API_BLE_BROADCAST_EVT, +#endif // #if (BLE_42_ADV_EN == TRUE) BTA_DM_API_SET_DATA_LENGTH_EVT, - BTA_DM_API_BLE_SET_LONG_ADV_EVT, #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE BTA_DM_API_CFG_FILTER_COND_EVT, BTA_DM_API_SCAN_FILTER_SETUP_EVT, @@ -190,28 +194,38 @@ enum { BTA_DM_API_READ_PHY_EVT, BTA_DM_API_SET_PER_DEF_PHY_EVT, BTA_DM_API_SET_PER_PHY_EVT, +#if (BLE_50_EXTEND_ADV_EN == TRUE) BTA_DM_API_SET_EXT_ADV_RAND_ADDR_EVT, BTA_DM_API_SET_EXT_ADV_PARAMS_EVT, BTA_DM_API_CFG_ADV_DATA_RAW_EVT, BTA_DM_API_EXT_ADV_ENABLE_EVT, BTA_DM_API_EXT_ADV_SET_REMOVE_EVT, BTA_DM_API_EXT_ADV_SET_CLEAR_EVT, +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) BTA_DM_API_PERIODIC_ADV_SET_PARAMS_EVT, BTA_DM_API_PERIODIC_ADV_CFG_DATA_EVT, BTA_DM_API_PERIODIC_ADV_ENABLE_EVT, +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) BTA_DM_API_PERIODIC_ADV_SYNC_EVT, BTA_DM_API_PERIODIC_ADV_SYNC_CANCEL_EVT, BTA_DM_API_PERIODIC_ADV_SYNC_TERMINATE_EVT, BTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LSIT_EVT, BTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LSIT_EVT, BTA_DM_API_PERIODIC_ADV_CLEAR_DEV_EVT, +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT, BTA_DM_API_START_EXT_SCAN_EVT, +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT, BTA_DM_API_EXT_CONN_EVT, +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) BTA_DM_API_DTM_ENH_TX_START_EVT, BTA_DM_API_DTM_ENH_RX_START_EVT, -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT, BTA_DM_API_PERIODIC_ADV_SYNC_TRANS_EVT, @@ -219,10 +233,16 @@ enum { BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT, #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #if BLE_INCLUDED == TRUE +#if (BLE_42_DTM_TEST_EN == TRUE) BTA_DM_API_DTM_TX_START_EVT, BTA_DM_API_DTM_RX_START_EVT, +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) BTA_DM_API_DTM_STOP_EVT, +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) +#if (BLE_42_ADV_EN == TRUE) BTA_DM_API_BLE_CLEAR_ADV_EVT, +#endif // #if (BLE_42_ADV_EN == TRUE) BTA_DM_API_SET_RPA_TIMEOUT_EVT, BTA_DM_API_ADD_DEV_TO_RESOLVING_LIST_EVT, BTA_DM_API_SET_PRIVACY_MODE_EVT, @@ -802,14 +822,6 @@ typedef struct { tBTA_ADD_DEV_TO_RESOLVING_LIST_CMPL_CBACK *p_add_dev_to_resolving_list_callback; // Callback function pointer } tBTA_DM_API_ADD_DEV_TO_RESOLVING_LIST; -/* set adv parameter for BLE advertising */ -typedef struct { - BT_HDR hdr; - UINT16 adv_int_min; - UINT16 adv_int_max; - tBLE_BD_ADDR *p_dir_bda; -} tBTA_DM_API_BLE_ADV_PARAMS; - /* set adv parameter for BLE advertising */ typedef struct { BT_HDR hdr; @@ -873,13 +885,6 @@ typedef struct { tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback; } tBTA_DM_API_SET_ADV_CONFIG_RAW; -typedef struct { - BT_HDR hdr; - UINT8 *adv_data; - UINT8 adv_data_len; - tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback; -} tBTA_DM_API_SET_LONG_ADV; - typedef struct { BT_HDR hdr; UINT8 batch_scan_full_max; @@ -928,6 +933,7 @@ typedef struct { BD_ADDR remote_bda; } tBTA_DM_API_BLE_DISCONNECT; +#if (BLE_42_DTM_TEST_EN == TRUE) typedef struct { BT_HDR hdr; UINT8 tx_channel; @@ -941,6 +947,7 @@ typedef struct { UINT8 rx_channel; tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback; } tBTA_DM_API_BLE_DTM_RX_START; +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) typedef struct { BT_HDR hdr; @@ -1020,8 +1027,8 @@ typedef struct { tBTA_DM_BLE_REF_VALUE ref_value; } tBTA_DM_API_SCAN_FILTER_PARAM_SETUP; #endif -#if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) typedef struct { BT_HDR hdr; UINT8 tx_channel; @@ -1037,7 +1044,9 @@ typedef struct { UINT8 modulation_index; tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback; } tBTA_DM_API_BLE_DTM_ENH_RX_START; +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_FEATURE_SUPPORT == TRUE) #define BTA_PHY_1M_MASK (1 << 0) #define BTA_PHY_2M_MASK (1 << 1) #define BTA_PHY_CODED_MASK (1 << 2) @@ -1306,11 +1315,9 @@ typedef union { tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy; tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy; tBTA_DM_API_LOCAL_ICON ble_local_icon; - tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params; tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all; tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data; tBTA_DM_API_SET_ADV_CONFIG_RAW ble_set_adv_data_raw; - tBTA_DM_API_SET_LONG_ADV ble_set_long_adv_data; #if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup; tBTA_DM_API_CFG_FILTER_COND ble_cfg_filter_cond; @@ -1339,36 +1346,47 @@ typedef union { tBTA_DM_API_READ_PHY ble_read_phy; tBTA_DM_API_SET_PER_DEF_PHY ble_set_per_def_phy; tBTA_DM_API_SET_PER_PHY ble_set_per_phy; +#if (BLE_50_EXTEND_ADV_EN == TRUE) tBTA_DM_API_EXT_ADV_SET_RAND_ADDR ble_set_ext_adv_rand_addr; tBTA_DM_API_EXT_ADV_SET_PARAMS ble_set_ext_adv_params; tBTA_DM_API_CFG_EXT_ADV_DATA ble_cfg_ext_adv_data; tBTA_DM_API_BLE_EXT_ADV ble_start_ext_adv; tBTA_DM_API_BLE_EXT_ADV_SET_REMOVE ble_ext_adv_set_remove; tBTA_DM_API_BLE_EXT_ADV_SET_CLEAR ble_ext_adv_set_clear; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) tBTA_DM_API_BLE_PERIODIC_ADV_SET_PARAMS ble_set_periodic_adv_params; tBTA_DM_API_CFG_PERIODIC_ADV_DATA ble_cfg_periodic_adv_data; tBTA_DM_API_ENABLE_PERIODIC_ADV ble_enable_periodic_adv; +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) tBTA_DM_API_PERIODIC_ADV_SYNC ble_periodic_adv_sync; tBTA_DM_API_PERIODIC_ADV_SYNC_CANCEL ble_periodic_adv_sync_cancel; tBTA_DM_API_PERIODIC_ADV_SYNC_TERM ble_periodic_adv_sync_term; tBTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LIST ble_periodic_adv_add_dev_to_list; tBTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LIST ble_periodic_adv_remove_dev_from_list; tBTA_DM_API_PERIODIC_ADV_DEV_CLEAR ble_periodic_adv_clear_dev; +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) tBTA_DM_API_SET_EXT_SCAN_PARAMS ble_set_ext_scan_params; tBTA_DM_API_EXT_SCAN ble_ext_scan; +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) tBTA_DM_API_SET_PER_EXT_CONN_PARAMS ble_set_per_ext_conn_params; +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) tBTA_DM_API_BLE_DTM_ENH_TX_START dtm_enh_tx_start; tBTA_DM_API_BLE_DTM_ENH_RX_START dtm_enh_rx_start; -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) tBTA_DM_API_PERIODIC_ADV_RECV_ENABLE ble_periodic_adv_recv_enable; tBTA_DM_API_PERIODIC_ADV_SYNC_TRANS ble_periodic_adv_sync_trans; tBTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS ble_periodic_adv_set_info_trans; tBTA_DM_API_SET_PAST_PARAMS ble_set_past_params; #endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == 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; +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) tBTA_DM_API_BLE_DTM_STOP dtm_stop; tBTA_DM_API_CLEAR_ADV ble_clear_adv; tBTA_DM_API_SET_PRIVACY_MODE ble_set_privacy_mode; @@ -1796,10 +1814,8 @@ extern void bta_dm_ble_clear_rand_address(tBTA_DM_MSG *p_data); extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data); extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data); extern void bta_dm_ble_config_local_icon (tBTA_DM_MSG *p_data); -extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_adv_params_all(tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data); -extern void bta_dm_ble_set_long_adv (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_adv_config_raw (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data); extern void bta_dm_ble_set_scan_rsp_raw (tBTA_DM_MSG *p_data); @@ -1818,17 +1834,21 @@ extern void btm_dm_ble_multi_adv_disable(tBTA_DM_MSG *p_data); extern void bta_dm_ble_multi_adv_data(tBTA_DM_MSG *p_data); extern void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data); extern void bta_dm_ble_multi_adv_enb(tBTA_DM_MSG *p_data); +#if (BLE_42_DTM_TEST_EN == TRUE) extern void bta_dm_ble_gap_dtm_tx_start(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_dtm_rx_start(tBTA_DM_MSG *p_data); +#endif// #if (BLE_42_DTM_TEST_EN == TRUE) extern void bta_dm_ble_gap_dtm_stop(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_clear_adv(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_set_rpa_timeout(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_add_dev_to_resolving_list(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_set_privacy_mode(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_set_csa_support(tBTA_DM_MSG *p_data); -#if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) extern void bta_dm_ble_gap_dtm_enhance_tx_start(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_dtm_enhance_rx_start(tBTA_DM_MSG *p_data); +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_FEATURE_SUPPORT == TRUE) extern void bta_dm_ble_gap_read_phy(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_set_prefer_default_phy(tBTA_DM_MSG *p_data); extern void bta_dm_ble_gap_set_prefer_phy(tBTA_DM_MSG *p_data); diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c index ee096928a2..eb2b091eae 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_act.c @@ -2326,92 +2326,6 @@ void bta_gattc_process_listen_all(UINT8 cif) } } } -/******************************************************************************* -** -** Function bta_gattc_listen -** -** Description Start or stop a listen for connection -** -** Returns void -** -********************************************************************************/ -void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) -{ - tBTA_GATTC_RCB *p_clreg = bta_gattc_cl_get_regcb(p_msg->api_listen.client_if); - tBTA_GATTC cb_data; - UNUSED(p_cb); - - cb_data.reg_oper.status = BTA_GATT_ERROR; - cb_data.reg_oper.client_if = p_msg->api_listen.client_if; - - if (p_clreg == NULL) { - APPL_TRACE_ERROR("bta_gattc_listen failed, unknown client_if: %d", - p_msg->api_listen.client_if); - return; - } - /* mark bg conn record */ - if (bta_gattc_mark_bg_conn(p_msg->api_listen.client_if, - (BD_ADDR_PTR) p_msg->api_listen.remote_bda, - p_msg->api_listen.start, - TRUE)) { - if (!GATT_Listen(p_msg->api_listen.client_if, - p_msg->api_listen.start, - p_msg->api_listen.remote_bda)) { - APPL_TRACE_ERROR("Listen failure"); - (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data); - } else { - cb_data.status = BTA_GATT_OK; - - (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data); - - if (p_msg->api_listen.start) { - /* if listen to a specific target */ - if (p_msg->api_listen.remote_bda != NULL) { - - /* if is a connected remote device */ - if (L2CA_GetBleConnRole(p_msg->api_listen.remote_bda) == HCI_ROLE_SLAVE && - bta_gattc_find_clcb_by_cif(p_msg->api_listen.client_if, - p_msg->api_listen.remote_bda, - BTA_GATT_TRANSPORT_LE) == NULL) { - - bta_gattc_init_clcb_conn(p_msg->api_listen.client_if, - p_msg->api_listen.remote_bda); - } - } - /* if listen to all */ - else { - APPL_TRACE_DEBUG("Listen For All now"); - /* go through all connected device and send - callback for all connected slave connection */ - bta_gattc_process_listen_all(p_msg->api_listen.client_if); - } - } - } - } -} - -/******************************************************************************* -** -** Function bta_gattc_broadcast -** -** Description Start or stop broadcasting -** -** Returns void -** -********************************************************************************/ -void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg) -{ - tBTA_GATTC_RCB *p_clreg = bta_gattc_cl_get_regcb(p_msg->api_listen.client_if); - tBTA_GATTC cb_data; - UNUSED(p_cb); - - cb_data.reg_oper.client_if = p_msg->api_listen.client_if; - cb_data.reg_oper.status = BTM_BleBroadcast(p_msg->api_listen.start, NULL); - //TODO need modify callback if used - if (p_clreg && p_clreg->p_cback) { - (*p_clreg->p_cback)(BTA_GATTC_LISTEN_EVT, &cb_data); - } -} /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c index 20cff5255a..8ac0ec4c96 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_api.c @@ -1090,66 +1090,6 @@ void BTA_GATTC_Clean(BD_ADDR remote_bda) } return; } -/******************************************************************************* -** -** Function BTA_GATTC_Listen -** -** Description Start advertisement to listen for connection request for a GATT -** client application. -** -** Parameters client_if: server interface. -** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. -** -** Returns void -** -*******************************************************************************/ -void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target_bda) -{ - tBTA_GATTC_API_LISTEN *p_buf; - - if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_malloc((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) { - p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT; - - p_buf->client_if = client_if; - p_buf->start = start; - if (target_bda) { - p_buf->remote_bda = (UINT8 *)(p_buf + 1); - memcpy(p_buf->remote_bda, target_bda, BD_ADDR_LEN); - } else { - p_buf->remote_bda = NULL; - } - - bta_sys_sendmsg(p_buf); - } - return; -} - -/******************************************************************************* -** -** Function BTA_GATTC_Broadcast -** -** Description Start broadcasting (non-connectable advertisements) -** -** Parameters client_if: client interface. -** start: to start or stop listening for connection -** -** Returns void -** -*******************************************************************************/ -void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start) -{ - tBTA_GATTC_API_LISTEN *p_buf; - - if ((p_buf = (tBTA_GATTC_API_LISTEN *) osi_malloc((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) { - p_buf->hdr.event = BTA_GATTC_API_BROADCAST_EVT; - p_buf->client_if = client_if; - p_buf->start = start; - bta_sys_sendmsg(p_buf); - } - return; -} /* Add For BLE PTS */ uint8_t BTA_GATTC_AutoDiscoverEnable(uint8_t enable) diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c b/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c index 47f210c872..c1d1e72033 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gattc_main.c @@ -381,15 +381,6 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg) case BTA_GATTC_API_CACHE_CLEAN_EVT: bta_gattc_process_api_cache_clean(p_cb, (tBTA_GATTC_DATA *) p_msg); break; -#if BLE_INCLUDED == TRUE - case BTA_GATTC_API_LISTEN_EVT: - bta_gattc_listen(p_cb, (tBTA_GATTC_DATA *) p_msg); - break; - case BTA_GATTC_API_BROADCAST_EVT: - bta_gattc_broadcast(p_cb, (tBTA_GATTC_DATA *) p_msg); - break; -#endif - case BTA_GATTC_ENC_CMPL_EVT: bta_gattc_process_enc_cmpl(p_cb, (tBTA_GATTC_DATA *) p_msg); break; @@ -485,8 +476,6 @@ static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code) return "BTA_GATTC_API_REFRESH_EVT"; case BTA_GATTC_API_CACHE_CLEAN_EVT: return "BTA_GATTC_API_CACHE_CLEAN_EVT"; - case BTA_GATTC_API_LISTEN_EVT: - return "BTA_GATTC_API_LISTEN_EVT"; case BTA_GATTC_API_DISABLE_EVT: return "BTA_GATTC_API_DISABLE_EVT"; case BTA_GATTC_API_CFG_MTU_EVT: diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c index 759baed015..692c59c660 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gatts_act.c @@ -882,41 +882,6 @@ void bta_gatts_send_service_change_indication (tBTA_GATTS_DATA *p_msg) } } -/******************************************************************************* -** -** Function bta_gatts_listen -** -** Description Start or stop listening for LE connection on a GATT server -** -** Returns none. -** -*******************************************************************************/ -void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg) -{ - tBTA_GATTS_RCB *p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_listen.server_if); - tBTA_GATTS cb_data; - UNUSED(p_cb); - - cb_data.reg_oper.status = BTA_GATT_OK; - cb_data.reg_oper.server_if = p_msg->api_listen.server_if; - - if (p_rcb == NULL) { - APPL_TRACE_ERROR("Unknown GATTS application"); - return; - } - - if (!GATT_Listen(p_msg->api_listen.server_if, - p_msg->api_listen.start, - p_msg->api_listen.remote_bda)) { - cb_data.status = BTA_GATT_ERROR; - APPL_TRACE_ERROR("bta_gatts_listen Listen failed"); - } - - if (p_rcb->p_cback) { - (*p_rcb->p_cback)(BTA_GATTS_LISTEN_EVT, &cb_data); - } -} - /******************************************************************************* ** ** Function bta_gatts_show_local_database diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gatts_api.c b/components/bt/host/bluedroid/bta/gatt/bta_gatts_api.c index ffe3abec6a..4e1f76f636 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gatts_api.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gatts_api.c @@ -603,43 +603,6 @@ void BTA_GATTS_SendServiceChangeIndication(tBTA_GATTS_IF server_if, BD_ADDR remo } -/******************************************************************************* -** -** Function BTA_GATTS_Listen -** -** Description Start advertisement to listen for connection request for a -** GATT server -** -** Parameters server_if: server interface. -** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. -** -** Returns void -** -*******************************************************************************/ -void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, BOOLEAN start, BD_ADDR_PTR target_bda) -{ - tBTA_GATTS_API_LISTEN *p_buf; - - if ((p_buf = (tBTA_GATTS_API_LISTEN *) osi_malloc((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL) { - p_buf->hdr.event = BTA_GATTS_API_LISTEN_EVT; - - p_buf->server_if = server_if; - p_buf->start = start; - - if (target_bda) { - p_buf->remote_bda = (UINT8 *)(p_buf + 1); - memcpy(p_buf->remote_bda, target_bda, BD_ADDR_LEN); - } else { - p_buf->remote_bda = NULL; - } - - bta_sys_sendmsg(p_buf); - } - return; -} - uint8_t BTA_GATTS_SetServiceChangeMode(uint8_t mode) { tGATT_STATUS status; diff --git a/components/bt/host/bluedroid/bta/gatt/bta_gatts_main.c b/components/bt/host/bluedroid/bta/gatt/bta_gatts_main.c index fe83d151bb..bf1174c5f7 100644 --- a/components/bt/host/bluedroid/bta/gatt/bta_gatts_main.c +++ b/components/bt/host/bluedroid/bta/gatt/bta_gatts_main.c @@ -112,9 +112,6 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg) bta_gatts_set_attr_value(p_srvc_cb, (tBTA_GATTS_DATA *) p_msg); break; } - case BTA_GATTS_API_LISTEN_EVT: - bta_gatts_listen(p_cb, (tBTA_GATTS_DATA *) p_msg); - break; case BTA_GATTS_API_ADD_INCL_SRVC_EVT: case BTA_GATTS_API_ADD_CHAR_EVT: case BTA_GATTS_API_ADD_DESCR_EVT: diff --git a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h index aa404e55a2..cb877fcfc2 100644 --- a/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h +++ b/components/bt/host/bluedroid/bta/gatt/include/bta_gattc_int.h @@ -66,8 +66,6 @@ enum { BTA_GATTC_INT_START_IF_EVT, BTA_GATTC_API_REG_EVT, BTA_GATTC_API_DEREG_EVT, - BTA_GATTC_API_LISTEN_EVT, - BTA_GATTC_API_BROADCAST_EVT, BTA_GATTC_API_DISABLE_EVT, BTA_GATTC_ENC_CMPL_EVT, BTA_GATTC_API_CACHE_ASSOC_EVT, @@ -201,14 +199,6 @@ typedef struct { tBTA_GATTC_EVT cmpl_evt; }tBTA_GATTC_API_READ_MULTI; -typedef struct { - BT_HDR hdr; - BD_ADDR_PTR remote_bda; - tBTA_GATTC_IF client_if; - BOOLEAN start; -} tBTA_GATTC_API_LISTEN; - - typedef struct { BT_HDR hdr; } tBTA_GATTC_API_CFG_MTU; @@ -278,8 +268,6 @@ typedef union { tBTA_GATTC_INT_START_IF int_start_if; tBTA_GATTC_INT_DEREG int_dereg; - /* if peripheral role is supported */ - tBTA_GATTC_API_LISTEN api_listen; } tBTA_GATTC_DATA; @@ -507,10 +495,6 @@ extern void bta_gattc_process_api_cache_clean(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DA extern void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); extern void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); -#if BLE_INCLUDED == TRUE -extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); -extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); -#endif /* utility functions */ extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport); extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_conn_id (UINT16 conn_id); diff --git a/components/bt/host/bluedroid/bta/gatt/include/bta_gatts_int.h b/components/bt/host/bluedroid/bta/gatt/include/bta_gatts_int.h index 51d6fd4ed6..854a28a208 100644 --- a/components/bt/host/bluedroid/bta/gatt/include/bta_gatts_int.h +++ b/components/bt/host/bluedroid/bta/gatt/include/bta_gatts_int.h @@ -51,7 +51,6 @@ enum { BTA_GATTS_API_OPEN_EVT, BTA_GATTS_API_CANCEL_OPEN_EVT, BTA_GATTS_API_CLOSE_EVT, - BTA_GATTS_API_LISTEN_EVT, BTA_GATTS_API_DISABLE_EVT, BTA_GATTS_API_SEND_SERVICE_CHANGE_EVT, BTA_GATTS_API_SHOW_LOCAL_DATABASE_EVT @@ -64,7 +63,7 @@ typedef UINT16 tBTA_GATTS_INT_EVT; /* max number of services allowed in the device */ #define BTA_GATTS_MAX_SRVC_NUM GATT_MAX_SR_PROFILES -/* internal strucutre for GATTC register API */ +/* internal structure for GATTC register API */ typedef struct { BT_HDR hdr; tBT_UUID app_uuid; @@ -148,13 +147,6 @@ typedef struct { typedef tBTA_GATTS_API_OPEN tBTA_GATTS_API_CANCEL_OPEN; -typedef struct { - BT_HDR hdr; - BD_ADDR_PTR remote_bda; - tBTA_GATTS_IF server_if; - BOOLEAN start; -} tBTA_GATTS_API_LISTEN; - typedef struct { BT_HDR hdr; tBTA_GATTS_IF server_if; @@ -177,8 +169,6 @@ typedef union { tBTA_GATTS_API_CANCEL_OPEN api_cancel_open; tBTA_GATTS_INT_START_IF int_start_if; - /* if peripheral role is supported */ - tBTA_GATTS_API_LISTEN api_listen; tBTA_GATTS_API_SEND_SERVICE_CHANGE api_send_service_change; } tBTA_GATTS_DATA; @@ -250,7 +240,6 @@ extern void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_m extern void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg); extern void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg); extern void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg); -extern void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg); extern void bta_gatts_send_service_change_indication (tBTA_GATTS_DATA *p_msg); extern void bta_gatts_show_local_database (void); 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 62b0273f10..b24872a5dd 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_api.h @@ -1615,6 +1615,7 @@ typedef struct { #define BTA_DM_BLE_5_GAP_READ_PHY_COMPLETE_EVT BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT +#if (BLE_50_EXTEND_ADV_EN == TRUE) #define BTA_DM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT @@ -1623,6 +1624,8 @@ typedef struct { #define BTA_DM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT @@ -1633,19 +1636,28 @@ typedef struct { #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) #define BTA_DM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) #define BTA_DM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT #define BTA_DM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT +#if (BLE_50_EXTEND_SCAN_EN == TRUE) #define BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT #define BTA_DM_BLE_5_GAP_SCAN_TIMEOUT_EVT BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) #define BTA_DM_BLE_5_GAP_ADV_TERMINATED_EVT BTM_BLE_5_GAP_ADV_TERMINATED_EVT #define BTA_DM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #define BTA_DM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT +#if (BLE_50_EXTEND_SYNC_EN == TRUE) #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT #define BTA_DM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #define BTA_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT #define BTA_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT @@ -2492,24 +2504,6 @@ extern void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interva UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback); -/******************************************************************************* -** -** Function BTA_DmSetBleAdvParams -** -** Description This function sets the advertising parameters BLE functionality. -** It is to be called when device act in peripheral or broadcaster -** role. -** -** Parameters: adv_int_min - adv interval minimum -** adv_int_max - adv interval max -** p_dir_bda - directed adv initiator address -** -** Returns void -** -*******************************************************************************/ -extern void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max, - tBLE_BD_ADDR *p_dir_bda); - extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max, UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own, tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol, @@ -2725,21 +2719,6 @@ extern void BTA_DmBleSetAdvConfig (tBTA_BLE_AD_MASK data_mask, extern void BTA_DmBleSetAdvConfigRaw (UINT8 *p_raw_adv, UINT32 raw_adv_len, tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); -/******************************************************************************* -** -** Function BTA_DmBleSetLongAdv -** -** Description This function is called to set long Advertising data -** -** Parameters adv_data : long advertising data. -** adv_data_len : long advertising data length. -** p_adv_data_cback : set long adv data complete callback. -** -** Returns None -** -*******************************************************************************/ -void BTA_DmBleSetLongAdv (UINT8 *adv_data, UINT32 adv_data_len, - tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback); /******************************************************************************* ** @@ -2916,9 +2895,11 @@ extern void BTA_DmBleDisconnect(BD_ADDR bd_addr); ** *******************************************************************************/ extern void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length, tBTA_SET_PKT_DATA_LENGTH_CBACK *p_set_pkt_data_cback); - +#if (BLE_42_DTM_TEST_EN == TRUE) extern void BTA_DmBleDtmTxStart(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); extern void BTA_DmBleDtmRxStart(uint8_t rx_channel, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) + extern void BTA_DmBleDtmStop(tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); extern void BTA_DmBleSetPrivacyMode(uint8_t addr_type, BD_ADDR addr, uint8_t privacy_mode, tBTA_SET_PRIVACY_MODE_CMPL_CBACK *p_cback); @@ -3179,11 +3160,13 @@ extern void BTA_DmBleGapPreferExtConnectParamsSet(BD_ADDR bd_addr, const tBTA_DM_BLE_CONN_PARAMS *phy_coded_conn_params); extern void BTA_DmBleGapExtConnect(tBLE_ADDR_TYPE own_addr_type, const BD_ADDR peer_addr); +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) extern void BTA_DmBleDtmEnhTxStart(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, uint8_t phy, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); extern void BTA_DmBleDtmEnhRxStart(uint8_t rx_channel, uint8_t phy, uint8_t modulation_index, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback); -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) extern void BTA_DmBleGapPeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable); diff --git a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h index ebfcd14369..a42d14084b 100644 --- a/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h +++ b/components/bt/host/bluedroid/bta/include/bta/bta_gatt_api.h @@ -1203,37 +1203,6 @@ extern void BTA_GATTC_CacheGetAddrList(tBTA_GATTC_IF client_if); *******************************************************************************/ extern void BTA_GATTC_Clean(BD_ADDR remote_bda); -/******************************************************************************* -** -** Function BTA_GATTC_Listen -** -** Description Start advertisement to listen for connection request. -** -** Parameters client_if: server interface. -** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. -** -** Returns void -** -*******************************************************************************/ -extern void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target_bda); - -/******************************************************************************* -** -** Function BTA_GATTC_Broadcast -** -** Description Start broadcasting (non-connectable advertisements) -** -** Parameters client_if: client interface. -** start: to start or stop listening for connection -** -** Returns void -** -*******************************************************************************/ -extern void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start); - - /******************************************************************************* ** ** Function BTA_GATTC_ConfigureMTU @@ -1559,24 +1528,6 @@ extern void BTA_GATTS_Close(UINT16 conn_id); void BTA_GATTS_SendServiceChangeIndication(tBTA_GATTS_IF server_if, BD_ADDR remote_bda); -/******************************************************************************* -** -** Function BTA_GATTS_Listen -** -** Description Start advertisement to listen for connection request for a -** GATT server -** -** Parameters server_if: server interface. -** start: to start or stop listening for connection -** remote_bda: remote device BD address, if listen to all device -** use NULL. -** -** Returns void -** -*******************************************************************************/ -extern void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, BOOLEAN start, - BD_ADDR_PTR target_bda); - /******************************************************************************* ** ** Function BTA_GATTS_ShowLocalDatabase 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 60b9f598eb..babddbfc1d 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 @@ -30,6 +30,7 @@ #if (BLE_INCLUDED == TRUE) #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) #if BTC_DYNAMIC_MEMORY == FALSE static tBTA_BLE_ADV_DATA gl_bta_adv_data; static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data; @@ -37,6 +38,7 @@ static tBTA_BLE_ADV_DATA gl_bta_scan_rsp_data; tBTA_BLE_ADV_DATA *gl_bta_adv_data_ptr; tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr; #endif +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) #define BTC_GAP_BLE_ADV_RPT_QUEUE_IDX (1) @@ -44,12 +46,14 @@ tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr; #define BTC_GAP_BLE_ADV_RPT_QUEUE_LEN_MAX (200) #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_SCAN_EN == TRUE) typedef struct { struct pkt_queue *adv_rpt_queue; struct osi_event *adv_rpt_ready; } btc_gap_ble_env_t; static btc_gap_ble_env_t btc_gap_ble_env; +#endif // #if (BLE_42_SCAN_EN == TRUE) #endif static inline void btc_gap_ble_cb_to_app(esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) @@ -88,6 +92,7 @@ static void btc_gap_ble_get_dev_name_callback(UINT8 status, char *name) } #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) static void btc_gap_adv_point_cleanup(void **buf) { if (NULL == *buf) { @@ -481,6 +486,7 @@ static void btc_clear_adv_callback(uint8_t status) BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } +#endif // #if (BLE_42_ADV_EN == TRUE) void btc_update_duplicate_exceptional_list_callback(tBTA_STATUS status, uint8_t subcode, uint32_t length, uint8_t *device_info) { @@ -511,6 +517,7 @@ static void btc_ble_update_duplicate_exceptional_list(uint8_t subcode, uint32_t BTA_DmUpdateDuplicateExceptionalList(subcode, info_type, device_info, p_update_duplicate_ignore_list_cback); } +#if (BLE_42_ADV_EN == TRUE) static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBTA_START_ADV_CMPL_CBACK start_adv_cback) { tBLE_BD_ADDR peer_addr; @@ -561,8 +568,9 @@ static void btc_ble_start_advertising (esp_ble_adv_params_t *ble_adv_params, tBT &peer_addr, start_adv_cback); } +#endif // #if (BLE_42_ADV_EN == TRUE) - +#if (BLE_42_SCAN_EN == TRUE) static void btc_scan_params_callback(tGATT_IF gatt_if, tBTM_STATUS status) { esp_ble_gap_cb_param_t param; @@ -743,6 +751,7 @@ static void btc_stop_scan_callback(tBTA_STATUS status) BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__); } } +#endif // #if (BLE_42_SCAN_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDATE_CONN_PRAMS *update_conn_params) { @@ -955,6 +964,7 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.set_perf_phy.status = btc_btm_status_to_esp_status(params->set_perf_phy.status); break; } +#if (BLE_50_EXTEND_ADV_EN == TRUE) case BTA_DM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT: msg.act = ESP_GAP_BLE_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT; param.ext_adv_set_rand_addr.status = btc_btm_status_to_esp_status(params->set_ext_rand_addr.status); @@ -1005,6 +1015,9 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, msg.act = ESP_GAP_BLE_EXT_ADV_SET_CLEAR_COMPLETE_EVT; param.ext_adv_clear.status = btc_btm_status_to_esp_status(params->adv_start.status); break; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) + +#if (BLE_50_PERIODIC_ADV_EN == TRUE) case BTA_DM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT: { msg.act = ESP_GAP_BLE_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT; param.peroid_adv_set_params.status = btc_btm_status_to_esp_status(params->per_adv_set_params.status); @@ -1059,6 +1072,9 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.period_adv_clear_dev.status = btc_btm_status_to_esp_status(params->per_adv_clear_dev.status); break; } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) + +#if (BLE_50_EXTEND_SCAN_EN == TRUE) case BTA_DM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT: { msg.act = ESP_GAP_BLE_SET_EXT_SCAN_PARAMS_COMPLETE_EVT; param.set_ext_scan_params.status = btc_btm_status_to_esp_status(params->ext_scan.status); @@ -1074,6 +1090,7 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.ext_scan_stop.status = btc_btm_status_to_esp_status(params->scan_stop.status); break; } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) case BTA_DM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT: { msg.act = ESP_GAP_BLE_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT; param.ext_conn_params_set.status = btc_btm_status_to_esp_status(params->ext_conn_set_params.status); @@ -1086,6 +1103,7 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.phy_update.tx_phy = params->phy_update.tx_phy; param.phy_update.rx_phy = params->phy_update.rx_phy; break; +#if (BLE_50_EXTEND_SCAN_EN == TRUE) case BTA_DM_BLE_5_GAP_EXT_ADV_REPORT_EVT: msg.act = ESP_GAP_BLE_EXT_ADV_REPORT_EVT; memcpy(¶m.ext_adv_report.params, ¶ms->ext_adv_report, sizeof(esp_ble_gap_ext_adv_report_t)); @@ -1097,6 +1115,8 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, case BTA_DM_BLE_5_GAP_SCAN_TIMEOUT_EVT: msg.act = ESP_GAP_BLE_SCAN_TIMEOUT_EVT; break; +#endif // #if (BLE_50_EXTEND_SCAN_EN == 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; param.adv_terminate.adv_instance = params->adv_term.adv_handle; @@ -1112,12 +1132,14 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, memcpy(param.scan_req_received.scan_addr, params->scan_req.scan_addr, sizeof(BD_ADDR)); break; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) case BTA_DM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT: { msg.act = ESP_GAP_BLE_CHANNEL_SELECT_ALGORITHM_EVT; param.channel_sel_alg.conn_handle = params->channel_sel.conn_handle; param.channel_sel_alg.channel_sel_alg = params->channel_sel.channel_sel_alg; break; } +#if (BLE_50_EXTEND_SYNC_EN == TRUE) case BTA_DM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT: { msg.act = ESP_GAP_BLE_PERIODIC_ADV_REPORT_EVT; memcpy(¶m.period_adv_report, ¶ms->period_adv_report, @@ -1146,6 +1168,8 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, param.periodic_adv_sync_estab.adv_clk_accuracy = params->sync_estab.adv_clk_accuracy; break; } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) + #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) case BTA_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT: msg.act = ESP_GAP_BLE_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT; @@ -1193,6 +1217,7 @@ void btc_ble_5_gap_callback(tBTA_DM_BLE_5_GAP_EVENT event, } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) void btc_dtm_tx_start_callback(void *p1) { UINT8 status; @@ -1247,7 +1272,9 @@ void btc_dtm_rx_start_callback(void *p1) } } } +#endif // #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)) void btc_dtm_stop_callback(void *p1) { UINT8 status; @@ -1276,6 +1303,7 @@ void btc_dtm_stop_callback(void *p1) } } } +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) static void btc_ble_vendor_hci_cmd_complete_callback(tBTA_VSC_CMPL *p_param) { @@ -1357,6 +1385,7 @@ void btc_get_whitelist_size(uint16_t *length) return; } #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_SCAN_EN == TRUE) static void btc_ble_start_scanning(uint32_t duration, tBTA_DM_SEARCH_CBACK *results_cb, tBTA_START_STOP_SCAN_CMPL_CBACK *start_scan_cb) @@ -1374,7 +1403,9 @@ static void btc_ble_stop_scanning(tBTA_START_STOP_SCAN_CMPL_CBACK *stop_scan_cb) uint8_t duration = 0; BTA_DmBleScan(false, duration, NULL, stop_scan_cb); } +#endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_42_ADV_EN == TRUE) static void btc_ble_stop_advertising(tBTA_START_STOP_ADV_CMPL_CBACK *stop_adv_cb) { bool stop_adv = false; @@ -1386,6 +1417,8 @@ static void btc_ble_clear_advertising(tBTA_CLEAR_ADV_CMPL_CBACK *clear_adv_cb) { BTA_DmBleClearAdv(clear_adv_cb); } +#endif // #if (BLE_42_ADV_EN == TRUE) + #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) static void btc_ble_update_conn_params(BD_ADDR bd_addr, uint16_t min_int, uint16_t max_int, uint16_t latency, uint16_t timeout) @@ -1494,7 +1527,7 @@ static void btc_gap_ble_set_channels(esp_gap_ble_channels channels) BTA_DmBleSetChannels(channels, btc_gap_ble_set_channels_cmpl_callback); } -#if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_DTM_TEST_EN == TRUE) static void btc_ble_dtm_tx_start(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) { BTA_DmBleDtmTxStart(tx_channel, len_of_data, pkt_payload, p_dtm_cmpl_cback); @@ -1505,9 +1538,9 @@ static void btc_ble_dtm_rx_start(uint8_t rx_channel, tBTA_DTM_CMD_CMPL_CBACK *p_ BTA_DmBleDtmRxStart(rx_channel, p_dtm_cmpl_cback); } -#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) -#if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) static void btc_ble_dtm_enhance_tx_start(uint8_t tx_channel, uint8_t len_of_data, uint8_t pkt_payload, uint8_t phy, tBTA_DTM_CMD_CMPL_CBACK *p_dtm_cmpl_cback) { BTA_DmBleDtmEnhTxStart(tx_channel, len_of_data, pkt_payload, phy, p_dtm_cmpl_cback); @@ -1518,14 +1551,15 @@ static void btc_ble_dtm_enhance_rx_start(uint8_t rx_channel, uint8_t phy, uint8_ BTA_DmBleDtmEnhRxStart(rx_channel, phy, modulation_index, p_dtm_cmpl_cback); } -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (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) { BTA_DmBleDtmStop(p_dtm_cmpl_cback); } - +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) static void btc_ble_set_privacy_mode(uint8_t addr_type, BD_ADDR addr, uint8_t privacy_mode, @@ -1552,6 +1586,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) { switch (msg->act) { #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src; btc_ble_gap_args_t *dst = (btc_ble_gap_args_t *) p_dest; @@ -1597,6 +1632,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) } break; } +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: { btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src; @@ -1650,6 +1686,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) break; } #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) case BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW: case BTC_GAP_BLE_CFG_EXT_SCAN_RSP_DATA_RAW: { btc_ble_5_gap_args_t *src = (btc_ble_5_gap_args_t *)p_src; @@ -1667,6 +1704,8 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) } break; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) case BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW: { 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; @@ -1683,6 +1722,8 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) } break; } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) case BTC_GAP_BLE_EXT_ADV_START: { 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; @@ -1709,6 +1750,7 @@ void btc_gap_ble_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src) } break; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: { btc_ble_gap_args_t *src = (btc_ble_gap_args_t *)p_src; @@ -1770,6 +1812,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) BTC_TRACE_DEBUG("%s \n", __func__); switch (msg->act) { #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { esp_ble_adv_data_t *adv = &((btc_ble_gap_args_t *)msg->arg)->cfg_adv_data.adv_data; if (adv->p_service_data) { @@ -1799,6 +1842,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) } break; } +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) case BTC_GAP_BLE_SET_SECURITY_PARAM_EVT: { uint8_t *value = ((btc_ble_gap_args_t *)msg->arg)->set_security_param.value; @@ -1826,6 +1870,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) break; } #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) case BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW: case BTC_GAP_BLE_CFG_EXT_SCAN_RSP_DATA_RAW: { uint8_t *value = ((btc_ble_5_gap_args_t *)msg->arg)->ext_adv_cfg_data.data; @@ -1834,6 +1879,8 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) } break; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) case BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW: { uint8_t *value = ((btc_ble_5_gap_args_t *)msg->arg)->periodic_adv_cfg_data.data; if (value) { @@ -1841,6 +1888,7 @@ void btc_gap_ble_arg_deep_free(btc_msg_t *msg) } break; } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) case BTC_GAP_BLE_EXT_ADV_START: { esp_ble_gap_ext_adv_t *value = ((btc_ble_5_gap_args_t *)msg->arg)->ext_adv_start.ext_adv; if (value) { @@ -1912,6 +1960,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) switch (msg->act) { #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) case BTC_GAP_BLE_ACT_CFG_ADV_DATA: { if (arg->cfg_adv_data.adv_data.set_scan_rsp == false) { btc_ble_set_adv_data(&arg->cfg_adv_data.adv_data, btc_adv_data_callback); @@ -1920,6 +1969,8 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) } break; } +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) case BTC_GAP_BLE_ACT_SET_SCAN_PARAM: btc_ble_set_scan_params(&arg->set_scan_param.scan_params, btc_scan_params_callback); break; @@ -1929,6 +1980,8 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) case BTC_GAP_BLE_ACT_STOP_SCAN: btc_ble_stop_scanning(btc_stop_scan_callback); break; +#endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_42_ADV_EN == TRUE) case BTC_GAP_BLE_ACT_START_ADV: btc_ble_start_advertising(&arg->start_adv.adv_params, btc_start_adv_callback); break; @@ -1938,6 +1991,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) case BTC_GAP_BLE_ACT_CLEAR_ADV: btc_ble_clear_advertising(btc_clear_adv_callback); break; +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) case BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM: btc_ble_update_conn_params(arg->conn_update_params.conn_params.bda, @@ -1999,6 +2053,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTA_DmGetDeviceName(btc_gap_ble_get_dev_name_callback, BT_DEVICE_TYPE_BLE); break; #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) case BTC_GAP_BLE_ACT_CFG_ADV_DATA_RAW: btc_ble_set_adv_data_raw(arg->cfg_adv_data_raw.raw_adv, arg->cfg_adv_data_raw.raw_adv_len, @@ -2009,6 +2064,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) arg->cfg_scan_rsp_data_raw.raw_scan_rsp_len, btc_scan_rsp_data_raw_callback); break; +#endif // #if (BLE_42_ADV_EN == TRUE) case BTC_GAP_BLE_UPDATE_DUPLICATE_SCAN_EXCEPTIONAL_LIST: btc_ble_update_duplicate_exceptional_list(arg->update_duplicate_exceptional_list.subcode, arg->update_duplicate_exceptional_list.info_type, @@ -2154,6 +2210,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) arg_5->set_def_phy.rx_phy_mask, arg_5->set_def_phy.phy_options); break; +#if (BLE_50_EXTEND_ADV_EN == TRUE) case BTC_GAP_BLE_SET_EXT_ADV_RAND_ADDR: BTA_DmBleGapExtAdvSetRandaddr(arg_5->ext_adv_set_rand_addr.instance, arg_5->ext_adv_set_rand_addr.rand_addr); break; @@ -2229,6 +2286,8 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) case BTC_GAP_BLE_EXT_ADV_SET_CLEAR: BTA_DmBleGapExtAdvSetClear(); break; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) case BTC_GAP_BLE_SET_PERIODIC_ADV_PARAMS: { tBTA_DM_BLE_Periodic_Adv_Params params = {0}; params.interval_min = arg_5->peridic_adv_set_params.params.interval_min; @@ -2254,6 +2313,8 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_ADV_STOP"); BTA_DmBleGapPeriodicAdvEnable(FALSE, arg_5->periodic_adv_stop.instance); break; +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) case BTC_GAP_BLE_PERIODIC_ADV_CREATE_SYNC: { tBTA_DM_BLE_Periodic_Sync_Params params = {0}; params.filter_policy = arg_5->periodic_adv_create_sync.params.filter_policy; @@ -2295,6 +2356,9 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTC_TRACE_DEBUG("BTC_GAP_BLE_PERIODIC_CLEAR_DEV"); BTA_DmBleGapPeriodicAdvClearDev(); break; +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) + +#if (BLE_50_EXTEND_SCAN_EN == TRUE) case BTC_GAP_BLE_SET_EXT_SCAN_PARAMS: { tBTA_DM_BLE_EXT_SCAN_PARAMS params = {0}; params.own_addr_type = arg_5->set_ext_scan_params.params.own_addr_type; @@ -2325,6 +2389,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) BTC_TRACE_DEBUG("BTC_GAP_BLE_STOP_EXT_SCAN"); BTA_DmBleGapExtScan(FALSE, 0, 0); break; +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) case BTC_GAP_BLE_SET_EXT_PEFER_CONNET_PARAMS: BTC_TRACE_DEBUG("BTC_GAP_BLE_SET_EXT_PEFER_CONNET_PARAMS"); BTA_DmBleGapPreferExtConnectParamsSet(arg_5->set_ext_conn_params.addr, @@ -2358,25 +2423,27 @@ void btc_gap_ble_call_handler(btc_msg_t *msg) (tBTA_DM_BLE_PAST_PARAMS *)&arg_5->set_periodic_adv_sync_trans_params.params); break; #endif -#if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_DTM_TEST_EN == TRUE) case BTC_GAP_BLE_DTM_TX_START: btc_ble_dtm_tx_start(arg->dtm_tx_start.tx_channel, arg->dtm_tx_start.len_of_data, arg->dtm_tx_start.pkt_payload, btc_dtm_tx_start_callback); break; case BTC_GAP_BLE_DTM_RX_START: btc_ble_dtm_rx_start(arg->dtm_rx_start.rx_channel, btc_dtm_rx_start_callback); break; -#endif // if (BLE_42_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) case BTC_GAP_BLE_DTM_STOP: btc_ble_dtm_stop(btc_dtm_stop_callback); break; -#if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) +#if (BLE_50_DTM_TEST_EN == TRUE) case BTC_GAP_BLE_DTM_ENH_TX_START: btc_ble_dtm_enhance_tx_start(arg_5->dtm_enh_tx_start.tx_channel, arg_5->dtm_enh_tx_start.len_of_data, arg_5->dtm_enh_tx_start.pkt_payload, arg_5->dtm_enh_tx_start.phy, btc_dtm_tx_start_callback); break; case BTC_GAP_BLE_DTM_ENH_RX_START: btc_ble_dtm_enhance_rx_start(arg_5->dtm_enh_rx_start.rx_channel, arg_5->dtm_enh_rx_start.phy, arg_5->dtm_enh_rx_start.modulation_index, btc_dtm_rx_start_callback); break; -#endif // if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) case BTC_GAP_BLE_ACT_VENDOR_HCI_CMD_EVT: BTA_DmsendVendorHciCmd(arg->vendor_cmd_send.opcode, arg->vendor_cmd_send.param_len, @@ -2410,6 +2477,7 @@ void btc_gap_callback_init(void) bool btc_gap_ble_init(void) { #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_SCAN_EN == TRUE) btc_gap_ble_env_t *p_env = &btc_gap_ble_env; p_env->adv_rpt_queue = pkt_queue_create(); assert(p_env->adv_rpt_queue != NULL); @@ -2417,6 +2485,7 @@ bool btc_gap_ble_init(void) p_env->adv_rpt_ready = osi_event_create(btc_gap_ble_adv_pkt_handler, NULL); assert(p_env->adv_rpt_ready != NULL); osi_event_bind(p_env->adv_rpt_ready, btc_get_current_thread(), BTC_GAP_BLE_ADV_RPT_QUEUE_IDX); +#endif // #if (BLE_42_SCAN_EN == TRUE) #endif return true; } @@ -2424,6 +2493,7 @@ bool btc_gap_ble_init(void) void btc_gap_ble_deinit(void) { #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_SCAN_EN == TRUE) btc_gap_ble_env_t *p_env = &btc_gap_ble_env; osi_event_delete(p_env->adv_rpt_ready); @@ -2431,9 +2501,11 @@ void btc_gap_ble_deinit(void) pkt_queue_destroy(p_env->adv_rpt_queue, NULL); p_env->adv_rpt_queue = NULL; - +#endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_42_ADV_EN == TRUE) btc_cleanup_adv_data(&gl_bta_adv_data); btc_cleanup_adv_data(&gl_bta_scan_rsp_data); +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) } #endif ///BLE_INCLUDED == TRUE 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 3157c8c813..df6a2c8212 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 @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,11 +12,13 @@ #if BTC_DYNAMIC_MEMORY == TRUE #if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_ADV_EN == TRUE) #include "bta/bta_api.h" extern tBTA_BLE_ADV_DATA *gl_bta_adv_data_ptr; extern tBTA_BLE_ADV_DATA *gl_bta_scan_rsp_data_ptr; #define gl_bta_adv_data (*gl_bta_adv_data_ptr) #define gl_bta_scan_rsp_data (*gl_bta_scan_rsp_data_ptr) +#endif // #if (BLE_42_ADV_EN == TRUE) #endif // BLE_42_FEATURE_SUPPORT #endif @@ -64,6 +66,7 @@ typedef enum { BTC_GAP_BLE_READ_PHY, BTC_GAP_BLE_SET_PREFERED_DEF_PHY, BTC_GAP_BLE_SET_DEF_PHY, +#if (BLE_50_EXTEND_ADV_EN == TRUE) BTC_GAP_BLE_SET_EXT_ADV_RAND_ADDR, BTC_GAP_BLE_SET_EXT_ADV_PARAMS, BTC_GAP_BLE_CFG_EXT_ADV_DATA_RAW, @@ -72,23 +75,32 @@ typedef enum { BTC_GAP_BLE_EXT_ADV_STOP, BTC_GAP_BLE_EXT_ADV_SET_REMOVE, BTC_GAP_BLE_EXT_ADV_SET_CLEAR, +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) BTC_GAP_BLE_SET_PERIODIC_ADV_PARAMS, BTC_GAP_BLE_CFG_PERIODIC_ADV_DATA_RAW, BTC_GAP_BLE_PERIODIC_ADV_START, BTC_GAP_BLE_PERIODIC_ADV_STOP, +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) BTC_GAP_BLE_PERIODIC_ADV_CREATE_SYNC, BTC_GAP_BLE_PERIODIC_ADV_SYNC_CANCEL, BTC_GAP_BLE_PERIODIC_ADV_SYNC_TERMINATE, BTC_GAP_BLE_PERIODIC_ADV_ADD_DEV_TO_LIST, BTC_GAP_BLE_PERIODIC_REMOVE_ADD_DEV_FROM_LIST, BTC_GAP_BLE_PERIODIC_CLEAR_DEV, +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) BTC_GAP_BLE_SET_EXT_SCAN_PARAMS, BTC_GAP_BLE_START_EXT_SCAN, BTC_GAP_BLE_STOP_EXT_SCAN, +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) BTC_GAP_BLE_SET_EXT_PEFER_CONNET_PARAMS, +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) BTC_GAP_BLE_DTM_ENH_TX_START, BTC_GAP_BLE_DTM_ENH_RX_START, -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) BTC_GAP_BLE_ACT_GET_DEV_NAME, #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) BTC_GAP_BLE_PERIODIC_ADV_RECV_ENABLE, @@ -96,10 +108,10 @@ typedef enum { BTC_GAP_BLE_PERIODIC_ADV_SET_INFO_TRANS, BTC_GAP_BLE_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS, #endif //#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) -#if (BLE_42_FEATURE_SUPPORT == TRUE) +#if (BLE_42_DTM_TEST_EN == TRUE) BTC_GAP_BLE_DTM_TX_START, BTC_GAP_BLE_DTM_RX_START, -#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) BTC_GAP_BLE_DTM_STOP, #if (BLE_42_FEATURE_SUPPORT == TRUE) BTC_GAP_BLE_ACT_CLEAR_ADV, @@ -257,6 +269,7 @@ typedef union { struct set_channels_args { esp_gap_ble_channels channels; } set_channels; +#if (BLE_42_DTM_TEST_EN == TRUE) struct dtm_tx_start_args { uint8_t tx_channel; uint8_t len_of_data; @@ -265,6 +278,7 @@ typedef union { struct dtm_rx_start_args { uint8_t rx_channel; } dtm_rx_start; +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) //BTC_DEV_VENDOR_HCI_CMD_EVT struct vendor_cmd_send_args { uint16_t opcode; @@ -301,7 +315,7 @@ typedef union { esp_ble_gap_phy_mask_t rx_phy_mask; uint16_t phy_options; } set_def_phy; - +#if (BLE_50_EXTEND_ADV_EN == TRUE) struct ext_adv_set_rand_addr_args { uint8_t instance; esp_bd_addr_t rand_addr; @@ -337,7 +351,9 @@ typedef union { struct ext_adv_set_remove_args { uint8_t instance; } ext_adv_set_remove; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) struct peridic_adv_set_params_args { uint8_t instance; esp_ble_gap_periodic_adv_params_t params; @@ -358,6 +374,7 @@ typedef union { struct periodic_adv_stop_args { uint8_t instance; } periodic_adv_stop; +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) struct periodic_adv_create_sync_args { esp_ble_gap_periodic_adv_sync_params_t params; 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 7026581804..b3f48a1196 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 @@ -179,12 +179,60 @@ #define UC_BT_BLE_42_FEATURES_SUPPORTED FALSE #endif +#ifdef CONFIG_BT_BLE_42_DTM_TEST_EN +#define UC_BT_BLE_42_DTM_TEST_EN CONFIG_BT_BLE_42_DTM_TEST_EN +#else +#define UC_BT_BLE_42_DTM_TEST_EN FALSE +#endif + +#ifdef CONFIG_BT_BLE_42_ADV_EN +#define UC_BT_BLE_42_ADV_EN CONFIG_BT_BLE_42_ADV_EN +#else +#define UC_BT_BLE_42_ADV_EN FALSE +#endif + +#ifdef CONFIG_BT_BLE_42_SCAN_EN +#define UC_BT_BLE_42_SCAN_EN CONFIG_BT_BLE_42_SCAN_EN +#else +#define UC_BT_BLE_42_SCAN_EN FALSE +#endif + #ifdef CONFIG_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER #define UC_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER CONFIG_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER #else #define UC_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER FALSE #endif +#ifdef CONFIG_BT_BLE_50_EXTEND_ADV_EN +#define UC_BT_BLE_50_EXTEND_ADV_EN CONFIG_BT_BLE_50_EXTEND_ADV_EN +#else +#define UC_BT_BLE_50_EXTEND_ADV_EN FALSE +#endif + +#ifdef CONFIG_BT_BLE_50_PERIODIC_ADV_EN +#define UC_BT_BLE_50_PERIODIC_ADV_EN CONFIG_BT_BLE_50_PERIODIC_ADV_EN +#else +#define UC_BT_BLE_50_PERIODIC_ADV_EN FALSE +#endif + +#ifdef CONFIG_BT_BLE_50_EXTEND_SCAN_EN +#define UC_BT_BLE_50_EXTEND_SCAN_EN CONFIG_BT_BLE_50_EXTEND_SCAN_EN +#else +#define UC_BT_BLE_50_EXTEND_SCAN_EN FALSE +#endif + +#ifdef CONFIG_BT_BLE_50_EXTEND_SYNC_EN +#define UC_BT_BLE_50_EXTEND_SYNC_EN CONFIG_BT_BLE_50_EXTEND_SYNC_EN +#else +#define UC_BT_BLE_50_EXTEND_SYNC_EN FALSE +#endif + +#ifdef CONFIG_BT_BLE_50_DTM_TEST_EN +#define UC_BT_BLE_50_DTM_TEST_EN CONFIG_BT_BLE_50_DTM_TEST_EN +#else +#define UC_BT_BLE_50_DTM_TEST_EN FALSE +#endif + #ifdef CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH #define UC_BT_BLE_FEAT_PERIODIC_ADV_ENH CONFIG_BT_BLE_FEAT_PERIODIC_ADV_ENH #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 91312484d9..16a4e0ce5f 100644 --- a/components/bt/host/bluedroid/common/include/common/bt_target.h +++ b/components/bt/host/bluedroid/common/include/common/bt_target.h @@ -236,6 +236,54 @@ #define BLE_50_FEATURE_SUPPORT FALSE #endif /* UC_BT_BLE_ENABLED */ +#if (UC_BT_BLE_42_DTM_TEST_EN == TRUE) +#define BLE_42_DTM_TEST_EN TRUE +#else +#define BLE_42_DTM_TEST_EN FALSE +#endif + +#if (UC_BT_BLE_42_ADV_EN == TRUE) +#define BLE_42_ADV_EN TRUE +#else +#define BLE_42_ADV_EN FALSE +#endif + +#if (UC_BT_BLE_42_SCAN_EN == TRUE) +#define BLE_42_SCAN_EN TRUE +#else +#define BLE_42_SCAN_EN FALSE +#endif + +#if (UC_BT_BLE_50_EXTEND_ADV_EN == TRUE) +#define BLE_50_EXTEND_ADV_EN TRUE +#else +#define BLE_50_EXTEND_ADV_EN FALSE +#endif + +#if (UC_BT_BLE_50_PERIODIC_ADV_EN == TRUE) +#define BLE_50_PERIODIC_ADV_EN TRUE +#else +#define BLE_50_PERIODIC_ADV_EN FALSE +#endif + +#if (UC_BT_BLE_50_EXTEND_SCAN_EN == TRUE) +#define BLE_50_EXTEND_SCAN_EN TRUE +#else +#define BLE_50_EXTEND_SCAN_EN FALSE +#endif + +#if (UC_BT_BLE_50_EXTEND_SYNC_EN == TRUE) +#define BLE_50_EXTEND_SYNC_EN TRUE +#else +#define BLE_50_EXTEND_SYNC_EN FALSE +#endif + +#if (UC_BT_BLE_50_DTM_TEST_EN == TRUE) +#define BLE_50_DTM_TEST_EN TRUE +#else +#define BLE_50_DTM_TEST_EN FALSE +#endif + #if (UC_BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #define BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER TRUE #else diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble.c b/components/bt/host/bluedroid/stack/btm/btm_ble.c index a69c1f0f2f..c2d9b6157d 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble.c @@ -766,6 +766,7 @@ BOOLEAN BTM_ReadConnectedTransportAddress(BD_ADDR remote_bda, tBT_TRANSPORT tran } #if (BLE_INCLUDED == TRUE) +#if (BLE_42_DTM_TEST_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleReceiverTest @@ -805,7 +806,8 @@ void BTM_BleTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, BTM_TRACE_ERROR("%s: Unable to Trigger LE transmitter test", __FUNCTION__); } } - +#endif // #if (BLE_42_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) /******************************************************************************* ** ** Function BTM_BleTestEnd @@ -837,9 +839,9 @@ void btm_ble_test_command_complete(UINT8 *p) (*p_cb)(p); } } +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) - -#if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleEnhancedReceiverTest @@ -882,7 +884,7 @@ void BTM_BleEnhancedTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, BTM_TRACE_ERROR("%s: Unable to Trigger LE enhanced transmitter test", __FUNCTION__); } } -#endif // BLE_50_FEATURE_SUPPORT +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) /******************************************************************************* ** 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 13a424586f..733b0c19c5 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 @@ -286,6 +286,7 @@ tBTM_STATUS BTM_BleSetPreferPhy(BD_ADDR bd_addr, UINT8 all_phys, UINT8 tx_phy_ma return BTM_SUCCESS; } +#if (BLE_50_EXTEND_ADV_EN == TRUE) tBTM_STATUS BTM_BleSetExtendedAdvRandaddr(UINT8 instance, BD_ADDR rand_addr) { tBTM_STATUS status = BTM_SUCCESS; @@ -678,7 +679,9 @@ tBTM_STATUS BTM_BleExtAdvSetClear(void) return status; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) tBTM_STATUS BTM_BlePeriodicAdvSetParams(UINT8 instance, tBTM_BLE_Periodic_Adv_Params *params) { tBTM_STATUS status = BTM_SUCCESS; @@ -806,7 +809,9 @@ end: return status; } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) tBTM_STATUS BTM_BlePeriodicAdvCreateSync(tBTM_BLE_Periodic_Sync_Params *params) { //tHCI_STATUS err = HCI_SUCCESS; @@ -864,6 +869,7 @@ end: return status; } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) void btm_set_phy_callback(UINT8 status) { @@ -874,6 +880,7 @@ void btm_set_phy_callback(UINT8 status) } +#if (BLE_50_EXTEND_SYNC_EN == TRUE) void btm_create_sync_callback(UINT8 status) { tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; @@ -881,6 +888,7 @@ void btm_create_sync_callback(UINT8 status) BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_PERIODIC_ADV_CREATE_SYNC_COMPLETE_EVT, &cb_params); } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) void btm_read_phy_callback(uint8_t hci_status, uint16_t conn_handle, uint8_t tx_phy, uint8_t rx_phy) { @@ -901,6 +909,7 @@ void btm_read_phy_callback(uint8_t hci_status, uint16_t conn_handle, uint8_t tx_ BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT, &cb_params); } +#if (BLE_50_EXTEND_SYNC_EN == TRUE) tBTM_STATUS BTM_BlePeriodicAdvSyncCancel(void) { tHCI_STATUS err = HCI_SUCCESS; @@ -1001,7 +1010,9 @@ tBTM_STATUS BTM_BlePeriodicAdvClearDev(void) return status; } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params) { UINT8 phy_mask = 0; @@ -1082,6 +1093,7 @@ end: return status; } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) void BTM_BleSetPreferExtenedConnParams (BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params) { @@ -1218,11 +1230,14 @@ void btm_ble_update_phy_evt(tBTM_BLE_UPDATE_PHY *params) return; } +#if (BLE_50_EXTEND_SCAN_EN == TRUE) void btm_ble_scan_timeout_evt(void) { BTM_ExtBleCallbackTrigger(BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT, NULL); } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params) { tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; @@ -1248,7 +1263,9 @@ void btm_ble_adv_set_terminated_evt(tBTM_BLE_ADV_TERMINAT *params) return; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) void btm_ble_ext_adv_report_evt(tBTM_BLE_EXT_ADV_REPORT *params) { tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; @@ -1266,6 +1283,7 @@ void btm_ble_ext_adv_report_evt(tBTM_BLE_EXT_ADV_REPORT *params) return; } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) void btm_ble_scan_req_received_evt(tBTM_BLE_SCAN_REQ_RECEIVED *params) { @@ -1301,6 +1319,7 @@ void btm_ble_channel_select_algorithm_evt(tBTM_BLE_CHANNEL_SEL_ALG *params) return; } +#if (BLE_50_EXTEND_SYNC_EN == TRUE) void btm_ble_periodic_adv_report_evt(tBTM_PERIOD_ADV_REPORT *params) { tBTM_BLE_5_GAP_CB_PARAMS cb_params = {0}; @@ -1354,6 +1373,7 @@ void btm_ble_periodic_adv_sync_establish_evt(tBTM_BLE_PERIOD_ADV_SYNC_ESTAB *par return; } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) uint8_t btm_ble_ext_adv_active_count(void) { diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c index 4cb282b79a..014bb415a7 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_bgconn.c @@ -689,10 +689,11 @@ static void btm_suspend_wl_activity(tBTM_BLE_WL_STATE wl_state) if (wl_state & BTM_BLE_WL_SCAN) { btm_ble_start_select_conn(FALSE, NULL); } +#if (BLE_42_ADV_EN == TRUE) if (wl_state & BTM_BLE_WL_ADV) { btm_ble_stop_adv(); } - +#endif // #if (BLE_42_ADV_EN == TRUE) } /******************************************************************************* ** @@ -707,7 +708,9 @@ void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state) { btm_ble_resume_bg_conn(); if (wl_state & BTM_BLE_WL_ADV) { +#if (BLE_42_ADV_EN == TRUE) btm_ble_start_adv(); +#endif // #if (BLE_42_ADV_EN == TRUE) } } @@ -724,7 +727,7 @@ void btm_resume_wl_activity(tBTM_BLE_WL_STATE wl_state) static void btm_wl_update_to_controller(void) { /* whitelist will be added in the btm_ble_resume_bg_conn(), we do not - support background connection now, so we nedd to use btm_execute_wl_dev_operation + support background connection now, so we need to use btm_execute_wl_dev_operation to add whitelist directly ,if we support background connection in the future, please delete btm_execute_wl_dev_operation(). */ btm_execute_wl_dev_operation(); diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c index 415805fe52..eaf511fcdd 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_gap.c @@ -246,56 +246,77 @@ const UINT8 btm_le_state_combo_tbl[BTM_BLE_STATE_MAX][BTM_BLE_STATE_MAX][2] = { /* check LE combo state supported */ #define BTM_LE_STATES_SUPPORTED(x, y, z) ((x)[(z)] & (y)) +#if (BLE_42_ADV_EN == TRUE) static osi_mutex_t adv_enable_lock; static osi_mutex_t adv_data_lock; static osi_mutex_t adv_param_lock; -static osi_mutex_t scan_enable_lock; -static osi_mutex_t scan_param_lock; osi_sem_t adv_enable_sem; osi_sem_t adv_data_sem; osi_sem_t adv_param_sem; -osi_sem_t scan_enable_sem; -osi_sem_t scan_param_sem; uint8_t adv_enable_status = 0; uint8_t adv_data_status = 0; uint8_t adv_param_status = 0; +#endif // #if (BLE_42_ADV_EN == TRUE) + +#if (BLE_42_SCAN_EN == TRUE) +static osi_mutex_t scan_enable_lock; +static osi_mutex_t scan_param_lock; +osi_sem_t scan_enable_sem; +osi_sem_t scan_param_sem; uint8_t scan_enable_status = 0; uint8_t scan_param_status = 0; +#endif // #if (BLE_42_SCAN_EN == TRUE) void btm_ble_lock_init(void) { +#if (BLE_42_ADV_EN == TRUE) osi_mutex_new(&adv_enable_lock); osi_mutex_new(&adv_data_lock); osi_mutex_new(&adv_param_lock); +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) osi_mutex_new(&scan_enable_lock); osi_mutex_new(&scan_param_lock); +#endif // #if (BLE_42_SCAN_EN == TRUE) } void btm_ble_lock_free(void) { +#if (BLE_42_ADV_EN == TRUE) osi_mutex_free(&adv_enable_lock); osi_mutex_free(&adv_data_lock); osi_mutex_free(&adv_param_lock); +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) osi_mutex_free(&scan_enable_lock); osi_mutex_free(&scan_param_lock); +#endif // #if (BLE_42_SCAN_EN == TRUE) } void btm_ble_sem_init(void) { +#if (BLE_42_ADV_EN == TRUE) osi_sem_new(&adv_enable_sem, 1, 0); osi_sem_new(&adv_data_sem, 1, 0); osi_sem_new(&adv_param_sem, 1, 0); +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) osi_sem_new(&scan_enable_sem, 1, 0); osi_sem_new(&scan_param_sem, 1, 0); +#endif // #if (BLE_42_SCAN_EN == TRUE) } void btm_ble_sem_free(void) { +#if (BLE_42_ADV_EN == TRUE) osi_sem_free(&adv_enable_sem); osi_sem_free(&adv_data_sem); osi_sem_free(&adv_param_sem); +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) osi_sem_free(&scan_enable_sem); osi_sem_free(&scan_param_sem); +#endif // #if (BLE_42_SCAN_EN == TRUE) } /******************************************************************************* @@ -380,8 +401,10 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy) if (p_cb->afp != adv_policy) { p_cb->afp = adv_policy; +#if (BLE_42_ADV_EN == TRUE) /* if adv active, stop and restart */ btm_ble_stop_adv (); +#endif // #if (BLE_42_ADV_EN == TRUE) if (p_cb->connectable_mode & BTM_BLE_CONNECTABLE) { p_cb->evt_type = btm_set_conn_mode_adv_init_addr(p_cb, p_addr_ptr, &init_addr_type, @@ -406,7 +429,9 @@ void BTM_BleUpdateAdvFilterPolicy(tBTM_BLE_AFP adv_policy) p_cb->afp); if (adv_mode == BTM_BLE_ADV_ENABLE) { +#if (BLE_42_ADV_EN == TRUE) btm_ble_start_adv (); +#endif // #if (BLE_42_ADV_EN == TRUE) } } @@ -512,8 +537,9 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration, btm_cb.ble_ctr_cb.addr_mgnt_cb.own_addr_type, BTM_BLE_DEFAULT_SFP); } - +#if (BLE_42_SCAN_EN == TRUE) status = btm_ble_start_scan(); +#endif // #if (BLE_42_SCAN_EN == TRUE) } if (status == BTM_CMD_STARTED) { @@ -535,6 +561,7 @@ tBTM_STATUS BTM_BleObserve(BOOLEAN start, UINT32 duration, } +#if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleScan @@ -612,7 +639,9 @@ tBTM_STATUS BTM_BleScan(BOOLEAN start, UINT32 duration, return status; } +#endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleBroadcast @@ -671,7 +700,7 @@ tBTM_STATUS BTM_BleBroadcast(BOOLEAN start, tBTM_START_STOP_ADV_CMPL_CBACK *p_s } return status; } - +#endif // #if (BLE_42_ADV_EN == TRUE) #if BLE_VND_INCLUDED == TRUE /******************************************************************************* ** @@ -1441,76 +1470,7 @@ static UINT8 btm_set_conn_mode_adv_init_addr(tBTM_BLE_INQ_CB *p_cb, return evt_type; } -/******************************************************************************* -** -** Function BTM_BleSetAdvParams -** -** Description This function is called to set advertising parameters. -** -** Parameters adv_int_min: minimum advertising interval -** adv_int_max: maximum advertising interval -** p_dir_bda: connectable direct initiator's LE device address -** chnl_map: advertising channel map. -** -** Returns void -** -*******************************************************************************/ -tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, - tBLE_BD_ADDR *p_dir_bda, - tBTM_BLE_ADV_CHNL_MAP chnl_map) -{ - tBTM_LE_RANDOM_CB *p_addr_cb = &btm_cb.ble_ctr_cb.addr_mgnt_cb; - tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; - tBTM_STATUS status = BTM_SUCCESS; - BD_ADDR p_addr_ptr = {0}; - tBLE_ADDR_TYPE init_addr_type = BLE_ADDR_PUBLIC; - tBLE_ADDR_TYPE own_addr_type = p_addr_cb->own_addr_type; - UINT8 adv_mode = p_cb->adv_mode; - - BTM_TRACE_EVENT ("BTM_BleSetAdvParams"); - - if (!controller_get_interface()->supports_ble()) { - return BTM_ILLEGAL_VALUE; - } - - if (!BTM_BLE_ISVALID_PARAM(adv_int_min, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX) || - !BTM_BLE_ISVALID_PARAM(adv_int_max, BTM_BLE_ADV_INT_MIN, BTM_BLE_ADV_INT_MAX)) { - return BTM_ILLEGAL_VALUE; - } - - p_cb->adv_interval_min = adv_int_min; - p_cb->adv_interval_max = adv_int_max; - p_cb->adv_chnl_map = chnl_map; - - if (p_dir_bda) { - memcpy(&p_cb->direct_bda, p_dir_bda, sizeof(tBLE_BD_ADDR)); - } - - BTM_TRACE_EVENT ("update params for an active adv\n"); - - btm_ble_stop_adv(); - - p_cb->evt_type = btm_set_conn_mode_adv_init_addr(p_cb, p_addr_ptr, &init_addr_type, - &own_addr_type); - - /* update adv params */ - btsnd_hcic_ble_write_adv_params (p_cb->adv_interval_min, - p_cb->adv_interval_max, - p_cb->evt_type, - own_addr_type, - init_addr_type, - p_addr_ptr, - p_cb->adv_chnl_map, - p_cb->afp); - - if (adv_mode == BTM_BLE_ADV_ENABLE) { - btm_ble_start_adv(); - } - - return status; -} - - +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleSetAdvParamsAll @@ -1605,6 +1565,7 @@ tBTM_STATUS BTM_BleStartAdv(void) return status; } +#endif // #if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleReadAdvParams @@ -1697,6 +1658,7 @@ void BTM_BleSetScanParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_ } +#if (BLE_42_SCAN_EN == TRUE) tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 addr_type_own, UINT8 scan_duplicate_filter, tBTM_BLE_SFP scan_filter_policy, tBLE_SCAN_PARAM_SETUP_CBACK scan_setup_status_cback) @@ -1752,8 +1714,9 @@ tBTM_STATUS BTM_BleSetScanFilterParams(tGATT_IF client_if, UINT32 scan_interval, osi_mutex_unlock(&scan_param_lock); return ret; } +#endif // #if (BLE_42_SCAN_EN == TRUE) - +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleWriteScanRsp @@ -1828,6 +1791,7 @@ tBTM_STATUS BTM_BleWriteScanRspRaw(UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_le return ret; } +#endif // #if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** @@ -1894,6 +1858,7 @@ tBTM_STATUS BTM_UpdateBleDuplicateExceptionalList(uint8_t subcode, uint32_t type return status; } +#if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** ** Function BTM_BleWriteAdvData @@ -1944,38 +1909,6 @@ tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p return ret; } -/******************************************************************************* -** -** Function BTM_BleWriteLongAdvData -** -** Description This function is called to write long advertising data. -** -** Parameters: adv_data: long advertising data -** adv_data_len: the length of long advertising data -** -** Returns void -** -*******************************************************************************/ -tBTM_STATUS BTM_BleWriteLongAdvData(uint8_t *adv_data, uint8_t adv_data_len) -{ - tBTM_STATUS status = BTM_NO_RESOURCES; - if (!controller_get_interface()->supports_ble()) { - return BTM_ILLEGAL_VALUE; - } - if(!adv_data || adv_data_len <= 0 || adv_data_len > BTM_BLE_LONG_ADV_MAX_LEN) { - return BTM_ILLEGAL_VALUE; - } - uint8_t long_adv[BTM_BLE_LONG_ADV_MAX_LEN + 1] = {0}; - long_adv[0] = adv_data_len; - memcpy(&long_adv[1], adv_data, adv_data_len); - status = BTM_VendorSpecificCommand(HCI_VENDOR_BLE_LONG_ADV_DATA, BTM_BLE_LONG_ADV_MAX_LEN + 1, long_adv, NULL); - if(status == BTM_CMD_STARTED) { - status = BTM_SUCCESS; - } - - return status; -} - /******************************************************************************* ** ** Function BTM_BleWriteAdvDataRaw @@ -2001,7 +1934,7 @@ tBTM_STATUS BTM_BleWriteAdvDataRaw(UINT8 *p_raw_adv, UINT32 raw_adv_len) return ret; } - +#endif // #if (BLE_42_ADV_EN == TRUE) /******************************************************************************* ** @@ -2171,16 +2104,20 @@ UINT16 BTM_BleReadConnectability(void) void BTM_Recovery_Pre_State(void) { +#if ((BLE_42_ADV_EN == TRUE) || (BLE_42_SCAN_EN == TRUE)) tBTM_BLE_INQ_CB *ble_inq_cb = &btm_cb.ble_ctr_cb.inq_var; - +#endif // #if ((BLE_42_ADV_EN == TRUE) || (BLE_42_SCAN_EN == TRUE)) +#if (BLE_42_ADV_EN == TRUE) if (ble_inq_cb->state & BTM_BLE_ADVERTISING) { btm_ble_stop_adv(); btm_ble_start_adv(); } +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) if (ble_inq_cb->state & BTM_BLE_SCANNING) { btm_ble_start_scan(); } - +#endif // #if (BLE_42_SCAN_EN == TRUE) return; } @@ -2621,7 +2558,9 @@ tBTM_STATUS btm_ble_set_discoverability(UINT16 combined_mode) if (evt_type != p_cb->evt_type || p_cb->adv_addr_type != own_addr_type || !p_cb->fast_adv_on) { +#if (BLE_42_ADV_EN == TRUE) btm_ble_stop_adv(); +#endif // #if (BLE_42_ADV_EN == TRUE) /* update adv params */ if (!btsnd_hcic_ble_write_adv_params (adv_int_min, @@ -2641,11 +2580,13 @@ tBTM_STATUS btm_ble_set_discoverability(UINT16 combined_mode) } if (status == BTM_SUCCESS && p_cb->adv_mode != new_mode) { +#if (BLE_42_ADV_EN == TRUE) if (new_mode == BTM_BLE_ADV_ENABLE) { status = btm_ble_start_adv(); } else { status = btm_ble_stop_adv(); } +#endif // #if (BLE_42_ADV_EN == TRUE) } if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) { @@ -2716,7 +2657,9 @@ tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode) btm_ble_set_adv_flag (combined_mode, btm_cb.btm_inq_vars.discoverable_mode); if (p_cb->evt_type != evt_type || p_cb->adv_addr_type != p_addr_cb->own_addr_type || !p_cb->fast_adv_on) { +#if (BLE_42_ADV_EN == TRUE) btm_ble_stop_adv(); +#endif // #if (BLE_42_ADV_EN == TRUE) if (!btsnd_hcic_ble_write_adv_params (adv_int_min, adv_int_max, @@ -2736,11 +2679,13 @@ tBTM_STATUS btm_ble_set_connectability(UINT16 combined_mode) /* update advertising mode */ if (status == BTM_SUCCESS && new_mode != p_cb->adv_mode) { +#if (BLE_42_ADV_EN == TRUE) if (new_mode == BTM_BLE_ADV_ENABLE) { status = btm_ble_start_adv(); } else { status = btm_ble_stop_adv(); } +#endif // #if (BLE_42_ADV_EN == TRUE) } if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) { @@ -2801,7 +2746,9 @@ tBTM_STATUS btm_ble_start_inquiry (UINT8 mode, UINT8 duration) /* enable IRK list */ //btm_ble_enable_resolving_list_for_platform(BTM_BLE_RL_SCAN); #endif +#if (BLE_42_SCAN_EN == TRUE) status = btm_ble_start_scan(); +#endif // #if (BLE_42_SCAN_EN == TRUE) } else if ((p_ble_cb->inq_var.scan_interval != BTM_BLE_LOW_LATENCY_SCAN_INT) || (p_ble_cb->inq_var.scan_window != BTM_BLE_LOW_LATENCY_SCAN_WIN)) { BTM_TRACE_DEBUG("%s, restart LE scan with low latency scan params", __FUNCTION__); @@ -3853,6 +3800,7 @@ void btm_ble_process_direct_adv_pkt(UINT8 *p) // TODO } +#if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** ** Function btm_ble_start_scan @@ -3890,6 +3838,7 @@ tBTM_STATUS btm_ble_start_scan(void) osi_mutex_unlock(&scan_enable_lock); return status; } +#endif // #if (BLE_42_SCAN_EN == TRUE) /******************************************************************************* ** @@ -3939,8 +3888,10 @@ void btm_ble_stop_inquiry(void) } else if ((p_ble_cb->inq_var.scan_interval != BTM_BLE_LOW_LATENCY_SCAN_INT) || (p_ble_cb->inq_var.scan_window != BTM_BLE_LOW_LATENCY_SCAN_WIN)) { BTM_TRACE_DEBUG("%s: setting default params for ongoing observe", __FUNCTION__); +#if (BLE_42_SCAN_EN == TRUE) btm_ble_stop_scan(); btm_ble_start_scan(); +#endif // #if (BLE_42_SCAN_EN == TRUE) } /* If we have a callback registered for inquiry complete, call it */ @@ -3991,6 +3942,7 @@ static void btm_ble_stop_observe(void) *******************************************************************************/ static void btm_ble_stop_discover(void) { +#if (BLE_42_SCAN_EN == TRUE) tBTM_BLE_CB *p_ble_cb = & btm_cb.ble_ctr_cb; tBTM_CMPL_CB *p_scan_cb = p_ble_cb->p_scan_cmpl_cb; btu_stop_timer (&p_ble_cb->scan_timer_ent); @@ -4018,6 +3970,7 @@ static void btm_ble_stop_discover(void) (p_scan_cb)((tBTM_INQUIRY_CMPL *) &btm_cb.btm_inq_vars.inq_cmpl_info); } osi_mutex_unlock(&scan_enable_lock); +#endif // #if (BLE_42_SCAN_EN == TRUE) } /******************************************************************************* @@ -4030,6 +3983,7 @@ static void btm_ble_stop_discover(void) ** *******************************************************************************/ typedef BOOLEAN (BTM_TOPOLOGY_FUNC_PTR)(tBTM_BLE_STATE_MASK); +#if (BLE_42_ADV_EN == TRUE) static BOOLEAN btm_ble_adv_states_operation(BTM_TOPOLOGY_FUNC_PTR *p_handler, UINT8 adv_evt) { BOOLEAN rt = FALSE; @@ -4062,7 +4016,6 @@ static BOOLEAN btm_ble_adv_states_operation(BTM_TOPOLOGY_FUNC_PTR *p_handler, UI return rt; } - /******************************************************************************* ** ** Function btm_ble_start_adv @@ -4174,14 +4127,19 @@ tBTM_STATUS btm_ble_stop_adv(void) } return rt; } +#endif // #if (BLE_42_ADV_EN == TRUE) tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda) { tBTM_STATUS rt = BTM_SUCCESS; - +#if (BLE_42_ADV_EN == TRUE) osi_mutex_lock(&adv_enable_lock, OSI_MUTEX_MAX_TIMEOUT); +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) osi_mutex_lock(&scan_enable_lock, OSI_MUTEX_MAX_TIMEOUT); +#endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_42_ADV_EN == TRUE) if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_ENABLE) { if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) { osi_sem_take(&adv_enable_sem, OSI_SEM_MAX_TIMEOUT); @@ -4190,7 +4148,9 @@ tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda) rt = BTM_BAD_VALUE_RET; } } +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) if (BTM_BLE_IS_DISCO_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) { if (btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_SCAN_DUPLICATE_DISABLE)) { osi_sem_take(&scan_enable_sem, OSI_SEM_MAX_TIMEOUT); @@ -4199,11 +4159,13 @@ tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda) rt = BTM_BAD_VALUE_RET; } } +#endif // #if (BLE_42_SCAN_EN == TRUE) if (rt == BTM_SUCCESS) { btsnd_hcic_ble_set_random_addr(random_bda); } +#if (BLE_42_ADV_EN == TRUE) if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_ENABLE) { if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_ENABLE)) { osi_sem_take(&adv_enable_sem, OSI_SEM_MAX_TIMEOUT); @@ -4212,7 +4174,9 @@ tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda) rt = BTM_BAD_VALUE_RET; } } +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) if (BTM_BLE_IS_DISCO_ACTIVE(btm_cb.ble_ctr_cb.scan_activity)) { if (btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, btm_cb.ble_ctr_cb.inq_var.scan_duplicate_filter)) { osi_sem_take(&scan_enable_sem, OSI_SEM_MAX_TIMEOUT); @@ -4221,9 +4185,14 @@ tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda) rt = BTM_BAD_VALUE_RET; } } +#endif // #if (BLE_42_SCAN_EN == TRUE) +#if (BLE_42_ADV_EN == TRUE) osi_mutex_unlock(&adv_enable_lock); +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) osi_mutex_unlock(&scan_enable_lock); +#endif // #if (BLE_42_SCAN_EN == TRUE) return rt; } @@ -4240,6 +4209,7 @@ tBTM_STATUS btm_ble_set_random_addr(BD_ADDR random_bda) *******************************************************************************/ static void btm_ble_start_slow_adv (void) { +#if (BLE_42_ADV_EN == TRUE) tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) { @@ -4258,9 +4228,9 @@ static void btm_ble_start_slow_adv (void) p_cb->evt_type, own_addr_type, init_addr_type, p_addr_ptr, p_cb->adv_chnl_map, p_cb->afp); - btm_ble_start_adv(); } +#endif // #if (BLE_42_ADV_EN == TRUE) } /******************************************************************************* ** diff --git a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c index 9ddf746ae9..39e249b13b 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c +++ b/components/bt/host/bluedroid/stack/btm/btm_ble_privacy.c @@ -683,10 +683,12 @@ BOOLEAN btm_ble_suspend_resolving_list_activity(void) p_ble_cb->suspended_rl_state = BTM_BLE_RL_IDLE; +#if (BLE_42_ADV_EN == TRUE) if (p_ble_cb->inq_var.adv_mode == BTM_BLE_ADV_ENABLE) { btm_ble_stop_adv(); p_ble_cb->suspended_rl_state |= BTM_BLE_RL_ADV; } +#endif // #if (BLE_42_ADV_EN == TRUE) if (BTM_BLE_IS_SCAN_ACTIVE(p_ble_cb->scan_activity)) { btm_ble_stop_scan(); @@ -714,15 +716,16 @@ BOOLEAN btm_ble_suspend_resolving_list_activity(void) void btm_ble_resume_resolving_list_activity(void) { tBTM_BLE_CB *p_ble_cb = &btm_cb.ble_ctr_cb; - +#if (BLE_42_ADV_EN == TRUE) if (p_ble_cb->suspended_rl_state & BTM_BLE_RL_ADV) { btm_ble_start_adv(); } - +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) if (p_ble_cb->suspended_rl_state & BTM_BLE_RL_SCAN) { btm_ble_start_scan(); } - +#endif // #if (BLE_42_SCAN_EN == TRUE) if (p_ble_cb->suspended_rl_state & BTM_BLE_RL_INIT) { btm_ble_resume_bg_conn(); } diff --git a/components/bt/host/bluedroid/stack/btm/btm_devctl.c b/components/bt/host/bluedroid/stack/btm/btm_devctl.c index d3c4ac61da..c5fca5ea16 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_devctl.c +++ b/components/bt/host/bluedroid/stack/btm/btm_devctl.c @@ -752,9 +752,6 @@ void btm_vsc_complete (UINT8 *p, UINT16 opcode, UINT16 evt_len, #if (BLE_INCLUDED == TRUE) tBTM_BLE_CB *ble_cb = &btm_cb.ble_ctr_cb; switch(opcode) { - case HCI_VENDOR_BLE_LONG_ADV_DATA: - BTM_TRACE_EVENT("Set long adv data complete\n"); - break; case HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST: { uint8_t subcode, status; uint32_t length; STREAM_TO_UINT8(status, p); diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index 2a6e21cd15..7e1b4e4c2c 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -136,13 +136,21 @@ static void btu_ble_proc_enhanced_conn_cmpl (UINT8 *p, UINT16 evt_len); //#endif #if (BLE_50_FEATURE_SUPPORT == TRUE) static void btu_ble_phy_update_complete_evt(UINT8 *p); +#if (BLE_50_EXTEND_SCAN_EN == TRUE) static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len); +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p); static void btu_ble_periodic_adv_report_evt(UINT8 *p, UINT8 evt_len); static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p); +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) static void btu_ble_scan_timeout_evt(UINT8 *p); +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) static void btu_ble_adv_set_terminate_evt(UINT8 *p); static void btu_ble_scan_req_received_evt(UINT8 *p); +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) static void btu_ble_channel_select_alg_evt(UINT8 *p); #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) @@ -389,10 +397,13 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_BLE_PHY_UPDATE_COMPLETE_EVT: btu_ble_phy_update_complete_evt(p); break; +#if (BLE_50_EXTEND_SCAN_EN == TRUE) case HCI_BLE_EXT_ADV_REPORT_EVT: //HCI_TRACE_ERROR("%s, HCI_BLE_EXT_ADV_REPORT_EVT.", __func__); btu_ble_ext_adv_report_evt(p, hci_evt_len); break; +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) case HCI_BLE_PERIOD_ADV_SYNC_ESTAB_EVT: btu_ble_periodic_adv_sync_establish_evt(p); break; @@ -402,15 +413,20 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_BLE_PERIOD_ADV_SYNC_LOST_EVT: btu_ble_periodic_adv_sync_lost_evt(p); break; +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) case HCI_BLE_SCAN_TIMEOUT_EVT: btu_ble_scan_timeout_evt(p); break; +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_ADV_SET_TERMINATED_EVT: btu_ble_adv_set_terminate_evt(p); break; case HCI_BLE_SCAN_REQ_RECEIVED_EVT: btu_ble_scan_req_received_evt(p); break; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_CHANNEL_SELECT_ALG: btu_ble_channel_select_alg_evt(p); break; @@ -1070,9 +1086,11 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l case HCI_BLE_TRANSMITTER_TEST: case HCI_BLE_RECEIVER_TEST: +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) case HCI_BLE_TEST_END: btm_ble_test_command_complete(p); break; +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) case HCI_BLE_CREATE_CONN_CANCEL: btm_ble_create_conn_cancel_complete(p); break; @@ -1107,6 +1125,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l break; #endif // #if (defined BLE_PRIVACY_SPT && BLE_PRIVACY_SPT == TRUE) #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_SET_EXT_ADV_PARAM: case HCI_BLE_SET_EXT_ADV_DATA: case HCI_BLE_SET_EXT_SCAN_RSP_DATA: @@ -1115,6 +1134,7 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l HCI_TRACE_EVENT("%s opcode 0x%x status 0x%x", __func__, opcode, status); break; } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) case HCI_BLE_READ_PHY: { uint16_t conn_handle; uint8_t tx_phy; @@ -1126,11 +1146,14 @@ static void btu_hcif_hdl_command_complete (UINT16 opcode, UINT8 *p, UINT16 evt_l btm_read_phy_callback(status, conn_handle, tx_phy, rx_phy); break; } +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) case HCI_BLE_ENH_RX_TEST: case HCI_BLE_ENH_TX_TEST: btm_ble_test_command_complete(p); break; -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) + #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) case HCI_BLE_SET_PERIOD_ADV_RECV_ENABLE: case HCI_BLE_SET_DEFAULT_PAST_PARAMS: @@ -1194,6 +1217,7 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) uint8_t *stream = response->data + response->offset + 3; STREAM_TO_UINT16(opcode, stream); switch (opcode) { +#if (BLE_42_ADV_EN == TRUE) case HCI_BLE_WRITE_ADV_DATA: adv_data_status = *stream; osi_sem_give(&adv_data_sem); @@ -1211,6 +1235,8 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) adv_param_status = *stream; osi_sem_give(&adv_param_sem); break; +#endif // #if (BLE_42_ADV_EN == TRUE) +#if (BLE_42_SCAN_EN == TRUE) case HCI_BLE_WRITE_SCAN_PARAMS: scan_param_status = *stream; osi_sem_give(&scan_param_sem); @@ -1219,6 +1245,7 @@ static void btu_hcif_command_complete_evt(BT_HDR *response, void *context) scan_enable_status = *stream; osi_sem_give(&scan_enable_sem); break; +#endif // #if (BLE_42_SCAN_EN == TRUE) default: break; } @@ -1287,6 +1314,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c btm_pm_proc_cmd_status(status); break; #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) case HCI_BLE_PERIOD_ADV_CREATE_SYNC: { uint8_t btm_status = BTM_SUCCESS; @@ -1297,6 +1325,7 @@ static void btu_hcif_hdl_command_status (UINT16 opcode, UINT8 status, UINT8 *p_c btm_create_sync_callback(btm_status); break; } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) case HCI_BLE_SET_PHY: { uint8_t btm_status = BTM_SUCCESS; @@ -2138,6 +2167,7 @@ static void btu_ble_phy_update_complete_evt(UINT8 *p) } #if BLE_PRIVACY_SPT == TRUE +#if (BLE_50_EXTEND_SCAN_EN == TRUE) /******************************************************************************* ** ** Function btm_ble_resolve_random_addr_adv_ext @@ -2158,8 +2188,10 @@ static void btm_ble_resolve_random_addr_adv_ext(void *p_rec, void *p) BDADDR_TO_STREAM(pp,bda); } } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) #endif +#if (BLE_50_EXTEND_SCAN_EN == TRUE) static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len) { tBTM_BLE_EXT_ADV_REPORT ext_adv_report = {0}; @@ -2240,7 +2272,9 @@ static void btu_ble_ext_adv_report_evt(UINT8 *p, UINT16 evt_len) } } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_SYNC_EN == TRUE) static void btu_ble_periodic_adv_sync_establish_evt(UINT8 *p) { tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab = {0}; @@ -2313,14 +2347,18 @@ static void btu_ble_periodic_adv_sync_lost_evt(UINT8 *p) btm_ble_periodic_adv_sync_lost_evt(&sync_lost); } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) static void btu_ble_scan_timeout_evt(UINT8 *p) { UNUSED(p); btm_ble_scan_timeout_evt(); } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) static void btu_ble_adv_set_terminate_evt(UINT8 *p) { tBTM_BLE_ADV_TERMINAT adv_term = {0}; @@ -2353,6 +2391,7 @@ static void btu_ble_scan_req_received_evt(UINT8 *p) btm_ble_scan_req_received_evt(&req_received); } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) static void btu_ble_channel_select_alg_evt(UINT8 *p) { diff --git a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c index 286f8e3ae5..3d28c5718e 100644 --- a/components/bt/host/bluedroid/stack/hcic/hciblecmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hciblecmds.c @@ -686,6 +686,7 @@ BOOLEAN btsnd_hcic_ble_ltk_req_neg_reply (UINT16 handle) return (TRUE); } +#if (BLE_42_DTM_TEST_EN == TRUE) BOOLEAN btsnd_hcic_ble_receiver_test(UINT8 rx_freq) { BT_HDR *p; @@ -733,7 +734,9 @@ BOOLEAN btsnd_hcic_ble_transmitter_test(UINT8 tx_freq, UINT8 test_data_len, UINT btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); } +#endif // // #if (BLE_42_DTM_TEST_EN == TRUE) +#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) BOOLEAN btsnd_hcic_ble_test_end(void) { BT_HDR *p; @@ -754,6 +757,7 @@ BOOLEAN btsnd_hcic_ble_test_end(void) btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); return (TRUE); } +#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE)) BOOLEAN btsnd_hcic_ble_read_host_supported (void) { @@ -1174,6 +1178,7 @@ BOOLEAN btsnd_hcic_ble_set_phy(UINT16 conn_handle, return TRUE; } +#if (BLE_50_DTM_TEST_EN == TRUE) UINT8 btsnd_hcic_ble_enhand_rx_test(UINT8 rx_channel, UINT8 phy, UINT8 modulation_idx) { @@ -1218,7 +1223,9 @@ UINT8 btsnd_hcic_ble_enhand_tx_test(UINT8 tx_channel, UINT8 len, return TRUE; } +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr) { BT_HDR *p; @@ -1432,7 +1439,9 @@ UINT8 btsnd_hcic_ble_clear_adv_set(void) return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); } +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) UINT8 btsnd_hcic_ble_set_periodic_adv_params(UINT8 adv_handle, UINT16 interval_min, UINT16 interval_max, @@ -1507,7 +1516,9 @@ UINT8 btsnd_hcic_ble_periodic_adv_enable(UINT8 enable, UINT8 adv_handle) return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); } +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) UINT8 btsnd_hcic_ble_set_ext_scan_params(UINT8 own_addr_type, UINT8 filter_policy, UINT8 phy_mask, UINT8 phy_count, tHCI_EXT_SCAN_PARAMS *params) @@ -1555,6 +1566,7 @@ UINT8 btsnd_hcic_ble_ext_scan_enable(UINT8 enable, UINT8 filter_dups, return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); } +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) { @@ -1627,6 +1639,7 @@ BOOLEAN btsnd_hcic_ble_create_ext_conn(tHCI_CreatExtConn *p_conn) } +#if (BLE_50_EXTEND_SYNC_EN == TRUE) BOOLEAN btsnd_hcic_ble_periodic_adv_create_sync(UINT8 option, UINT8 adv_sid, UINT8 adv_addr_type, BD_ADDR adv_addr, UINT16 sync_timeout, UINT8 unused) @@ -1750,6 +1763,7 @@ UINT8 btsnd_hcic_ble_read_periodic_adv_list_size(void) return btu_hcif_send_cmd_sync(LOCAL_BR_EDR_CONTROLLER_ID, p); } +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) UINT8 btsnd_hcic_ble_read_trans_power(void) { 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 3dc7dc8b33..123018c38f 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 @@ -367,7 +367,6 @@ typedef UINT32 tBTM_BLE_AD_MASK; #define BTM_BLE_AD_TYPE_MANU HCI_EIR_MANUFACTURER_SPECIFIC_TYPE /* 0xff */ typedef UINT8 tBTM_BLE_AD_TYPE; -#define BTM_BLE_LONG_ADV_MAX_LEN 249 /* Security settings used with L2CAP LE COC */ #define BTM_SEC_LE_LINK_ENCRYPTED 0x01 @@ -1013,6 +1012,7 @@ typedef void (tBTM_SET_CSA_SUPPORT_CMPL_CBACK) (tBTM_STATUS status); #define BTM_BLE_5_GAP_READ_PHY_COMPLETE_EVT 1 #define BTM_BLE_5_GAP_SET_PREFERED_DEFAULT_PHY_COMPLETE_EVT 2 #define BTM_BLE_5_GAP_SET_PREFERED_PHY_COMPLETE_EVT 3 +#if (BLE_50_EXTEND_ADV_EN == TRUE) #define BTM_BLE_5_GAP_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT 4 #define BTM_BLE_5_GAP_EXT_ADV_SET_PARAMS_COMPLETE_EVT 5 #define BTM_BLE_5_GAP_EXT_ADV_DATA_SET_COMPLETE_EVT 6 @@ -1021,6 +1021,8 @@ typedef void (tBTM_SET_CSA_SUPPORT_CMPL_CBACK) (tBTM_STATUS status); #define BTM_BLE_5_GAP_EXT_ADV_STOP_COMPLETE_EVT 9 #define BTM_BLE_5_GAP_EXT_ADV_SET_REMOVE_COMPLETE_EVT 10 #define BTM_BLE_5_GAP_EXT_ADV_SET_CLEAR_COMPLETE_EVT 11 +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) #define BTM_BLE_5_GAP_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT 12 #define BTM_BLE_5_GAP_PERIODIC_ADV_DATA_SET_COMPLETE_EVT 13 #define BTM_BLE_5_GAP_PERIODIC_ADV_START_COMPLETE_EVT 14 @@ -1031,19 +1033,28 @@ typedef void (tBTM_SET_CSA_SUPPORT_CMPL_CBACK) (tBTM_STATUS status); #define BTM_BLE_5_GAP_PERIODIC_ADV_ADD_DEV_COMPLETE_EVT 19 #define BTM_BLE_5_GAP_PERIODIC_ADV_REMOVE_DEV_COMPLETE_EVT 20 #define BTM_BLE_5_GAP_PERIODIC_ADV_CLEAR_DEV_COMPLETE_EVT 21 +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) #define BTM_BLE_5_GAP_SET_EXT_SCAN_PARAMS_COMPLETE_EVT 22 #define BTM_BLE_5_GAP_EXT_SCAN_START_COMPLETE_EVT 23 #define BTM_BLE_5_GAP_EXT_SCAN_STOP_COMPLETE_EVT 24 +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) #define BTM_BLE_5_GAP_PREFER_EXT_CONN_PARAMS_SET_COMPLETE_EVT 25 #define BTM_BLE_5_GAP_PHY_UPDATE_COMPLETE_EVT 26 +#if (BLE_50_EXTEND_SCAN_EN == TRUE) #define BTM_BLE_5_GAP_EXT_ADV_REPORT_EVT 27 #define BTM_BLE_5_GAP_SCAN_TIMEOUT_EVT 28 +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) #define BTM_BLE_5_GAP_ADV_TERMINATED_EVT 29 #define BTM_BLE_5_GAP_SCAN_REQ_RECEIVED_EVT 30 +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #define BTM_BLE_5_GAP_CHANNEL_SELETE_ALGORITHM_EVT 31 +#if (BLE_50_EXTEND_SYNC_EN == TRUE) #define BTM_BLE_5_GAP_PERIODIC_ADV_REPORT_EVT 32 #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_LOST_EVT 33 #define BTM_BLE_5_GAP_PERIODIC_ADV_SYNC_ESTAB_EVT 34 +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) #define BTM_BLE_GAP_PERIODIC_ADV_RECV_ENABLE_COMPLETE_EVT 35 #define BTM_BLE_GAP_PERIODIC_ADV_SYNC_TRANS_COMPLETE_EVT 36 @@ -1313,12 +1324,15 @@ typedef union { tBTM_BLE_READ_PHY_CMPL read_phy; tBTM_BLE_SET_PREF_DEF_PHY_CMPL set_perf_def_phy; tBTM_BLE_SET_PERF_PHY_CMPL set_perf_phy; +#if (BLE_50_EXTEND_ADV_EN == TRUE) tBTM_BLE_EXT_ADV_SET_RAND_ADDR_CMPL set_ext_rand_addr; tBTM_BLE_EXT_ADV_SET_PARAMS_CMPL set_params; tBTM_BLE_EXT_ADV_DATA_SET_CMPL adv_data_set; tBTM_BLE_EXT_ADV_SCAN_RSP_DATA_SET_CMPL scan_rsp_data_set; tBTM_BLE_EXT_ADV_START_CMPL adv_start; tBTM_BLE_EXT_ADV_STOP_CMPL adv_stop; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) +#if (BLE_50_PERIODIC_ADV_EN == TRUE) tBTM_BLE_PERIOD_ADV_SET_PARAMS_CMPL per_adv_set_params; tBTM_BLE_PERIOD_ADV_DATA_SET_CMPL per_adv_data_set; tBTM_BLE_PERIOD_ADV_START_CMPL per_adv_start; @@ -1329,18 +1343,27 @@ typedef union { tBTM_BLE_PERIOD_ADV_ADD_DEV_CMPL per_adv_add_dev; tBTM_BLE_PERIOD_ADV_REMOVE_DEV_CMPL per_adv_remove_dev; tBTM_BLE_PEROID_ADV_CLEAR_DEV_CMPL per_adv_clear_dev; +#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE) +#if (BLE_50_EXTEND_SCAN_EN == TRUE) tBTM_BLE_SET_EXT_SCAN_PARAMS_CMPL ext_scan; tBTM_BLE_EXT_SCAN_START_CMPL scan_start; tBTM_BLE_EXT_SCAN_STOP_CMPL scan_stop; +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) tBTM_BLE_PREF_EXT_CONN_SET_PARAMS_CMPL ext_conn_set_params; tBTM_BLE_PHY_UPDATE_CMPL phy_update; +#if (BLE_50_EXTEND_SCAN_EN == TRUE) tBTM_BLE_EXT_ADV_REPORT ext_adv_report; +#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE) +#if (BLE_50_EXTEND_ADV_EN == TRUE) tBTM_BLE_ADV_TERMINAT adv_term; tBTM_BLE_SCAN_REQ_RECEIVED scan_req; +#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) tBTM_BLE_CHANNEL_SEL_ALG channel_sel; +#if (BLE_50_EXTEND_SYNC_EN == TRUE) tBTM_PERIOD_ADV_REPORT period_adv_report; tBTM_BLE_PERIOD_ADV_SYNC_LOST sync_lost; tBTM_BLE_PERIOD_ADV_SYNC_ESTAB sync_estab; +#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) tBTM_BLE_PERIOD_ADV_RECV_ENABLE_CMPL per_adv_recv_enable; tBTM_BLE_PERIOD_ADV_SYNC_TRANS_CMPL per_adv_sync_trans; @@ -1424,23 +1447,6 @@ BOOLEAN BTM_SecAddBleDevice (BD_ADDR bd_addr, BD_NAME bd_name, BOOLEAN BTM_SecAddBleKey (BD_ADDR bd_addr, tBTM_LE_KEY_VALUE *p_le_key, tBTM_LE_KEY_TYPE key_type); -/******************************************************************************* -** -** Function BTM_BleSetAdvParams -** -** Description This function is called to set advertising parameters. -** -** Parameters: None. -** -** Returns void -** -*******************************************************************************/ -//extern -tBTM_STATUS BTM_BleSetAdvParams(UINT16 adv_int_min, UINT16 adv_int_max, - tBLE_BD_ADDR *p_dir_bda, tBTM_BLE_ADV_CHNL_MAP chnl_map); - - - /******************************************************************************* ** ** Function BTM_BleSetAdvParamsAll @@ -1485,20 +1491,6 @@ tBTM_STATUS BTM_BleStartAdv(void); tBTM_STATUS BTM_BleWriteAdvData(tBTM_BLE_AD_MASK data_mask, tBTM_BLE_ADV_DATA *p_data); -/******************************************************************************* -** -** Function BTM_BleWriteLongAdvData -** -** Description This function is called to write long advertising data. -** -** Parameters: adv_data: long advertising data -** adv_data_len: the length of long advertising data -** -** Returns void -** -*******************************************************************************/ -tBTM_STATUS BTM_BleWriteLongAdvData(uint8_t *adv_data, uint8_t adv_data_len); - /******************************************************************************* ** ** Function BTM_BleWriteAdvDataRaw @@ -2789,12 +2781,13 @@ tBTM_STATUS BTM_BleSetExtendedScanParams(tBTM_BLE_EXT_SCAN_PARAMS *params); tBTM_STATUS BTM_BleExtendedScan(BOOLEAN enable, UINT16 duration, UINT16 period); void BTM_BleSetPreferExtenedConnParams(BD_ADDR bd_addr, tBTM_EXT_CONN_PARAMS *params); +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) void BTM_BleEnhancedReceiverTest(UINT8 rx_freq, UINT8 phy, UINT8 modulation_index, tBTM_CMPL_CB *p_cmd_cmpl_cback); void BTM_BleEnhancedTransmitterTest(UINT8 tx_freq, UINT8 test_data_len, UINT8 packet_payload, UINT8 phy, tBTM_CMPL_CB *p_cmd_cmpl_cback); - -#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE) void BTM_BlePeriodicAdvRecvEnable(UINT16 sync_handle, UINT8 enable); diff --git a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h index 0943c624f9..054b616993 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcidefs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcidefs.h @@ -357,8 +357,12 @@ #define HCI_BLE_READ_PHY (0x0030 | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_DEFAULT_PHY (0x0031 | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_PHY (0x0032 | HCI_GRP_BLE_CMDS) +#endif +#if (BLE_50_DTM_TEST_EN == TRUE) #define HCI_BLE_ENH_RX_TEST (0x0033 | HCI_GRP_BLE_CMDS) #define HCI_BLE_ENH_TX_TEST (0x0034 | HCI_GRP_BLE_CMDS) +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_FEATURE_SUPPORT == TRUE) #define HCI_BLE_SET_ADV_RAND_ADDR (0x0035 | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_EXT_ADV_PARAM (0x0036 | HCI_GRP_BLE_CMDS) #define HCI_BLE_SET_EXT_ADV_DATA (0x0037 | HCI_GRP_BLE_CMDS) @@ -461,8 +465,6 @@ #define HCI_BLE_ENERGY_INFO_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_ENERGY_INFO) /* Extended BLE Scan parameters OCF */ #define HCI_BLE_EXTENDED_SCAN_PARAMS_OCF HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_EXTENDED_SCAN_PARAMS) -/* Long BLE Adv data OCF */ -#define HCI_VENDOR_BLE_LONG_ADV_DATA HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_LONG_ADV) /* BLE update duplicate scan exceptional list */ #define HCI_VENDOR_BLE_UPDATE_DUPLICATE_EXCEPTIONAL_LIST HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_DUPLICATE_EXCEPTIONAL_LIST) #define HCI_VENDOR_BLE_SET_ADV_FLOW_CONTROL HCI_ESP_VENDOR_OPCODE_BUILD(HCI_VENDOR_OGF, HCI_ESP_GROUP_BLE, HCI_SUBCODE_BLE_SET_ADV_FLOW_CONTROL) diff --git a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h index 252efa7219..6d21f06f23 100644 --- a/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h +++ b/components/bt/host/bluedroid/stack/include/stack/hcimsgs.h @@ -764,8 +764,12 @@ void btsnd_hcic_vendor_spec_cmd (BT_HDR *buffer, UINT16 opcode, #define HCIC_PARAM_SIZE_BLE_READ_PHY 2 #define HCIC_PARAM_SIZE_BLE_SET_DEF_PHY 3 #define HCIC_PARAM_SIZE_BLE_SET_PHY 7 +#endif +#if (BLE_50_DTM_TEST_EN == TRUE) #define HCIC_PARAM_SIZE_ENH_RX_TEST 3 #define HCIC_PARAM_SIZE_ENH_TX_TEST 4 +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_FEATURE_SUPPORT == TRUE) #define HCIC_PARAM_SIZE_EXT_RAND_ADDR 7 #define HCIC_PARAM_SIZE_EXT_ADV_SET_PARAMS 25 #define HCIC_PARAM_SIZE_EXT_ADV_WRITE_DATA 251 @@ -963,14 +967,17 @@ UINT8 btsnd_hcic_ble_set_prefered_default_phy(UINT8 all_phys, BOOLEAN btsnd_hcic_ble_set_phy(UINT16 conn_handle, UINT8 all_phys, UINT8 tx_phys, UINT8 rx_phys, UINT16 phy_options); - +#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) +#if (BLE_50_DTM_TEST_EN == TRUE) UINT8 btsnd_hcic_ble_enhand_rx_test(UINT8 rx_channel, UINT8 phy, UINT8 modulation_idx); UINT8 btsnd_hcic_ble_enhand_tx_test(UINT8 tx_channel, UINT8 len, UINT8 packect, UINT8 phy); +#endif // #if (BLE_50_DTM_TEST_EN == TRUE) +#if (BLE_50_FEATURE_SUPPORT == TRUE) UINT8 btsnd_hcic_ble_set_extend_rand_address(UINT8 adv_handle, BD_ADDR rand_addr); UINT8 btsnd_hcic_ble_set_ext_adv_params(UINT8 adv_handle, UINT16 properties, UINT32 interval_min, diff --git a/components/bt/host/bluedroid/stack/l2cap/l2c_link.c b/components/bt/host/bluedroid/stack/l2cap/l2c_link.c index c3118fdd5c..0d4fab8767 100644 --- a/components/bt/host/bluedroid/stack/l2cap/l2c_link.c +++ b/components/bt/host/bluedroid/stack/l2cap/l2c_link.c @@ -483,19 +483,23 @@ BOOLEAN l2c_link_hci_disc_comp (UINT16 handle, UINT8 reason) #endif // (GATTC_CONNECT_RETRY_EN == TRUE) #if (BLE_50_FEATURE_SUPPORT == TRUE) + #if (BLE_50_EXTEND_ADV_EN == TRUE) if(btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) { p_lcb->retry_create_con ++; L2CAP_TRACE_DEBUG("slave restart extend adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason); BTM_BleStartExtAdvRestart(handle); } + #endif // #if (BLE_50_EXTEND_ADV_EN == TRUE) #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) #if (BLE_42_FEATURE_SUPPORT == TRUE) + #if (BLE_42_ADV_EN == TRUE) if(!btm_ble_inter_get() && p_lcb->link_role == HCI_ROLE_SLAVE) { p_lcb->retry_create_con ++; L2CAP_TRACE_DEBUG("slave resatrt adv, retry count %d reason 0x%x\n", p_lcb->retry_create_con, reason); btm_ble_start_adv(); } + #endif // #if (BLE_42_ADV_EN == TRUE) #endif // #if (BLE_42_FEATURE_SUPPORT == TRUE) }