From 27b333e73617d0ed9e38e2ac7758196fe57af963 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Fri, 16 May 2025 15:07:21 +0800 Subject: [PATCH] fix(ble): added missed printf for ll log interface --- components/bt/controller/esp32c2/bt.c | 19 +++++++++++++------ components/bt/controller/esp32c6/bt.c | 19 +++++++++++++------ components/bt/controller/esp32h2/bt.c | 19 +++++++++++++------ 3 files changed, 39 insertions(+), 18 deletions(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index 7bffc4f9ae..becd445b34 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -117,6 +117,11 @@ struct ext_funcs_t { #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag); + +enum { + BLE_LOG_INTERFACE_FLAG_CONTINUE = 0, + BLE_LOG_INTERFACE_FLAG_END, +}; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED /* External functions or variables @@ -409,20 +414,22 @@ void esp_bt_read_ctrl_log_from_flash(bool output) #if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag) { - bool end = flag ? true : false; + bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END)); #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE esp_bt_controller_log_storage(len, addr, end); #else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; portENTER_CRITICAL_SAFE(&spinlock); esp_panic_handler_feed_wdts(); - for (int i = 0; i < len; i++) { - esp_rom_printf("%02x ", addr[i]); - } - if (end) { - esp_rom_printf("\n"); + if (len && addr) { + for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); } } + if (len_append && addr_append) { + for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); } + } + if (end) { esp_rom_printf("\n"); } + portEXIT_CRITICAL_SAFE(&spinlock); #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE } diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index bd023da749..b4ede8ee80 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -111,6 +111,11 @@ struct ext_funcs_t { #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag); + +enum { + BLE_LOG_INTERFACE_FLAG_CONTINUE = 0, + BLE_LOG_INTERFACE_FLAG_END, +}; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED /* External functions or variables @@ -1478,20 +1483,22 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po #if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag) { - bool end = flag ? true : false; + bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END)); #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE esp_bt_controller_log_storage(len, addr, end); #else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; portENTER_CRITICAL_SAFE(&spinlock); esp_panic_handler_feed_wdts(); - for (int i = 0; i < len; i++) { - esp_rom_printf("%02x ", addr[i]); - } - if (end) { - esp_rom_printf("\n"); + if (len && addr) { + for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); } } + if (len_append && addr_append) { + for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); } + } + if (end) { esp_rom_printf("\n"); } + portEXIT_CRITICAL_SAFE(&spinlock); #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE } diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 7b512b4f5b..5eb38543d3 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -102,6 +102,11 @@ struct ext_funcs_t { #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED typedef void (*interface_func_t) (uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag); + +enum { + BLE_LOG_INTERFACE_FLAG_CONTINUE = 0, + BLE_LOG_INTERFACE_FLAG_END, +}; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED /* External functions or variables ************************************************************************ @@ -1404,20 +1409,22 @@ esp_power_level_t esp_ble_tx_power_get_enhanced(esp_ble_enhanced_power_type_t po #if !CONFIG_BT_LE_CONTROLLER_LOG_SPI_OUT_ENABLED static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, uint32_t len_append, const uint8_t *addr_append, uint32_t flag) { - bool end = flag ? true : false; + bool end = (flag & BIT(BLE_LOG_INTERFACE_FLAG_END)); #if CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE esp_bt_controller_log_storage(len, addr, end); #else // !CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED; portENTER_CRITICAL_SAFE(&spinlock); esp_panic_handler_feed_wdts(); - for (int i = 0; i < len; i++) { - esp_rom_printf("%02x ", addr[i]); - } - if (end) { - esp_rom_printf("\n"); + if (len && addr) { + for (int i = 0; i < len; i++) { esp_rom_printf("%02x ", addr[i]); } } + if (len_append && addr_append) { + for (int i = 0; i < len_append; i++) { esp_rom_printf("%02x ", addr_append[i]); } + } + if (end) { esp_rom_printf("\n"); } + portEXIT_CRITICAL_SAFE(&spinlock); #endif // CONFIG_BT_LE_CONTROLLER_LOG_STORAGE_ENABLE }