Skip to content

Build and Run a Thread Example

This section demonstrates how to build a Thread example (like OpenThread CLI) with the nRF5 SDK for Thread and run it.

Before you start building, remember to set up the Thread development environment first. See Setup the Thread SDK for details.

Building OpenThread CLI

You can find the source code and the project file of OpenThread CLI in the following folder: pitaya-go/examples/openthread/cli.

Navigate to the directory with the OpenThread Full Thread Device (FTD) CLI Makefile:

cd ./pitaya-go/examples/openthread/cli/ftd/armgcc

Run make to build the example:

make

Programming OpenThread CLI

If compiled successfully, the firmware is located in openthread/cli/ftd/armgcc/_build with the name nrf52840_xxaa.hex.

While pushing the USER button, press the RESET button to enter the DFU (Device Firmware Update) mode. Then program the firmware using the nRF Connect for Desktop tool.

Tip

See Programming section for details about how to program your Pitaya Go.

Testing

Perform the following steps to test the OpenThread CLI:

  1. Run a terminal application like PuTTY or screen:

    screen /dev/cu.usbmodemD2E39D222D781 115200
    
  2. Press Enter on the keyboard to bring up the OpenThread CLI > prompt.

  3. Generate, view, and commit a new Active Operational Dataset:

    > dataset init new
    Done
    > dataset
    Active Timestamp: 1
    Channel: 24
    Channel Mask: 07fff800
    Ext PAN ID: 57a7486ff74c8538
    Mesh Local Prefix: fda9:4820:7a9c:66ba/64
    Master Key: aa8da3931ffcbcb26c8b4b7c9b4114c1
    Network Name: OpenThread-4d92
    PAN ID: 0x4d92
    PSKc: 22537a67d4040e34848d6d82ca2c313c
    Security Policy: 0, onrcb
    Done
    > dataset commit active
    Done
    
  4. Bring up the IPv6 interface:

    > ifconfig up
    Done
    
  5. Start Thread protocol operation. Observe that the GREEN LED is lit.

    > thread start
    Done
    
  6. Wait a few seconds and verify that the device has become a Thread Leader:

    > state
    leader
    Done
    
  7. View IPv6 addresses assigned to the Thread interface:

    > ipaddr
    fda9:4820:7a9c:66ba:0:ff:fe00:fc00
    fda9:4820:7a9c:66ba:0:ff:fe00:8800
    fda9:4820:7a9c:66ba:4d7b:9ef4:cbdf:8cd3
    fe80:0:0:0:3c1d:5115:ccc5:6ba7
    Done
    

Next Steps

Create an Issue

Interested in contributing to this project? Want to report a bug? Feel free to click here: