From b5b54570b2356f9c4df922b3a48346b722f6eaa2 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Mon, 23 Mar 2026 23:44:26 +0800 Subject: [PATCH] feat(bt): add BT_LOG_CRITICAL_ONLY bandwidth-optimized log mode Add Kconfig options for bandwidth-optimized logging via the BLE Log Async Output system. When enabled, controller log levels default to 2 and host/mesh log encoding is auto-selected. - BT_LOG_CRITICAL_ONLY parent: selects BLE_LOG_ENABLED + compression - BT_LOG_CRITICAL_ONLY_CTRL: supports both NimBLE and non-NimBLE (C3) controllers with default level override - BT_LOG_CRITICAL_ONLY_HOST: host-agnostic, selects compressed log for Bluedroid conditionally - BT_LOG_CRITICAL_ONLY_MESH: placeholder for mesh log encoding - Guards against BT_STACK_NO_LOG conflict --- components/bt/common/Kconfig.in | 49 +++++++++++++++++++++ components/bt/controller/esp32c3/Kconfig.in | 1 + 2 files changed, 50 insertions(+) diff --git a/components/bt/common/Kconfig.in b/components/bt/common/Kconfig.in index 7144e8896c..1a2146a6a4 100644 --- a/components/bt/common/Kconfig.in +++ b/components/bt/common/Kconfig.in @@ -131,6 +131,7 @@ menu "BT Logs" int "Controller log output level" depends on BT_LE_CONTROLLER_LOG_ENABLED range 0 5 + default 2 if BT_LOG_CRITICAL_ONLY_CTRL default 1 help The output level of controller log. @@ -159,6 +160,54 @@ menu "BT Logs" Implement esp_task_wdt_isr_user_handler to get controller logs when task wdt issue is triggered. endmenu + menuconfig BT_LOG_CRITICAL_ONLY + bool "Enable bandwidth-optimized log mode (critical logs only)" + default n + depends on !BT_STACK_NO_LOG + select BLE_LOG_ENABLED + select BLE_COMPRESSED_LOG_ENABLE + help + Enable bandwidth-optimized logging for the BLE Log Async Output + system. When enabled, only high-severity logs are captured and + log encoding is applied to reduce UART/SPI DMA bandwidth usage. + + Each stack component below can be independently enabled. + Requires a DMA-backed output peripheral — configure in: + BLE Log Module → BLE Log peripheral choice. + + if BT_LOG_CRITICAL_ONLY + config BT_LOG_CRITICAL_ONLY_CTRL + bool "Controller: bandwidth-optimized logging" + depends on SOC_ESP_NIMBLE_CONTROLLER || BT_CTRL_RUN_IN_FLASH_ONLY + select BT_LE_CONTROLLER_LOG_ENABLED if SOC_ESP_NIMBLE_CONTROLLER + select BT_CTRL_LE_LOG_EN if !SOC_ESP_NIMBLE_CONTROLLER + default y + help + Enable controller log output via the async transport with + a reduced output level for bandwidth optimization. + The controller log level defaults to 2 when active. + + config BT_LOG_CRITICAL_ONLY_HOST + bool "Host: bandwidth-optimized logging" + select BLE_HOST_COMPRESSED_LOG_ENABLE if BT_BLUEDROID_ENABLED + default y + help + Enable host stack log encoding via the async transport. + For Bluedroid, the per-level compression options control + which severity levels are encoded — configure in: + Settings of BLE Log Compression → BLE Host log compression. + + config BT_LOG_CRITICAL_ONLY_MESH + bool "Mesh: bandwidth-optimized logging" + depends on SOC_BLE_MESH_SUPPORTED && BLE_MESH + select BLE_MESH_COMPRESSED_LOG_ENABLE + default y + help + Enable mesh log encoding via the async transport. + The per-level compression options are configured in: + Settings of BLE Log Compression → BLE Mesh log compression. + endif # BT_LOG_CRITICAL_ONLY + source "$IDF_PATH/components/bt/common/ble_log/Kconfig.in" endmenu diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index 006114d432..74ebbc1b60 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -622,6 +622,7 @@ menu "Controller debug log Options (Experimental)" depends on BT_CTRL_LE_LOG_EN int "The level of BLE log" range 0 5 + default 2 if BT_LOG_CRITICAL_ONLY_CTRL default 1 config BT_CTRL_LE_LOG_BUF1_SIZE