diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 854ba158bd..c6b85dcdb3 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -1104,26 +1104,29 @@ if(CONFIG_BT_ENABLED) endif() if(CONFIG_BLE_MESH_V11_SUPPORT) + +set(BLE_MESH_LIB_NAME "libble_mesh.a") + if(CONFIG_IDF_TARGET_ESP32) - add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32/libble_mesh.a") + add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32/${BLE_MESH_LIB_NAME}") target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) elseif(CONFIG_IDF_TARGET_ESP32S3) - add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32s3/libble_mesh.a") + add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32s3/${BLE_MESH_LIB_NAME}") target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) elseif(CONFIG_IDF_TARGET_ESP32C3) - add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c3/libble_mesh.a") + add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c3/${BLE_MESH_LIB_NAME}") target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) elseif(CONFIG_IDF_TARGET_ESP32C6) - add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c6/libble_mesh.a") + add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c6/${BLE_MESH_LIB_NAME}") target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) elseif(CONFIG_IDF_TARGET_ESP32C61) - add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c61/libble_mesh.a") + add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c61/${BLE_MESH_LIB_NAME}") target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) elseif(CONFIG_IDF_TARGET_ESP32H2) - add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32h2/libble_mesh.a") + add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32h2/${BLE_MESH_LIB_NAME}") target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) elseif(CONFIG_IDF_TARGET_ESP32C5) - add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c5/libble_mesh.a") + add_prebuilt_library(ble_mesh "esp_ble_mesh/lib/lib/esp32c5/${BLE_MESH_LIB_NAME}") target_link_libraries(${COMPONENT_LIB} PRIVATE ble_mesh) 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 382c33a2cf..904bd5e284 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 @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2025-2026 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -61,6 +61,7 @@ int ble_compressed_log_cb_get(uint8_t source, ble_cp_log_buffer_mgmt_t **mgmt) { #if CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE case BLE_COMPRESSED_LOG_OUT_SOURCE_MESH: + case BLE_COMPRESSED_LOG_OUT_SOURCE_MESH_LIB: buffer_mgmt = BUF_MGMT_NAME(mesh); last_handle = &mesh_last_task_handle; break; @@ -102,23 +103,10 @@ static inline int ble_compressed_log_buffer_free(ble_cp_log_buffer_mgmt_t *mgmt) return 0; } -int ble_log_compressed_hex_print(uint8_t source, uint32_t log_index, size_t args_cnt, ...) +static inline +int ble_log_compressed_hex_print_internal(ble_cp_log_buffer_mgmt_t *mgmt, uint32_t log_index, size_t args_cnt, va_list args) { - ble_cp_log_buffer_mgmt_t *mgmt = NULL; uint8_t arg_type = 0; - va_list args; - - ble_compressed_log_cb_get(source, &mgmt); - - if (args_cnt == 0) { - ble_log_cp_push_u8(mgmt, LOG_HEADER(LOG_TYPE_HEX_ARGS, 0)); - ble_log_cp_push_u16(mgmt, log_index); - ble_compressed_log_output(source, mgmt->buffer, mgmt->idx); - ble_compressed_log_buffer_free(mgmt); - return 0; - } - - va_start(args, args_cnt); ble_log_cp_push_u8(mgmt, LOG_HEADER(LOG_TYPE_HEX_ARGS, args_cnt)); ble_log_cp_push_u16(mgmt, log_index); @@ -142,7 +130,7 @@ int ble_log_compressed_hex_print(uint8_t source, uint32_t log_index, size_t args } if (arg_type >= ARG_SIZE_TYPE_MAX) { printf("Found invalid arg type %08lx type %d", log_index, arg_type); - assert(0); + return 0; } } @@ -232,10 +220,43 @@ int ble_log_compressed_hex_print(uint8_t source, uint32_t log_index, size_t args break; } } + return 0; +} + +int ble_log_compressed_hex_printv(uint8_t source, uint32_t log_index, size_t args_cnt, va_list args) +{ + ble_cp_log_buffer_mgmt_t *mgmt = NULL; + + if (ble_compressed_log_cb_get(source, &mgmt)) { + return 0; + } + + ble_log_compressed_hex_print_internal(mgmt, log_index, args_cnt, args); + ble_compressed_log_output(source, mgmt->buffer, mgmt->idx); + ble_compressed_log_buffer_free(mgmt); + return 0; +} + +int ble_log_compressed_hex_print(uint8_t source, uint32_t log_index, size_t args_cnt, ...) +{ + ble_cp_log_buffer_mgmt_t *mgmt = NULL; + + if (ble_compressed_log_cb_get(source, &mgmt)) { + return 0; + } + + if (args_cnt == 0) { + ble_log_cp_push_u8(mgmt, LOG_HEADER(LOG_TYPE_HEX_ARGS, 0)); + ble_log_cp_push_u16(mgmt, log_index); + } else { + va_list args; + va_start(args, args_cnt); + ble_log_compressed_hex_print_internal(mgmt, log_index, args_cnt, args); + va_end(args); + } ble_compressed_log_output(source, mgmt->buffer, mgmt->idx); ble_compressed_log_buffer_free(mgmt); - va_end(args); return 0; } @@ -243,7 +264,9 @@ int ble_log_compressed_hex_print_buf(uint8_t source, uint32_t log_index, uint8_t { ble_cp_log_buffer_mgmt_t *mgmt = NULL; - ble_compressed_log_cb_get(source, &mgmt); + if (ble_compressed_log_cb_get(source, &mgmt)) { + return 0; + } if (buf == NULL && len != 0) { ble_log_cp_push_u8(mgmt, LOG_HEADER(LOG_TYPE_INFO, LOG_TYPE_INFO_NULL_BUF)); 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 5365939e0e..b6cce4af75 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 @@ -7,6 +7,7 @@ #define _BLE_LOG_COMPRESSION_UTILS_H #include "ble_log.h" +#include #define CONCAT(a, b) a##b #define _CONCAT(a, b) CONCAT(a, b) @@ -47,6 +48,7 @@ enum { BLE_COMPRESSED_LOG_OUT_SOURCE_HOST, BLE_COMPRESSED_LOG_OUT_SOURCE_MESH, + BLE_COMPRESSED_LOG_OUT_SOURCE_MESH_LIB, }; enum { diff --git a/components/bt/esp_ble_mesh/lib/ext.c b/components/bt/esp_ble_mesh/lib/ext.c index 75434312d5..7a8b37706f 100644 --- a/components/bt/esp_ble_mesh/lib/ext.c +++ b/components/bt/esp_ble_mesh/lib/ext.c @@ -14,6 +14,10 @@ #include "bta/bta_api.h" #endif +#if CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE +#include "log_compression/utils.h" +#endif + #include "btc_ble_mesh_agg_model.h" #include "btc_ble_mesh_brc_model.h" #include "btc_ble_mesh_df_model.h" @@ -5019,6 +5023,31 @@ void bt_mesh_lib_log_debug(const char *format, ...) #endif } +void ble_mesh_lib_compressed_out(uint8_t log_level, uint32_t log_index, size_t arg_cnt, ...) +{ +#if CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE + if (BLE_MESH_LOG_LEVEL >= log_level) { + va_list args = {0}; + 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_MESH_LIB, log_index, arg_cnt, args); + va_end(args); + } +#endif + return; +} + +void ble_mesh_lib_compressed_buf_out(uint8_t log_level, uint32_t log_index, uint8_t buf_idx, const uint8_t *buf, uint8_t len) +{ +#if CONFIG_BLE_MESH_COMPRESSED_LOG_ENABLE + if (BLE_MESH_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_MESH_LIB, log_index, buf_idx, buf, len); + } +#endif + return; +} + /** * @brief Keep symbols alive. * @note Dummy function to stop the linker from