libraries/OpenThread/examples/CLI/SimpleThreadNetwork/ExtendedRouterNode/README.md
This example demonstrates how to create an OpenThread Router or Child node that joins an existing Thread network, with extended functionality showing both CLI Helper Functions API and native OpenThread API usage.
The example shows how to retrieve network information using both methods and demonstrates error handling.
| 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.otGetRespCmd()) and native OpenThread API (otLinkGetPanId()) usageOpenThreadBefore uploading the sketch, configure the network parameters to match the Leader node:
#define CLI_NETWORK_KEY "00112233445566778899aabbccddeeff"
#define CLI_NETWORK_CHANNEL "24"
Important:
ExtendedRouterNode.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 Router/Child
Make sure the Leader Node is already running
PanID[using CLI]: 0x1234
PanID[using OT API]: 0x1234
Thread NetworkInformation:
---------------------------
Role: Router
RLOC16: 0xfc00
Network Name: OpenThread-ESP
Channel: 24
PAN ID: 0x1234
Extended PAN ID: dead00beef00cafe
Network Key: 00112233445566778899aabbccddeeff
Mesh Local EID: fd00:db8:a0:0:0:ff:fe00:fc00
Leader RLOC: fd00:db8:a0:0:0:ff:fe00:0
Node RLOC: fd00:db8:a0:0:0:ff:fe00:fc00
---------------------------
The Extended Router/Child node is automatically configured in setup() using the following sequence:
This example demonstrates two ways to access OpenThread information:
otGetRespCmd("panid", resp) to get PAN ID via CLIotLinkGetPanId(esp_openthread_get_instance()) to get PAN ID directlyBoth methods should return the same value, demonstrating API equivalence.
Once the device joins the network, the loop() function displays comprehensive network information using OpenThread.otPrintNetworkInformation(), including:
The ExtendedRouterNode example consists of the following main components:
setup():
OpenThread.begin(false) (no auto-start)otExecCommand() - Executes CLI commands with error handlingloop():
OpenThread.otPrintNetworkInformation()This example is licensed under the Apache License, Version 2.0.