|
|
@@ -1,14 +1,15 @@
|
|
|
-# OpenThread command line example
|
|
|
+| Supported Targets | ESP32-H2 |
|
|
|
+| ----------------- | -------- |
|
|
|
|
|
|
-## Overview
|
|
|
+# OpenThread Command Line Example
|
|
|
|
|
|
-This example demonstrates a [basic OpenThread command line](https://github.com/openthread/openthread/blob/master/src/cli/README.md).
|
|
|
+This example demonstrates an [OpenThread CLI](https://github.com/openthread/openthread/blob/master/src/cli/README.md), with some additional features such as TCP, UDP and Iperf.
|
|
|
|
|
|
## How to use example
|
|
|
|
|
|
-### Hardware connection
|
|
|
+### Hardware Required
|
|
|
|
|
|
-To run this example, it's used to use an DevKit C board and connect PIN4 and PIN5 to the UART TX and RX port of another 15.4 capable radio co-processor ([RCP](https://openthread.io/platforms/co-processor?hl=en))
|
|
|
+To run this example, an ESP32-H2 board is required.
|
|
|
|
|
|
### Configure the project
|
|
|
|
|
|
@@ -26,56 +27,57 @@ Build the project and flash it to the board, then run monitor tool to view seria
|
|
|
idf.py -p PORT build flash monitor
|
|
|
```
|
|
|
|
|
|
-Now you'll get an interactive OpenThread command line shell.
|
|
|
+Now you'll get an OpenThread command line shell.
|
|
|
|
|
|
-## Example Output
|
|
|
+### Example Output
|
|
|
|
|
|
+The `help` command will print all of the supported commands.
|
|
|
```bash
|
|
|
-I (1540) OPENTHREAD: [INFO]-PLAT----: RCP reset: RESET_POWER_ON
|
|
|
-I (1610) OPENTHREAD: [NOTE]-PLAT----: RCP API Version: 3
|
|
|
-I (1840) OPENTHREAD: [INFO]-CORE----: Non-volatile: Read NetworkInfo {rloc:0x7404, extaddr:aee4a5cc7ed1ad88, role:Child, mode:0x0f, version:2, keyseq:0x0, ...
|
|
|
-I (1850) OPENTHREAD: [INFO]-CORE----: Non-volatile: ... pid:0x1161bcdc, mlecntr:0x5a17, maccntr:0x5a91, mliid:33158c466ab576d4}
|
|
|
-I (1900) OPENTHREAD: [INFO]-CORE----: Non-volatile: Read ParentInfo {extaddr:36505631b12ea5e3, version:2}
|
|
|
-I (1900) OPENTHREAD: [INFO]-CORE----: Notifier: StateChanged (0x1007c300) [KeySeqCntr NetData Channel PanId NetName ExtPanId MstrKey ActDset]
|
|
|
+> 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-H2 boards flashed with this ot_cli example are required.
|
|
|
+
|
|
|
+On the first device, run the following commands:
|
|
|
+```bash
|
|
|
+> factoryreset
|
|
|
+... # the device will reboot
|
|
|
|
|
|
-> ifconfig up
|
|
|
-I (11320) OPENTHREAD: [INFO]-CLI-----: execute command: ifconfig up
|
|
|
-Done
|
|
|
-I (11340) OPENTHREAD: [INFO]-CORE----: Notifier: StateChanged (0x01001009) [Ip6+ LLAddr Ip6Mult+ NetifState]
|
|
|
> dataset init new
|
|
|
-I (105650) OPENTHREAD: [INFO]-CLI-----: execute command: dataset init new
|
|
|
Done
|
|
|
-
|
|
|
-> dataset
|
|
|
-I (107460) OPENTHREAD: [INFO]-CLI-----: execute command: dataset
|
|
|
-Active Timestamp: 1
|
|
|
-Channel: 14
|
|
|
-Channel Mask: 0x07fff800
|
|
|
-Ext PAN ID: d9d69bf6535735ec
|
|
|
-Mesh Local Prefix: fd73:192f:f27:2a5c::/64
|
|
|
-Master Key: 7ad0ec87abbd8c41f07d004922b480bf
|
|
|
-Network Name: OpenThread-a5fe
|
|
|
-PAN ID: 0xa5fe
|
|
|
-PSKc: ef028c933febdeb226f6681cc780272a
|
|
|
-Security Policy: 672, onrcb
|
|
|
-Done
|
|
|
-
|
|
|
> dataset commit active
|
|
|
-I (134350) OPENTHREAD: [INFO]-CLI-----: execute command: dataset commit active
|
|
|
-I (134350) OPENTHREAD: [INFO]-MESH-CP-: Active dataset set
|
|
|
Done
|
|
|
-I (134380) OPENTHREAD: [INFO]-CORE----: Notifier: StateChanged (0x101fc110) [MLAddr KeySeqCntr Channel PanId NetName ExtPanId MstrKey PSKc SecPolicy ...
|
|
|
-I (134390) OPENTHREAD: [INFO]-CORE----: Notifier: StateChanged (0x101fc110) ... ActDset]
|
|
|
-
|
|
|
->thread start
|
|
|
-I (177250) OPENTHREAD: [INFO]-CLI-----: execute command: thread start
|
|
|
-I (177250) OPENTHREAD: [NOTE]-MLE-----: Role Disabled -> Detached
|
|
|
-I (177280) OPENTHREAD: [INFO]-CORE----: Non-volatile: Read NetworkInfo {rloc:0x7404, extaddr:aee4a5cc7ed1ad88, role:Child, mode:0x0f, version:2, keyseq:0x0, ...
|
|
|
-I (177290) OPENTHREAD: [INFO]-CORE----: Non-volatile: ... pid:0x1161bcdc, mlecntr:0x5a17, maccntr:0x5a91, mliid:33158c466ab576d4}
|
|
|
-I (194054) OPENTHREAD: [INFO]-CORE----: Non-volatile: Saved NetworkInfo {rloc:0x7404, extaddr:aee4a5cc7ed1ad88, role:Child, mode:0x0f, version:2, keyseq:0x0, ...
|
|
|
-I (194064) OPENTHREAD: [INFO]-CORE----: Non-volatile: ... pid:0x1161bcdc, mlecntr:0x5e00, maccntr:0x5e79, mliid:33158c466ab576d4}
|
|
|
-I (194074) OPENTHREAD: [INFO]-MLE-----: Send Child Update Request to parent (fe80:0:0:0:3450:5631:b12e:a5e3)
|
|
|
-Done
|
|
|
+> ifconfig up
|
|
|
+Done
|
|
|
+> thread start
|
|
|
+Done
|
|
|
|
|
|
# After some seconds
|
|
|
|
|
|
@@ -83,195 +85,80 @@ Done
|
|
|
leader
|
|
|
Done
|
|
|
```
|
|
|
-
|
|
|
-## Example1: Set up network
|
|
|
-
|
|
|
-You need to prepare two esp32h2(or two ESP devices each connected to a 15.4 RCP) and flashed with this example.
|
|
|
-
|
|
|
-### Step 1 Configure the project
|
|
|
-
|
|
|
+Now the first device has formed a Thread network as a leader. Get some information which will be used in next steps:
|
|
|
```bash
|
|
|
-idf.py menuconfig
|
|
|
-```
|
|
|
-
|
|
|
-### Step 2 Build, Flash, and Run
|
|
|
+> 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
|
|
|
```
|
|
|
-idf.py -p PORT flash monitor
|
|
|
-```
|
|
|
-
|
|
|
-### Step 3 Set up network
|
|
|
|
|
|
-On the first device, run:
|
|
|
+On the second device, set the active dataset from leader, and start Thread interface:
|
|
|
```bash
|
|
|
-> extaddr 166e0a0000000001
|
|
|
-Done
|
|
|
-> dataset channel 17
|
|
|
-Done
|
|
|
-> dataset panid 0xface
|
|
|
-Done
|
|
|
-> dataset extpanid 000db80000000000
|
|
|
-Done
|
|
|
-> dataset networkname GRL
|
|
|
-Done
|
|
|
-> dataset masterkey 00112233445566778899aabbccddeeff
|
|
|
-Done
|
|
|
-> dataset meshlocalprefix FD00:0DB8:0000:0000::
|
|
|
-Done
|
|
|
-> dataset pskc 00000000000000000000000000000000
|
|
|
-Done
|
|
|
-> dataset activetimestamp 1
|
|
|
-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, on the second device run:
|
|
|
+> factoryreset
|
|
|
+... # the device will reboot
|
|
|
|
|
|
-```bash
|
|
|
-> extaddr 166e0a0000000002
|
|
|
-Done
|
|
|
-> dataset channel 17
|
|
|
-Done
|
|
|
-> dataset panid 0xface
|
|
|
-Done
|
|
|
-> dataset extpanid 000db80000000000
|
|
|
-Done
|
|
|
-> dataset networkname GRL
|
|
|
-Done
|
|
|
-> dataset masterkey 00112233445566778899aabbccddeeff
|
|
|
-Done
|
|
|
-> dataset meshlocalprefix FD00:0DB8:0000:0000::
|
|
|
-Done
|
|
|
-> dataset pskc 00000000000000000000000000000000
|
|
|
-Done
|
|
|
-> dataset activetimestamp 1
|
|
|
-Done
|
|
|
-> dataset commit active
|
|
|
-Done
|
|
|
+> dataset set active 0e080000000000010000000300001835060004001fffe00208fe7bb701f5f1125d0708fd75cbde7c6647bd0510b3914792d44f45b6c7d76eb9306eec94030f4f70656e5468726561642d35383332010258320410e35c581af5029b054fc904a24c2b27700c0402a0fff8
|
|
|
> ifconfig up
|
|
|
Done
|
|
|
> thread start
|
|
|
Done
|
|
|
|
|
|
- # After some seconds
|
|
|
+# 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).
|
|
|
|
|
|
-Now the second device has joined the Thread network and acting as a router (or a child).
|
|
|
-
|
|
|
-## Example2: TCP/UDP server and client
|
|
|
-
|
|
|
-You need to prepare two ESP devices each connected to a 15.4 RCP and flashed with this example.
|
|
|
-
|
|
|
-### Step 1 Configure the project and Set up network
|
|
|
-
|
|
|
-```bash
|
|
|
-idf.py menuconfig
|
|
|
-```
|
|
|
-Enable the operation: Example Configuration -> Enable custom command in ot-cli
|
|
|
-
|
|
|
-After configuring the project project, you should follow 'Example1' to set up network.
|
|
|
-
|
|
|
-
|
|
|
-### Step 2 Set up tcp/udp socket server and client
|
|
|
-
|
|
|
-In leader device, run this command in command line shell.
|
|
|
+## TCP and UDP Example
|
|
|
|
|
|
+On the leader device, start a TCP or UDP server:
|
|
|
```bash
|
|
|
-# for setup a tcp server
|
|
|
> tcpsockserver
|
|
|
-
|
|
|
-# for setup an udp server
|
|
|
-> udpsockserver
|
|
|
-```
|
|
|
-
|
|
|
-Then run this command to get the leader IPv6 address.
|
|
|
-
|
|
|
-```bash
|
|
|
-> ipaddr
|
|
|
-fd00:db8:0:0:0:ff:fe00:fc00
|
|
|
-fd00:db8:0:0:0:ff:fe00:ac00
|
|
|
-fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
-fe80:0:0:0:146e:a00:0:1
|
|
|
+Done
|
|
|
+I (1310225) ot_socket: Socket created
|
|
|
+I (1310225) ot_socket: Socket bound, port 12345
|
|
|
+I (1310225) ot_socket: Socket listening, timeout is 30 seconds
|
|
|
```
|
|
|
-
|
|
|
-In router device, run this command to set up a socket client in command line shell.
|
|
|
-
|
|
|
+or (UDP Server)
|
|
|
```bash
|
|
|
-# for setup a tcp client
|
|
|
-> tcpsockclient fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
-
|
|
|
-# for setup an udp client
|
|
|
-> udpsockclient fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
+> udpsockserver
|
|
|
+Done
|
|
|
+I (1339815) ot_socket: Socket created
|
|
|
+I (1339815) ot_socket: Socket bound, port 54321
|
|
|
+I (1339815) ot_socket: Waiting for data, timeout is 30 seconds
|
|
|
+Done
|
|
|
```
|
|
|
|
|
|
-You will get
|
|
|
-
|
|
|
+On router device, start a TCP or UDP client (replace with the leader's IPv6 address):
|
|
|
```bash
|
|
|
-# in leader device
|
|
|
-
|
|
|
-> tcpsockserver
|
|
|
-I(173437) OPENTHREAD:[INFO]-CLI-----: execute command: tcpsockserver
|
|
|
-> I (173437) ot_secket: Socket created
|
|
|
-I (173437) ot_secket: Socket bound, port 12345
|
|
|
-I (173457) ot_secket: Socket listening, timeout is 30 seconds
|
|
|
-I(175007) OPENTHREAD:[INFO]-MLE-----: Send Advertisement (ff02:0:0:0:0:0:0:1)
|
|
|
-
|
|
|
-......
|
|
|
-
|
|
|
-I (182187) ot_secket: Received 28 bytes from client:
|
|
|
-I (182187) ot_secket: This message is from client
|
|
|
-I (182187) ot_secket: Socket accepted ip address: FD00:DB8::498:DDB:EC7:49DC
|
|
|
-I (182189) ot_secket: Socket server is closed.
|
|
|
-
|
|
|
-# in router device
|
|
|
-
|
|
|
-> tcpsockclient fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
-I(37731) OPENTHREAD:[INFO]-CLI-----: execute command: tcpsockclient fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
-> I (37741) ot_secket: Socket created, connecting to b80d00fd:0:4acb4a28:422a3bcb:12345
|
|
|
-I(37751) OPENTHREAD:[INFO]-ARP-----: Sending address query for fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
-
|
|
|
-......
|
|
|
-
|
|
|
-I (38171) ot_secket: Successfully connected
|
|
|
-
|
|
|
-......
|
|
|
-
|
|
|
-I (38321) ot_secket: Received 28 bytes from fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
-I (38321) ot_secket: This message is from server
|
|
|
-I (38323) ot_secket: Socket client is closed.
|
|
|
+> tcpsockclient fdde:ad00:beef:0:a7c6:6311:9c8c:271b
|
|
|
+Done
|
|
|
+ot_socket: Socket created, connecting to fdde:ad00:beef:0:a7c6:6311:9c8c:271b:12345
|
|
|
+ot_socket: Successfully connected
|
|
|
+...
|
|
|
```
|
|
|
-
|
|
|
-## Example3 iperf:
|
|
|
-
|
|
|
-### Step 1 Configure the project and Set up network
|
|
|
-
|
|
|
+or (UDP Client)
|
|
|
```bash
|
|
|
-idf.py menuconfig
|
|
|
+> udpsockclient fdde:ad00:beef:0:a7c6:6311:9c8c:271b
|
|
|
+Done
|
|
|
+ot_socket: Socket created, sending to fdde:ad00:beef:0:a7c6:6311:9c8c:271b:54321
|
|
|
+ot_socket: Message sent
|
|
|
+...
|
|
|
```
|
|
|
-Enable the operation: Openthread -> Enable custom command in ot-cli
|
|
|
-
|
|
|
-After configuring the project project, you should follow 'Example1' to set up network.
|
|
|
|
|
|
-### Step 2 Iperf test:
|
|
|
+### Iperf Example
|
|
|
|
|
|
-Run this command for iperf help:
|
|
|
+Print the iperf help:
|
|
|
```bash
|
|
|
iperf
|
|
|
-I(272113) OPENTHREAD:[INFO]-CLI-----: execute command: iperf
|
|
|
---iperf parameter---
|
|
|
-s : server mode, only receive
|
|
|
-u : upd mode
|
|
|
@@ -287,32 +174,56 @@ create a udp client : iperf -c <addr> -u -i 3 -t 60 -p 5001 -l 512
|
|
|
Done
|
|
|
```
|
|
|
|
|
|
-In leader device, run this command to get the leader IPv6 address.
|
|
|
-
|
|
|
+On the leader device, start iperf TCP or UDP server:
|
|
|
```bash
|
|
|
-> ipaddr
|
|
|
-fd00:db8:0:0:0:ff:fe00:fc00
|
|
|
-fd00:db8:0:0:0:ff:fe00:ac00
|
|
|
-fd00:db8:0:0:284a:cb4a:cb3b:2a42
|
|
|
-fe80:0:0:0:146e:a00:0:1
|
|
|
+> iperf -V -s -i 3 -p 5001 -t 20
|
|
|
+i:3
|
|
|
+dp:5001
|
|
|
+sp:5001
|
|
|
+t:20
|
|
|
+Done
|
|
|
```
|
|
|
-
|
|
|
-Then run this command in command line shell.
|
|
|
-
|
|
|
+or (UDP Server)
|
|
|
```bash
|
|
|
-# for setting up an iperf tcp server
|
|
|
-> iperf -V -s -i 3 -p 5001 -t 20
|
|
|
-
|
|
|
-# for setting up an iperf udp server
|
|
|
> iperf -V -s -u -i 3 -p 5001 -t 20
|
|
|
+i:3
|
|
|
+dp:5001
|
|
|
+sp:5001
|
|
|
+t:20
|
|
|
+Done
|
|
|
```
|
|
|
|
|
|
-In router device, run this command in command line shell.
|
|
|
+On the router device, start iperf TCP or UDP client:
|
|
|
|
|
|
```bash
|
|
|
-# for setting up an iperf tcp client
|
|
|
-> iperf -V -c fd00:db8:0:0:284a:cb4a:cb3b:2a42 -i 1 -t 14 -p 5001 -l 512
|
|
|
-
|
|
|
-# for setting up an iperf udp client
|
|
|
-> iperf -V -c fd00:db8:0:0:284a:cb4a:cb3b:2a42 -u -i 1 -t 14 -p 5001 -l 512
|
|
|
+> iperf -V -c fdde:ad00:beef:0:a7c6:6311:9c8c:271b -i 1 -t 5 -p 5001 -l 85
|
|
|
+ip:fdde:ad00:beef:0:a7c6:6311:9c8c:271b
|
|
|
+i:1
|
|
|
+t:5
|
|
|
+dp:5001
|
|
|
+sp:5001
|
|
|
+Done
|
|
|
+ Interval Bandwidth
|
|
|
+ 0- 1 sec 0.05 Mbits/sec
|
|
|
+ 1- 2 sec 0.05 Mbits/sec
|
|
|
+ 2- 3 sec 0.05 Mbits/sec
|
|
|
+ 3- 4 sec 0.05 Mbits/sec
|
|
|
+ 4- 5 sec 0.05 Mbits/sec
|
|
|
+ 0- 5 sec 0.05 Mbits/sec
|
|
|
+```
|
|
|
+or (UDP Client)
|
|
|
+```bash
|
|
|
+> iperf -V -c fdde:ad00:beef:0:a7c6:6311:9c8c:271b -u -i 1 -t 5 -p 5001 -l 85
|
|
|
+ip:fdde:ad00:beef:0:a7c6:6311:9c8c:271b
|
|
|
+i:1
|
|
|
+t:5
|
|
|
+dp:5001
|
|
|
+sp:5001
|
|
|
+Done
|
|
|
+ 0- 1 sec 0.05 Mbits/sec
|
|
|
+ 1- 2 sec 0.05 Mbits/sec
|
|
|
+ 2- 3 sec 0.05 Mbits/sec
|
|
|
+ 3- 4 sec 0.05 Mbits/sec
|
|
|
+ 4- 5 sec 0.05 Mbits/sec
|
|
|
+ 0- 5 sec 0.05 Mbits/sec
|
|
|
```
|