Skip to content

Commit fb08e4e

Browse files
feat(bt/bluedroid): optimize bluedroid menuconfig
1 parent 0959bee commit fb08e4e

34 files changed

+680
-715
lines changed

components/bt/common/btc/core/btc_task.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ static void btc_deinit_mem(void) {
389389
}
390390

391391
#if (BLE_42_FEATURE_SUPPORT == TRUE)
392+
#if (BLE_42_ADV_EN == TRUE)
392393
if (gl_bta_adv_data_ptr) {
393394
osi_free(gl_bta_adv_data_ptr);
394395
gl_bta_adv_data_ptr = NULL;
@@ -398,6 +399,7 @@ static void btc_deinit_mem(void) {
398399
osi_free(gl_bta_scan_rsp_data_ptr);
399400
gl_bta_scan_rsp_data_ptr = NULL;
400401
}
402+
#endif // #if (BLE_42_ADV_EN == TRUE)
401403
#endif // BLE_42_FEATURE_SUPPORT
402404

403405
#if GATTS_INCLUDED == TRUE && GATT_DYNAMIC_MEMORY == TRUE
@@ -452,6 +454,7 @@ static bt_status_t btc_init_mem(void) {
452454

453455
#if BTC_DYNAMIC_MEMORY == TRUE
454456
#if (BLE_42_FEATURE_SUPPORT == TRUE)
457+
#if (BLE_42_ADV_EN == TRUE)
455458
if ((gl_bta_adv_data_ptr = (tBTA_BLE_ADV_DATA *)osi_malloc(sizeof(tBTA_BLE_ADV_DATA))) == NULL) {
456459
goto error_exit;
457460
}
@@ -461,6 +464,7 @@ static bt_status_t btc_init_mem(void) {
461464
goto error_exit;
462465
}
463466
memset((void *)gl_bta_scan_rsp_data_ptr, 0, sizeof(tBTA_BLE_ADV_DATA));
467+
#endif // #if (BLE_42_ADV_EN == TRUE)
464468
#endif // (BLE_42_FEATURE_SUPPORT == TRUE)
465469
#endif // BTC_DYNAMIC_MEMORY == TRUE
466470

components/bt/host/bluedroid/Kconfig.in

Lines changed: 89 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ config BT_BLE_ENABLED
229229
help
230230
This enables Bluetooth Low Energy
231231

232-
config BT_GATTS_ENABLE
232+
menuconfig BT_GATTS_ENABLE
233233
bool "Include GATT server module(GATTS)"
234234
depends on BT_BLE_ENABLED
235235
default y
@@ -319,7 +319,7 @@ config BT_GATTS_APPEARANCE_WRITABLE
319319
help
320320
Enabling this option allows remote GATT clients to write appearance
321321

322-
config BT_GATTC_ENABLE
322+
menuconfig BT_GATTC_ENABLE
323323
bool "Include GATT client module(GATTC)"
324324
depends on BT_BLE_ENABLED
325325
default y
@@ -357,7 +357,16 @@ config BT_GATTC_CONNECT_RETRY_COUNT
357357
help
358358
The number of attempts to reconnect if the connection establishment failed
359359

360-
config BT_BLE_SMP_ENABLE
360+
config BT_BLE_ESTAB_LINK_CONN_TOUT
361+
int "Timeout of BLE connection establishment"
362+
depends on BT_GATTC_ENABLE
363+
range 1 60
364+
default 30
365+
help
366+
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
367+
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
368+
369+
menuconfig BT_BLE_SMP_ENABLE
361370
bool "Include BLE security module(SMP)"
362371
depends on BT_BLE_ENABLED
363372
default y
@@ -390,6 +399,23 @@ config BT_BLE_SMP_BOND_NVS_FLASH
390399
help
391400
This select can save SMP bonding keys to nvs flash
392401

402+
config BT_BLE_RPA_SUPPORTED
403+
bool "Update RPA to Controller"
404+
depends on (BT_BLE_SMP_ENABLE && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR
405+
default n if (BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED)
406+
default y if BT_CONTROLLER_DISABLED
407+
help
408+
This enables controller RPA list function.
409+
For ESP32, ESP32 only support network privacy mode. If this option is enabled, ESP32 will only accept
410+
advertising packets from peer devices that contain private address, HW will not receive the advertising
411+
packets contain identity address after IRK changed. If this option is disabled, address resolution will
412+
be performed in the host, so the functions that require controller to resolve address in the white list
413+
cannot be used. This option is disabled by default on ESP32, please enable or disable this option according
414+
to your own needs.
415+
416+
For other BLE chips, devices support network privacy mode and device privacy mode,
417+
users can switch the two modes according to their own needs. So this option is enabled by default.
418+
393419
config BT_STACK_NO_LOG
394420
bool "Disable BT debug logs (minimize bin size)"
395421
depends on BT_BLUEDROID_ENABLED
@@ -1194,15 +1220,6 @@ config BT_BLE_ACT_SCAN_REP_ADV_SCAN
11941220

11951221
# Memory reserved at start of DRAM for Bluetooth stack
11961222

1197-
config BT_BLE_ESTAB_LINK_CONN_TOUT
1198-
int "Timeout of BLE connection establishment"
1199-
depends on BT_BLE_ENABLED
1200-
range 1 60
1201-
default 30
1202-
help
1203-
Bluetooth Connection establishment maximum time, if connection time exceeds this value, the connection
1204-
establishment fails, ESP_GATTC_OPEN_EVT or ESP_GATTS_OPEN_EVT is triggered.
1205-
12061223
config BT_MAX_DEVICE_NAME_LEN
12071224
int "length of bluetooth device name"
12081225
depends on BT_BLUEDROID_ENABLED
@@ -1213,23 +1230,6 @@ config BT_MAX_DEVICE_NAME_LEN
12131230
the complete device name, then only the shortname will be displayed, the rest parts that can't fit in
12141231
will be truncated.
12151232

1216-
config BT_BLE_RPA_SUPPORTED
1217-
bool "Update RPA to Controller"
1218-
depends on (BT_BLUEDROID_ENABLED && ((BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED) || BT_CONTROLLER_DISABLED)) # NOERROR
1219-
default n if (BT_CONTROLLER_ENABLED && !SOC_BLE_DEVICE_PRIVACY_SUPPORTED)
1220-
default y if BT_CONTROLLER_DISABLED
1221-
help
1222-
This enables controller RPA list function.
1223-
For ESP32, ESP32 only support network privacy mode. If this option is enabled, ESP32 will only accept
1224-
advertising packets from peer devices that contain private address, HW will not receive the advertising
1225-
packets contain identity address after IRK changed. If this option is disabled, address resolution will
1226-
be performed in the host, so the functions that require controller to resolve address in the white list
1227-
cannot be used. This option is disabled by default on ESP32, please enable or disable this option according
1228-
to your own needs.
1229-
1230-
For other BLE chips, devices support network privacy mode and device privacy mode,
1231-
users can switch the two modes according to their own needs. So this option is enabled by default.
1232-
12331233
config BT_BLE_RPA_TIMEOUT
12341234
int "Timeout of resolvable private address"
12351235
depends on BT_BLE_ENABLED
@@ -1239,7 +1239,7 @@ config BT_BLE_RPA_TIMEOUT
12391239
This set RPA timeout of Controller and Host.
12401240
Default is 900 s (15 minutes). Range is 1 s to 1 hour (3600 s).
12411241

1242-
config BT_BLE_50_FEATURES_SUPPORTED
1242+
menuconfig BT_BLE_50_FEATURES_SUPPORTED
12431243
bool "Enable BLE 5.0 features(please disable BLE 4.2 if enable BLE 5.0)"
12441244
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
12451245
default y
@@ -1248,6 +1248,41 @@ config BT_BLE_50_FEATURES_SUPPORTED
12481248
This option is universally supported in chips that support BLE, except for ESP32.
12491249
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
12501250

1251+
config BT_BLE_50_EXTEND_ADV_EN
1252+
bool "Enable BLE extend advertising"
1253+
depends on BT_BLE_50_FEATURES_SUPPORTED
1254+
default y
1255+
help
1256+
This enables BLE extend advertising
1257+
1258+
config BT_BLE_50_PERIODIC_ADV_EN
1259+
bool "Enable BLE periodic advertising"
1260+
depends on BT_BLE_50_FEATURES_SUPPORTED
1261+
default y
1262+
help
1263+
This enables BLE periodic advertising
1264+
1265+
config BT_BLE_50_EXTEND_SCAN_EN
1266+
bool "Enable BLE extend scan"
1267+
depends on BT_BLE_50_FEATURES_SUPPORTED
1268+
default y
1269+
help
1270+
This enables BLE extend scan
1271+
1272+
config BT_BLE_50_EXTEND_SYNC_EN
1273+
bool "Enable BLE periodic advertising sync"
1274+
depends on BT_BLE_50_FEATURES_SUPPORTED
1275+
default y
1276+
help
1277+
This enables BLE periodic advertising sync
1278+
1279+
config BT_BLE_50_DTM_TEST_EN
1280+
bool "Enable BLE 5.0 DTM test"
1281+
depends on BT_BLE_50_FEATURES_SUPPORTED
1282+
default y
1283+
help
1284+
This enables BLE 5.0 direct test mode
1285+
12511286
config BT_BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER
12521287
bool "Enable BLE periodic advertising sync transfer feature"
12531288
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
12691304
help
12701305
Enable the create sync enhancements
12711306

1272-
config BT_BLE_42_FEATURES_SUPPORTED
1307+
menuconfig BT_BLE_42_FEATURES_SUPPORTED
12731308
bool "Enable BLE 4.2 features(please disable BLE 5.0 if enable BLE 4.2)"
1274-
depends on (BT_BLE_ENABLED && ((BT_CONTROLLER_ENABLED && SOC_BLE_50_SUPPORTED) || BT_CONTROLLER_DISABLED))
1309+
depends on BT_BLE_ENABLED
1310+
default y if IDF_TARGET_ESP32
12751311
default n
12761312
help
12771313
This enables BLE 4.2 features.
12781314
This option is universally supported by all ESP chips with BLE capabilities.
12791315
BLE 4.2 and BLE 5.0 cannot be used simultaneously.
12801316

1317+
config BT_BLE_42_DTM_TEST_EN
1318+
bool "Enable BLE 4.2 DTM test"
1319+
depends on BT_BLE_42_FEATURES_SUPPORTED
1320+
default y
1321+
help
1322+
This enables BLE 4.2 direct test mode
1323+
1324+
config BT_BLE_42_ADV_EN
1325+
bool "Enable BLE 4.2 advertising"
1326+
depends on BT_BLE_42_FEATURES_SUPPORTED
1327+
default y
1328+
help
1329+
This enables BLE v4.2 advertising
1330+
1331+
config BT_BLE_42_SCAN_EN
1332+
bool "Enable BLE 4.2 scan"
1333+
depends on BT_BLE_42_FEATURES_SUPPORTED
1334+
default y
1335+
help
1336+
This enables BLE v4.2 scan
1337+
12811338
config BT_BLE_HIGH_DUTY_ADV_INTERVAL
12821339
bool "Enable BLE high duty advertising interval feature"
12831340
depends on BT_BLE_ENABLED

components/bt/host/bluedroid/api/esp_gap_ble_api.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -28,6 +28,7 @@ esp_gap_ble_cb_t esp_ble_gap_get_callback(void)
2828
}
2929

3030
#if (BLE_42_FEATURE_SUPPORT == TRUE)
31+
#if (BLE_42_ADV_EN == TRUE)
3132
esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
3233
{
3334
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)
5152
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy,
5253
btc_gap_ble_arg_deep_free)== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
5354
}
55+
#endif // #if (BLE_42_ADV_EN == TRUE)
5456

