@@ -241,7 +241,12 @@ struct osi_funcs_t {
241241};
242242
243243#if CONFIG_BT_CTRL_LE_LOG_EN
244- typedef void (* interface_func_t ) (uint32_t len , const uint8_t * addr , bool end );
244+ typedef void (* interface_func_t ) (uint32_t len , const uint8_t * addr , uint32_t len_append , const uint8_t * addr_append , uint32_t flag );
245+
246+ enum {
247+ BLE_LOG_INTERFACE_FLAG_CONTINUE = 0 ,
248+ BLE_LOG_INTERFACE_FLAG_END ,
249+ };
245250#endif // CONFIG_BT_CTRL_LE_LOG_EN
246251
247252/* External functions or values
@@ -304,11 +309,14 @@ extern void btdm_aa_check_enhance_enable(void);
304309
305310/* BLE Log module */
306311#if CONFIG_BT_CTRL_LE_LOG_EN
312+ extern int r_ble_log_init_simple (interface_func_t interface , void * handler );
313+ extern void r_ble_log_deinit_simple (void );
307314extern int r_ble_log_init_async (interface_func_t bt_controller_log_interface , bool task_create , uint8_t buffers , uint32_t * bufs_size );
308315extern int r_ble_log_deinit_async (void );
309316extern void r_ble_log_async_select_dump_buffers (uint8_t buffers );
310317extern void r_ble_log_async_output_dump_all (bool output );
311318extern void esp_panic_handler_feed_wdts (void );
319+ extern int r_ble_log_ctrl_level_and_mod (uint8_t level , uint32_t mod_en );
312320#endif // CONFIG_BT_CTRL_LE_LOG_EN
313321#if (CONFIG_BT_BLUEDROID_ENABLED || CONFIG_BT_NIMBLE_ENABLED )
314322extern void scan_stack_enableAdvFlowCtrlVsCmd (bool en );
@@ -399,12 +407,13 @@ static esp_err_t try_heap_caps_add_region(intptr_t start, intptr_t end);
399407static void bt_controller_deinit_internal (void );
400408
401409#if CONFIG_BT_CTRL_LE_LOG_EN
402- static void esp_bt_controller_log_interface ( uint32_t len , const uint8_t * addr , bool end );
410+ #if ! CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
403411#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
404412void esp_bt_read_ctrl_log_from_flash (bool output );
405413static int esp_bt_controller_log_storage (uint32_t len , const uint8_t * addr , bool end );
406414static void esp_bt_ctrl_log_partition_get_and_erase_first_block (void );
407- #endif // #if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
415+ #endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
416+ #endif // !CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
408417#endif // CONFIG_BT_CTRL_LE_LOG_EN
409418
410419/* Local variable definition
@@ -538,18 +547,14 @@ static bool is_filled = false;
538547#endif // CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
539548
540549#if CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2
541- static IRAM_ATTR void esp_bt_controller_log_interface (uint32_t len , const uint8_t * addr , bool end )
542- {
543- ble_log_write_hex_ll (len , addr , 0 , NULL , 0 );
544- }
545-
546550void esp_ble_controller_log_dump_all (bool output )
547551{
548552 ble_log_dump_to_console ();
549553}
550554#else /* !CONFIG_BT_CTRL_LE_LOG_MODE_BLE_LOG_V2 */
551- static void esp_bt_controller_log_interface (uint32_t len , const uint8_t * addr , bool end )
555+ 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 )
552556{
557+ bool end = (flag & BIT (BLE_LOG_INTERFACE_FLAG_END ));
553558 if (log_output_mode == LOG_STORAGE_TO_FLASH ) {
554559#if CONFIG_BT_CTRL_LE_LOG_STORAGE_EN
555560 esp_bt_controller_log_storage (len , addr , end );
@@ -558,24 +563,19 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b
558563 portMUX_TYPE spinlock = portMUX_INITIALIZER_UNLOCKED ;
559564 portENTER_CRITICAL_SAFE (& spinlock );
560565 esp_panic_handler_feed_wdts ();
561- for (int i = 0 ; i < len ; i ++ ) {
562- esp_rom_printf ("%02x " , addr [i ]);
563- }
564566
565- if (end ) {
566- esp_rom_printf ("\n" );
567+ if (len && addr ) {
568+ for (int i = 0 ; i < len ; i ++ ) { esp_rom_printf ("%02x " , addr [i ]); }
569+ }
570+ if (len_append && addr_append ) {
571+ for (int i = 0 ; i < len_append ; i ++ ) { esp_rom_printf ("%02x " , addr_append [i ]); }
567572 }
573+ if (end ) { esp_rom_printf ("\n" ); }
574+
568575 portEXIT_CRITICAL_SAFE (& spinlock );
569576 }
570577}
571578
572- #if CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
573- static IRAM_ATTR void esp_bt_controller_spi_log_interface (uint32_t len , const uint8_t * addr , bool end )
574- {
575- ble_log_spi_out_ll_write (len , addr , 0 , NULL , 0 );
576- }
577- #endif // CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
578-
579579void esp_ble_controller_log_dump_all (bool output )
580580{
581581 if (log_output_mode == LOG_STORAGE_TO_FLASH ) {
@@ -612,16 +612,13 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
612612 }
613613
614614 esp_err_t ret = ESP_OK ;
615- uint8_t buffers = 0 ;
616615
617- #if CONFIG_BT_CTRL_LE_LOG_EN
618- buffers |= ESP_BLE_LOG_BUF_CONTROLLER ;
619- #endif // CONFIG_BT_CTRL_LE_LOG_EN
620- #if CONFIG_BT_CTRL_LE_HCI_LOG_EN
621- buffers |= ESP_BLE_LOG_BUF_HCI ;
622- #endif // CONFIG_BT_CTRL_LE_HCI_LOG_EN
616+ ret = r_ble_log_init_simple (ble_log_write_hex_ll , NULL );
617+ if (ret != ESP_OK ) {
618+ return ret ;
619+ }
623620
624- ret = r_ble_log_init_async ( esp_bt_controller_log_interface , true, buffers , ( uint32_t * ) log_bufs_size );
621+ ret = r_ble_log_ctrl_level_and_mod ( BLE_LOG_LEVEL , BLE_LOG_MODE_EN );
625622 if (ret == ESP_OK ) {
626623 log_is_inited = true;
627624 }
@@ -664,14 +661,19 @@ esp_err_t esp_bt_controller_log_init(uint8_t log_output_mode)
664661 case LOG_SPI_OUT :
665662 task_create = true;
666663#if CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
667- bt_controller_log_interface = esp_bt_controller_spi_log_interface ;
664+ bt_controller_log_interface = ble_log_spi_out_ll_write ;
668665#endif // CONFIG_BT_CTRL_LE_LOG_SPI_OUT_EN
669666 break ;
670667 default :
671668 assert (0 );
672669 }
673670
674671 ret = r_ble_log_init_async (bt_controller_log_interface , task_create , buffers , (uint32_t * )log_bufs_size );
672+ if (ret != ESP_OK ) {
673+ return ret ;
674+ }
675+
676+ ret = r_ble_log_ctrl_level_and_mod (BLE_LOG_LEVEL , BLE_LOG_MODE_EN );
675677 if (ret == ESP_OK ) {
676678 log_is_inited = true;
677679 }
0 commit comments