nRF5 SDK for Thread v0.11.0
Thread CLI Example

The Thread CLI example demonstrates a minimal OpenThread application that enables user interaction through built-in command line interface (CLI). It can be used as a base for more sophisticated applications. This example has similar functionality as the CLI example available in the official OpenThread repository but has been adopted to use with the nRF5 SDK. For additional information about the example, refer to OpenThread CLI Example.

Description

The CLI example is provided in two configurations - UART and USB. The former one uses UART communication and SEGGER J-Link as a UART-USB converter. The latter one uses the USB peripheral that is available in nRF52840 and communicates as a native USB CDC device.

If native USB CDC connectivity is used on Windows XP/7 hosts, you must manually install the driver that is located in the example directory:

Windows 8 (and later) hosts will pick the correct driver (usbser.sys) automatically.

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.

Network state is indicated by BSP_LED_0. When the device is not connected to a network, the LED blinks at a 200 ms period. Once the device connects to a network, either as a Child or as a Leader, the LED stops blinking and remains turned on.

When the application starts, you can configure the network using the following commands:

> panid 0xabcd
Done
> ifconfig up
Done
> thread start
Done

Once the device is connected, you can check its role using the state command:

> state
Leader
Done

The actual state may differ, depending on when the device joined the network.

To obtain the IP addresses of a device, run 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

Once there are two or more devices in the network, you can ping one from another with the ping command:

> 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.

Setup

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

Testing

To test this example, you need at least two nRF52840 Development Kits.

  1. Build the example according to the instructions in Building examples.
  2. Program both development kits with the selected CLI application (UART or USB).
  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. The application uses the following UART settings:
    • Baud rate: 115.200
    • 8 data bits
    • 1 stop bit
    • No parity
    • HW flow control: None
  4. Set up the Thread network on both devices as described in Description (panid, ifconfig, and thread commands). Be sure to set the same PAN ID on both devices.
  5. Wait until both devices are connected to the network (BSP_LED_0 stops blinking).
  6. Check IP addresses on one of the devices.
  7. Ping one of the IP addresses from the other device. You will receive a response from the first device.

Documentation feedback | Developer Zone | Subscribe | Updated