55-
57+
#if (BLE_42_SCAN_EN == TRUE)
5658
esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params)
5759
{
5860
btc_msg_t msg = {0};
@@ -99,7 +101,9 @@ esp_err_t esp_ble_gap_stop_scanning(void)
99101
msg.act = BTC_GAP_BLE_ACT_STOP_SCAN;
100102
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
101103
}
104+
#endif // #if (BLE_42_SCAN_EN == TRUE)
102105

106+
#if (BLE_42_ADV_EN == TRUE)
103107
esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params)
104108
{
105109
btc_msg_t msg = {0};
@@ -140,6 +144,7 @@ esp_err_t esp_ble_gap_clear_advertising(void)
140144

141145
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
142146
}
147+
#endif // #if (BLE_42_ADV_EN == TRUE)
143148
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
144149

145150
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
536541
}
537542

538543
#if (BLE_42_FEATURE_SUPPORT == TRUE)
544+
#if (BLE_42_ADV_EN == TRUE)
539545
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
540546
{
541547
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
557563
btc_gap_ble_arg_deep_free) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
558564

559565
}
566+
#endif // #if (BLE_42_ADV_EN == TRUE)
560567
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
561568
esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
562569
{
@@ -933,7 +940,7 @@ esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize)
933940
return ESP_FAIL;
934941
}
935942

