nRF5 SDK for Thread
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 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

Currently, only the GCC project is supported. You can find the source code and the make file 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 project by running the make command in the project folder. Note that you must have the make tool available on your system. If you are using Windows, you can use the MinGW environment (http://www.mingw.org/).
  2. Program both development kits with the CLI application.
  3. Connect to the boards through UART. 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