|
53 | 53 | #define HUB_VARIANT 0x0000 |
54 | 54 | #endif |
55 | 55 |
|
56 | | -#define DEBUG 0 |
| 56 | +#define DEBUG 1 |
57 | 57 |
|
58 | 58 | #if DEBUG |
59 | 59 | #include <pbdrv/../../drv/uart/uart_debug_first_port.h> |
60 | 60 | #define DEBUG_PRINT pbdrv_uart_debug_printf |
| 61 | +#include <pbdrv/../../drv/uart/uart_debug_first_port.h> |
| 62 | +#define DEBUG_PRINT pbdrv_uart_debug_printf |
| 63 | +static void pbdrv_hci_dump_reset(void) { |
| 64 | +} |
| 65 | +static void pbdrv_hci_dump_log_packet(uint8_t packet_type, uint8_t in, uint8_t* packet, uint16_t len) { |
| 66 | + pbdrv_uart_debug_printf("HCI %s packet type: %02x, len: %u\n", in ? "in" : "out", packet_type, len); |
| 67 | +} |
| 68 | +static void pbdrv_hci_dump_log_message(int log_level, const char* format, va_list argptr) { |
| 69 | + pbdrv_uart_debug_vprintf(format, argptr); |
| 70 | + pbdrv_uart_debug_printf("\n"); |
| 71 | +} |
| 72 | +static const hci_dump_t bluetooth_btstack_classic_hci_dump = { |
| 73 | + .reset = pbdrv_hci_dump_reset, |
| 74 | + .log_packet = pbdrv_hci_dump_log_packet, |
| 75 | + .log_message = pbdrv_hci_dump_log_message, |
| 76 | +}; |
61 | 77 | #else |
62 | 78 | #define DEBUG_PRINT(...) |
63 | 79 | #endif |
@@ -1213,6 +1229,15 @@ void pbdrv_bluetooth_init_hci(void) { |
1213 | 1229 | btstack_run_loop_init(&bluetooth_btstack_run_loop); |
1214 | 1230 |
|
1215 | 1231 | hci_init(pdata->transport_instance(), pdata->transport_config()); |
| 1232 | + |
| 1233 | +#if DEBUG |
| 1234 | + hci_dump_init(&bluetooth_btstack_classic_hci_dump); |
| 1235 | + hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_INFO, true); |
| 1236 | + hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_ERROR, true); |
| 1237 | + hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_DEBUG, true); |
| 1238 | + hci_dump_enable_packet_log(true); |
| 1239 | +#endif |
| 1240 | + |
1216 | 1241 | if (pdata->chipset_instance != NULL) { |
1217 | 1242 | hci_set_chipset(pdata->chipset_instance()); |
1218 | 1243 | } |
|
0 commit comments