936-
#if (BLE_42_FEATURE_SUPPORT == TRUE)
943+
#if (BLE_42_DTM_TEST_EN == TRUE)
937944
esp_err_t esp_ble_dtm_tx_start(const esp_ble_dtm_tx_t *tx_params)
938945
{
939946
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)
973980

974981
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
975982
}
976-
#endif // #if (BLE_42_FEATURE_SUPPORT == TRUE)
983+
#endif // #if (BLE_42_DTM_TEST_EN == TRUE)
977984

978-
#if (BLE_50_FEATURE_SUPPORT == TRUE)
985+
#if (BLE_50_DTM_TEST_EN == TRUE)
979986
esp_err_t esp_ble_dtm_enh_tx_start(const esp_ble_dtm_enh_tx_t *tx_params)
980987
{
981988
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)
10151022

10161023
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_5_gap_args_t), NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
10171024
}
1018-
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
1025+
#endif // #if (BLE_50_DTM_TEST_EN == TRUE)
10191026

1027+
#if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
10201028
esp_err_t esp_ble_dtm_stop(void)
10211029
{
10221030
btc_msg_t msg = {0};
@@ -1029,6 +1037,7 @@ esp_err_t esp_ble_dtm_stop(void)
10291037

10301038
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
10311039
}
1040+
#endif // #if ((BLE_42_DTM_TEST_EN == TRUE) || (BLE_50_DTM_TEST_EN == TRUE))
10321041

