diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index c24bb67fc6..a329881eeb 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -119,6 +119,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 @@ -411,20 +416,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/esp32c5/bt.c b/components/bt/controller/esp32c5/bt.c index 37c2fa6601..7d332a06fb 100644 --- a/components/bt/controller/esp32c5/bt.c +++ b/components/bt/controller/esp32c5/bt.c @@ -103,6 +103,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 ************************************************************************ @@ -1410,20 +1415,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/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 8c31fa860e..74e1d58555 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -110,6 +110,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 @@ -1481,20 +1486,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 86e8637cb7..22b1aaa3eb 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 }