From 917134f8904bb13ffd34f24fbbb14e3c67a32fa5 Mon Sep 17 00:00:00 2001 From: zwl Date: Sat, 30 Mar 2024 14:51:34 +0800 Subject: [PATCH 1/4] ble: support only legacy adv and slave function on esp32c2 --- components/bt/controller/esp32c2/Kconfig.in | 29 +++++++++++++++++ components/bt/controller/esp32c2/bt.c | 9 ++++++ components/bt/controller/esp32c2/esp_bt_cfg.h | 31 +++++++++++++++++-- .../bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- 4 files changed, 68 insertions(+), 3 deletions(-) diff --git a/components/bt/controller/esp32c2/Kconfig.in b/components/bt/controller/esp32c2/Kconfig.in index 2bc40fb1c5..9543582b9c 100644 --- a/components/bt/controller/esp32c2/Kconfig.in +++ b/components/bt/controller/esp32c2/Kconfig.in @@ -450,6 +450,7 @@ config BT_LE_USE_ESP_TIMER config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP bool "BLE adv report flow control supported" + depends on BT_LE_ROLE_OBSERVER_ENABLE default y help The function is mainly used to enable flow control for advertising reports. When it is enabled, @@ -498,3 +499,31 @@ config BT_LE_CCA_RSSI_THRESH default 20 help Power threshold of CCA in unit of -1 dBm. + +config BT_LE_ROLE_CENTROL_ENABLE + bool "Enable BLE Centrol role function" + depends on !BT_NIMBLE_ENABLED + default y + help + Enable centrol role function. + +config BT_LE_ROLE_PERIPHERAL_ENABLE + bool "Enable BLE Peripheral role function" + depends on !BT_NIMBLE_ENABLED + default y + help + Enable Peripheral role function. + +config BT_LE_ROLE_BROADCASTER_ENABLE + bool "Enable BLE Broadcaster role function" + depends on !BT_NIMBLE_ENABLED + default y + help + Enable broadcaster role function. + +config BT_LE_ROLE_OBSERVER_ENABLE + bool "Enable BLE Observer role function" + depends on !BT_NIMBLE_ENABLED + default y + help + Enable observer role function. diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 7bd15c727b..38ae519a56 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -652,6 +652,15 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ret; } +#if DEFAULT_BT_LE_50_FEATURE_SUPPORT || DEFAULT_BT_LE_ROLE_CENTROL || DEFAULT_BT_LE_ROLE_OBSERVER + extern int esp_ble_rom_func_ptr_init_all(void); + esp_ble_rom_func_ptr_init_all(); +#else + ESP_LOGI(NIMBLE_PORT_LOG_TAG, "Init only legacy adv and slave function"); + extern int esp_ble_rom_func_ptr_init_legacy_adv_and_slave(void); + esp_ble_rom_func_ptr_init_legacy_adv_and_slave(); +#endif + /* Initialize the function pointers for OS porting */ npl_freertos_funcs_init(); struct npl_funcs_t *p_npl_funcs = npl_freertos_funcs_get(); diff --git a/components/bt/controller/esp32c2/esp_bt_cfg.h b/components/bt/controller/esp32c2/esp_bt_cfg.h index 1f0d74e1e2..0cb4168e03 100644 --- a/components/bt/controller/esp32c2/esp_bt_cfg.h +++ b/components/bt/controller/esp32c2/esp_bt_cfg.h @@ -46,6 +46,10 @@ extern "C" { #define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0) #endif + #define DEFAULT_BT_LE_ROLE_OBSERVER MYNEWT_VAL(BLE_ROLE_OBSERVER) + #define DEFAULT_BT_LE_ROLE_CENTROL MYNEWT_VAL(BLE_ROLE_CENTRAL) + #define DEFAULT_BT_LE_ROLE_PERIPHERAL MYNEWT_VAL(BLE_ROLE_PERIPHERAL) + #define DEFAULT_BT_LE_ROLE_BROADCASTER MYNEWT_VAL(BLE_ROLE_BROADCASTER) #else #if CONFIG_BT_LE_LL_CFG_FEAT_LE_CODED_PHY @@ -57,13 +61,13 @@ extern "C" { #if defined(CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST) #define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (CONFIG_BT_LE_MAX_PERIODIC_ADVERTISER_LIST) #else - #define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (5) + #define DEFAULT_BT_LE_MAX_PERIODIC_ADVERTISER_LIST (0) #endif #if defined(CONFIG_BT_LE_MAX_PERIODIC_SYNCS) #define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (CONFIG_BT_LE_MAX_PERIODIC_SYNCS) #else - #define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (1) + #define DEFAULT_BT_LE_MAX_PERIODIC_SYNCS (0) #endif #if defined(CONFIG_BT_LE_MAX_CONNECTIONS) @@ -125,6 +129,29 @@ extern "C" { #define DEFAULT_BT_LE_50_FEATURE_SUPPORT (0) #endif + #if defined(CONFIG_BT_LE_ROLE_CENTROL_ENABLE) + #define DEFAULT_BT_LE_ROLE_CENTROL (1) + #else + #define DEFAULT_BT_LE_ROLE_CENTROL (0) + #endif + + #if defined(CONFIG_BT_LE_ROLE_PERIPHERAL_ENABLE) + #define DEFAULT_BT_LE_ROLE_PERIPHERAL (1) + #else + #define DEFAULT_BT_LE_ROLE_PERIPHERAL (0) + #endif + + #if defined(CONFIG_BT_LE_ROLE_BROADCASTER_ENABLE) + #define DEFAULT_BT_LE_ROLE_BROADCASTER (1) + #else + #define DEFAULT_BT_LE_ROLE_BROADCASTER (0) + #endif + + #if defined(CONFIG_BT_LE_ROLE_OBSERVER_ENABLE) + #define DEFAULT_BT_LE_ROLE_OBSERVER (1) + #else + #define DEFAULT_BT_LE_ROLE_OBSERVER (0) + #endif #endif #define DEFAULT_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF CONFIG_BT_LE_COEX_PHY_CODED_TX_RX_TLIM_EFF diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index ea4595a563..b9a902c355 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit ea4595a5630326d428ee3457df654e1840b5e101 +Subproject commit b9a902c3551ef4a2032b6662a4cbb018125ddfda From dcb9780302312f8a44609e11a38061dcc9c0bc6a Mon Sep 17 00:00:00 2001 From: zwl Date: Mon, 15 Apr 2024 19:07:18 +0800 Subject: [PATCH 2/4] ble: optimize bt cmakelists.txt file --- components/bt/CMakeLists.txt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index d005c340c0..d32a6d372c 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -847,17 +847,8 @@ if(CONFIG_BT_ENABLED) target_link_directories(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3") target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) - elseif(CONFIG_IDF_TARGET_ESP32C2 AND CONFIG_BT_CONTROLLER_ENABLED) - add_prebuilt_library(libble_app "controller/lib_esp32c2/esp32c2-bt-lib/libble_app.a") - target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app) - elseif(CONFIG_IDF_TARGET_ESP32C6 AND CONFIG_BT_CONTROLLER_ENABLED) - add_prebuilt_library(libble_app "controller/lib_esp32c6/esp32c6-bt-lib/libble_app.a") - target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app) - elseif(CONFIG_IDF_TARGET_ESP32H2 AND CONFIG_BT_CONTROLLER_ENABLED) - add_prebuilt_library(libble_app "controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a") - target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app) - elseif(CONFIG_IDF_TARGET_ESP32C5 AND CONFIG_BT_CONTROLLER_ENABLED) - add_prebuilt_library(libble_app "controller/lib_esp32c5/esp32c5-bt-lib/libble_app.a") + elseif(CONFIG_BT_CONTROLLER_ENABLED) + add_prebuilt_library(libble_app "controller/lib_${target}/${target}-bt-lib/libble_app.a") target_link_libraries(${COMPONENT_LIB} PRIVATE libble_app) endif() From 89b0e94782e5fee21dc8acad670a6491819a5817 Mon Sep 17 00:00:00 2001 From: zwl Date: Mon, 22 Apr 2024 11:08:49 +0800 Subject: [PATCH 3/4] ble: update sdkconfig.defaults.esp32c2 file for blufi example --- examples/bluetooth/blufi/sdkconfig.defaults.esp32c2 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/bluetooth/blufi/sdkconfig.defaults.esp32c2 b/examples/bluetooth/blufi/sdkconfig.defaults.esp32c2 index aa4d6be851..128be8ddd8 100644 --- a/examples/bluetooth/blufi/sdkconfig.defaults.esp32c2 +++ b/examples/bluetooth/blufi/sdkconfig.defaults.esp32c2 @@ -9,4 +9,10 @@ CONFIG_BT_NIMBLE_BLUFI_ENABLE=y # CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y CONFIG_MBEDTLS_DHM_C=y +# The config items for NIMBLE HOST CONFIG_BT_NIMBLE_ENABLED=y +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n +CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=n +CONFIG_BT_NIMBLE_SECURITY_ENABLE=n +CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=n From c31a06d2574a0065044794df68814149b1eb5005 Mon Sep 17 00:00:00 2001 From: zwl Date: Mon, 22 Apr 2024 11:15:50 +0800 Subject: [PATCH 4/4] ble: update sdkconfig.defaults.esp32c6 file for blufi example --- examples/bluetooth/blufi/sdkconfig.defaults.esp32c6 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/bluetooth/blufi/sdkconfig.defaults.esp32c6 b/examples/bluetooth/blufi/sdkconfig.defaults.esp32c6 index de0c360c8a..128be8ddd8 100644 --- a/examples/bluetooth/blufi/sdkconfig.defaults.esp32c6 +++ b/examples/bluetooth/blufi/sdkconfig.defaults.esp32c6 @@ -9,5 +9,10 @@ CONFIG_BT_NIMBLE_BLUFI_ENABLE=y # CONFIG_BT_BLE_50_FEATURES_SUPPORTED is not set CONFIG_BT_BLE_42_FEATURES_SUPPORTED=y CONFIG_MBEDTLS_DHM_C=y +# The config items for NIMBLE HOST CONFIG_BT_NIMBLE_ENABLED=y +CONFIG_BT_NIMBLE_ROLE_CENTRAL=n +CONFIG_BT_NIMBLE_ROLE_OBSERVER=n CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT=n +CONFIG_BT_NIMBLE_SECURITY_ENABLE=n +CONFIG_BT_NIMBLE_CRYPTO_STACK_MBEDTLS=n