10331042
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)
10341043
{
@@ -1125,6 +1134,7 @@ esp_err_t esp_ble_gap_set_preferred_phy(esp_bd_addr_t bd_addr,
11251134
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
11261135
}
11271136

1137+
#if (BLE_50_EXTEND_ADV_EN == TRUE)
11281138
esp_err_t esp_ble_gap_ext_adv_set_rand_addr(uint8_t instance, esp_bd_addr_t rand_addr)
11291139
{
11301140
btc_msg_t msg;
@@ -1280,7 +1290,9 @@ esp_err_t esp_ble_gap_ext_adv_set_clear(void)
12801290

12811291
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
12821292
}
1293+
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
12831294

1295+
#if (BLE_50_PERIODIC_ADV_EN == TRUE)
12841296
esp_err_t esp_ble_gap_periodic_adv_set_params(uint8_t instance, const esp_ble_gap_periodic_adv_params_t *params)
12851297
{
12861298
btc_msg_t msg;
@@ -1375,7 +1387,9 @@ esp_err_t esp_ble_gap_periodic_adv_stop(uint8_t instance)
13751387
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
13761388

13771389
}
1390+
#endif // #if (BLE_50_PERIODIC_ADV_EN == TRUE)
13781391

1392+
#if (BLE_50_EXTEND_SYNC_EN == TRUE)
13791393
esp_err_t esp_ble_gap_periodic_adv_create_sync(const esp_ble_gap_periodic_adv_sync_params_t *params)
13801394
{
13811395
btc_msg_t msg;
@@ -1488,7 +1502,9 @@ esp_err_t esp_ble_gap_periodic_adv_clear_dev(void)
14881502
== BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
14891503

14901504
}
1505+
#endif // #if (BLE_50_EXTEND_SYNC_EN == TRUE)
14911506

1507+
#if (BLE_50_EXTEND_SCAN_EN == TRUE)
14921508
esp_err_t esp_ble_gap_set_ext_scan_params(const esp_ble_ext_scan_params_t *params)
14931509
{
14941510
btc_msg_t msg;
@@ -1540,6 +1556,7 @@ esp_err_t esp_ble_gap_stop_ext_scan(void)
15401556

15411557
return (btc_transfer_context(&msg, NULL, 0, NULL, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
15421558
}
1559+
#endif // #if (BLE_50_EXTEND_SCAN_EN == TRUE)
15431560

15441561
esp_err_t esp_ble_gap_prefer_ext_connect_params_set(esp_bd_addr_t addr,
15451562
esp_ble_gap_phy_mask_t phy_mask,

components/bt/host/bluedroid/api/include/api/esp_gap_ble_api.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,6 +1291,7 @@ typedef union {
12911291
struct ble_set_perf_phy_cmpl_evt_param {
12921292
esp_bt_status_t status; /*!< Indicate perf phy set status */
12931293
} set_perf_phy; /*!< Event parameter of ESP_GAP_BLE_SET_PREFERRED_PHY_COMPLETE_EVT */
1294+
#if (BLE_50_EXTEND_ADV_EN == TRUE)
12941295
/**
12951296
* @brief ESP_GAP_BLE_EXT_ADV_SET_RAND_ADDR_COMPLETE_EVT
12961297
*/
@@ -1349,6 +1350,7 @@ typedef union {
13491350
esp_bt_status_t status; /*!< Indicate advertising stop operation success status */
13501351
uint8_t instance; /*!< extend advertising handle */
13511352
} ext_adv_clear; /*!< Event parameter of ESP_GAP_BLE_EXT_ADV_SET_CLEAR_COMPLETE_EVT */
1353+
#endif // #if (BLE_50_EXTEND_ADV_EN == TRUE)
13521354
/**
13531355
* @brief ESP_GAP_BLE_PERIODIC_ADV_SET_PARAMS_COMPLETE_EVT
13541356
*/

0 commit comments

Comments
 (0)