snippets: Add nus-console snippet

Allowing to be applied on various samples to enable UART over Bluetooth
LE NUS without added complexity.
Tested with nrf52840dk/nrf52840 on the following samples:
- samples/subsys/console/echo.
- samples/subsys/console/getchar.
- samples/subsys/console/getline.
- samples/subsys/logging/logger.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
This commit is contained in:
Luis Ubieda 2024-03-06 13:24:45 -05:00 committed by Carles Cufí
parent 6fbbd6de24
commit 0beefffd1b
4 changed files with 74 additions and 0 deletions

View file

@ -0,0 +1,37 @@
.. _snippet-nus-console:
NUS Console Snippet (nus-console)
########################################
.. code-block:: console
west build -S nus-console [...]
Overview
********
This snippet redirects serial console output to a UART over NUS (Bluetooth LE) instance.
The Bluetooth Serial device used shall be configured using :ref:`devicetree`.
Requirements
************
Hardware support for:
- :kconfig:option:`CONFIG_BT`
- :kconfig:option:`CONFIG_BT_PERIPHERAL`
- :kconfig:option:`CONFIG_BT_NUS`
- :kconfig:option:`CONFIG_SERIAL`
- :kconfig:option:`CONFIG_CONSOLE`
- :kconfig:option:`CONFIG_UART_CONSOLE`
A devicetree node with node label ``bt_nus_console_uart`` that points to an enabled
device node with nus-uart support. This should look roughly like this in
:ref:`your devicetree <get-devicetree-outputs>`:
.. code-block:: DTS
bt_nus_console_uart: bt_nus_console_uart {
compatible = "zephyr,nus-uart";
/* ... */
};

View file

@ -0,0 +1,16 @@
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_NUS=y
CONFIG_UART_BT=y
CONFIG_BT_NUS_AUTO_START_BLUETOOTH=y
# Bluetooth optimizations to allow larger data packets.
CONFIG_BT_RX_STACK_SIZE=2048
CONFIG_BT_L2CAP_TX_MTU=512
CONFIG_BT_BUF_ACL_RX_SIZE=502
CONFIG_BT_BUF_ACL_TX_SIZE=502
CONFIG_BT_CTLR_DATA_LENGTH_MAX=251

View file

@ -0,0 +1,17 @@
/*
* Copyright (c) 2024 Croxel, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
/ {
chosen {
zephyr,console = &bt_nus_console_uart;
};
bt_nus_console_uart: bt_nus_console_uart {
compatible = "zephyr,nus-uart";
rx-fifo-size = <1024>;
tx-fifo-size = <1024>;
};
};

View file

@ -0,0 +1,4 @@
name: nus-console
append:
EXTRA_CONF_FILE: nus-console.conf
EXTRA_DTC_OVERLAY_FILE: nus-console.overlay