* feat(OThread): Add Library * fix(OpenThread): fixes file list in CMakeLists.txt * fix(openthread): Fixes JSON CI Files * fix(openthread): Fixes JSON CI Files * fix(openthread): Include Openthread guarding * fix(openthread): COAP parametrization * fix(openthread): Include Openthread guarding * fix(openthread): Improves commentaries and code * fix(openthread): Improves code * fix(openthread): Includes StreamString.h * feat(openthread): New Scan Example * feat(openthread): Improved Scan Example * feat(openthread): README.md Initial documentation for ESP3 Arduino OpenThread CLI API. * feat(openthread): helper functions documentation Create helper_functions.md for ESP32 Arduino OpenThread API * fix(openthread): begin end * feat(openthread): onReceice example * fix(openthread): tx queue error * fix(doc): fixing documentation apresentation Fixes the documentation first paragraph in order to make it easier fore reading. It also displays in the very top which SoC are supported by the library. * fix(doc): documentation format * feat(openthread): commentary * fix(openthread): Typo, start/stop console * fix(openthread): library properties * ci(pre-commit): Apply automatic fixes * feat(openthread): formatting text * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: Lucas Saavedra Vaz <32426024+lucasssvaz@users.noreply.github.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
37 lines
1,021 B
C++
37 lines
1,021 B
C++
/*
|
|
OpenThread.begin() will automatically start a node in a Thread Network
|
|
This will demonstrate how to capture the CLI response in a callback function
|
|
The device state shall change from "disabled" to valid Thread states along time
|
|
*/
|
|
|
|
#include "OThreadCLI.h"
|
|
|
|
// reads all the lines sent by CLI, one by one
|
|
// ignores some lines that are just a sequence of \r\n
|
|
void otReceivedLine() {
|
|
String line = "";
|
|
while (OThreadCLI.available() > 0) {
|
|
char ch = OThreadCLI.read();
|
|
if (ch != '\r' && ch != '\n') {
|
|
line += ch;
|
|
}
|
|
}
|
|
// ignores empty lines, usually EOL sequence
|
|
if (line.length() > 0) {
|
|
Serial.print("OpenThread CLI RESP===> ");
|
|
Serial.println(line.c_str());
|
|
}
|
|
}
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
OThreadCLI.begin(); // AutoStart
|
|
OThreadCLI.onReceive(otReceivedLine);
|
|
}
|
|
|
|
void loop() {
|
|
// sends the "state" command to the CLI every second
|
|
// the onReceive() Callback Function will read and process the response
|
|
OThreadCLI.println("state");
|
|
delay(1000);
|
|
}
|