External Commissioning in Thread Network
- 4 minutes read - 728 wordsIn our previous article, we set up a commissioner within a Thread network by starting the commissioner from a thread node. However, a Thread network can also be provisioned using an external commissioner outside the thread network.
This article will guide you through the configuration of an external commissioner for a Thread network using a Commissioner CLI setup on a mac/linux pc.
Commissioner CLI
The Commissioner CLI can be built on macOS or Linux using the following steps:
Build Commissioner CLI
Clone the ot-commisioner
repository and build it.
$ git clone https://github.com/openthread/ot-commissioner
$ cd ot-commissioner
$ ./script/bootstrap.sh
OS is Darwin
==> Updating Homebrew...
Updated 3 taps (homebrew/services, homebrew/core and homebrew/cask).
==> New Formulae
bombardier cspell dyff flow-control garnet mdq ruby-lsp taskflow vscli zns
$ mkdir build
$ cd build
$ cmake -DCMAKE_INSTALL_PREFIX=/usr/local -GNinja .
-- The C compiler identification is AppleClang 16.0.0.16000026
-----
$ ninja -j1
Install Commissioner CLI
Install the commissioner CLI using ninja
$ sudo ninja install
[0/1] Install the project...
-- Install configuration: "Debug"
-- Installing: /usr/local/etc/commissioner
-- Installing: /usr/local/etc/commissioner/active-dataset.json
-- Installing: /usr/local/bin/commissionerd.py
-- Installing: /usr/local/bin/commissioner_ctl.py
-- Installing: /etc/systemd/system/commissionerd.service
Run Commissioner CLI
On successful installation Commissioner CLI should be available to run with commissioner-cli command, and we can run commissioner commands
$ commissioner-cli
____ ______ _ _ ________ ____
/ __ \/_ __/ _________ ____ ___ ____ ___ (_)_________(_)___ ____ ___ _____ / ____/ / / _/
/ / / / / /_____/ ___/ __ \/ __ `__ \/ __ `__ \/ / ___/ ___/ / __ \/ __ \/ _ \/ ___/ / / / / / /
/ /_/ / / /_____/ /__/ /_/ / / / / / / / / / / / (__ |__ ) / /_/ / / / / __/ / / /___/ /____/ /
\____/ /_/ \___/\____/_/ /_/ /_/_/ /_/ /_/_/____/____/_/\____/_/ /_/\___/_/ \____/_____/___/
>
Connecting with Border Router
In a previous article, we set up a Border Router on a Raspberry Pi, where we could start and manage a Thread network through a web interface as well.
Find the IoT Practices Publication for more details.
To connect an external commissioner to the Border Router, we need:
- Border Router Agent Address
- Border Router Agent Port
- Pre-Shared Key for Commissioner (PSKc)
Getting Border Agent Address and Port
The Border Router can be discovered using the DNS service name _meshcop._udp.local
. Run the following command on the system where the Commissioner CLI is installed:
$ dns-sd -B _meshcop._udp local
Browsing for _meshcop._udp.local
DATE: ---Fri 28 Feb 2025---
14:48:22.014 ...STARTING...
Timestamp A/R Flags if Domain Service Type Instance Name
14:48:22.017 Add 2 15 local. _meshcop._udp. OpenThread BorderRouter #EA14
Notice the instance name OpenThread BorderRouter #EA14
and list more details for it
$ dns-sd -L "OpenThread BorderRouter #EA14" _meshcop._udp local
Lookup OpenThread BorderRouter #EA14._meshcop._udp.local
DATE: ---Fri 28 Feb 2025---
14:47:21.379 ...STARTING...
14:47:21.572 OpenThread\032BorderRouter\032#EA14._meshcop._udp.local. can be reached at kuldeep.local.:49154 (interface 15)
rv=1 id=??AF\\x1B?T?2?H???? vn=OpenThread mn=BorderRouter nn=OpenThreadDemo xp=\\x11\\x11\\x11\\x11\"\"\"\" tv=1.4.0 xa=??\\x02\\x16???\\x14 sb=\\\x00\\\x00\\x0F? at=\\\x00\\\x00\\\x00\\\x00\\\x00\\x01\\\x00\\\x00 pt=\\x01?1k sq== bb=? dn=DefaultDomain omr=@?\\x04\$\\x1Aj?\\\x00\\x01
- Address:
kuldeep.local.
(or the IPv4/IPv6 address of the Raspberry Pi) - Port:
49154
Getting PSKc
If the PSKc is already set on the Border Router, retrieve it by running following on border router (Raspberry Pi terminal):
kuldeep@kuldeep:~ $ sudo ot-ctl pskc
445f2b5ca6f2a93a55ce570a70efeecb
Done
kuldeep@kuldeep:~ $
If the PSKc is not available, generate it using the PSKc generator with the Network Name, Extended PAN ID, and Passphrase:
kuldeep@kuldeep:~ $ cd ~/ot-br-posix/build/otbr/tools
kuldeep@kuldeep:~/ot-br-posix/build/otbr/tools $./pskc j01Nme 1111111122222222 OpenThreadDemo
445f2b5ca6f2a93a55ce570a70efeecb
Start Commissioner
Set PSKc in commissioner configuration and start the commissioner with address and port.
$ commissioner-cli
____ ______ _ _ ________ ____
/ __ \/_ __/ _________ ____ ___ ____ ___ (_)_________(_)___ ____ ___ _____ / ____/ / / _/
/ / / / / /_____/ ___/ __ \/ __ `__ \/ __ `__ \/ / ___/ ___/ / __ \/ __ \/ _ \/ ___/ / / / / / /
/ /_/ / / /_____/ /__/ /_/ / / / / / / / / / / / (__ |__ ) / /_/ / / / / __/ / / /___/ /____/ /
\____/ /_/ \___/\____/_/ /_/ /_/_/ /_/ /_/_/____/____/_/\____/_/ /_/\___/_/ \____/_____/___/
> state
disabled
[done]
> config set pskc 445f2b5ca6f2a93a55ce570a70efeecb
[done]
> start 192.168.1.7 49154
[done]
> joiner enableall meshcop J01NME
[done]
> state
active
[done]
>
Join Thread Network
Try to Join your Joiner implemented earlier or just use ot commands on a thread node.
>joiner start <PSKd>
#IOT
#network
#cloud
#getting started
#learning
#technology
#fundamentals
#thread
#openthread
#tcp
#nRF
#SDK