Created
August 4, 2024 15:30
-
-
Save maxpromer/e42ddeb673adecc65527ae238cff9435 to your computer and use it in GitHub Desktop.
This file contains 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" | |
#include "OThreadCLI_Util.h" | |
void setup() { | |
Serial.begin(115200); | |
pinMode(9, INPUT_PULLUP); | |
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("udp open"); | |
} | |
bool led_on = false; | |
void loop() { | |
if (OThreadCLI.available()) { | |
String line = OThreadCLI.readStringUntil('\n'); | |
if (line.length() > 0) { | |
Serial.println(line); | |
} | |
} | |
ot_device_role_t role = otGetDeviceRole(); | |
if (role != OT_ROLE_DISABLED && role != OT_ROLE_DETACHED) { | |
if (digitalRead(9) == LOW) { | |
while(digitalRead(9) == LOW) delay(10); | |
led_on = !led_on; | |
OThreadCLI.print("udp send ff05::abcd 20617 "); | |
OThreadCLI.print(led_on ? "ON" : "OFF"); | |
OThreadCLI.println(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment