Skip to content

Commit 11ec1d1

Browse files
committed
ci(pre-commit): Apply automatic fixes
1 parent b60a354 commit 11ec1d1

File tree

21 files changed

+131
-150
lines changed

21 files changed

+131
-150
lines changed

Diff for: libraries/OpenThread/README.md

-2
Original file line numberDiff line numberDiff line change
@@ -70,5 +70,3 @@ extern OpenThreadCLI OThreadCLI;
7070
- `setTxBufferSize(size_t tx_queue_len)`: Sets the transmit buffer size (default is 256 bytes).
7171
- `setRxBufferSize(size_t rx_queue_len)`: Sets the receive buffer size (default is 1024 bytes).
7272
- `write(uint8_t)`, `available()`, `read()`, `peek()`, `flush()`: Standard Stream methods implementation for OpenThread CLI object.
73-
74-

Diff for: libraries/OpenThread/examples/COAP/coap_lamp/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"esp32s2": false,
77
"esp32s3": false
88
}
9-
}
9+
}

Diff for: libraries/OpenThread/examples/COAP/coap_lamp/coap_lamp.ino

+17-28
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,25 @@
11
#include "OThreadCLI.h"
22
#include "OThreadCLI_Util.h"
33

4-
#define OT_CHANNEL "24"
5-
#define OT_NETWORK_KEY "00112233445566778899aabbccddeeff"
6-
#define OT_MCAST_ADDR "ff05::abcd"
4+
#define OT_CHANNEL "24"
5+
#define OT_NETWORK_KEY "00112233445566778899aabbccddeeff"
6+
#define OT_MCAST_ADDR "ff05::abcd"
77
#define OT_COAP_RESOURCE_NAME "Lamp"
88

99
const char *otSetupLeader[] = {
1010
// clear/disable all
11-
"coap", "stop",
12-
"thread", "stop",
13-
"ifconfig", "down",
14-
"dataset", "clear",
11+
"coap", "stop", "thread", "stop", "ifconfig", "down", "dataset", "clear",
1512
// set dataset
16-
"dataset", "init new",
17-
"dataset channel", OT_CHANNEL,
18-
"dataset networkkey", OT_NETWORK_KEY,
19-
"dataset", "commit active",
13+
"dataset", "init new", "dataset channel", OT_CHANNEL, "dataset networkkey", OT_NETWORK_KEY, "dataset", "commit active",
2014
// network start
21-
"ifconfig", "up",
22-
"thread", "start"
15+
"ifconfig", "up", "thread", "start"
2316
};
2417

2518
const char *otCoapLamp[] = {
2619
// create a multicast IPv6 Address for this device
2720
"ipmaddr add", OT_MCAST_ADDR,
2821
// start and create a CoAP resource
29-
"coap", "start",
30-
"coap resource", OT_COAP_RESOURCE_NAME,
31-
"coap set", "0"
22+
"coap", "start", "coap resource", OT_COAP_RESOURCE_NAME, "coap set", "0"
3223
};
3324

