Skip to content

Commit 5876561

Browse files
committed
pbio/drv/bluetooth_btstack: Use common HCI logging.
We don't need duplicates for EV3 and the POSIX variants.
1 parent 0772d87 commit 5876561

2 files changed

Lines changed: 24 additions & 21 deletions

File tree

lib/pbio/drv/bluetooth/bluetooth_btstack.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,23 @@
5252
#define DEBUG_PRINT(...)
5353
#endif
5454

55+
#if DEBUG == 2
56+
static void btstack_hci_dump_reset(void) {
57+
}
58+
static void btstack_hci_dump_log_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) {
59+
pbio_debug("HCI %s packet type: %02x, len: %u\n", in ? "in" : "out", packet_type, len);
60+
}
61+
static void btstack_hci_dump_log_message(int log_level, const char *format, va_list argptr) {
62+
pbio_debug_va(format, argptr);
63+
pbio_debug("\n");
64+
}
65+
static const hci_dump_t pbdrv_bluetooth_btstack_hci_dump = {
66+
.reset = btstack_hci_dump_reset,
67+
.log_packet = btstack_hci_dump_log_packet,
68+
.log_message = btstack_hci_dump_log_message,
69+
};
70+
#endif
71+
5572
typedef enum {
5673
CON_STATE_NONE,
5774
CON_STATE_WAIT_ADV_IND,
@@ -1087,6 +1104,13 @@ void pbdrv_bluetooth_init_hci(void) {
10871104
return;
10881105
}
10891106

1107+
#if DEBUG == 2
1108+
hci_dump_init(&pbdrv_bluetooth_btstack_hci_dump);
1109+
hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_INFO, true);
1110+
hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_ERROR, true);
1111+
hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_DEBUG, true);
1112+
#endif
1113+
10901114
static btstack_packet_callback_registration_t hci_event_callback_registration;
10911115

10921116
#if PBDRV_CONFIG_BLUETOOTH_BTSTACK_LE

lib/pbio/drv/bluetooth/bluetooth_btstack_ev3.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,6 @@
4848
#if DEBUG
4949
#include <pbio/debug.h>
5050
#define DEBUG_PRINT pbio_debug
51-
static void pbdrv_hci_dump_reset(void) {
52-
}
53-
static void pbdrv_hci_dump_log_packet(uint8_t packet_type, uint8_t in, uint8_t *packet, uint16_t len) {
54-
pbio_debug("HCI %s packet type: %02x, len: %u\n", in ? "in" : "out", packet_type, len);
55-
}
56-
static void pbdrv_hci_dump_log_message(int log_level, const char *format, va_list argptr) {
57-
pbio_debug_va(format, argptr);
58-
pbio_debug("\n");
59-
}
60-
static const hci_dump_t bluetooth_btstack_classic_hci_dump = {
61-
.reset = pbdrv_hci_dump_reset,
62-
.log_packet = pbdrv_hci_dump_log_packet,
63-
.log_message = pbdrv_hci_dump_log_message,
64-
};
6551
#else
6652
#define DEBUG_PRINT(...)
6753
#endif
@@ -146,13 +132,6 @@ static void ev3_control_init(const void *config) {
146132
// Start the module in a defined (and disabled) state.
147133
ev3_control_off();
148134

149-
#if DEBUG
150-
hci_dump_init(&bluetooth_btstack_classic_hci_dump);
151-
hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_INFO, true);
152-
hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_ERROR, true);
153-
hci_dump_enable_log_level(HCI_DUMP_LOG_LEVEL_DEBUG, true);
154-
#endif
155-
156135
DEBUG_PRINT("Bluetooth: Finished init control\n");
157136
}
158137

0 commit comments

Comments
 (0)