esp-idf/examples/openthread/ot_cli
2023-03-13 10:27:51 +08:00
..
main openthread: set ot-netif as the default netif for cli example 2023-02-03 16:27:40 +08:00
CMakeLists.txt openthread: use managed component for extension commands 2022-07-18 16:39:30 +08:00
partitions.csv OpenThread: add OpenThread and porting 2021-04-02 14:49:49 +08:00
README.md CI: add openthread build CI for ESP32-H2 2023-02-27 17:51:19 +08:00
sdkconfig.ci.cli esp32h2: renaming esp32h2 to esp32h4 2022-11-08 17:05:33 +08:00
sdkconfig.ci.cli_c6 openthread: add ci for esp32c6 2023-02-02 16:29:19 +08:00
sdkconfig.ci.cli_h2 openthread: add openthread ci for ESP32-H2 2023-03-13 10:27:51 +08:00
sdkconfig.ci.disable_cli openthread: fix compile errors when disabling openthread cli 2023-01-13 22:12:54 +08:00
sdkconfig.defaults openthread: remove port libs 2022-12-30 09:36:41 +00:00

Supported Targets ESP32-C6 ESP32-H2 ESP32-H4

OpenThread Command Line Example

This example demonstrates an OpenThread CLI, with some additional features such as TCP, UDP and Iperf.

How to use example

Hardware Required

To run this example, an ESP32-H4 board is required.

Configure the project

idf.py menuconfig

The example can run with the default configuration.

Build, Flash, and Run

Build the project and flash it to the board, then run monitor tool to view serial output:

idf.py -p PORT build flash monitor

Now you'll get an OpenThread command line shell.

Example Output

The help command will print all of the supported commands.

>  help
I(7058) OPENTHREAD:[INFO]-CLI-----: execute command: help
bbr
bufferinfo
ccathreshold
channel
child
childip
childmax
childsupervision
childtimeout
coap
contextreusedelay
counters
dataset
delaytimermin
diag
discover
dns
domainname
eidcache
eui64
extaddr
extpanid
factoryreset
...

Set Up Network

To run this example, at least two ESP32-H4 boards flashed with this ot_cli example are required.

On the first device, run the following commands:

> factoryreset
... # the device will reboot

> dataset init new
Done
> dataset commit active
Done
> ifconfig up
Done
> thread start
Done

# After some seconds

> state
leader
Done

Now the first device has formed a Thread network as a leader. Get some information which will be used in next steps:

> ipaddr
fdde:ad00:beef:0:0:ff:fe00:fc00
fdde:ad00:beef:0:0:ff:fe00:8000
fdde:ad00:beef:0:a7c6:6311:9c8c:271b
fe80:0:0:0:5c27:a723:7115:c8f8

# Get the Active Dataset
> dataset active -x
0e080000000000010000000300001835060004001fffe00208fe7bb701f5f1125d0708fd75cbde7c6647bd0510b3914792d44f45b6c7d76eb9306eec94030f4f70656e5468726561642d35383332010258320410e35c581af5029b054fc904a24c2b27700c0402a0fff8

On the second device, set the active dataset from leader, and start Thread interface:

> factoryreset
... # the device will reboot

> dataset set active 0e080000000000010000000300001835060004001fffe00208fe7bb701f5f1125d0708fd75cbde7c6647bd0510b3914792d44f45b6c7d76eb9306eec94030f4f70656e5468726561642d35383332010258320410e35c581af5029b054fc904a24c2b27700c0402a0fff8
> ifconfig up
Done
> thread start
Done

# After some seconds

> state
router  # child is also a valid state
Done

The second device has joined the Thread network as a router (or a child).

Extension commands

You can refer to the extension command about the extension commands.

The following examples are supported by ot_cli:

  • TCP and UDP Example
  • Iperf Example