3425
bool otDeviceSetup(const char **otSetupCmds, uint8_t nCmds1, const char **otCoapCmds, uint8_t nCmds2, ot_device_role_t expectedRole) {
@@ -47,7 +38,7 @@ bool otDeviceSetup(const char **otSetupCmds, uint8_t nCmds1, const char **otCoap
4738
}
4839
Serial.println("OpenThread started.\r\nWaiting for activating correct Device Role.");
4940
// wait for the expected Device Role to start
50-
uint8_t tries = 24; // 24 x 2.5 sec = 1 min
41+
uint8_t tries = 24; // 24 x 2.5 sec = 1 min
5142
while (tries && otGetDeviceRole() != expectedRole) {
5243
Serial.print(".");
5344
delay(2500);
@@ -72,22 +63,20 @@ bool otDeviceSetup(const char **otSetupCmds, uint8_t nCmds1, const char **otCoap
7263
}
7364
Serial.println("OpenThread setup done. Node is ready.");
7465
// all fine! LED goes Green
75-
neopixelWrite(RGB_BUILTIN, 0, 64, 8); // GREEN ... Lamp is ready!
66+
neopixelWrite(RGB_BUILTIN, 0, 64, 8); // GREEN ... Lamp is ready!
7667
return true;
7768
}
7869

7970
void setupNode() {
8071
// tries to set the Thread Network node and only returns when succeded
8172
bool startedCorrectly = false;
8273
while (!startedCorrectly) {
83-
startedCorrectly |= otDeviceSetup(otSetupLeader, sizeof(otSetupLeader) / sizeof(char *) / 2,
84-
otCoapLamp, sizeof(otCoapLamp) / sizeof(char *) / 2,
85-
OT_ROLE_LEADER);
74+
startedCorrectly |=
75+
otDeviceSetup(otSetupLeader, sizeof(otSetupLeader) / sizeof(char *) / 2, otCoapLamp, sizeof(otCoapLamp) / sizeof(char *) / 2, OT_ROLE_LEADER);
8676
if (!startedCorrectly) {
8777
Serial.println("Setup Failed...\r\nTrying again...");
8878
}
8979
}
90-
9180
}
9281

9382
// this function is used by the Lamp mode to listen for CoAP frames from the Switch Node
@@ -107,16 +96,16 @@ void otCOAPListen() {
10796
log_i("CoAP PUT [%s]\r\n", payload == '0' ? "OFF" : "ON");
10897
if (payload == '0') {
10998
for (int16_t c = 248; c > 16; c -= 8) {
110-
neopixelWrite(RGB_BUILTIN, c, c, c); // ramp down
99+
neopixelWrite(RGB_BUILTIN, c, c, c); // ramp down
111100
delay(5);
112101
}
113-
neopixelWrite(RGB_BUILTIN, 0, 0, 0); // Lamp Off
102+
neopixelWrite(RGB_BUILTIN, 0, 0, 0); // Lamp Off
114103
} else {
115104
for (int16_t c = 16; c < 248; c += 8) {
116-
neopixelWrite(RGB_BUILTIN, c, c, c); // ramp up
105+
neopixelWrite(RGB_BUILTIN, c, c, c); // ramp up
117106
delay(5);
118107
}
119-
neopixelWrite(RGB_BUILTIN, 255, 255, 255); // Lamp On
108+
neopixelWrite(RGB_BUILTIN, 255, 255, 255); // Lamp On
120109
}
121110
}
122111
}
@@ -126,8 +115,8 @@ void setup() {
126115
Serial.begin(115200);
127116
// LED starts RED, indicating not connected to Thread network.
128117
neopixelWrite(RGB_BUILTIN, 64, 0, 0);
129-
OThreadCLI.begin(false); // No AutoStart is necessary
130-
OThreadCLI.setTimeout(250); // waits 250ms for the OpenThread CLI response
118+
OThreadCLI.begin(false); // No AutoStart is necessary
119+
OThreadCLI.setTimeout(250); // waits 250ms for the OpenThread CLI response
131120
setupNode();
132121
// LED goes Green when all is ready and Red when failed.
133122
}

Diff for: libraries/OpenThread/examples/COAP/coap_switch/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"esp32s2": false,
77
"esp32s3": false
88
}
9-
}
9+
}

Diff for: libraries/OpenThread/examples/COAP/coap_switch/coap_switch.ino

+22-27
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,30 @@
11
#include "OThreadCLI.h"
22
#include "OThreadCLI_Util.h"
33

4-
#define USER_BUTTON 9 // C6/H2 Boot button
5-
#define OT_CHANNEL "24"
6-
#define OT_NETWORK_KEY "00112233445566778899aabbccddeeff"
7-
#define OT_MCAST_ADDR "ff05::abcd"
4+
#define USER_BUTTON 9 // C6/H2 Boot button
5+
#define OT_CHANNEL "24"
6+
#define OT_NETWORK_KEY "00112233445566778899aabbccddeeff"
7+
#define OT_MCAST_ADDR "ff05::abcd"
88
#define OT_COAP_RESOURCE_NAME "Lamp"
99

