Bluetooth: NUS shell transport¶
The Nordic UART Service (NUS) shell transport sample demonstrates how to use the Nordic UART Service (NUS) shell transport to receive shell commands from a remote device.
Overview¶
When the connection is established, you can connect to the sample through the Nordic UART Service (NUS) by using a host application. You can then send shell commands, that are executed on the device that runs the sample, and see the logs. See Sending shell commands for more information about the host tools available, in nRF Connect SDK, for communicating with the sample.
Requirements¶
The sample supports the following development kits:
Hardware platforms |
PCA |
Board name |
Build target |
---|---|---|---|
PCA10095 |
|
||
PCA10056 |
|
||
PCA10040 |
|
||
PCA10010 |
|
||
PCA10100 |
|
You also need an additional nRF52 development kit, like the PCA10040 for connecting using the bt_nus_shell.py
script.
Alternatively, you can use BLE Console for connecting, using Linux only.
Building and running¶
This sample can be found under samples/bluetooth/shell_bt_nus
in the nRF Connect SDK folder structure.
See Building and programming a sample application for information about how to build and program the application.
Testing¶
The nRF Connect SDK provides two alternatives for testing the sample:
Testing using shell_bt_nus. It is a Python script that requires a console application, like PuTTY, and a second development kit.
Testing using the BLE Console. It is a stand-alone application for Linux.
Testing using shell_bt_nus¶
The script file scripts/shell/bt_nus_shell.py
contains a cross-platform example host application, written in Python 2.
The script uses an additional Nordic development kit, like the PCA10040, as a Bluetooth central device.
It connects to the specified device and forwards all NUS traffic to the network port.
You can then use a console application, like PuTTY, to connect to that port and use the shell.
The default port is set to 8889
.
After programming the sample to your development kits, test it by performing the following steps:
Start a console application, like PuTTY, and connect through UART to the
shell_bt_nus
application running on the development kit to check the log. See Testing a sample application for more information on how to connect with PuTTY through UART.On the host PC, install Python 2.
Run the following command to install the Bluetooth LE driver:
pip2 install pc_ble_driver_py
Run the following command to install nRF Util:
pip2 install --user nrfutil==4.0.0
Connect to your PC the nRF52 development kit meant to use the
bt_nus_shell.py
script.Start the
bt_nus_shell.py
script with the correct parameters, for example:bt_nus_shell.py --name BT_NUS_shell --com COM237 --family NRF52 --snr 682560213
Open a console application, like PuTTY, and open a new session, setting the Connection Type to Raw and the Destination Address to
127.0.0.1:8889
.Press Enter in the terminal window. A console prompt is displayed showing a log message that indicates the active connection.
Enter the commands that you want to execute.
Testing using the BLE Console¶
See BLE Console for more information on how to test the sample using the BLE Console.
Dependencies¶
This sample uses the following nRF Connect SDK libraries:
In addition, it uses the following Zephyr libraries: