|
54 | 54 | #define HUB_VARIANT 0x0000 |
55 | 55 | #endif |
56 | 56 |
|
57 | | -#define DEBUG 0 |
| 57 | +#define DEBUG 1 |
58 | 58 |
|
59 | 59 | #if DEBUG |
60 | 60 | #include <pbdrv/../../drv/uart/uart_debug_first_port.h> |
61 | 61 | #define DEBUG_PRINT pbdrv_uart_debug_printf |
| 62 | +#include <pbdrv/../../drv/uart/uart_debug_first_port.h> |
| 63 | +#define DEBUG_PRINT pbdrv_uart_debug_printf |
| 64 | +static void pbdrv_hci_dump_reset(void) { |
| 65 | +} |
| 66 | +static void pbdrv_hci_dump_log_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) { |
| 67 | + pbdrv_uart_debug_printf("HCI %s packet type: %02x, len: %u\n", in ? "in" : "out", packet_type, len); |
| 68 | +} |
| 69 | +static void pbdrv_hci_dump_log_message(int log_level, const char *format, va_list argptr) { |
| 70 | + pbdrv_uart_debug_vprintf(format, argptr); |
| 71 | + pbdrv_uart_debug_printf("\n"); |
| 72 | +} |
| 73 | +static const hci_dump_t bluetooth_btstack_classic_hci_dump = { |
| 74 | + .reset = pbdrv_hci_dump_reset, |
| 75 | + .log_packet = pbdrv_hci_dump_log_packet, |
| 76 | + .log_message = pbdrv_hci_dump_log_message, |
| 77 | +}; |
62 | 78 | #else |
63 | 79 | #define DEBUG_PRINT(...) |
64 | 80 | #endif |
@@ -1143,6 +1159,15 @@ void pbdrv_bluetooth_init_hci(void) { |
1143 | 1159 | btstack_run_loop_init(&bluetooth_btstack_run_loop); |
1144 | 1160 |
|
1145 | 1161 | hci_init(pdata->transport_instance(), pdata->transport_config()); |
| 1162 | + |
| 1163 | + #if DEBUG |
| 1164 | + hci_dump_init(&bluetooth_btstack_classic_hci_dump); |
| 1165 | + hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_INFO, true); |
| 1166 | + hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_ERROR, true); |
| 1167 | + hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_DEBUG, true); |
| 1168 | + hci_dump_enable_packet_log(true); |
| 1169 | + #endif |
| 1170 | + |
1146 | 1171 | if (pdata->chipset_instance != NULL) { |
1147 | 1172 | hci_set_chipset(pdata->chipset_instance()); |
1148 | 1173 | } |
|
0 commit comments