Skip to content

Commit 5c29d8c

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 38e0ca9 commit 5c29d8c

22 files changed

Lines changed: 424 additions & 523 deletions

File tree

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
requires:
22
- CONFIG_OPENTHREAD_ENABLED=y
33
- CONFIG_SOC_IEEE802154_SUPPORTED=y
4-

libraries/OpenThread/examples/Native/CoAP/CoAP_CRUD/notes_client/notes_client.ino

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
#include "OThread.h"
3030
#include "OThreadCoAP.h"
3131

32-
const char PSKD[] = "J01NME";
33-
const uint8_t CHANNEL_HINT = 15;
32+
const char PSKD[] = "J01NME";
33+
const uint8_t CHANNEL_HINT = 15;
3434
const uint32_t JOIN_TIMEOUT_MS = 60000;
3535
const uint32_t ATTACH_TIMEOUT_MS = 30000;
36-
const uint32_t ATTACH_DOT_MS = 2000;
36+
const uint32_t ATTACH_DOT_MS = 2000;
3737

3838
OThreadCoAPClient CoapClient;
3939
static IPAddress serverIp;
@@ -81,8 +81,7 @@ static bool joinNetwork() {
8181
}
8282

8383
serverIp = OThread.getLeaderRloc();
84-
Serial.printf("Attached as %s. Notes server: %s\n",
85-
OThread.otGetStringDeviceRole(), serverIp.toString().c_str());
84+
Serial.printf("Attached as %s. Notes server: %s\n", OThread.otGetStringDeviceRole(), serverIp.toString().c_str());
8685
return true;
8786
}
8887

libraries/OpenThread/examples/Native/CoAP/CoAP_CRUD/notes_server/notes_server.ino

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,16 @@
2323
#include "OThread.h"
2424
#include "OThreadCoAP.h"
2525

26-
const char PSKD[] = "J01NME";
26+
const char PSKD[] = "J01NME";
2727
const uint32_t JOINER_WINDOW_SEC = 600;
28-
const uint8_t CHANNEL = 15;
29-
const uint16_t PAN_ID = 0xC0DE;
30-
const uint8_t NETKEY[OT_NETWORK_KEY_SIZE] = {
31-
0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11,
32-
0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99
33-
};
28+
const uint8_t CHANNEL = 15;
29+
const uint16_t PAN_ID = 0xC0DE;
30+
const uint8_t NETKEY[OT_NETWORK_KEY_SIZE] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99};
3431

3532
OThreadCoAPResourceStore Notes;
3633

3734
const uint32_t ATTACH_TIMEOUT_MS = 30000;
38-
const uint32_t ATTACH_DOT_MS = 2000;
35+
const uint32_t ATTACH_DOT_MS = 2000;
3936

