OpenThread
DART-MX8M-MINI OpenThread Overview
DART-MX8M-MINI SoMs ordered with the WBE option feature an IW612 based tri-radio module that supports Wi-Fi 6, Bluetooth/Bluetooth Low Energy 5.2, and 802.15.4.
The 802.15.4 radio coprocessor is managed by OpenThread. Thread is an IPv6-based networking protocol designed for low-power Internet of Things devices in an IEEE802.15.4-2015 wireless mesh network. OpenThread released by Google is an open-source implementation of Thread.
The OpenThread core runs on the host processor (mx8mm) and communicates with the 802.15.4 coprocessor via OpenThread Daemon (ot-daemon) using SPI. Clients can connect to the ot-daemon UNIX socket and communicate using OpenThread CLI as a protocol.
Configuring ot-daemon
ot-daemon is started with the following command:
ot-daemon "spinel+spi://?gpio-int-device=&gpio-int-line=&gpio-reset-device=&gpio-reset-line=&spi-mode=0&spi-speed=1000000&spi-reset-delay=500" &
This is done automatically on boot by Variscite's ot-service and the scripts in /etc/openthread on boot. The service can be managed using systemd:
systemctl <start|stop|restart|status|enable|disable> variscite-ot.service
For example, you can stop and disable the service:
# Stop the service systemctl stop variscite-ot # Start the service systemctl disable variscite-ot
Managing OpenThread using ot-client-iwxxx-spi
ot-client-iwxxx-spi uses the ot-daemon UNIX socket and can be used to manage OpenThread. It requires that ot-daemon is first running. As a reminder, the variscite-ot service starts this by default.
For example, you can read the extended MAC address of your device:
# ot-client-iwxxx-spi extaddr 52fc4e6d3cd98e30 Done
The following sections demonstrate how to create a network on imx8mm-var-dart-a and connect to the network on imx8mm-var-dart-b.
Create OpenThread network using ot-client-iwxxx-spi
Reset to factory settings:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi factoryreset && sleep 2
Initialize a new operational dataset:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi dataset init new Done
Set Channel to 26:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi dataset channel 26 Done
Set PAN ID to 0x1234:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi dataset panid 0x1234 Done
Set Extended PAN ID:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi dataset extpanid dead00beef00cafe Done
Generate a new networkkey (this will change everytime):
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi dataset networkkey c9ca829c5a194f86e141a8721f1f38aa Done
Set Network Name to "ThreadTest":
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi dataset networkname ThreadTest Done
Activate the dataset:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi dataset commit active Done
Enable Network Interface:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi ifconfig up Done
Start Thread:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi thread start Done
Print the State:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi state detached ...wait a few seconds... root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi state leader
Variscite provides an example script in /etc/openthread/variscite-ot-server to create an OpenThread network. It is only meant to be an example to accelerate the development process. For example:
root@# /etc/openthread/variscite-ot-server start State is detached, waiting for state=leader State is detached, waiting for state=leader State is detached, waiting for state=leader State is leader Network key c9ca829c5a194f86e141a8721f1f38aa saved to /tmp/ot-wpan0.key
Connect to OpenThread network using ot-client-iwxxx-spi
Reset to factory defaults:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi factoryreset && sleep 2
Set Channel to 26:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi channel 26 Done
Set PAN ID to 0x1234:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi panid 0x1234 Done
Set Extended PAN ID:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi extpanid dead00beef00cafe Done
Use the Network Key printed by the server:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi networkkey c9ca829c5a194f86e141a8721f1f38aa Done
Set Network Name to "ThreadTest":
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi networkname ThreadTest Done
Enable Network Interface:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi ifconfig up Done
Start Thread:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi thread start Done
Set Client Mode to "Router Eligible" (rn):
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi mode rn
Scan for available networks:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi scan | PAN | MAC Address | Ch | dBm | LQI | +------+------------------+----+-----+-----+ | 1234 | 12c8abdf0f9fe7ee | 26 | -45 | 137 | Done
Print the State:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi state detached ...wait a few seconds... root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi state child
Variscite provides an example script in /etc/openthread/variscite-ot-client to connect to an OpenThread network. It is only meant to be an example to accelerate the development process. For example:
root@imx8mm-var-dart-b:~# /etc/openthread/variscite-ot-client start c9ca829c5a194f86e141a8721f1f38aa Scanning for available networks: | PAN | MAC Address | Ch | dBm | LQI | +------+------------------+----+-----+-----+ | 1234 | 962ba3d53bbc9bb6 | 26 | -46 | 133 | Done State is detached, waiting to connect to the network State is detached, waiting to connect to the network State is detached, waiting to connect to the network State is child, connected to the network
Verify to OpenThread connection
Print neighbor and child tables
Once connected, you can see imx8mm-var-dart-b in imx8mm-var-dart-a's neighbor table:
Print imx8mm-var-dart-b's Extended MAC Address:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi eui64 5affa2feffef2650 Done
Print imx8mm-var-dart-a's neighbor table:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi neighbor table | Role | RLOC16 | Age | Avg RSSI | Last RSSI |R|D|N| Extended MAC | Version | +------+--------+-----+----------+-----------+-+-+-+------------------+---------+ | C | 0x8401 | 0 | -22 | 0 |1|0|1| 56c65fbdfa6e4a80 | 3 |
Done
Print imx8mm-var-dart-a's child table:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi child table | ID | RLOC16 | Timeout | Age | LQ In | C_VN |R|D|N|Ver|CSL|QMsgCnt| Extended MAC | +-----+--------+------------+------------+-------+------+-+-+-+---+---+-------+------------------+ | 3 | 0x8403 | 240 | 186 | 3 | 15 |1|0|1| 3| 0 | 0 | 56c65fbdfa6e4a80 |
Done
Ping imx8mm-var-dart-a from imx8mm-var-dart-b
First, print the IP Addresses of imx8mm-var-dart-a and imx8mm-var-dart-b.
imx8mm-var-dart-a:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi ipaddr fdde:ad00:beef:0:0:ff:fe00:fc00 # Leader's Anycast Locator (ALOC) fdde:ad00:beef:0:0:ff:fe00:0 # Routing Locator (RLOC) fdde:ad00:beef:0:f5f2:aaeb:8a8c:a9fc # Mesh-Local EID (ML-EID) fe80:0:0:0:1442:b824:c762:fa70 # Link-Local Address (LLA)
imx8mm-var-dart-b:
root@imx8mm-var-dart-a:~# ot-client-iwxxx-spi ipaddr fdde:ad00:beef:0:0:ff:fe00:1 # Routing Locator (RLOC) fdde:ad00:beef:0:c177:ef1:a128:7d09 # Mesh-Local EID (ML-EID) fe80:0:0:0:54c6:5fbd:fa6e:4a80 # Link-Local Address (LLA)
Then, ping imx8mm-var-dart-a (Leader) from imx8mm-var-dart-b (Child) using the mesh-local address:
root@imx8mm-var-dart-b:~# ot-client-iwxxx-spi ping fdde:ad00:beef:0:0:ff:fe00:0 16 bytes from fdde:ad00:beef:0:0:ff:fe00:0: icmp_seq=8 hlim=64 time=17ms 1 packets transmitted, 1 packets received. Packet loss = 0.0%. Round-trip min/avg/max = 17/17.0/17 ms. Done