Last active
August 4, 2024 14:58
-
-
Save maxpromer/056c5ebf07c41c05e63033188e4ff0f7 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" | |
#include "OThreadCLI_Util.h" | |
void setup() { | |
Serial.begin(115200); | |
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"); | |
} | |
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) { | |
static unsigned long timer = 0; | |
if ((millis() - timer) >= 2000) { | |
timer = millis(); | |
OThreadCLI.println("udp send ff05::abcd 20617 ESP"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment