Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
9e26803
feat(OThread): Add Library
SuGlider Jun 20, 2024
fb2a502
Merge branch 'master' into OpenThread
SuGlider Jun 20, 2024
1a66bc1
fix(OpenThread): fixes file list in CMakeLists.txt
SuGlider Jun 20, 2024
827b72c
Merge branch 'OpenThread' of https://github.com/SuGlider/arduino-esp3…
SuGlider Jun 20, 2024
54f043a
fix(openthread): Fixes JSON CI Files
SuGlider Jun 20, 2024
69f4fce
Merge branch 'master' into OpenThread
SuGlider Jun 20, 2024
3e11343
fix(openthread): Fixes JSON CI Files
SuGlider Jun 20, 2024
1b2530d
fix(openthread): Include Openthread guarding
SuGlider Jun 20, 2024
739b77c
fix(openthread): COAP parametrization
SuGlider Jun 20, 2024
3687c5f
fix(openthread): Include Openthread guarding
SuGlider Jun 20, 2024
bbece1c
fix(openthread): Improves commentaries and code
SuGlider Jun 20, 2024
5c677be
fix(openthread): Improves code
SuGlider Jun 20, 2024
436a7ff
fix(openthread): Includes StreamString.h
SuGlider Jun 20, 2024
378f993
Merge branch 'master' into OpenThread
SuGlider Jun 20, 2024
ce46f4a
feat(openthread): New Scan Example
SuGlider Jun 20, 2024
7fece86
feat(openthread): Improved Scan Example
SuGlider Jun 20, 2024
001ae42
feat(openthread): README.md
SuGlider Jun 21, 2024
198e6e8
feat(openthread): helper functions documentation
SuGlider Jun 21, 2024
28d7c44
fix(openthread): begin end
SuGlider Jun 22, 2024
3507a9d
feat(openthread): onReceice example
SuGlider Jun 23, 2024
f9d1e55
Merge branch 'OpenThread' of https://github.com/SuGlider/arduino-esp3…
SuGlider Jun 23, 2024
176f92b
fix(openthread): tx queue error
SuGlider Jun 23, 2024
6b0b9af
fix(doc): fixing documentation apresentation
SuGlider Jun 23, 2024
4ec1397
fix(doc): documentation format
SuGlider Jun 24, 2024
2aaa575
feat(openthread): commentary
SuGlider Jun 24, 2024
46cf9aa
Merge branch 'master' into OpenThread
lucasssvaz Jun 24, 2024
eb7b019
fix(openthread): Typo, start/stop console
SuGlider Jun 24, 2024
919bf79
Merge branch 'OpenThread' of https://github.com/SuGlider/arduino-esp3…
SuGlider Jun 24, 2024
b60a354
fix(openthread): library properties
SuGlider Jun 24, 2024
11ec1d1
ci(pre-commit): Apply automatic fixes
lucasssvaz Jun 24, 2024
55f9378
feat(openthread): formatting text
SuGlider Jun 24, 2024
81d62e9
ci(pre-commit): Apply automatic fixes
pre-commit-ci-lite[bot] Jun 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(openthread): New Scan Example
  • Loading branch information
SuGlider committed Jun 20, 2024
commit ce46f4a66d37f364306584b663680e02022b74cc
68 changes: 68 additions & 0 deletions libraries/OpenThread/examples/ThreadScan/ThreadScan.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
OpenThread.begin(true) will automatically start a node in a Thread Network
Full scanning requires the thread node to be at least in Child state.

This will scan the IEEE 802.14.5 devices in the local area using CLI "scan" command
As soon as this device turns into a Child, Router or Leader, it will be able to
scan for Local Thread Networks as well.

*/

#include "OThreadCLI.h"
#include "OThreadCLI_Util.h"

bool otPrintRespCLI(const char *cmd, Stream &output) {
char cliResp[256];
if (cmd == NULL) {
return true;
}
OThreadCLI.println(cmd);
while (1) {
size_t len = OThreadCLI.readBytesUntil('\n', cliResp, sizeof(cliResp));
if (len == 0) {
return false; // timeout for reading a response from CLI
}
// clip it on EOL
for (int i = 0; i < len; i++) {
if (cliResp[i] == '\r' || cliResp[i] == '\n') {
cliResp[i] = '\0';
}
}
if (!strncmp(cliResp, "Done", 4)) {
return true; // finished with success
}
if (!strncmp(cliResp, "Error", 4)) {
return false; // the CLI command or its arguments are not valid
}
output.println(cliResp);
}
}

void setup() {
Serial.begin(115200);
OThreadCLI.begin(true); // For scanning, AutoStart must be active, any setup
OThreadCLI.setTimeout(10000); // 10 seconds for reading a line from CLI - scanning takes time
Serial.println();
Serial.println("This sketch will continuosly scan the Thread Local Network and all devices IEEE 802.15.4 compatible");
}

void loop() {
Serial.println();
Serial.println("Scanning for near by IEEE 802.15.4 devices:");
// 802.15.4 Scan just need a previous OThreadCLI.begin() to tun on the 802.15.4 stack
if (!otPrintRespCLI("scan", Serial)) {
Serial.println("802.15.4 Scan Failed...");
}
delay(5000);
if (otGetDeviceRole() < OT_ROLE_CHILD) {
Serial.println();
Serial.println("This device has not started Thread yet, bypassing Discovery Scan");
return;
}
Serial.println();
Serial.println("Scanning - MLE Discover:");
if (!otPrintRespCLI("discover", Serial)) {
Serial.println("MLE Discover Failed...");
}
delay(5000);
}
9 changes: 9 additions & 0 deletions libraries/OpenThread/examples/ThreadScan/ci.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"targets": {
"esp32": false,
"esp32c2": false,
"esp32c3": false,
"esp32s2": false,
"esp32s3": false
}
}