4037
static void onNotesChanged(const char *basePath, void *ctx) {
4138
(void)ctx;
@@ -104,13 +101,17 @@ void setup() {
104101
Serial.println("Starting CoAP server...");
105102
if (!OThreadCoAPServer.begin()) {
106103
Serial.println("CoAP server failed.");
107-
while (1) { delay(1000); }
104+
while (1) {
105+
delay(1000);
106+
}
108107
}
109108

110109
Notes.onChange(onNotesChanged);
111110
if (!Notes.attach(OThreadCoAPServer, "notes", 8)) {
112111
Serial.println("ResourceStore attach failed.");
113-
while (1) { delay(1000); }
112+
while (1) {
113+
delay(1000);
114+
}
114115
}
115116

116117
Serial.println("Ready. REST endpoints:");

libraries/OpenThread/examples/Native/CoAP/CoAP_Greenhouse/greenhouse_client/greenhouse_client.ino

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,27 @@
3030
#include "OThread.h"
3131
#include "OThreadCoAP.h"
3232

33-
const char PSKD[] = "J01NME";
34-
const uint8_t CHANNEL_HINT = 15;
35-
const uint32_t JOIN_TIMEOUT_MS = 60000;
33+
const char PSKD[] = "J01NME";
34+
const uint8_t CHANNEL_HINT = 15;
35+
const uint32_t JOIN_TIMEOUT_MS = 60000;
3636
const uint32_t ATTACH_TIMEOUT_MS = 30000;
37-
const uint32_t ATTACH_DOT_MS = 2000;
38-
const uint32_t TELEMETRY_MS = 8000;
39-
const uint32_t CONTROL_MS = 24000;
40-
const float TEMP_FAN_ON_C = 26.0f;
41-
const float LIGHT_VALVE_LUX = 8000.0f;
42-
43-
static const uint8_t COAP_PSK[] = {
44-
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
45-
0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x00
46-
};
37+
const uint32_t ATTACH_DOT_MS = 2000;
38+
const uint32_t TELEMETRY_MS = 8000;
39+
const uint32_t CONTROL_MS = 24000;
40+
const float TEMP_FAN_ON_C = 26.0f;
41+
const float LIGHT_VALVE_LUX = 8000.0f;
42+
43+
static const uint8_t COAP_PSK[] = {0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x00};
4744
static const char COAP_PSK_ID[] = "esp-coap-demo";
4845

49-
OThreadCoAPClient PlainClient;
46+
OThreadCoAPClient PlainClient;
5047
OThreadCoAPSecureClient SecureClient;
5148

5249
static IPAddress serverIp;
53-
static uint32_t lastTelemetryMs = 0;
54-
static uint32_t lastControlMs = 0;
55-
static float lastTempC = 0.0f;
56-
static float lastLightLux = 0.0f;
50+
static uint32_t lastTelemetryMs = 0;
51+
static uint32_t lastControlMs = 0;
52+
static float lastTempC = 0.0f;
53+
static float lastLightLux = 0.0f;
5754

5855
static bool waitForAttach(uint32_t timeoutMs, uint32_t dotMs) {
5956
uint32_t start = millis();
@@ -93,8 +90,7 @@ static bool joinNetwork() {
9390
return false;
9491
}
9592
serverIp = OThread.getLeaderRloc();
96-
Serial.printf("Attached as %s. Greenhouse server: %s\n",
97-
OThread.otGetStringDeviceRole(), serverIp.toString().c_str());
93+
Serial.printf("Attached as %s. Greenhouse server: %s\n", OThread.otGetStringDeviceRole(), serverIp.toString().c_str());
9894
return true;
9995
}
10096

@@ -127,8 +123,7 @@ static bool sendSecurePut(const char *path, uint8_t percent) {
127123
Serial.printf("CON PUT %s failed: %s\n", path, OThreadCoAP::errorToString(code));
128124
return false;
129125
}
130-
Serial.printf("[CoAPS CON] PUT %s=%u -> %s\n",
131-
path, (unsigned)percent, OThreadCoAP::responseCodeToString(code));
126+
Serial.printf("[CoAPS CON] PUT %s=%u -> %s\n", path, (unsigned)percent, OThreadCoAP::responseCodeToString(code));
132127
return true;
133128
}
134129

@@ -137,11 +132,10 @@ static bool runControlLoop() {
137132
return false;
138133
}
139134

140-
uint8_t fanSpeed = (lastTempC > TEMP_FAN_ON_C) ? 75 : 15;
141-
uint8_t valveOpen = (lastLightLux < LIGHT_VALVE_LUX) ? 60 : 10;
135+
uint8_t fanSpeed = (lastTempC > TEMP_FAN_ON_C) ? 75 : 15;
136+
uint8_t valveOpen = (lastLightLux < LIGHT_VALVE_LUX) ? 60 : 10;
142137

143-
Serial.printf("Control: temp=%.1f fan=%u%% light=%.0f valve=%u%%\n",
144-
lastTempC, (unsigned)fanSpeed, lastLightLux, (unsigned)valveOpen);
138+
Serial.printf("Control: temp=%.1f fan=%u%% light=%.0f valve=%u%%\n", lastTempC, (unsigned)fanSpeed, lastLightLux, (unsigned)valveOpen);
145139

146140
if (!SecureClient.connect(serverIp)) {
147141
Serial.println("DTLS connect failed.");
@@ -181,7 +175,7 @@ void setup() {
181175

182176
Serial.println("Ready. Polling telemetry and running control loop.");
183177
lastTelemetryMs = millis();
184-
lastControlMs = millis();
178+
lastControlMs = millis();
185179
}
186180

187181
void loop() {

libraries/OpenThread/examples/Native/CoAP/CoAP_Greenhouse/greenhouse_server/greenhouse_server.ino

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,29 @@
2828
#include "OThread.h"
2929
#include "OThreadCoAP.h"
3030

31-
const char PSKD[] = "J01NME";
31+
const char PSKD[] = "J01NME";
3232
const uint32_t JOINER_WINDOW_SEC = 600;
33-
const uint8_t CHANNEL = 15;
34-
const uint16_t PAN_ID = 0xBEE5;
35-
const uint8_t NETKEY[OT_NETWORK_KEY_SIZE] = {
36-
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
37-
0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x05
38-
};
33+
const uint8_t CHANNEL = 15;
34+
const uint16_t PAN_ID = 0xBEE5;
35+
const uint8_t NETKEY[OT_NETWORK_KEY_SIZE] = {0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x05};
3936

4037
const uint32_t ATTACH_TIMEOUT_MS = 30000;
41-
const uint32_t ATTACH_DOT_MS = 2000;
38+
const uint32_t ATTACH_DOT_MS = 2000;
4239

43-
static const uint8_t COAP_PSK[] = {
44-
0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80,
45-
0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x00
46-
};
40+
static const uint8_t COAP_PSK[] = {0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70, 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0, 0x00};
4741
static const char COAP_PSK_ID[] = "esp-coap-demo";
4842

4943
struct GreenhouseState {
50-
float tempC;
51-
float lightLux;
44+
float tempC;
45+
float lightLux;
5246
uint8_t valvePercent;
5347
uint8_t fanSpeed;
5448
};
5549

5650
static GreenhouseState s_state = {24.0f, 12000.0f, 0, 0};
5751

5852
static void logRequestKind(const char *path, OThreadCoAPRequest &req) {
59-
Serial.printf("[%s] %s from %s\n",
60-
req.isConfirmable() ? "CON" : "NON",
61-
path,
62-
req.remoteIP().toString().c_str());
53+
Serial.printf("[%s] %s from %s\n", req.isConfirmable() ? "CON" : "NON", path, req.remoteIP().toString().c_str());
6354
}
6455

6556
static void onGreenhouseTemp(OThreadCoAPRequest &req, OThreadCoAPResponse &resp, void *ctx) {
@@ -206,26 +197,28 @@ void setup() {
206197
}
207198

208199
Serial.println("Starting CoAP servers...");
209-
OThreadCoAPServer.on("greenhouse/temp", OT_COAP_METHOD_GET, onGreenhouseTemp, &s_state);
200+
OThreadCoAPServer.on("greenhouse/temp", OT_COAP_METHOD_GET, onGreenhouseTemp, &s_state);
210201
OThreadCoAPServer.on("greenhouse/light", OT_COAP_METHOD_GET, onGreenhouseLight, &s_state);
211202
if (!OThreadCoAPServer.begin()) {
212203
Serial.println("Plain CoAP server start failed.");
213-
while (1) { delay(1000); }
204+
while (1) {
205+
delay(1000);
206+
}
214207
}
215208
Serial.println("Ready.");
216-
Serial.printf("Plain CoAP on port %u: GET greenhouse/temp, greenhouse/light\n",
217-
(unsigned)OT_COAP_DEFAULT_PORT);
209+
Serial.printf("Plain CoAP on port %u: GET greenhouse/temp, greenhouse/light\n", (unsigned)OT_COAP_DEFAULT_PORT);
218210

219211
if (OThreadCoAP::secureApiEnabled()) {
220212
OThreadCoAPSecureServer.setPSK(COAP_PSK, sizeof(COAP_PSK), COAP_PSK_ID);
221213
OThreadCoAPSecureServer.on("valve/water", OT_COAP_METHOD_PUT, onValveWater, &s_state);
222-
OThreadCoAPSecureServer.on("fan/speed", OT_COAP_METHOD_PUT, onFanSpeed, &s_state);
214+
OThreadCoAPSecureServer.on("fan/speed", OT_COAP_METHOD_PUT, onFanSpeed, &s_state);
223215
if (!OThreadCoAPSecureServer.begin()) {
224216
Serial.println("CoAPS server start failed.");
225-
while (1) { delay(1000); }
217+
while (1) {
218+
delay(1000);
219+
}
226220
}
227-
Serial.printf("CoAPS on port %u: PUT valve/water, fan/speed (PSK id \"%s\")\n",
228-
(unsigned)OT_COAP_SECURE_DEFAULT_PORT, COAP_PSK_ID);
221+
Serial.printf("CoAPS on port %u: PUT valve/water, fan/speed (PSK id \"%s\")\n", (unsigned)OT_COAP_SECURE_DEFAULT_PORT, COAP_PSK_ID);
229222
} else {
230223
Serial.println("CoAPS is not enabled in this build. Secure actuators will not run.");
231224
Serial.println("Plain CoAP telemetry continues.");

libraries/OpenThread/examples/Native/CoAP/CoAP_Light_Switch/light/light.ino

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,19 @@
2626
#include "OThread.h"
2727
#include "OThreadCoAP.h"
2828

29-
const char PSKD[] = "J01NME";
29+
const char PSKD[] = "J01NME";
3030
const uint32_t JOINER_WINDOW_SEC = 600;
31-
const uint8_t CHANNEL = 15;
32-
const uint16_t PAN_ID = 0xABCD;
33-
const uint8_t EXTPANID[OT_EXT_PAN_ID_SIZE] = {0xDE, 0xAD, 0x00, 0xBE, 0xEF, 0x00, 0xCA, 0xFE};
34-
const uint8_t NETKEY[OT_NETWORK_KEY_SIZE] = {
35-
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
36-
0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
37-
};
38-
const char NETWORK_NAME[] = "ESP_OT_CoAP_Lamp";
31+
const uint8_t CHANNEL = 15;
32+
const uint16_t PAN_ID = 0xABCD;
33+
const uint8_t EXTPANID[OT_EXT_PAN_ID_SIZE] = {0xDE, 0xAD, 0x00, 0xBE, 0xEF, 0x00, 0xCA, 0xFE};
34+
const uint8_t NETKEY[OT_NETWORK_KEY_SIZE] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff};
35+
const char NETWORK_NAME[] = "ESP_OT_CoAP_Lamp";
3936

4037
const uint32_t ATTACH_TIMEOUT_MS = 30000;
41-
const uint32_t ATTACH_DOT_MS = 2000;
38+
const uint32_t ATTACH_DOT_MS = 2000;
4239

4340
// Realm-local multicast — switches can PUT here without knowing unicast address
44-
const uint8_t LAMP_GROUP_BYTES[16] = {
45-
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab, 0xcd
47-
};
41+
const uint8_t LAMP_GROUP_BYTES[16] = {0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab, 0xcd};
4842
const IPAddress LAMP_GROUP(IPv6, LAMP_GROUP_BYTES);
4943

5044
// lampTarget is the commanded state, written by the CoAP handler on the
@@ -107,8 +101,9 @@ static void onLamp(OThreadCoAPRequest &req, OThreadCoAPResponse &resp, void *ctx
107101
return;
108102
}
109103
lampTarget = (cmd == '1'); // loop() picks this up and drives the LED
110-
Serial.printf("CoAP PUT from %s -> %s%s\n", req.remoteIP().toString().c_str(), lampTarget ? "ON" : "OFF",
111-
req.isMulticast() ? " (multicast, no reply)" : "");
104+
Serial.printf(
105+
"CoAP PUT from %s -> %s%s\n", req.remoteIP().toString().c_str(), lampTarget ? "ON" : "OFF", req.isMulticast() ? " (multicast, no reply)" : ""
106+
);
112107
if (replyAllowed) {
113108
resp.setCode(OT_COAP_RESP_CHANGED);
114109
resp.setPayload(lampTarget ? "1" : "0");
@@ -194,14 +189,18 @@ void setup() {
194189
OThreadCoAPServer.on("Lamp", OT_COAP_METHOD_GET | OT_COAP_METHOD_PUT, onLamp);
195190
if (!OThreadCoAPServer.begin()) {
196191
Serial.println("CoAP server failed.");
197-
while (1) { delay(1000); }
192+
while (1) {
193+
delay(1000);
194+
}
198195
}
199196

200197
// Subscribe the interface to the lamp group; without this the node never
201198
// receives datagrams addressed to the custom realm-local group ff03::abcd.
202199
if (!OThreadCoAPServer.joinMulticastGroup(LAMP_GROUP)) {
203200
Serial.println("Failed to join multicast group.");
204-
while (1) { delay(1000); }
201+
while (1) {
202+
delay(1000);
203+
}
205204
}
206205

207206
Serial.printf("Ready. CoAP resource 'Lamp' (multicast group %s)\n", LAMP_GROUP.toString().c_str());

libraries/OpenThread/examples/Native/CoAP/CoAP_Light_Switch/switch/switch.ino

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,13 @@
2727
#define USER_BUTTON BOOT_PIN // BOOT button GPIO provided by Arduino.h
2828
#endif
2929

30-
const char PSKD[] = "J01NME";
31-
const uint8_t CHANNEL_HINT = 15;
32-
const uint32_t JOIN_TIMEOUT_MS = 60000;
30+
const char PSKD[] = "J01NME";
31+
const uint8_t CHANNEL_HINT = 15;
32+
const uint32_t JOIN_TIMEOUT_MS = 60000;
3333
const uint32_t ATTACH_TIMEOUT_MS = 30000;
34-
const uint32_t ATTACH_DOT_MS = 2000;
34+
const uint32_t ATTACH_DOT_MS = 2000;
3535

36-
const uint8_t LAMP_GROUP_BYTES[16] = {
37-
0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38-
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab, 0xcd
39-
};
36+
const uint8_t LAMP_GROUP_BYTES[16] = {0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xab, 0xcd};
4037
const IPAddress LAMP_GROUP(IPv6, LAMP_GROUP_BYTES);
4138

4239
OThreadCoAPClient CoapClient;

0 commit comments

Comments
 (0)