libraries/OpenThread/examples/CLI/SimpleThreadNetwork/LeaderNode/README.md
This example demonstrates how to create an OpenThread Leader node using the CLI Helper Functions API.
The Leader node is the first device in a Thread network that manages the network and assigns router IDs. This example shows how to configure a Leader node manually using OpenThread CLI commands.
| SoC | Thread | Status |
|---|---|---|
| ESP32-H2 | ✅ | Fully supported |
| ESP32-C6 | ✅ | Fully supported |
| ESP32-C5 | ✅ | Fully supported |
CONFIG_OPENTHREAD_ENABLED). This is done automatically when using the ESP32 Arduino OpenThread library.OpenThread.begin(false) which does not automatically start a Thread network, allowing manual configuration.OpenThreadBefore uploading the sketch, you can modify the network configuration:
#define CLI_NETWORK_KEY "dataset networkkey 00112233445566778899aabbccddeeff"
#define CLI_NETWORK_CHANNEL "dataset channel 24"
Important:
LeaderNode.ino sketch in the Arduino IDE.Once the sketch is running, open the Serial Monitor at a baud rate of 115200. You should see output similar to the following:
Setting up OpenThread Node as Leader
=============================================
Thread Node State: Leader
Network Name: OpenThread-ESP
Channel: 24
PanID: 0x1234
Extended PAN ID: dead00beef00cafe
Network Key: 00112233445566778899aabbccddeeff
IP Address: fd00:db8:a0:0:0:ff:fe00:0
Multicast IP Address: ff02::1
Multicast IP Address: ff03::1
...
The Leader node is automatically configured in setup() using the following sequence:
Once the device becomes a Leader, the loop() function displays:
To join other devices to this network:
The LeaderNode example consists of the following main components:
setup():
OpenThread.begin(false) (no auto-start)OThreadCLI.println() - Sends CLI commandsloop():
OpenThread.otGetDeviceRole()otThreadGetNetworkName() - Network nameotLinkGetChannel() - ChannelotLinkGetPanId() - PAN IDotThreadGetExtendedPanId() - Extended PAN IDotThreadGetNetworkKey() - Network keyotIp6GetUnicastAddresses() - Unicast IPv6 addressesotIp6GetMulticastAddresses() - Multicast IPv6 addressesThis example is licensed under the Apache License, Version 2.0.