1010
const char *otSetupChild[] = {
1111
// clear/disable all
12-
"coap", "stop",
13-
"thread", "stop",
14-
"ifconfig", "down",
15-
"dataset", "clear",
12+
"coap", "stop", "thread", "stop", "ifconfig", "down", "dataset", "clear",
1613
// set dataset
17-
"dataset channel", OT_CHANNEL,
18-
"dataset networkkey", OT_NETWORK_KEY,
19-
"dataset", "commit active",
14+
"dataset channel", OT_CHANNEL, "dataset networkkey", OT_NETWORK_KEY, "dataset", "commit active",
2015
// network start
21-
"ifconfig", "up",
22-
"thread", "start"
16+
"ifconfig", "up", "thread", "start"
2317
};
2418

2519
const char *otCoapSwitch[] = {
2620
// start and create a CoAP resource
27-
"coap", "start",
21+
"coap",
22+
"start",
2823
};
2924

30-
bool otDeviceSetup(const char **otSetupCmds, uint8_t nCmds1, const char **otCoapCmds, uint8_t nCmds2, ot_device_role_t expectedRole1, ot_device_role_t expectedRole2) {
25+
bool otDeviceSetup(
26+
const char **otSetupCmds, uint8_t nCmds1, const char **otCoapCmds, uint8_t nCmds2, ot_device_role_t expectedRole1, ot_device_role_t expectedRole2
27+
) {
3128
Serial.println("Starting OpenThread.");
3229
Serial.println("Running as Switch - use the BOOT button to toggle the other C6/H2 as a Lamp");
3330
uint8_t i;
@@ -43,7 +40,7 @@ bool otDeviceSetup(const char **otSetupCmds, uint8_t nCmds1, const char **otCoap
4340
}
4441
Serial.println("OpenThread started.\r\nWaiting for activating correct Device Role.");
4542
// wait for the expected Device Role to start
46-
uint8_t tries = 24; // 24 x 2.5 sec = 1 min
43+
uint8_t tries = 24; // 24 x 2.5 sec = 1 min
4744
while (tries && otGetDeviceRole() != expectedRole1 && otGetDeviceRole() != expectedRole2) {
4845
Serial.print(".");
4946
delay(2500);
@@ -68,23 +65,21 @@ bool otDeviceSetup(const char **otSetupCmds, uint8_t nCmds1, const char **otCoap
6865
}
6966
Serial.println("OpenThread setup done. Node is ready.");
7067
// all fine! LED goes and stays Blue
71-
neopixelWrite(RGB_BUILTIN, 0, 0, 64); // BLUE ... Swtich is ready!
68+
neopixelWrite(RGB_BUILTIN, 0, 0, 64); // BLUE ... Swtich is ready!
7269
return true;
7370
}
7471

75-
7672
void setupNode() {
7773
// tries to set the Thread Network node and only returns when succeded
7874
bool startedCorrectly = false;
7975
while (!startedCorrectly) {
80-
startedCorrectly |= otDeviceSetup(otSetupChild, sizeof(otSetupChild) / sizeof(char *) / 2,
81-
otCoapSwitch, sizeof(otCoapSwitch) / sizeof(char *) / 2,
82-
OT_ROLE_CHILD, OT_ROLE_ROUTER);
76+
startedCorrectly |= otDeviceSetup(
77+
otSetupChild, sizeof(otSetupChild) / sizeof(char *) / 2, otCoapSwitch, sizeof(otCoapSwitch) / sizeof(char *) / 2, OT_ROLE_CHILD, OT_ROLE_ROUTER
78+
);
8379
if (!startedCorrectly) {
8480
Serial.println("Setup Failed...\r\nTrying again...");
8581
}
8682
}
87-
8883
}
8984

9085
// Sends the CoAP frame to the Lamp node
@@ -133,12 +128,12 @@ bool otCoapPUT(bool lampState) {
133128
void checkUserButton() {
134129
static long unsigned int lastPress = 0;
135130
const long unsigned int debounceTime = 500;
136-
static bool lastLampState = true; // first button press will turn the Lamp OFF from inital Green
131+
static bool lastLampState = true; // first button press will turn the Lamp OFF from inital Green
137132

138-
pinMode(USER_BUTTON, INPUT_PULLUP); // C6/H2 User Button
133+
pinMode(USER_BUTTON, INPUT_PULLUP); // C6/H2 User Button
139134
if (millis() > lastPress + debounceTime && digitalRead(USER_BUTTON) == LOW) {
140135
lastLampState = !lastLampState;
141-
if (!otCoapPUT(lastLampState)) { // failed: Lamp Node is not responding due to be off or unreachable
136+
if (!otCoapPUT(lastLampState)) { // failed: Lamp Node is not responding due to be off or unreachable
142137
// timeout from the CoAP PUT message... restart the node.
143138
neopixelWrite(RGB_BUILTIN, 255, 0, 0); // RED ... something failed!
144139
Serial.println("Reseting the Node as Switch... wait.");
@@ -153,8 +148,8 @@ void setup() {
153148
Serial.begin(115200);
154149
// LED starts RED, indicating not connected to Thread network.
155150
neopixelWrite(RGB_BUILTIN, 64, 0, 0);
156-
OThreadCLI.begin(false); // No AutoStart is necessary
157-
OThreadCLI.setTimeout(250); // waits 250ms for the OpenThread CLI response
151+
OThreadCLI.begin(false); // No AutoStart is necessary
152+
OThreadCLI.setTimeout(250); // waits 250ms for the OpenThread CLI response
158153
setupNode();
159154
// LED goes and keeps Blue when all is ready and Red when failed.
160155
}

Diff for: libraries/OpenThread/examples/SimpleCLI/SimpleCLI.ino

+4-5
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,19 @@
22
* OpenThread.begin(false) will not automatically start a node in a Thread Network
33
* The user will need to start it manually using the OpenThread CLI commands
44
* Use the Serial Monitor to interact with the OpenThread CLI
5-
*
5+
*
66
* Type 'help' for a list of commands.
77
* Documentation: https://openthread.io/reference/cli/commands
8-
*
8+
*
99
*/
1010

1111
#include "OThreadCLI.h"
1212

1313
void setup() {
1414
Serial.begin(115200);
15-
OThreadCLI.begin(false); // No AutoStart - fresh start
15+
OThreadCLI.begin(false); // No AutoStart - fresh start
1616
Serial.println("OpenThread CLI started - type 'help' for a list of commands.");
1717
OThreadCLI.startConsole(Serial);
1818
}
1919

20-
void loop() {
21-
}
20+
void loop() {}

Diff for: libraries/OpenThread/examples/SimpleCLI/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"esp32s2": false,
77
"esp32s3": false
88
}
9-
}
9+
}

Diff for: libraries/OpenThread/examples/SimpleNode/SimpleNode.ino

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* OpenThread.begin() will automatically start a node in a Thread Network
33
* If NVS is empty, default configuration will be as follow:
4-
*
4+
*
55
* NETWORK_NAME "OpenThread-ESP"
66
* MESH_LOCAL_PREFIX "fd00:db8:a0:0::/64"
77
* NETWORK_CHANNEL 15
@@ -21,8 +21,8 @@
2121

2222
void setup() {
2323
Serial.begin(115200);
24-
OThreadCLI.begin(); // AutoStart using Thread default settings
25-
otPrintNetworkInformation(Serial); // Print Current Thread Network Information
24+
OThreadCLI.begin(); // AutoStart using Thread default settings
25+
otPrintNetworkInformation(Serial); // Print Current Thread Network Information
2626
}
2727

2828
void loop() {

Diff for: libraries/OpenThread/examples/SimpleNode/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"esp32s2": false,
77
"esp32s3": false
88
}
9-
}
9+
}

Diff for: libraries/OpenThread/examples/SimpleThreadNetwork/LeaderNode/LeaderNode.ino

+8-8
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
* OpenThread.begin(false) will not automatically start a node in a Thread Network
33
* A Leader node is the first device, that has a complete dataset, to start Thread
44
* A complete dataset is easily achieved by using the OpenThread CLI command "dataset init new"
5-
*
6-
* In order to allow other node to join the network,
5+
*
6+
* In order to allow other node to join the network,
77
* all of them shall use the same network master key
88
* The network master key is a 16-byte key that is used to secure the network
9-
*
9+
*
1010
* Using the same channel will make the process faster
11-
*
11+
*
1212
*/
1313

1414
#include "OThreadCLI.h"
1515
#include "OThreadCLI_Util.h"
1616

17-
#define CLI_NETWORK_KEY "dataset networkkey 00112233445566778899aabbccddeeff"
17+
#define CLI_NETWORK_KEY "dataset networkkey 00112233445566778899aabbccddeeff"
1818
#define CLI_NETWORK_CHANEL "dataset channel 24"
1919

2020
void setup() {
2121
Serial.begin(115200);
22-
OThreadCLI.begin(false); // No AutoStart - fresh start
22+
OThreadCLI.begin(false); // No AutoStart - fresh start
2323
Serial.println("Setting up OpenThread Node as Leader");
24-
24+
2525
OThreadCLI.println("dataset init new");
2626
OThreadCLI.println(CLI_NETWORK_KEY);
2727
OThreadCLI.println(CLI_NETWORK_CHANEL);
@@ -34,4 +34,4 @@ void loop() {
3434
Serial.print("Thread Node State: ");
3535
Serial.println(otGetStringDeviceRole());
3636
delay(5000);
37-
}
37+
}

Diff for: libraries/OpenThread/examples/SimpleThreadNetwork/LeaderNode/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"esp32s2": false,
77
"esp32s3": false
88
}
9-
}
9+
}

