Skip to content

Commit d1a3f4f

Browse files
jhedbergmmahadevan108
authored andcommitted
Bluetooth: Host: Fix monitor UART selection
Most boards set zephyr,bt-mon-uart to point at the same device as zephyr,console. It's still useful to have the possibility of having these as two different devices, however it's useful to fall back to the UART console in case a dedicated monitor UART hasn't been specified. This also ensures that the fallback only happens if the console UART isn't enabled, but a DT chosen property exists for it. Additionally, we now get a user friendly error in case the Bluetooth UART monitor feature has been enabled in Kconfig but there isn't a suitable UART available for it in devicetree. Signed-off-by: Johan Hedberg <[email protected]>
1 parent 4e77640 commit d1a3f4f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

subsys/bluetooth/host/monitor.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,15 @@ static void poll_out(char c)
150150
}
151151
#elif defined(CONFIG_BT_DEBUG_MONITOR_UART)
152152
static const struct device *const monitor_dev =
153+
#if DT_HAS_CHOSEN(zephyr_bt_mon_uart)
153154
DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_mon_uart));
155+
#elif !defined(CONFIG_UART_CONSOLE) && DT_HAS_CHOSEN(zephyr_console)
156+
/* Fall back to console UART if it's available */
157+
DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
158+
#else
159+
NULL;
160+
#error "BT_DEBUG_MONITOR_UART enabled but no UART specified"
161+
#endif
154162

155163
static void poll_out(char c)
156164
{

0 commit comments

Comments
 (0)