diff --git a/components/bt/common/ble_log/extension/log_compression/CMakeLists.txt b/components/bt/common/ble_log/extension/log_compression/CMakeLists.txt index 0c757ca5c43..35416088f91 100644 --- a/components/bt/common/ble_log/extension/log_compression/CMakeLists.txt +++ b/components/bt/common/ble_log/extension/log_compression/CMakeLists.txt @@ -15,6 +15,16 @@ set(HOST_LOG_INDEX_HEADER "\"\"") set(BLE_HOST_TAGS "") set(BLE_HOST_TAGS_PRESERVE "") +# default config value for ble iso module +# (esp_ble_iso owns the unified LOG_* family; consumers like esp_ble_audio +# and future HID-over-ISO compile under the same BLE_ISO module so that all +# share one iso_log_index.h and one log-id counter — no per-consumer +# bookkeeping, no redefinition risk.) +set(BLE_ISO_CODE_PATH "") +set(BLE_ISO_LOG_INDEX_HEADER "\"\"") +set(BLE_ISO_TAGS "") +set(BLE_ISO_TAGS_PRESERVE "") + if(CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE) list(APPEND LOG_COMPRESSED_MODULE "BLE_MESH") @@ -31,6 +41,26 @@ if(CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE) list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH ${BLE_MESH_CODE_PATH}) endif() +if(CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE) + list(APPEND LOG_COMPRESSED_MODULE "BLE_ISO") + + # esp_ble_audio sources share the same LOG_* macro family from + # esp_ble_iso/include/zephyr/logging/log.h; compile them under the + # single BLE_ISO module so they all hit one iso_log_index.h with one + # monotonic log-id counter. Future ISO consumers (e.g. HID-over-ISO) + # extend this list the same way — no per-consumer index header or + # Kconfig toggle. + set(BLE_ISO_CODE_PATH "esp_ble_iso" "esp_ble_audio") + set(BLE_ISO_LOG_INDEX_HEADER "iso_log_index.h") + set(BLE_ISO_LOG_SCRIPT_PATH + "${CMAKE_CURRENT_LIST_DIR}/scripts/module_scripts/ble_iso/make_iso_log_macro.py") + include(${CMAKE_CURRENT_LIST_DIR}/cmake/ble_iso_log_tags.cmake) + if(NOT EXISTS "${CMAKE_BINARY_DIR}/ble_log/include/${BLE_ISO_LOG_INDEX_HEADER}") + file(WRITE "${CMAKE_BINARY_DIR}/ble_log/include/${BLE_ISO_LOG_INDEX_HEADER}" "") + endif() + list(APPEND LOG_COMPRESSED_MODULE_CODE_PATH ${BLE_ISO_CODE_PATH}) +endif() + if(CONFIG_BLE_HOST_COMPRESSED_LOG_ENABLE AND CONFIG_BT_BLUEDROID_ENABLED) list(APPEND LOG_COMPRESSED_MODULE "BLE_HOST") @@ -127,6 +157,12 @@ if(LOG_COMPRESSED_MODULE) file(WRITE "${CMAKE_BINARY_DIR}/ble_log/module_info.yml") endif() set(YML_IN "${BT_ROOT_PATH}/common/ble_log/extension/log_compression/scripts/configs/module_info.yml.in") + + # BLE_ISO has multiple code paths; rewrite CMake list ";" → YAML ", " + # into a sibling variable so BLE_ISO_CODE_PATH itself stays a CMake + # list usable by any later code that wants to iterate or append. + string(REPLACE ";" ", " BLE_ISO_CODE_PATH_YAML "${BLE_ISO_CODE_PATH}") + configure_file(${YML_IN} ${CONFIG_FILE_PATH} @ONLY) string(REPLACE ";" "|" MODULE_CODE_PATH "${LOG_COMPRESSED_MODULE_CODE_PATH}") diff --git a/components/bt/common/ble_log/extension/log_compression/Kconfig.in b/components/bt/common/ble_log/extension/log_compression/Kconfig.in index c95f7a23390..90f1172becc 100644 --- a/components/bt/common/ble_log/extension/log_compression/Kconfig.in +++ b/components/bt/common/ble_log/extension/log_compression/Kconfig.in @@ -689,4 +689,112 @@ if BLE_COMPRESSED_LOG_ENABLE Please refer to the help information in BLE_BLUEDROID_APPL_ERROR_LOG_PRESERVE endmenu endif + + # --------------------------------------------------------------------- + # BLE ISO log compression (esp_ble_iso component) + # --------------------------------------------------------------------- + menuconfig BLE_ISO_COMPRESSED_LOG_ENABLE + bool "Enable BLE ISO log compression(Preview)" + depends on BLE_COMPRESSED_LOG_ENABLE + depends on BT_ISO + default n + help + Apply compression to ESP-BLE-ISO host shim logs (the + esp_ble_iso component) AND every IDF-source consumer that + shares the ISO LOG_* macro family — currently esp_ble_audio, + and future modules such as HID-over-ISO. All such sources + share one iso_log_index.h with one monotonic log-id counter. + Requires base BLE compression to be enabled. + + Note: prebuilt libraries (e.g. libble_audio.a) emit logs via + an independent runtime callback (BLE_AUDIO_LIB) and are not + governed by this option. + + Note: This library depends on additional Python packages. It + will function correctly only after these dependencies are + installed; refer to: + "components/bt/common/ble_log/log_compression/README.en.md" + for installation instructions. + + If the required packages are not installed, the + log-compression mechanism will remain disabled even when this + Config is enabled. + + config BLE_ISO_COMPRESSED_LOG_BUFFER_LEN + int "BLE ISO log buffer length" + depends on BLE_ISO_COMPRESSED_LOG_ENABLE + default 512 + help + Maximum output length for a single log. Shared by every IDF + source compiled into the BLE_ISO compression channel + (esp_ble_iso, esp_ble_audio, and future ISO consumers). + + if BLE_ISO_COMPRESSED_LOG_ENABLE + + menu "Select the stack log tag to be compressed" + config BLE_ISO_STACK_ERR_LOG_COMPRESSION + bool "Compress ERROR log" + default y + help + The error log in the BLE-ISO component will be compressed + + config BLE_ISO_STACK_ERR_LOG_PRESERVE + bool "Keep the original error log statement" + depends on BLE_ISO_STACK_ERR_LOG_COMPRESSION + default y + help + When this option is enabled, the log data will be output + through both the compressed log interface and the original + UART interface at the same time, meaning that the log + statements will appear on both paths. However, please note + that this dual-output approach introduces additional code + and string constants, which will increase the size of the + firmware binary file. When this option is disabled, the + logs will no longer be printed through the original UART + output path; instead, they will only be output through the + compressed log interface. As the code and strings related + to the original UART output are omitted, the size of the + firmware binary file can be effectively reduced. + + config BLE_ISO_STACK_WARN_LOG_COMPRESSION + bool "Compress warn log" + default y + help + The warn log in the BLE-ISO component will be compressed. + + config BLE_ISO_STACK_WARN_LOG_PRESERVE + bool "Keep the original warn log statement" + depends on BLE_ISO_STACK_WARN_LOG_COMPRESSION + default y + help + Please refer to the help information in BLE_ISO_STACK_ERR_LOG_PRESERVE. + + config BLE_ISO_STACK_INFO_LOG_COMPRESSION + bool "Compress info log" + default y + help + The info log in the BLE-ISO component will be compressed. + + config BLE_ISO_STACK_INFO_LOG_PRESERVE + bool "Keep the original info log statement" + depends on BLE_ISO_STACK_INFO_LOG_COMPRESSION + default n + help + Please refer to the help information in BLE_ISO_STACK_ERR_LOG_PRESERVE. + + config BLE_ISO_STACK_DEBUG_LOG_COMPRESSION + bool "Compress debug log" + default y + help + The debug log in the BLE-ISO component will be compressed. + + config BLE_ISO_STACK_DEBUG_LOG_PRESERVE + bool "Keep the original debug log statement" + depends on BLE_ISO_STACK_DEBUG_LOG_COMPRESSION + default n + help + Please refer to the help information in BLE_ISO_STACK_ERR_LOG_PRESERVE. + + endmenu + endif endif diff --git a/components/bt/common/ble_log/extension/log_compression/ble_log_compression.c b/components/bt/common/ble_log/extension/log_compression/ble_log_compression.c index 703fb28b809..908f80289c1 100644 --- a/components/bt/common/ble_log/extension/log_compression/ble_log_compression.c +++ b/components/bt/common/ble_log/extension/log_compression/ble_log_compression.c @@ -50,6 +50,16 @@ INIT_BUFFER_MGMT(mesh, LOG_CP_MAX_LOG_BUFFER_USED_SIMU); char * mesh_last_task_handle = NULL; #endif +#if CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE +/* The BLE_ISO buffer is shared by every source compiled into the unified + * ISO channel: esp_ble_iso, esp_ble_audio (and future ISO consumers, e.g. + * HID-over-ISO), as well as the AUDIO_LIB runtime callback (prebuilt + * libble_audio.a, source code 5) — they all funnel here. */ +DECLARE_BUFFERS(iso, CONFIG_BLE_ISO_COMPRESSED_LOG_BUFFER_LEN, LOG_CP_MAX_LOG_BUFFER_USED_SIMU); +INIT_BUFFER_MGMT(iso, LOG_CP_MAX_LOG_BUFFER_USED_SIMU); +char * iso_last_task_handle = NULL; +#endif + #if CONFIG_BLE_HOST_COMPRESSED_LOG_ENABLE && CONFIG_BT_BLUEDROID_ENABLED DECLARE_BUFFERS(host, CONFIG_BLE_HOST_COMPRESSED_LOG_BUFFER_LEN, LOG_CP_MAX_LOG_BUFFER_USED_SIMU); INIT_BUFFER_MGMT(host, LOG_CP_MAX_LOG_BUFFER_USED_SIMU); @@ -80,6 +90,13 @@ int ble_compressed_log_cb_get(uint8_t source, ble_cp_log_buffer_mgmt_t **mgmt) last_handle = &mesh_last_task_handle; break; #endif +#if CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE + case BLE_COMPRESSED_LOG_OUT_SOURCE_ISO: + case BLE_COMPRESSED_LOG_OUT_SOURCE_AUDIO_LIB: + buffer_mgmt = BUF_MGMT_NAME(iso); + last_handle = &iso_last_task_handle; + break; +#endif #if CONFIG_BLE_HOST_COMPRESSED_LOG_ENABLE && (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED) case BLE_COMPRESSED_LOG_OUT_SOURCE_HOST: #if CONFIG_BT_BLUEDROID_ENABLED diff --git a/components/bt/common/ble_log/extension/log_compression/cmake/ble_iso_log_tags.cmake b/components/bt/common/ble_log/extension/log_compression/cmake/ble_iso_log_tags.cmake new file mode 100644 index 00000000000..e40791e75c7 --- /dev/null +++ b/components/bt/common/ble_log/extension/log_compression/cmake/ble_iso_log_tags.cmake @@ -0,0 +1,25 @@ +set(_BLE_ISO_TAG_MAP + CONFIG_BLE_ISO_STACK_ERR_LOG_COMPRESSION + CONFIG_BLE_ISO_STACK_ERR_LOG_PRESERVE + LOG_ERR + + CONFIG_BLE_ISO_STACK_WARN_LOG_COMPRESSION + CONFIG_BLE_ISO_STACK_WARN_LOG_PRESERVE + LOG_WRN + + CONFIG_BLE_ISO_STACK_INFO_LOG_COMPRESSION + CONFIG_BLE_ISO_STACK_INFO_LOG_PRESERVE + LOG_INF + + CONFIG_BLE_ISO_STACK_DEBUG_LOG_COMPRESSION + CONFIG_BLE_ISO_STACK_DEBUG_LOG_PRESERVE + LOG_DBG +) + +include(${CMAKE_CURRENT_LIST_DIR}/tag_table_function.cmake) + +set(BLE_ISO_TAGS "") +set(BLE_ISO_TAGS_PRESERVE "") +tag_table_to_lists(_BLE_ISO_TAG_MAP BLE_ISO_TAGS BLE_ISO_TAGS_PRESERVE) +set(BLE_ISO_TAGS "${BLE_ISO_TAGS}" PARENT_SCOPE) +set(BLE_ISO_TAGS_PRESERVE "${BLE_ISO_TAGS_PRESERVE}" PARENT_SCOPE) diff --git a/components/bt/common/ble_log/extension/log_compression/include/log_compression/utils.h b/components/bt/common/ble_log/extension/log_compression/include/log_compression/utils.h index 6feac9e943e..6197b1d6e0f 100644 --- a/components/bt/common/ble_log/extension/log_compression/include/log_compression/utils.h +++ b/components/bt/common/ble_log/extension/log_compression/include/log_compression/utils.h @@ -10,8 +10,13 @@ #include #include +#ifndef CONCAT #define CONCAT(a, b) a##b +#endif + +#ifndef _CONCAT #define _CONCAT(a, b) CONCAT(a, b) +#endif #define _0 0 #define _1 1 @@ -27,8 +32,10 @@ #define __COUNT_ARGS(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _n, X...) _n #define COUNT_ARGS(X...) __COUNT_ARGS(, ##X, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) +#ifndef FOR_EACH_IDX #define FOR_EACH_IDX(macro, name, len, ...) \ _CONCAT(_FOR_EACH_, COUNT_ARGS(__VA_ARGS__))(macro, name, len, __VA_ARGS__) +#endif #define _FOR_EACH_0(m, n, l, ...) #define _FOR_EACH_1(m, n, l, i1, ...) m(n, l, i1) @@ -50,6 +57,8 @@ enum { BLE_COMPRESSED_LOG_OUT_SOURCE_HOST, BLE_COMPRESSED_LOG_OUT_SOURCE_MESH, BLE_COMPRESSED_LOG_OUT_SOURCE_MESH_LIB, + BLE_COMPRESSED_LOG_OUT_SOURCE_ISO, + BLE_COMPRESSED_LOG_OUT_SOURCE_AUDIO_LIB, }; enum { diff --git a/components/bt/common/ble_log/extension/log_compression/scripts/ble_log_compress.py b/components/bt/common/ble_log/extension/log_compression/scripts/ble_log_compress.py index b4378dff57b..ea76d622a95 100644 --- a/components/bt/common/ble_log/extension/log_compression/scripts/ble_log_compress.py +++ b/components/bt/common/ble_log/extension/log_compression/scripts/ble_log_compress.py @@ -76,6 +76,8 @@ SOURCE_ENUM_MAP = { 'BLE_HOST': 0, 'BLE_MESH': 1, 'BLE_MESH_LIB': 2, + 'BLE_ISO': 3, + 'BLE_AUDIO_LIB': 4, } # Functions that require hex formatting diff --git a/components/bt/common/ble_log/extension/log_compression/scripts/configs/module_info.yml.in b/components/bt/common/ble_log/extension/log_compression/scripts/configs/module_info.yml.in index 5201f57503a..9d92d65bde2 100644 --- a/components/bt/common/ble_log/extension/log_compression/scripts/configs/module_info.yml.in +++ b/components/bt/common/ble_log/extension/log_compression/scripts/configs/module_info.yml.in @@ -18,6 +18,14 @@ log_config: tags: [@BLE_HOST_TAGS@] tags_with_preserve: [@BLE_HOST_TAGS_PRESERVE@] + BLE_ISO: + description: "BLE ISO (and consumers: esp_ble_audio, future HID-over-ISO)" + code_path: [@BLE_ISO_CODE_PATH_YAML@] + log_index_file: @BLE_ISO_LOG_INDEX_HEADER@ + script: @BLE_ISO_LOG_SCRIPT_PATH@ + tags: [@BLE_ISO_TAGS@] + tags_with_preserve: [@BLE_ISO_TAGS_PRESERVE@] + @BLE_COMPRESSED_LIB_NAME@: description: "@BLE_COMPRESSED_LIB_DESC@" code_path: [@BLE_COMPRESSED_LIB_CODE_DIR@] diff --git a/components/bt/common/ble_log/extension/log_compression/scripts/module_scripts/ble_iso/make_iso_log_macro.py b/components/bt/common/ble_log/extension/log_compression/scripts/module_scripts/ble_iso/make_iso_log_macro.py new file mode 100644 index 00000000000..6bb347d35ad --- /dev/null +++ b/components/bt/common/ble_log/extension/log_compression/scripts/module_scripts/ble_iso/make_iso_log_macro.py @@ -0,0 +1,73 @@ +# SPDX-FileCopyrightText: 2026 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: Apache-2.0 +"""Macro generator shared by the BLE_ISO and BLE_AUDIO compression modules. + +Both components consume the LOG_ERR / LOG_WRN / LOG_INF / LOG_DBG macros +defined in components/bt/esp_ble_iso/include/zephyr/logging/log.h and gate +output through CONFIG_BT_ISO_LOG_LEVEL with the BT_ISO_LOG_* numeric levels. +""" + +import textwrap + + +def generate_iso_log_prefix(tag: str, print_statm: str) -> str: + """Wrap a compressed-print statement with the matching level check.""" + level = tag.split('_')[-1] # LOG_ERR -> ERR + + if level == 'ERR': + log_level = 'BT_ISO_LOG_ERROR' + elif level == 'WRN': + log_level = 'BT_ISO_LOG_WARN' + elif level == 'INF': + log_level = 'BT_ISO_LOG_INFO' + elif level == 'DBG': + log_level = 'BT_ISO_LOG_DEBUG' + else: + return '' + + used_log_levl = 'CONFIG_BT_ISO_LOG_LEVEL' + + return f'{{do {{ if (({used_log_levl} >= {log_level})) {{ {print_statm}; }} }} while (0);}}\\\n' + + +def gen_header_head() -> str: + head = textwrap.dedent(""" + // Compression function declarations + extern int ble_log_compressed_hex_print + (uint8_t source, uint32_t log_index, size_t args_size_cnt, ...); + extern int ble_log_compressed_hex_print_buf + (uint8_t source, uint32_t log_index, uint8_t buf_idx, const uint8_t *buf, size_t len); + """) + return head + + +def gen_compressed_stmt(log_index: int, module_id: int, func_name: str, fmt: str, args: list, buffer_args: list) -> str: + if len(args) == 0: + stmt = f' ble_log_compressed_hex_print({module_id}, {log_index}, 0);' + for idx, buffer_arg in enumerate(buffer_args): + stmt += '\\\n' + stmt += ( + f' ble_log_compressed_hex_print_buf(' + f'{module_id}, {log_index}, {idx}, ' + f'(const uint8_t *){buffer_arg["buffer"]}, {buffer_arg["length"]});' + ) + stmt += '\\\n' + return ' ' + generate_iso_log_prefix(func_name, stmt) + + size_str = ', '.join([arg['size_type'] for arg in args]) + # Strip both backslash-newline continuations and bare newlines from arg + # names so they don't leak into the generated C macro body — the same + # cleanup the NimBLE / Bluedroid generators do. + args_str = ', '.join([arg['name'] for arg in args]).replace('\\\n', '').replace('\n', '') + stmt = f' ble_log_compressed_hex_print({module_id}, {log_index}, {len(args)}, {size_str}, {args_str});' + + for idx, buffer_arg in enumerate(buffer_args): + stmt += '\\\n' + stmt += ( + f' ble_log_compressed_hex_print_buf(' + f'{module_id}, {log_index}, {idx}, ' + f'(const uint8_t *){buffer_arg["buffer"]}, {buffer_arg["length"]});' + ) + + stmt += '\\\n' + return ' ' + generate_iso_log_prefix(func_name, stmt) diff --git a/components/bt/esp_ble_audio/Kconfig.in b/components/bt/esp_ble_audio/Kconfig.in index 8b576a15901..ab5be28b4cd 100644 --- a/components/bt/esp_ble_audio/Kconfig.in +++ b/components/bt/esp_ble_audio/Kconfig.in @@ -100,21 +100,33 @@ menu "OTS Options" endmenu config BT_AUDIO_NO_LOG - bool "Disable BLE Audio Debug Log" + bool "Disable BLE Audio Lib Debug Log" default n help - Select this to save the BLE Audio related rodata code size. Enabling - this option will disable the output of BLE Audio debug log. + Select this to save rodata code size by disabling the debug log + emitted by the BLE Audio prebuilt library (printed with the + "LEA_LIB" tag). -menu "BLE Audio Debug Log Level" + Note: this option does NOT affect logs from the BLE Audio IDF + source files (esp_ble_audio component, "LEA_*" tags) - those + are controlled by BT_ISO_NO_LOG / BT_ISO_LOG_LEVEL under the + "BLE ISO Options" menu. + +menu "BLE Audio Lib Debug Log Level" depends on !BT_AUDIO_NO_LOG choice BT_AUDIO_LOG_LEVEL - prompt "LE_AUDIO_LOG_LEVEL" + prompt "BLE_AUDIO_LIB_LOG_LEVEL" default BT_AUDIO_LOG_LEVEL_WARNING depends on !BT_AUDIO_NO_LOG help - Define BLE Audio trace level. + Define the trace level of the BLE Audio prebuilt library + (logs printed with the "LEA_LIB" tag). + + Note: logs from the BLE Audio IDF source files + (esp_ble_audio component, "LEA_*" tags) are controlled + separately by BT_ISO_LOG_LEVEL under the "BLE ISO Options" + menu. config BT_AUDIO_LOG_LEVEL_NONE bool "NONE" diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/init.c b/components/bt/esp_ble_audio/host/adapter/nimble/init.c index b7745205828..e9392e2442f 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/init.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/init.c @@ -23,6 +23,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_NINIT, CONFIG_BT_ISO_LOG_LEVEL); + #if CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT #define ASCS_ASE_SNK_CCCD_COUNT CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT #else /* CONFIG_BT_ASCS_MAX_ASE_SNK_COUNT */ diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/ascs.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/ascs.c index d19314b1a7c..0eb873d6747 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/ascs.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/ascs.c @@ -29,6 +29,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_ASCS, CONFIG_BT_ISO_LOG_LEVEL); + static const ble_uuid16_t ascs_uuid_ase_cp = BLE_UUID16_INIT(BT_UUID_ASCS_ASE_CP_VAL); static const ble_uuid16_t ascs_uuid_ase_snk = BLE_UUID16_INIT(BT_UUID_ASCS_ASE_SNK_VAL); static const ble_uuid16_t ascs_uuid_ase_src = BLE_UUID16_INIT(BT_UUID_ASCS_ASE_SRC_VAL); diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/bass.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/bass.c index 096b0800b96..f9fbad6b5f2 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/bass.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/bass.c @@ -29,6 +29,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_BASS, CONFIG_BT_ISO_LOG_LEVEL); + static const ble_uuid16_t bass_uuid_control_point = BLE_UUID16_INIT(BT_UUID_BASS_CONTROL_POINT_VAL); static const ble_uuid16_t bass_uuid_recv_state = BLE_UUID16_INIT(BT_UUID_BASS_RECV_STATE_VAL); diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/cas.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/cas.c index 1b7bd929074..fdc0407c186 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/cas.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/cas.c @@ -21,6 +21,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_CAS, CONFIG_BT_ISO_LOG_LEVEL); + #if CONFIG_BT_CAP_ACCEPTOR_SET_MEMBER extern struct ble_gatt_svc_def *cas_get_included_csis(void *csis_svc_p); diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/csis.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/csis.c index 992e84a0c8f..0504a1fd876 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/csis.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/csis.c @@ -31,6 +31,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_CSIS, CONFIG_BT_ISO_LOG_LEVEL); + #define CSIS_SVC_COUNT CONFIG_BT_CSIP_SET_MEMBER_MAX_INSTANCE_COUNT #define CSIS_CHR_COUNT (4 + 1) diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/has.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/has.c index 599e06e95f0..2b80ceafc05 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/has.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/has.c @@ -29,6 +29,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_HAS, CONFIG_BT_ISO_LOG_LEVEL); + static const ble_uuid16_t has_uuid_features = BLE_UUID16_INIT(BT_UUID_HAS_HEARING_AID_FEATURES_VAL); static const ble_uuid16_t has_uuid_control_point = BLE_UUID16_INIT(BT_UUID_HAS_PRESET_CONTROL_POINT_VAL); static const ble_uuid16_t has_uuid_preset_index = BLE_UUID16_INIT(BT_UUID_HAS_ACTIVE_PRESET_INDEX_VAL); diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mcs.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mcs.c index 2353808a177..811b01d8b08 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mcs.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mcs.c @@ -34,6 +34,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_MCS, CONFIG_BT_ISO_LOG_LEVEL); + #if CONFIG_BT_OTS #define INC_OTS_CHR_COUNT 8 /* - OTS Feature (M) * - Object Name (M) diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mics.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mics.c index d20fe88f482..69aa2b5fdc2 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mics.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/mics.c @@ -29,6 +29,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_MICS, CONFIG_BT_ISO_LOG_LEVEL); + #define INC_AICS_CHR_COUNT (6 + 1) #define INC_AICS_CHR_FLAGS_STATE \ diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/pacs.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/pacs.c index a32ea80c54d..d6afe254d86 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/pacs.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/pacs.c @@ -27,6 +27,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_PACS, CONFIG_BT_ISO_LOG_LEVEL); + #if CONFIG_BT_PAC_SNK static uint16_t pacs_snk_handle; #if CONFIG_BT_PAC_SNK_LOC diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/server.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/server.c index 6dfe2b090fa..872908cfe8d 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/server.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/server.c @@ -25,6 +25,8 @@ #include "common/host.h" +LOG_MODULE_REGISTER(LEA_GSRV, CONFIG_BT_ISO_LOG_LEVEL); + static ssize_t gatts_read_cb(void *arg, uint16_t offset, const void *data, uint16_t len) { struct os_mbuf *om; diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tbs.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tbs.c index ee1391c3400..aa376634c8c 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tbs.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tbs.c @@ -27,6 +27,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_TBS, CONFIG_BT_ISO_LOG_LEVEL); + static const struct ble_gatt_svc_def gatt_svc_gtbs[] = { { /* Generic Telephone Bearer Service */ diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tmas.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tmas.c index 1f9a511da1e..3b74e210e4f 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tmas.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/tmas.c @@ -27,6 +27,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_TMAS, CONFIG_BT_ISO_LOG_LEVEL); + static const struct ble_gatt_svc_def gatt_svc_tmas[] = { { /* Telephony and Media Audio Service */ diff --git a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/vcs.c b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/vcs.c index 7691e3671d8..467958d18a0 100644 --- a/components/bt/esp_ble_audio/host/adapter/nimble/profiles/vcs.c +++ b/components/bt/esp_ble_audio/host/adapter/nimble/profiles/vcs.c @@ -29,6 +29,8 @@ #include "../../../lib/include/audio.h" +LOG_MODULE_REGISTER(LEA_VCS, CONFIG_BT_ISO_LOG_LEVEL); + #define VOCS_INST_COUNT CONFIG_BT_VCP_VOL_REND_VOCS_INSTANCE_COUNT #define INC_VOCS_CHR_COUNT (4 + 1) diff --git a/components/bt/esp_ble_audio/host/common/include/common/init.h b/components/bt/esp_ble_audio/host/common/include/common/init.h index 6f4418e6458..9deca7f7127 100644 --- a/components/bt/esp_ble_audio/host/common/include/common/init.h +++ b/components/bt/esp_ble_audio/host/common/include/common/init.h @@ -7,6 +7,7 @@ #ifndef HOST_COMMON_INIT_H_ #define HOST_COMMON_INIT_H_ +#include #include #include "sdkconfig.h" @@ -57,6 +58,11 @@ int bt_le_micp_mic_dev_init(void); int bt_le_audio_start(void *info); +void ble_audio_lib_compressed_out(uint8_t log_level, uint32_t log_index, size_t arg_cnt, ...); + +void ble_audio_lib_compressed_buf_out(uint8_t log_level, uint32_t log_index, uint8_t buf_idx, + const uint8_t *buf, size_t len); + #ifdef __cplusplus } #endif diff --git a/components/bt/esp_ble_audio/host/common/init.c b/components/bt/esp_ble_audio/host/common/init.c index e4ee6f4b1eb..a1de419d75c 100644 --- a/components/bt/esp_ble_audio/host/common/init.c +++ b/components/bt/esp_ble_audio/host/common/init.c @@ -4,8 +4,10 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include +#include #include #include "sdkconfig.h" @@ -48,6 +50,12 @@ #include "esp_ble_audio_common_api.h" +#if CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE +#include "log_compression/utils.h" +#endif + +LOG_MODULE_REGISTER(LEA_INIT, CONFIG_BT_ISO_LOG_LEVEL); + _Static_assert(sizeof(struct bt_le_audio_start_info) == sizeof(esp_ble_audio_start_info_t), "Mismatch LE Audio start info structure"); @@ -1109,11 +1117,11 @@ struct lib_ext_funcs { void (*_ots_metadata_display)(void *metadata, uint16_t count); }; -#define LEA_TAG "LIB" +#define LEA_TAG "LEA_LIB" static void log_debug(const char *format, ...) { -#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_DEBUG) +#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) va_list args; va_start(args, format); @@ -1124,12 +1132,12 @@ static void log_debug(const char *format, ...) esp_log_write(ESP_LOG_INFO, LEA_TAG, BT_ISO_LOG_RESET_COLOR "\n"); va_end(args); -#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_DEBUG) */ +#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) */ } static void log_info(const char *format, ...) { -#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_INFO) +#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_INFO) va_list args; va_start(args, format); @@ -1139,12 +1147,12 @@ static void log_info(const char *format, ...) esp_log_write(ESP_LOG_INFO, LEA_TAG, BT_ISO_LOG_RESET_COLOR "\n"); va_end(args); -#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_INFO) */ +#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_INFO) */ } static void log_warn(const char *format, ...) { -#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_WARN) +#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_WARN) va_list args; va_start(args, format); @@ -1154,12 +1162,12 @@ static void log_warn(const char *format, ...) esp_log_write(ESP_LOG_WARN, LEA_TAG, BT_ISO_LOG_RESET_COLOR "\n"); va_end(args); -#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_WARN) */ +#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_WARN) */ } static void log_error(const char *format, ...) { -#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_ERROR) +#if (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_ERROR) va_list args; va_start(args, format); @@ -1169,7 +1177,7 @@ static void log_error(const char *format, ...) esp_log_write(ESP_LOG_ERROR, LEA_TAG, BT_ISO_LOG_RESET_COLOR "\n"); va_end(args); -#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_AUDIO_LOG_ERROR) */ +#endif /* (CONFIG_BT_AUDIO_LOG_LEVEL >= BT_ISO_LOG_ERROR) */ } static const struct lib_ext_funcs ext_funcs = { @@ -2140,3 +2148,42 @@ int bt_le_audio_start(void *info) return bt_le_nimble_audio_start(info); } + +void ble_audio_lib_compressed_out(uint8_t log_level, uint32_t log_index, size_t arg_cnt, ...) +{ +#if CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE + if (CONFIG_BT_ISO_LOG_LEVEL >= log_level) { + va_list args; + va_start(args, arg_cnt); + extern int ble_log_compressed_hex_printv(uint8_t source, uint32_t log_index, + size_t args_cnt, va_list args); + ble_log_compressed_hex_printv(BLE_COMPRESSED_LOG_OUT_SOURCE_AUDIO_LIB, + log_index, arg_cnt, args); + va_end(args); + } +#else + (void)log_level; + (void)log_index; + (void)arg_cnt; +#endif +} + +void ble_audio_lib_compressed_buf_out(uint8_t log_level, uint32_t log_index, uint8_t buf_idx, + const uint8_t *buf, size_t len) +{ +#if CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE + if (CONFIG_BT_ISO_LOG_LEVEL >= log_level) { + extern int ble_log_compressed_hex_print_buf(uint8_t source, uint32_t log_index, + uint8_t buf_idx, const uint8_t *buf, + size_t len); + ble_log_compressed_hex_print_buf(BLE_COMPRESSED_LOG_OUT_SOURCE_AUDIO_LIB, + log_index, buf_idx, buf, len); + } +#else + (void)log_level; + (void)log_index; + (void)buf_idx; + (void)buf; + (void)len; +#endif +} diff --git a/components/bt/esp_ble_audio/host/services/ots/ots.c b/components/bt/esp_ble_audio/host/services/ots/ots.c index 15167a72e5b..292bc9e6be8 100644 --- a/components/bt/esp_ble_audio/host/services/ots/ots.c +++ b/components/bt/esp_ble_audio/host/services/ots/ots.c @@ -26,7 +26,7 @@ #include -LOG_MODULE_REGISTER(bt_ots, CONFIG_BT_OTS_LOG_LEVEL); +LOG_MODULE_REGISTER(LEA_OTS, CONFIG_BT_ISO_LOG_LEVEL); #if defined(CONFIG_BT_OTS_OACP_CREATE_SUPPORT) #define OACP_FEAT_BIT_CREATE BIT(BT_OTS_OACP_FEAT_CREATE) diff --git a/components/bt/esp_ble_audio/host/services/ots/ots_client.c b/components/bt/esp_ble_audio/host/services/ots/ots_client.c index fb7c041021e..c563561ba2a 100644 --- a/components/bt/esp_ble_audio/host/services/ots/ots_client.c +++ b/components/bt/esp_ble_audio/host/services/ots/ots_client.c @@ -26,9 +26,9 @@ #include "ots_oacp_internal.h" #include "ots_olcp_internal.h" -#define LOG_LEVEL CONFIG_BT_OTS_CLIENT_LOG_LEVEL #include -LOG_MODULE_REGISTER(bt_otc); + +LOG_MODULE_REGISTER(LEA_OTC, CONFIG_BT_ISO_LOG_LEVEL); /* TODO: KConfig options */ #define OTS_CLIENT_INST_COUNT 1 @@ -1653,12 +1653,14 @@ static int decode_record(struct net_buf_simple *buf, rec->metadata.id = net_buf_simple_pull_le48(buf); - if (IS_ENABLED(CONFIG_BT_OTS_CLIENT_LOG_LEVEL_DBG)) { +#if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) + { char t[BT_OTS_OBJ_ID_STR_LEN]; (void)bt_ots_obj_id_to_str(rec->metadata.id, t, sizeof(t)); LOG_DBG("Object ID 0x%s", t); } +#endif if ((start_len - buf->len) + sizeof(uint8_t) > rec->len) { LOG_WRN("incorrect DirListing record, reclen %u too short, " diff --git a/components/bt/esp_ble_audio/host/services/ots/ots_dir_list.c b/components/bt/esp_ble_audio/host/services/ots/ots_dir_list.c index 1b7c885cb46..c6fd36f93cf 100644 --- a/components/bt/esp_ble_audio/host/services/ots/ots_dir_list.c +++ b/components/bt/esp_ble_audio/host/services/ots/ots_dir_list.c @@ -18,7 +18,7 @@ #include -LOG_MODULE_DECLARE(bt_ots, CONFIG_BT_OTS_LOG_LEVEL); +LOG_MODULE_REGISTER(LEA_OTS, CONFIG_BT_ISO_LOG_LEVEL); static struct bt_ots_dir_list dir_lists[CONFIG_BT_OTS_MAX_INST_CNT]; diff --git a/components/bt/esp_ble_audio/host/services/ots/ots_l2cap.c b/components/bt/esp_ble_audio/host/services/ots/ots_l2cap.c index 3dfa740c16a..62552aae056 100644 --- a/components/bt/esp_ble_audio/host/services/ots/ots_l2cap.c +++ b/components/bt/esp_ble_audio/host/services/ots/ots_l2cap.c @@ -17,14 +17,7 @@ #include -/* This l2cap is the only OTS-file in use for OTC. - * If only OTC is used, the OTS log module must be registered here. - */ -#if defined(CONFIG_BT_OTS) -LOG_MODULE_DECLARE(bt_ots, CONFIG_BT_OTS_LOG_LEVEL); -#elif defined(CONFIG_BT_OTS_CLIENT) -LOG_MODULE_REGISTER(bt_ots, CONFIG_BT_OTS_CLIENT_LOG_LEVEL); -#endif +LOG_MODULE_REGISTER(LEA_OTS, CONFIG_BT_ISO_LOG_LEVEL); /* According to Bluetooth specification Assigned Numbers that are used in the * Logical Link Control for protocol/service multiplexers. diff --git a/components/bt/esp_ble_audio/host/services/ots/ots_oacp.c b/components/bt/esp_ble_audio/host/services/ots/ots_oacp.c index d135c1cb5dc..162787a719d 100644 --- a/components/bt/esp_ble_audio/host/services/ots/ots_oacp.c +++ b/components/bt/esp_ble_audio/host/services/ots/ots_oacp.c @@ -21,7 +21,7 @@ #include -LOG_MODULE_DECLARE(bt_ots, CONFIG_BT_OTS_LOG_LEVEL); +LOG_MODULE_REGISTER(LEA_OTS, CONFIG_BT_ISO_LOG_LEVEL); #define OACP_PROC_TYPE_SIZE 1 diff --git a/components/bt/esp_ble_audio/host/services/ots/ots_obj_manager.c b/components/bt/esp_ble_audio/host/services/ots/ots_obj_manager.c index 833336d4284..4ebc3c5148e 100644 --- a/components/bt/esp_ble_audio/host/services/ots/ots_obj_manager.c +++ b/components/bt/esp_ble_audio/host/services/ots/ots_obj_manager.c @@ -16,8 +16,6 @@ #include -LOG_MODULE_DECLARE(bt_ots, CONFIG_BT_OTS_LOG_LEVEL); - struct bt_gatt_ots_pool_item { sys_dnode_t dnode; struct bt_gatt_ots_object val; diff --git a/components/bt/esp_ble_audio/host/services/ots/ots_olcp.c b/components/bt/esp_ble_audio/host/services/ots/ots_olcp.c index 95e3477ae00..f6e84d12732 100644 --- a/components/bt/esp_ble_audio/host/services/ots/ots_olcp.c +++ b/components/bt/esp_ble_audio/host/services/ots/ots_olcp.c @@ -19,7 +19,7 @@ #include -LOG_MODULE_DECLARE(bt_ots, CONFIG_BT_OTS_LOG_LEVEL); +LOG_MODULE_REGISTER(LEA_OTS, CONFIG_BT_ISO_LOG_LEVEL); #define OLCP_PROC_TYPE_SIZE 1 diff --git a/components/bt/esp_ble_iso/Kconfig.in b/components/bt/esp_ble_iso/Kconfig.in index 099231c7a9e..6461c3e224a 100644 --- a/components/bt/esp_ble_iso/Kconfig.in +++ b/components/bt/esp_ble_iso/Kconfig.in @@ -98,21 +98,35 @@ if BT_ISO endif # BT_ISO_BROADCAST config BT_ISO_NO_LOG - bool "Disable ISO Debug Log" + bool "Disable BLE ISO Debug Log" default n help - Select this to save the ISO related rodata code size. Enabling - this option will disable the output of ISO debug log. + Select this to save rodata code size by disabling the debug + log emitted by the BLE ISO IDF source files (printed with + "ISO_*" tags). - menu "ISO Debug Log Level" + Note: this option also gates logs from the BLE Audio IDF + source files (esp_ble_audio component, with "LEA_*" tags) + because they share the same log header. Logs from the BLE + Audio prebuilt library are gated separately by + BT_AUDIO_NO_LOG. + + menu "BLE ISO Debug Log Level" depends on !BT_ISO_NO_LOG choice BT_ISO_LOG_LEVEL - prompt "ISO_LOG_LEVEL" + prompt "BLE_ISO_LOG_LEVEL" default BT_ISO_LOG_LEVEL_WARNING depends on !BT_ISO_NO_LOG help - Define ISO trace level. + Define the trace level of the BLE ISO IDF source files + (logs printed with "ISO_*" tags). + + Note: this level also applies to the BLE Audio IDF + source files (esp_ble_audio component, "LEA_*" tags) + because they share the same log header. The trace + level of the BLE Audio prebuilt library is configured + separately by BT_AUDIO_LOG_LEVEL. config BT_ISO_LOG_LEVEL_NONE bool "NONE" diff --git a/components/bt/esp_ble_iso/host/adapter/nimble/gap.c b/components/bt/esp_ble_iso/host/adapter/nimble/gap.c index 867cd3238d5..9e435760fe3 100644 --- a/components/bt/esp_ble_iso/host/adapter/nimble/gap.c +++ b/components/bt/esp_ble_iso/host/adapter/nimble/gap.c @@ -25,6 +25,8 @@ #include "nimble/hs_error.h" +LOG_MODULE_REGISTER(ISO_NGAP, CONFIG_BT_ISO_LOG_LEVEL); + /* Map a NimBLE connection's security state to Zephyr bt_security_t. * * To reach L3/L4 the app must configure NimBLE for authenticated pairing: diff --git a/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.c b/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.c index f29bb32ed50..8fe8311ef1f 100644 --- a/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.c +++ b/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.c @@ -27,6 +27,8 @@ #include "nimble/hs_error.h" #include "common/app/gatt.h" +LOG_MODULE_REGISTER(ISO_NGAT, CONFIG_BT_ISO_LOG_LEVEL); + void bt_le_nimble_gatt_post_event(void *param) { struct bt_le_gatt_event_param *qev; diff --git a/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.db.c b/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.db.c index b49ebf64a4a..ab00577286a 100644 --- a/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.db.c +++ b/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.db.c @@ -24,6 +24,8 @@ #include "common/host.h" +LOG_MODULE_REGISTER(ISO_NGDB, CONFIG_BT_ISO_LOG_LEVEL); + static int gattc_db_find_inc_svcs_cb_safe(uint16_t conn_handle, const struct ble_gatt_error *error, const struct ble_gatt_svc *svc, diff --git a/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.nrp.c b/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.nrp.c index 470c2f8ba09..c58ace5253a 100644 --- a/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.nrp.c +++ b/components/bt/esp_ble_iso/host/adapter/nimble/gatt/gatt.nrp.c @@ -26,6 +26,8 @@ #include "nimble/hs_error.h" +LOG_MODULE_REGISTER(ISO_NGRP, CONFIG_BT_ISO_LOG_LEVEL); + struct gatt_nrp_node { uint8_t type; diff --git a/components/bt/esp_ble_iso/host/adapter/nimble/iso.c b/components/bt/esp_ble_iso/host/adapter/nimble/iso.c index 6538a0d1ec6..774466622e7 100644 --- a/components/bt/esp_ble_iso/host/adapter/nimble/iso.c +++ b/components/bt/esp_ble_iso/host/adapter/nimble/iso.c @@ -21,6 +21,8 @@ #include "nimble/hs_error.h" +LOG_MODULE_REGISTER(ISO_NISO, CONFIG_BT_ISO_LOG_LEVEL); + extern int ble_hs_iso_evt_rx_cb_set(void *cb); #if CONFIG_BT_ISO_RX extern int ble_hs_iso_pkt_rx_cb_set(ble_hs_iso_pkt_rx_fn cb); diff --git a/components/bt/esp_ble_iso/host/adapter/nimble/l2cap.c b/components/bt/esp_ble_iso/host/adapter/nimble/l2cap.c index c4d48396e48..4b9ce128f1d 100644 --- a/components/bt/esp_ble_iso/host/adapter/nimble/l2cap.c +++ b/components/bt/esp_ble_iso/host/adapter/nimble/l2cap.c @@ -25,6 +25,8 @@ #include "nimble/hs_error.h" +LOG_MODULE_REGISTER(ISO_N2CAP, CONFIG_BT_ISO_LOG_LEVEL); + _Static_assert(CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM && "At least one L2CAP coc shall be supported"); #define OTS_L2CAP_BUF_COUNT (3 * CONFIG_BT_NIMBLE_L2CAP_COC_MAX_NUM) diff --git a/components/bt/esp_ble_iso/host/common/adv.c b/components/bt/esp_ble_iso/host/common/adv.c index 8962c847008..666b0e8de9b 100644 --- a/components/bt/esp_ble_iso/host/common/adv.c +++ b/components/bt/esp_ble_iso/host/common/adv.c @@ -18,6 +18,8 @@ #include "common/host.h" +LOG_MODULE_REGISTER(ISO_ADV, CONFIG_BT_ISO_LOG_LEVEL); + static struct bt_le_ext_adv ext_adv_pool[CONFIG_BT_EXT_ADV_MAX_ADV_SET]; static struct bt_le_ext_adv *ext_adv_find(uint8_t adv_handle) diff --git a/components/bt/esp_ble_iso/host/common/app/gap.c b/components/bt/esp_ble_iso/host/common/app/gap.c index 24a312910b1..df3b0a373a9 100644 --- a/components/bt/esp_ble_iso/host/common/app/gap.c +++ b/components/bt/esp_ble_iso/host/common/app/gap.c @@ -18,6 +18,8 @@ #include "common/host.h" #include "common/app/gap.h" +LOG_MODULE_REGISTER(ISO_AGAP, CONFIG_BT_ISO_LOG_LEVEL); + static bt_le_gap_app_cb gap_app_cb; int bt_le_gap_app_cb_register(bt_le_gap_app_cb cb) diff --git a/components/bt/esp_ble_iso/host/common/app/gatt.c b/components/bt/esp_ble_iso/host/common/app/gatt.c index 6c1d75c57c2..d90b9a75446 100644 --- a/components/bt/esp_ble_iso/host/common/app/gatt.c +++ b/components/bt/esp_ble_iso/host/common/app/gatt.c @@ -18,6 +18,8 @@ #include "common/host.h" #include "common/app/gatt.h" +LOG_MODULE_REGISTER(ISO_AGAT, CONFIG_BT_ISO_LOG_LEVEL); + static bt_le_gatt_app_cb gatt_app_cb; int bt_le_gatt_app_cb_register(bt_le_gatt_app_cb cb) diff --git a/components/bt/esp_ble_iso/host/common/conn.c b/components/bt/esp_ble_iso/host/common/conn.c index e1d6a64ae2f..191ebbc4fbc 100644 --- a/components/bt/esp_ble_iso/host/common/conn.c +++ b/components/bt/esp_ble_iso/host/common/conn.c @@ -21,6 +21,8 @@ #include "common/host.h" #include "common/app/gap.h" +LOG_MODULE_REGISTER(ISO_CONN, CONFIG_BT_ISO_LOG_LEVEL); + static struct bt_conn acl_conns[CONFIG_BT_MAX_CONN]; extern struct bt_conn iso_conns[CONFIG_BT_ISO_MAX_CHAN]; diff --git a/components/bt/esp_ble_iso/host/common/gatt.c b/components/bt/esp_ble_iso/host/common/gatt.c index 4dc2e9ac344..a45bb6548a6 100644 --- a/components/bt/esp_ble_iso/host/common/gatt.c +++ b/components/bt/esp_ble_iso/host/common/gatt.c @@ -22,6 +22,8 @@ #include "common/host.h" +LOG_MODULE_REGISTER(ISO_GATT, CONFIG_BT_ISO_LOG_LEVEL); + static sys_slist_t gatt_db = SYS_SLIST_STATIC_INIT(&gatt_db); static struct gattc_sub subscriptions[CONFIG_BT_MAX_CONN]; diff --git a/components/bt/esp_ble_iso/host/common/hci.c b/components/bt/esp_ble_iso/host/common/hci.c index 4e808abf2d2..b2d1bd1bb68 100644 --- a/components/bt/esp_ble_iso/host/common/hci.c +++ b/components/bt/esp_ble_iso/host/common/hci.c @@ -21,6 +21,8 @@ #include "common/host.h" +LOG_MODULE_REGISTER(ISO_HCI, CONFIG_BT_ISO_LOG_LEVEL); + struct cmd_data { /** HCI status of the command completion */ uint8_t status; diff --git a/components/bt/esp_ble_iso/host/common/host.c b/components/bt/esp_ble_iso/host/common/host.c index deb07b61197..42e5b44971b 100644 --- a/components/bt/esp_ble_iso/host/common/host.c +++ b/components/bt/esp_ble_iso/host/common/host.c @@ -15,6 +15,8 @@ #include "common/app/gap.h" #include "common/app/gatt.h" +LOG_MODULE_REGISTER(ISO_HOST, CONFIG_BT_ISO_LOG_LEVEL); + static struct k_mutex host_mutex; #define TIMEOUT_MS (5000 / portTICK_PERIOD_MS) /* 5s */ diff --git a/components/bt/esp_ble_iso/host/common/iso.c b/components/bt/esp_ble_iso/host/common/iso.c index 7b54364aa84..108cfffe303 100644 --- a/components/bt/esp_ble_iso/host/common/iso.c +++ b/components/bt/esp_ble_iso/host/common/iso.c @@ -23,6 +23,8 @@ #include "common/task.h" #include "common/app/gap.h" +LOG_MODULE_REGISTER(ISO_SHIM, CONFIG_BT_ISO_LOG_LEVEL); + #ifdef CONFIG_BT_NIMBLE_ISO_STD_FLOW_CTRL #define ISO_STD_FLOW_CTRL true #else /* CONFIG_BT_NIMBLE_ISO_STD_FLOW_CTRL */ diff --git a/components/bt/esp_ble_iso/host/common/l2cap.c b/components/bt/esp_ble_iso/host/common/l2cap.c index e4416f03109..580f46cb4d8 100644 --- a/components/bt/esp_ble_iso/host/common/l2cap.c +++ b/components/bt/esp_ble_iso/host/common/l2cap.c @@ -20,6 +20,8 @@ #include "common/host.h" #include "common/app/gap.h" +LOG_MODULE_REGISTER(ISO_L2CAP, CONFIG_BT_ISO_LOG_LEVEL); + #define L2CAP_LE_MIN_MTU 23 #define L2CAP_ECRED_MIN_MTU 64 diff --git a/components/bt/esp_ble_iso/host/common/scan.c b/components/bt/esp_ble_iso/host/common/scan.c index 0a6a23a9c5a..6479cd0fb5c 100644 --- a/components/bt/esp_ble_iso/host/common/scan.c +++ b/components/bt/esp_ble_iso/host/common/scan.c @@ -20,6 +20,8 @@ #include "common/host.h" +LOG_MODULE_REGISTER(ISO_SCAN, CONFIG_BT_ISO_LOG_LEVEL); + static sys_slist_t scan_cbs = SYS_SLIST_STATIC_INIT(&scan_cbs); _LIB_ONLY diff --git a/components/bt/esp_ble_iso/host/common/task.c b/components/bt/esp_ble_iso/host/common/task.c index bc21e380448..62a24d068d9 100644 --- a/components/bt/esp_ble_iso/host/common/task.c +++ b/components/bt/esp_ble_iso/host/common/task.c @@ -21,6 +21,8 @@ #include "common/app/gap.h" #include "common/app/gatt.h" +LOG_MODULE_REGISTER(ISO_TASK, CONFIG_BT_ISO_LOG_LEVEL); + static QueueHandle_t iso_queue_handle; static TaskHandle_t iso_task_handle; diff --git a/components/bt/esp_ble_iso/host/iso/iso.c b/components/bt/esp_ble_iso/host/iso/iso.c index 4aaad599cfc..92a6c3d71bb 100644 --- a/components/bt/esp_ble_iso/host/iso/iso.c +++ b/components/bt/esp_ble_iso/host/iso/iso.c @@ -44,7 +44,7 @@ #warning "FreeRTOS with 1ms tick rate is strongly recommended for running ISO." #endif /* CONFIG_FREERTOS_HZ < 1000 */ -LOG_MODULE_REGISTER(bt_iso, CONFIG_BT_ISO_LOG_LEVEL); +LOG_MODULE_REGISTER(ISO_CORE, CONFIG_BT_ISO_LOG_LEVEL); #if defined(CONFIG_BT_DEBUG_ISO_DATA) #define BT_ISO_DATA_DBG(fmt, ...) LOG_DBG(fmt, ##__VA_ARGS__) diff --git a/components/bt/esp_ble_iso/host/utils/crypto.c b/components/bt/esp_ble_iso/host/utils/crypto.c index cdfcbaf93bd..59568261bd0 100644 --- a/components/bt/esp_ble_iso/host/utils/crypto.c +++ b/components/bt/esp_ble_iso/host/utils/crypto.c @@ -32,6 +32,8 @@ #include "esp_random.h" +LOG_MODULE_REGISTER(ISO_CRYPTO, CONFIG_BT_ISO_LOG_LEVEL); + int bt_rand(void *buf, size_t len) { if (buf == NULL || len == 0) { diff --git a/components/bt/esp_ble_iso/host/utils/timer.c b/components/bt/esp_ble_iso/host/utils/timer.c index f082b978fa7..30a8f8307e9 100644 --- a/components/bt/esp_ble_iso/host/utils/timer.c +++ b/components/bt/esp_ble_iso/host/utils/timer.c @@ -21,6 +21,8 @@ #include "common/host.h" +LOG_MODULE_REGISTER(ISO_TIMER, CONFIG_BT_ISO_LOG_LEVEL); + static void iso_timer_cb(void *arg) { struct k_work *work = arg; diff --git a/components/bt/esp_ble_iso/include/zephyr/kernel.h b/components/bt/esp_ble_iso/include/zephyr/kernel.h index 0f863a97d30..b4b2e74a672 100644 --- a/components/bt/esp_ble_iso/include/zephyr/kernel.h +++ b/components/bt/esp_ble_iso/include/zephyr/kernel.h @@ -51,13 +51,24 @@ static inline void k_mutex_delete(struct k_mutex *mutex) mutex->handle = NULL; } +/* Inline log helper with a fixed tag. These functions are inlined into many + * translation units (including api/ wrappers), and not all of them call + * LOG_MODULE_REGISTER, so we cannot reference the per-TU __iso_log_tag + * here. Use a hardcoded "ISO_MUTEX" tag instead, keeping the same level + * gating. */ +#if CONFIG_BT_ISO_NO_LOG || (CONFIG_BT_ISO_LOG_LEVEL < BT_ISO_LOG_ERROR) +#define K_MUTEX_LOG_ERR(fmt, args...) +#else +#define K_MUTEX_LOG_ERR(fmt, args...) BT_ISO_LOGE("ISO_MUTEX", fmt, ## args) +#endif + static inline int k_mutex_lock(struct k_mutex *mutex, uint32_t timeout) { assert(mutex); assert(mutex->handle); if (xSemaphoreTakeRecursive(mutex->handle, timeout) != pdTRUE) { - LOG_ERR("KMutexLockFail"); + K_MUTEX_LOG_ERR("LockFail"); return -EIO; } @@ -70,7 +81,7 @@ static inline int k_mutex_unlock(struct k_mutex *mutex) assert(mutex->handle); if (xSemaphoreGiveRecursive(mutex->handle) != pdTRUE) { - LOG_ERR("KMutexUnlockFail"); + K_MUTEX_LOG_ERR("UnlockFail"); return -EIO; } diff --git a/components/bt/esp_ble_iso/include/zephyr/logging/log.h b/components/bt/esp_ble_iso/include/zephyr/logging/log.h index de95ea05bd9..d061b50e331 100644 --- a/components/bt/esp_ble_iso/include/zephyr/logging/log.h +++ b/components/bt/esp_ble_iso/include/zephyr/logging/log.h @@ -1,5 +1,6 @@ /* * SPDX-FileCopyrightText: 2018 Nordic Semiconductor ASA + * SPDX-FileContributor: 2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,15 +15,28 @@ #include "esp_log.h" +/* esp_ble_iso, esp_ble_audio and any future ISO consumer are compiled + * under the unified BLE_ISO compression channel and share one + * iso_log_index.h with one monotonic log-id counter — no per-consumer + * index header, no per-TU sentinel needed. */ +#if CONFIG_BLE_ISO_COMPRESSED_LOG_ENABLE +#include "iso_log_index.h" +#endif + #ifdef __cplusplus extern "C" { #endif -extern int ets_printf(const char *fmt, ...); +/* Define a per-translation-unit log tag. + * The first argument is the module name (an identifier); it is stringified to + * produce the tag passed to esp_log_write(). LOG_MODULE_DECLARE has the same + * effect and is provided for Zephyr API parity (in our port the two expand to + * identical code). */ +#define LOG_MODULE_REGISTER(name, ...) \ + static const char *const __iso_log_tag __attribute__((unused)) = #name -#define LOG_MODULE_REGISTER(...) - -#define LOG_MODULE_DECLARE(...) +#define LOG_MODULE_DECLARE(name, ...) \ + static const char *const __iso_log_tag __attribute__((unused)) = #name #define BT_ISO_LOG_COLOR_BLACK "30" #define BT_ISO_LOG_COLOR_RED "31" @@ -47,14 +61,6 @@ extern int ets_printf(const char *fmt, ...); #define BT_ISO_LOG_DEBUG 4 #define BT_ISO_LOG_VERBOSE 5 -#define BT_AUDIO_LOG_ERROR BT_ISO_LOG_ERROR -#define BT_AUDIO_LOG_WARN BT_ISO_LOG_WARN -#define BT_AUDIO_LOG_INFO BT_ISO_LOG_INFO -#define BT_AUDIO_LOG_DEBUG BT_ISO_LOG_DEBUG -#define BT_AUDIO_LOG_VERBOSE BT_ISO_LOG_VERBOSE - -#define BT_ISO_LOG_TAG "ISO" - #define BT_ISO_LOGE(tag, format, ...) \ esp_log_write(ESP_LOG_ERROR, tag, LOG_FORMAT(E, format), \ esp_log_timestamp(), tag, ##__VA_ARGS__); @@ -78,25 +84,25 @@ extern int ets_printf(const char *fmt, ...); #define LOG_DBG(fmt, args...) #else /* CONFIG_BT_ISO_NO_LOG */ #if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_ERROR) -#define LOG_ERR(fmt, args...) BT_ISO_LOGE(BT_ISO_LOG_TAG, fmt, ## args) +#define LOG_ERR(fmt, args...) BT_ISO_LOGE(__iso_log_tag, fmt, ## args) #else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_ERROR) */ #define LOG_ERR(fmt, args...) #endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_ERROR) */ #if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_WARN) -#define LOG_WRN(fmt, args...) BT_ISO_LOGW(BT_ISO_LOG_TAG, fmt, ## args) +#define LOG_WRN(fmt, args...) BT_ISO_LOGW(__iso_log_tag, fmt, ## args) #else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_WARN) */ #define LOG_WRN(fmt, args...) #endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_WARN) */ #if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_INFO) -#define LOG_INF(fmt, args...) BT_ISO_LOGI(BT_ISO_LOG_TAG, fmt, ## args) +#define LOG_INF(fmt, args...) BT_ISO_LOGI(__iso_log_tag, fmt, ## args) #else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_INFO) */ #define LOG_INF(fmt, args...) #endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_INFO) */ #if (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) -#define LOG_DBG(fmt, args...) BT_ISO_LOGD(BT_ISO_LOG_TAG, fmt, ## args) +#define LOG_DBG(fmt, args...) BT_ISO_LOGD(__iso_log_tag, fmt, ## args) #else /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) */ #define LOG_DBG(fmt, args...) #endif /* (CONFIG_BT_ISO_LOG_LEVEL >= BT_ISO_LOG_DEBUG) */ diff --git a/examples/bluetooth/esp_ble_audio/common_components/example_init/ble_audio_example_init.c b/examples/bluetooth/esp_ble_audio/common_components/example_init/ble_audio_example_init.c index ff3a3a402a0..876ca84fa1a 100644 --- a/examples/bluetooth/esp_ble_audio/common_components/example_init/ble_audio_example_init.c +++ b/examples/bluetooth/esp_ble_audio/common_components/example_init/ble_audio_example_init.c @@ -10,6 +10,10 @@ #include "esp_log.h" #include "sdkconfig.h" +#if CONFIG_BLE_LOG_ENABLED +#include "ble_log.h" +#endif + #include "nimble/nimble_port.h" #include "nimble/nimble_port_freertos.h" @@ -221,18 +225,33 @@ esp_err_t bluetooth_init(void) { esp_err_t ret; + /* When controller log is disabled (or running in v1 mode), the + * automatic ble_log_init() inside esp_bt_controller_init() is skipped. + * Init manually here so HOST/ISO/AUDIO compressed logs aren't dropped + * during NimBLE bring-up. The function is idempotent. + * + * TODO: Remove this block (and the ble_log_flush() below) once + * ble_log_init() is decoupled from the controller log path and + * owns its own initialization independently. */ +#if CONFIG_BLE_LOG_ENABLED && \ + !(CONFIG_BT_LE_CONTROLLER_LOG_ENABLED && CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2) + if (!ble_log_init()) { + ESP_LOGE(TAG, "Failed to init ble_log"); + return ESP_FAIL; + } +#endif + example_audio_sem = xSemaphoreCreateBinary(); if (example_audio_sem == NULL) { ESP_LOGE(TAG, "Failed to create audio semaphore"); - return ESP_FAIL; + ret = ESP_FAIL; + goto err_log; } ret = nimble_port_init(); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to init nimble %d ", ret); - vSemaphoreDelete(example_audio_sem); - example_audio_sem = NULL; - return ret; + goto err_sem; } /* Initialize the NimBLE host configuration */ @@ -254,5 +273,27 @@ esp_err_t bluetooth_init(void) xSemaphoreTake(example_audio_sem, portMAX_DELAY); + /* Drain startup-phase log buffers and emit a FLUSH boundary so the + * parser resets stats here — the example's runtime logs start clean. + * + * TODO: Remove together with the manual ble_log_init() above once + * ble_log_init() is decoupled from the controller log path. */ +#if CONFIG_BLE_LOG_ENABLED + ble_log_flush(); +#endif + return ESP_OK; + +err_sem: + vSemaphoreDelete(example_audio_sem); + example_audio_sem = NULL; +err_log: + /* Mirror the manual ble_log_init() block above — same Kconfig gate so + * we only deinit what we initialized; the controller-owned path is + * left alone. */ +#if CONFIG_BLE_LOG_ENABLED && \ + !(CONFIG_BT_LE_CONTROLLER_LOG_ENABLED && CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2) + ble_log_deinit(); +#endif + return ret; } diff --git a/examples/bluetooth/esp_ble_iso/common_components/example_init/ble_iso_example_init.c b/examples/bluetooth/esp_ble_iso/common_components/example_init/ble_iso_example_init.c index 1e78f18d344..f63b3fc0558 100644 --- a/examples/bluetooth/esp_ble_iso/common_components/example_init/ble_iso_example_init.c +++ b/examples/bluetooth/esp_ble_iso/common_components/example_init/ble_iso_example_init.c @@ -10,6 +10,10 @@ #include "esp_log.h" #include "sdkconfig.h" +#if CONFIG_BLE_LOG_ENABLED +#include "ble_log.h" +#endif + #include "nimble/nimble_port.h" #include "nimble/nimble_port_freertos.h" @@ -56,18 +60,33 @@ esp_err_t bluetooth_init(void) { esp_err_t ret; + /* When controller log is disabled (or running in v1 mode), the + * automatic ble_log_init() inside esp_bt_controller_init() is skipped. + * Init manually here so HOST/ISO/AUDIO compressed logs aren't dropped + * during NimBLE bring-up. The function is idempotent. + * + * TODO: Remove this block (and the ble_log_flush() below) once + * ble_log_init() is decoupled from the controller log path and + * owns its own initialization independently. */ +#if CONFIG_BLE_LOG_ENABLED && \ + !(CONFIG_BT_LE_CONTROLLER_LOG_ENABLED && CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2) + if (!ble_log_init()) { + ESP_LOGE(TAG, "Failed to init ble_log"); + return ESP_FAIL; + } +#endif + example_iso_sem = xSemaphoreCreateBinary(); if (example_iso_sem == NULL) { ESP_LOGE(TAG, "Failed to create iso semaphore"); - return ESP_FAIL; + ret = ESP_FAIL; + goto err_log; } ret = nimble_port_init(); if (ret != ESP_OK) { ESP_LOGE(TAG, "Failed to init nimble %d ", ret); - vSemaphoreDelete(example_iso_sem); - example_iso_sem = NULL; - return ret; + goto err_sem; } /* Initialize the NimBLE host configuration */ @@ -89,5 +108,27 @@ esp_err_t bluetooth_init(void) xSemaphoreTake(example_iso_sem, portMAX_DELAY); + /* Drain startup-phase log buffers and emit a FLUSH boundary so the + * parser resets stats here — the example's runtime logs start clean. + * + * TODO: Remove together with the manual ble_log_init() above once + * ble_log_init() is decoupled from the controller log path. */ +#if CONFIG_BLE_LOG_ENABLED + ble_log_flush(); +#endif + return ESP_OK; + +err_sem: + vSemaphoreDelete(example_iso_sem); + example_iso_sem = NULL; +err_log: + /* Mirror the manual ble_log_init() block above — same Kconfig gate so + * we only deinit what we initialized; the controller-owned path is + * left alone. */ +#if CONFIG_BLE_LOG_ENABLED && \ + !(CONFIG_BT_LE_CONTROLLER_LOG_ENABLED && CONFIG_BT_LE_CONTROLLER_LOG_MODE_BLE_LOG_V2) + ble_log_deinit(); +#endif + return ret; }