Diff for: libraries/OpenThread/examples/SimpleThreadNetwork/RouterNode/RouterNode.ino

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
/*
22
* OpenThread.begin(false) will not automatically start a node in a Thread Network
3-
* A Router/Child node is the device that will join an existing Thread Network
4-
*
5-
* In order to allow this node to join the network,
3+
* A Router/Child node is the device that will join an existing Thread Network
4+
*
5+
* In order to allow this node to join the network,
66
* it shall use the same network master key as used by the Leader Node
77
* The network master key is a 16-byte key that is used to secure the network
8-
*
8+
*
99
* Using the same channel will make the process faster
10-
*
10+
*
1111
*/
1212

1313
#include "OThreadCLI.h"
1414
#include "OThreadCLI_Util.h"
1515

16-
#define CLI_NETWORK_KEY "dataset networkkey 00112233445566778899aabbccddeeff"
16+
#define CLI_NETWORK_KEY "dataset networkkey 00112233445566778899aabbccddeeff"
1717
#define CLI_NETWORK_CHANEL "dataset channel 24"
1818

1919
void setup() {
2020
Serial.begin(115200);
21-
OThreadCLI.begin(false); // No AutoStart - fresh start
21+
OThreadCLI.begin(false); // No AutoStart - fresh start
2222
Serial.println("Setting up OpenThread Node as Router/Child");
2323
Serial.println("Make sure the Leader Node is already running");
2424

Diff for: libraries/OpenThread/examples/SimpleThreadNetwork/RouterNode/ci.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
"esp32s2": false,
77
"esp32s3": false
88
}
9-
}
9+
}

Diff for: libraries/OpenThread/examples/ThreadScan/ThreadScan.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313

1414
void setup() {
1515
Serial.begin(115200);
16-
OThreadCLI.begin(true); // For scanning, AutoStart must be active, any setup
17-
OThreadCLI.setTimeout(100); // Set a timeout for the CLI response
16+
OThreadCLI.begin(true); // For scanning, AutoStart must be active, any setup
17+
OThreadCLI.setTimeout(100); // Set a timeout for the CLI response
1818
Serial.println();
1919
Serial.println("This sketch will continuously scan the Thread Local Network and all devices IEEE 802.15.4 compatible");
2020
}

0 commit comments

Comments
 (0)