Created
August 4, 2024 15:30
-
-
Save maxpromer/b0aa7b3760a5fce26ce511153f27ca4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "OThreadCLI.h" | |
void setup() { | |
Serial.begin(115200); | |
neopixelWrite(8, 0, 0, 0); | |
OThreadCLI.begin(false); // No AutoStart - fresh start | |
// Start Console | |
Serial.println("OpenThread CLI started - type 'help' for a list of commands."); | |
OThreadCLI.startConsole(Serial); | |
// Send Command | |
OThreadCLI.println("dataset init new"); | |
OThreadCLI.println("dataset networkkey 573f031c08ef326c288f3f33f791c401"); | |
OThreadCLI.println("dataset networkname OpenThread"); | |
OThreadCLI.println("dataset panid 0x550c"); | |
OThreadCLI.println("dataset extpanid fa283d35a4c0cf9d"); | |
OThreadCLI.println("dataset meshlocalprefix fdff:e519:cd12:ec6::"); | |
OThreadCLI.println("dataset channel 12"); | |
OThreadCLI.println("dataset commit active"); | |
OThreadCLI.println("ifconfig up"); | |
OThreadCLI.println("thread start"); | |
OThreadCLI.println("ipmaddr add ff05::abcd"); | |
OThreadCLI.println("udp open"); | |
OThreadCLI.println("udp bind :: 20617"); | |
} | |
void loop() { | |
String line = OThreadCLI.readStringUntil('\n'); | |
if (line.length() > 0) { | |
Serial.println(line); | |
if (line.indexOf("ON") > 0) { | |
Serial.println("ON LED!"); | |
neopixelWrite(8, 0, 255, 0); | |
} else { | |
Serial.println("OFF LED!"); | |
neopixelWrite(8, 0, 0, 0); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment