diff --git a/components/bt/controller/esp32c2/Kconfig.in b/components/bt/controller/esp32c2/Kconfig.in index f834701471c4..05e15708f1e9 100644 --- a/components/bt/controller/esp32c2/Kconfig.in +++ b/components/bt/controller/esp32c2/Kconfig.in @@ -464,23 +464,3 @@ config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD config BT_LE_RELEASE_IRAM_SUPPORTED bool default y - -config BT_LE_TX_CCA_ENABLED - bool "BLE enable TX CCA feature" - default n - help - Enable the BLE (Bluetooth Low Energy) LBT (Listen Before Talk) function. Before transmitting a packet, - monitor the in-band CCA (Clear Channel Assessment). If the airborne carrier energy is too high, abandon - the packet transmission. Enabling this feature may potentially decrease BLE performance. In certain - countries and regions, when the maximum transmission power exceeds a certain limit, support for LBT - interference avoidance mechanisms is required. If the maximum transmission power does not reach the limit, - it may not be necessary to enable this function. - Please refer to the relevant certification regulations for details. - -config BT_LE_CCA_RSSI_THRESH - int "Power threshold to refrain packet transmission in unit of -1 dBm" - depends on BT_LE_TX_CCA_ENABLED - range 1 100 - default 75 - help - If a carrier signal above the threshold is detected in the air, refrain from packet transmission. diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index e06655269ea0..a51df56326dc 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -1019,7 +1019,7 @@ void esp_ble_controller_log_dump_all(bool output) esp_panic_handler_reconfigure_wdts(5000); BT_ASSERT_PRINT("\r\n[DUMP_START:"); ble_log_async_output_dump_all(output); - BT_ASSERT_PRINT("]\r\n"); + BT_ASSERT_PRINT(":DUMP_END]\r\n"); portEXIT_CRITICAL_SAFE(&spinlock); } #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED diff --git a/components/bt/controller/esp32c6/Kconfig.in b/components/bt/controller/esp32c6/Kconfig.in index 560e5ada4e72..465d713eb360 100644 --- a/components/bt/controller/esp32c6/Kconfig.in +++ b/components/bt/controller/esp32c6/Kconfig.in @@ -382,7 +382,7 @@ config BT_LE_WHITELIST_SIZE config BT_LE_LL_DUP_SCAN_LIST_COUNT int "BLE duplicate scan list count" - range 1 100 + range 5 100 default 20 help config the max count of duplicate scan list @@ -543,15 +543,6 @@ config BT_LE_SCAN_DUPL_TYPE default 2 if BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE default 0 -config BT_LE_SCAN_DUPL_CACHE_SIZE - int "Maximum number of devices in scan duplicate filter" - depends on BT_LE_SCAN_DUPL - range 10 1000 - default 100 - help - Maximum number of devices which can be recorded in scan duplicate filter. - When the maximum amount of device in the filter is reached, the cache will be refreshed. - config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD int "Duplicate scan list refresh period (seconds)" depends on BT_LE_SCAN_DUPL @@ -571,23 +562,3 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD config BT_LE_MSYS_INIT_IN_CONTROLLER bool "Msys Mbuf Init in Controller" default y - -config BT_LE_TX_CCA_ENABLED - bool "BLE enable TX CCA feature" - default n - help - Enable the BLE (Bluetooth Low Energy) LBT (Listen Before Talk) function. Before transmitting a packet, - monitor the in-band CCA (Clear Channel Assessment). If the airborne carrier energy is too high, abandon - the packet transmission. Enabling this feature may potentially decrease BLE performance. In certain - countries and regions, when the maximum transmission power exceeds a certain limit, support for LBT - interference avoidance mechanisms is required. If the maximum transmission power does not reach the limit, - it may not be necessary to enable this function. - Please refer to the relevant certification regulations for details. - -config BT_LE_CCA_RSSI_THRESH - int "Power threshold to refrain packet transmission in unit of -1 dBm" - depends on BT_LE_TX_CCA_ENABLED - range 1 100 - default 75 - help - If a carrier signal above the threshold is detected in the air, refrain from packet transmission. diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index c189f2c824a0..761e080bfc87 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -665,7 +665,7 @@ void ble_controller_scan_duplicate_config(void) uint32_t duplicate_mode = FILTER_DUPLICATE_DEFAULT; uint32_t cache_size = 100; #if CONFIG_BT_LE_SCAN_DUPL == true - cache_size = CONFIG_BT_LE_SCAN_DUPL_CACHE_SIZE; + cache_size = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT; if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 0) { duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_PDUTYPE; } else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 1) { @@ -911,9 +911,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) esp_pm_lock_acquire(s_pm_lock); #endif // CONFIG_PM_ENABLE esp_phy_enable(PHY_MODEM_BT); - esp_btbb_enable(); s_ble_active = true; } + esp_btbb_enable(); #if CONFIG_SW_COEXIST_ENABLE coex_enable(); #endif // CONFIG_SW_COEXIST_ENABLE @@ -929,8 +929,8 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode) #if CONFIG_SW_COEXIST_ENABLE coex_disable(); #endif + esp_btbb_disable(); if (s_ble_active) { - esp_btbb_disable(); esp_phy_disable(PHY_MODEM_BT); #if CONFIG_PM_ENABLE esp_pm_lock_release(s_pm_lock); @@ -952,8 +952,8 @@ esp_err_t esp_bt_controller_disable(void) #if CONFIG_SW_COEXIST_ENABLE coex_disable(); #endif + esp_btbb_disable(); if (s_ble_active) { - esp_btbb_disable(); esp_phy_disable(PHY_MODEM_BT); #if CONFIG_PM_ENABLE esp_pm_lock_release(s_pm_lock); @@ -1192,7 +1192,7 @@ void esp_ble_controller_log_dump_all(bool output) esp_panic_handler_reconfigure_wdts(5000); BT_ASSERT_PRINT("\r\n[DUMP_START:"); ble_log_async_output_dump_all(output); - BT_ASSERT_PRINT("]\r\n"); + BT_ASSERT_PRINT(":DUMP_END]\r\n"); portEXIT_CRITICAL_SAFE(&spinlock); } #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index ee7106ad8991..9e8fabe76f93 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -373,7 +373,7 @@ config BT_LE_WHITELIST_SIZE config BT_LE_LL_DUP_SCAN_LIST_COUNT int "BLE duplicate scan list count" - range 1 100 + range 5 100 default 20 help config the max count of duplicate scan list @@ -535,16 +535,6 @@ config BT_LE_SCAN_DUPL_TYPE default 2 if BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE default 0 - -config BT_LE_SCAN_DUPL_CACHE_SIZE - int "Maximum number of devices in scan duplicate filter" - depends on BT_LE_SCAN_DUPL - range 10 1000 - default 100 - help - Maximum number of devices which can be recorded in scan duplicate filter. - When the maximum amount of device in the filter is reached, the cache will be refreshed. - config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD int "Duplicate scan list refresh period (seconds)" depends on BT_LE_SCAN_DUPL @@ -564,23 +554,3 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD config BT_LE_MSYS_INIT_IN_CONTROLLER bool default y - -config BT_LE_TX_CCA_ENABLED - bool "BLE enable TX CCA feature" - default n - help - Enable the BLE (Bluetooth Low Energy) LBT (Listen Before Talk) function. Before transmitting a packet, - monitor the in-band CCA (Clear Channel Assessment). If the airborne carrier energy is too high, abandon - the packet transmission. Enabling this feature may potentially decrease BLE performance. In certain - countries and regions, when the maximum transmission power exceeds a certain limit, support for LBT - interference avoidance mechanisms is required. If the maximum transmission power does not reach the limit, - it may not be necessary to enable this function. - Please refer to the relevant certification regulations for details. - -config BT_LE_CCA_RSSI_THRESH - int "Power threshold to refrain packet transmission in unit of -1 dBm" - depends on BT_LE_TX_CCA_ENABLED - range 1 100 - default 75 - help - If a carrier signal above the threshold is detected in the air, refrain from packet transmission. diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 43a4ba0199ee..11b4526716cd 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -640,7 +640,7 @@ void ble_controller_scan_duplicate_config(void) uint32_t duplicate_mode = FILTER_DUPLICATE_DEFAULT; uint32_t cache_size = 100; #if CONFIG_BT_LE_SCAN_DUPL == true - cache_size = CONFIG_BT_LE_SCAN_DUPL_CACHE_SIZE; + cache_size = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT; if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 0) { duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_PDUTYPE; } else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 1) { @@ -1164,7 +1164,7 @@ void esp_ble_controller_log_dump_all(bool output) esp_panic_handler_reconfigure_wdts(5000); BT_ASSERT_PRINT("\r\n[DUMP_START:"); ble_log_async_output_dump_all(output); - BT_ASSERT_PRINT("]\r\n"); + BT_ASSERT_PRINT(":DUMP_END]\r\n"); portEXIT_CRITICAL_SAFE(&spinlock); } #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index 909c8bca55ac..7f3eb5f55684 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit 909c8bca55acdcbba1c32620482a7d1a10c28a07 +Subproject commit 7f3eb5f5568439cdb32dfe9dbf69d99e9c72e69f diff --git a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib index c832dbc04d68..e4d0d86b6f4f 160000 --- a/components/bt/controller/lib_esp32c6/esp32c6-bt-lib +++ b/components/bt/controller/lib_esp32c6/esp32c6-bt-lib @@ -1 +1 @@ -Subproject commit c832dbc04d6894a380fe7b92c303602a5241ef16 +Subproject commit e4d0d86b6f4fe4233f53e71d7dfa18faa0f19f27 diff --git a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib index 49a90d0ad509..90793e831955 160000 --- a/components/bt/controller/lib_esp32h2/esp32h2-bt-lib +++ b/components/bt/controller/lib_esp32h2/esp32h2-bt-lib @@ -1 +1 @@ -Subproject commit 49a90d0ad509a1ec95fcacfc67d578a97de4c1ee +Subproject commit 90793e83195547303e0fd190c890c8bff754d5d3 diff --git a/components/bt/porting/npl/freertos/include/nimble/nimble_npl_os.h b/components/bt/porting/npl/freertos/include/nimble/nimble_npl_os.h index 742e1446cc34..6c8d23c0911a 100644 --- a/components/bt/porting/npl/freertos/include/nimble/nimble_npl_os.h +++ b/components/bt/porting/npl/freertos/include/nimble/nimble_npl_os.h @@ -122,6 +122,7 @@ struct npl_funcs_t { void (*p_ble_npl_hw_exit_critical)(uint32_t); uint32_t (*p_ble_npl_get_time_forever)(void); uint8_t (*p_ble_npl_hw_is_in_critical)(void); + void (*p_ble_npl_eventq_put_to_front)(struct ble_npl_eventq *, struct ble_npl_event *); }; extern struct npl_funcs_t *npl_funcs; diff --git a/components/bt/porting/npl/freertos/src/npl_os_freertos.c b/components/bt/porting/npl/freertos/src/npl_os_freertos.c index ebf89d3cdd53..4e68c0e62c64 100644 --- a/components/bt/porting/npl/freertos/src/npl_os_freertos.c +++ b/components/bt/porting/npl/freertos/src/npl_os_freertos.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 * - * SPDX-FileContributor: 2019-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2019-2023 Espressif Systems (Shanghai) CO LTD */ #include @@ -37,11 +37,19 @@ static const char *TAG = "Timer"; #error "not defined SOC_ESP_NIMBLE_CONTROLLER or SOC_ESP_NIMBLE_CONTROLLER is zero" #endif +#if CONFIG_BT_NIMBLE_ENABLED #define BLE_HOST_CO_COUNT (8) #define BLE_HOST_EV_COUNT (11 + BLE_HOST_CO_COUNT) #define BLE_HOST_EVQ_COUNT (3) #define BLE_HOST_SEM_COUNT (10) #define BLE_HOST_MUTEX_COUNT (4) +#else +#define BLE_HOST_CO_COUNT (0) +#define BLE_HOST_EV_COUNT (0) +#define BLE_HOST_EVQ_COUNT (0) +#define BLE_HOST_SEM_COUNT (0) +#define BLE_HOST_MUTEX_COUNT (0) +#endif struct os_mempool ble_freertos_ev_pool; static os_membuf_t *ble_freertos_ev_buf = NULL; @@ -240,6 +248,32 @@ IRAM_ATTR npl_freertos_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_eve BLE_LL_ASSERT(ret == pdPASS); } +void +IRAM_ATTR npl_freertos_eventq_put_to_front(struct ble_npl_eventq *evq, struct ble_npl_event *ev) +{ + BaseType_t woken; + BaseType_t ret; + struct ble_npl_eventq_freertos *eventq = (struct ble_npl_eventq_freertos *)evq->eventq; + struct ble_npl_event_freertos *event = (struct ble_npl_event_freertos *)ev->event; + + if (event->queued) { + return; + } + + event->queued = true; + + if (in_isr()) { + ret = xQueueSendToFrontFromISR(eventq->q, &ev, &woken); + if( woken == pdTRUE ) { + portYIELD_FROM_ISR(); + } + } else { + ret = xQueueSendToFront(eventq->q, &ev, portMAX_DELAY); + } + + BLE_LL_ASSERT(ret == pdPASS); +} + void IRAM_ATTR npl_freertos_eventq_remove(struct ble_npl_eventq *evq, struct ble_npl_event *ev) @@ -986,6 +1020,7 @@ const struct npl_funcs_t npl_funcs_ro = { .p_ble_npl_eventq_deinit = npl_freertos_eventq_deinit, .p_ble_npl_eventq_get = npl_freertos_eventq_get, .p_ble_npl_eventq_put = npl_freertos_eventq_put, + .p_ble_npl_eventq_put_to_front = npl_freertos_eventq_put_to_front, .p_ble_npl_eventq_remove = npl_freertos_eventq_remove, .p_ble_npl_event_run = npl_freertos_event_run, .p_ble_npl_eventq_is_empty = npl_freertos_eventq_is_empty, diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h2 b/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h2 index aa5aebe523c9..c0485ed3cb81 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h2 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.32m.esp32h2 @@ -19,4 +19,5 @@ CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y # Sleep Config # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c6 b/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c6 index 83adc91d0c22..100772c3d5b2 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c6 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.40m.esp32c6 @@ -22,4 +22,5 @@ CONFIG_FREERTOS_USE_TICKLESS_IDLE=y # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_PHY_MAC_BB_PD=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c2 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c2 index 9f941613f70d..00b2b40f9db9 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c2 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c2 @@ -17,3 +17,4 @@ CONFIG_XTAL_FREQ=26 # Sleep Config # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c6 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c6 index ff9c87fcbcb5..ffe6bd1e946c 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c6 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32c6 @@ -22,6 +22,7 @@ CONFIG_FREERTOS_USE_TICKLESS_IDLE=y # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y CONFIG_ESP_PHY_MAC_BB_PD=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config # diff --git a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h2 b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h2 index 51e03d318ec5..7b7e5084ceda 100644 --- a/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h2 +++ b/examples/bluetooth/nimble/power_save/sdkconfig.defaults.esp32h2 @@ -19,6 +19,7 @@ CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y # Sleep Config # CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y # end of Sleep Config #