Skip to content

Commit 4175638

Browse files
authored
feat(openthread): improve the example
Update ExtendedRoterNode.ino with more use of API
1 parent 00f0d0a commit 4175638

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

libraries/OpenThread/examples/SimpleThreadNetwork/ExtendedRoterNode/ExtendedRoterNode.ino

+9-10
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include "OThreadCLI_Util.h"
33

44
// Leader node shall use the same Network Key and channel
5-
#define CLI_NETWORK_KEY "dataset networkkey 00112233445566778899aabbccddeeff"
6-
#define CLI_NETWORK_CHANEL "dataset channel 24"
5+
#define CLI_NETWORK_KEY "00112233445566778899aabbccddeeff"
6+
#define CLI_NETWORK_CHANEL "24"
77
bool otStatus = true;
88

99
void setup() {
@@ -12,14 +12,12 @@ void setup() {
1212
Serial.println("Setting up OpenThread Node as Router/Child");
1313
Serial.println("Make sure the Leader Node is already running");
1414

15-
// This sketch will use CLI responses, therefore, it shall always process each CLI return
16-
char resp[256];
17-
otStatus &= otGetRespCmd("dataset clear", resp);
18-
otStatus &= otGetRespCmd(CLI_NETWORK_KEY, resp);
19-
otStatus &= otGetRespCmd(CLI_NETWORK_CHANEL, resp);
20-
otStatus &= otGetRespCmd("dataset commit active", resp);
21-
otStatus &= otGetRespCmd("ifconfig up", resp);
22-
otStatus &= otGetRespCmd("thread start", resp);
15+
otStatus &= otExecCommand("dataset", "clear");
16+
otStatus &= otExecCommand("dataset networkkey", CLI_NETWORK_KEY);
17+
otStatus &= otExecCommand("dataset channel", CLI_NETWORK_CHANEL);
18+
otStatus &= otExecCommand("dataset", "commit active");
19+
otStatus &= otExecCommand("ifconfig", "up");
20+
otStatus &= otExecCommand("thread", "start");
2321

2422
if (!otStatus) {
2523
Serial.println("\r\n\t===> Failed starting Thread Network!");
@@ -41,6 +39,7 @@ void setup() {
4139
// print the PanID using 2 methods
4240

4341
// CLI
42+
char resp[256];
4443
if (otGetRespCmd("panid", resp)) {
4544
Serial.printf("\r\nPanID[using CLI]: %s\r\n", resp);
4645
} else {

0 commit comments

Comments
 (0)