diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2023-04-13 11:33:43 +1000 |
---|---|---|
committer | Jim Mussared <jim.mussared@gmail.com> | 2023-04-26 11:37:20 +1000 |
commit | a42a8022d8d2c9fc1fe05ff5ac60b650e481a62d (patch) | |
tree | 6466d0e51ecfa031602b14e514a58c8857b90798 /extmod | |
parent | ab31e23f7a0bc8379f117f0e31403751cbfcf837 (diff) | |
download | micropython-a42a8022d8d2c9fc1fe05ff5ac60b650e481a62d.tar.gz micropython-a42a8022d8d2c9fc1fe05ff5ac60b650e481a62d.zip |
extmod/modbluetooth: Make all HCI transports trace in the same format.
- Use HCI_TRACE macro consistently.
- Use the same colour formatting.
- Add a tool to convert to .pcap for Wireshark.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod')
-rw-r--r-- | extmod/nimble/hal/hal_uart.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/extmod/nimble/hal/hal_uart.c b/extmod/nimble/hal/hal_uart.c index 6c17da0860..7713f75d8d 100644 --- a/extmod/nimble/hal/hal_uart.c +++ b/extmod/nimble/hal/hal_uart.c @@ -39,6 +39,9 @@ #endif #define HCI_TRACE (0) +#define COL_OFF "\033[0m" +#define COL_GREEN "\033[0;32m" +#define COL_BLUE "\033[0;34m" static hal_uart_tx_cb_t hal_uart_tx_cb; static void *hal_uart_tx_arg; @@ -71,11 +74,11 @@ void hal_uart_start_tx(uint32_t port) { } #if HCI_TRACE - printf("< [% 8d] %02x", (int)mp_hal_ticks_ms(), mp_bluetooth_hci_cmd_buf[0]); + printf(COL_GREEN "< [% 8d] %02x", (int)mp_hal_ticks_ms(), mp_bluetooth_hci_cmd_buf[0]); for (size_t i = 1; i < len; ++i) { printf(":%02x", mp_bluetooth_hci_cmd_buf[i]); } - printf("\n"); + printf(COL_OFF "\n"); #endif mp_bluetooth_hci_uart_write(mp_bluetooth_hci_cmd_buf, len); @@ -92,7 +95,7 @@ int hal_uart_close(uint32_t port) { STATIC void mp_bluetooth_hci_uart_char_cb(uint8_t chr) { #if HCI_TRACE - printf("> %02x\n", chr); + printf(COL_BLUE "> [% 8d] %02x" COL_OFF "\n", (int)mp_hal_ticks_ms(), chr); #endif hal_uart_rx_cb(hal_uart_rx_arg, chr); } |