nRF5 SDK for Thread and Zigbee v4.1.0
Thread CLI Example

Table of Contents

This information applies to the following SoCs: nRF52833 and nRF52840.

The Thread CLI example demonstrates a minimal OpenThread application that enables user interaction through built-in command line interface (CLI). You can use it as a base for more sophisticated applications.

This example has similar functionality as the OpenThread CLI Example, but has been adopted to use the nRF5 SDK.

The following table lists the available CLI example configurations.

Configuration Description Stack variant used Available for
FTD UART Uses the UART communication and SEGGER J-Link as a UART-USB converter. Thread FTD PCA10056, PCA10100
FTD USB Uses the USB peripheral that is available in the nRF52 devices and communicates as a native USB CDC device. Thread FTD PCA10056, PCA10059 (with bootloader, see nRF52840 Dongle), PCA10100
MTD UART Uses the UART communication and SEGGER J-Link as a UART-USB converter. Thread MTD PCA10056, PCA10068 with nRF52811, PCA10100
MTD USB Uses the USB peripheral that is available in the nRF52 devices and communicates as a native USB CDC device. Thread MTD PCA10056, PCA10059 (with bootloader, see nRF52840 Dongle), PCA10100

Driver installation on host

The CLI example requires for the host PC to be able to connect to it. Some PC USB drivers might be needed. The driver installation depends on the host operating system.

Operating System Installation procedure
Windows XP or 7 If the native USB CDC connectivity is used, manually install the nordic_cdc_acm.inf driver.
The file that is located at <InstallFolder>\examples\usb_drivers
Windows 8 and later Hosts pick the correct usbser.sys driver file automatically.
Most of modern Linux and MacOS Hosts handle the driver installation automatically.
Driver installation per Operating System

The CLI application starts in disconnected state and remains so until appropriate commands are issued by the user. These commands can be issued by using a serial line connection with a terminal application like PuTTy.


Setup

You can find the source code and the makefile in the following folder: <InstallFolder>\examples\thread\cli.

LED assignments

This example uses LED assignments as described in Thread BSP LED and button reference for the following LEDs:


Testing

Note
The following testing procedure uses the nRF52840 device.
Precondition
  • To test this example, you need at least two nRF52840 Development Kits or one nRF52840 and one nRF52811 Development Kits.
  • Make sure you disabled the Mass Storage Device and forced Hardware Flow Control in SEGGER J-Link. See Configuring SEGGER J-Link software for details.

To test the example:

  1. Build the example according to the instructions in Building examples. Skip this step if you are testing this example as part of Running precompiled examples.
  2. Program each development kit with the selected CLI application (UART or USB). Skip this step if you are testing this example as part of Running precompiled examples.
  3. Connect to the boards through UART. If UART CLI is used, use the SEGGER J-Link USB port, otherwise use the native nRF USB port.
  4. Start a terminal application like PuTTy. The application uses the following UART settings:
    • Baud rate: 115200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  5. Set up the Thread network on each device by using the following commands:
    > panid 0xabcd
    Done
    > ifconfig up
    Done
    > thread start
    Done
    Set the same PAN ID on all devices.
  6. Wait until LED1 stops blinking, which indicates that both devices are connected to the network, either as a Child or as a Leader.
  7. Check the device role with the following command:
    > state
    Leader
    Done
    The actual state may differ, depending on when the device joined the network.
  8. Check IP addresses of the devices by running the following command:
    > ipaddr
    fdde:ad00:beef:0:0:ff:fe00:6000
    fdde:ad00:beef:0:96dc:d278:c12c:d2de
    fe80:0:0:0:e01d:b81b:ed09:be37
    Done
  9. On one of the devices, ping the IP address of the other device:
    > ping fdde:ad00:beef:0:96dc:d278:c12c:d2de
    You will receive a response from the other device:
    > ping fdde:ad00:beef:0:96dc:d278:c12c:d2de
    16 bytes from fdde:ad00:beef:0:96dc:d278:c12c:d2de: icmp_seq=2 hlim=64 time=11ms

For a complete list of CLI commands, run the help command. For complete CLI documentation, refer to OpenThread CLI Reference.


Documentation feedback | Developer Zone | Subscribe | Updated