@alteriom/painlessmesh 2.0.3 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +123 -0
- package/CONTRIBUTING.md +51 -8
- package/examples/sendToInternet/README.md +54 -2
- package/examples/sendToInternet/callmebot.h +139 -0
- package/examples/sendToInternet/sendToInternet.ino +117 -39
- package/library.json +1 -1
- package/library.properties +1 -1
- package/package.json +1 -1
- package/src/AlteriomPainlessMesh.h +3 -3
- package/src/arduino/wifi.hpp +78 -62
- package/src/painlessMeshSTA.cpp +38 -4
- package/src/painlessMeshSTA.h +13 -1
- package/src/painlessmesh/buffer.hpp +11 -6
- package/src/painlessmesh/gateway.hpp +413 -71
- package/src/painlessmesh/layout.hpp +16 -0
- package/src/painlessmesh/mesh.hpp +251 -106
package/src/painlessMeshSTA.h
CHANGED
|
@@ -62,7 +62,14 @@ class StationScan {
|
|
|
62
62
|
// The station got an address: its link is up. Cleared once the drop
|
|
63
63
|
// callbacks have judged a disconnect, so they can tell a link that was
|
|
64
64
|
// up and went away from an attempt that never got that far.
|
|
65
|
-
void stationUp() {
|
|
65
|
+
void stationUp() {
|
|
66
|
+
stationLinkUp = true;
|
|
67
|
+
// A link again, so the immediate-rescan allowance is restored now
|
|
68
|
+
// rather than at the next scan. Without this a node that dropped
|
|
69
|
+
// twice inside one scan interval paid the full fifteen seconds for
|
|
70
|
+
// the second drop (#459).
|
|
71
|
+
rejoinScanned = false;
|
|
72
|
+
}
|
|
66
73
|
void stationDown() { stationLinkUp = false; }
|
|
67
74
|
bool stationLinkUp = false;
|
|
68
75
|
// The station link was closed by this node's own channel move a moment
|
|
@@ -147,6 +154,11 @@ class StationScan {
|
|
|
147
154
|
// channel re-detection runs, and consuming those results here found them
|
|
148
155
|
// already deleted, reported "wifi scan failed", and rescanned at once.
|
|
149
156
|
bool scanRequested = false;
|
|
157
|
+
// Whether this node has already scanned at once on losing its last
|
|
158
|
+
// connection. Cleared the moment it has one again, so the immediate
|
|
159
|
+
// rescan is one per outage and not a scan loop: a node that is out of
|
|
160
|
+
// the mesh and finds nothing still falls back to the interval below.
|
|
161
|
+
bool rejoinScanned = false;
|
|
150
162
|
// Set when the next station scan must cover every channel: the empty
|
|
151
163
|
// scans have piled up and the node is looking for the channel the mesh
|
|
152
164
|
// moved to. The re-detection is this task's ordinary asynchronous scan
|
|
@@ -206,12 +206,17 @@ class SentBuffer {
|
|
|
206
206
|
size_t requestLength(size_t buffer_length) {
|
|
207
207
|
// Use highest priority message available
|
|
208
208
|
auto* msg = getNextMessage();
|
|
209
|
-
if (!msg)
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
209
|
+
if (!msg) return 0;
|
|
210
|
+
// A caller with no room is owed nothing. The subtraction below leaves
|
|
211
|
+
// space for the terminator toCharArray() always writes; on an unsigned
|
|
212
|
+
// zero it wraps to SIZE_MAX instead, min() then picks the message, and
|
|
213
|
+
// the answer comes back *larger* than was asked for -- which the
|
|
214
|
+
// documented contract above forbids and read() then acts on, writing
|
|
215
|
+
// length + 1 bytes into a buffer the caller said had none.
|
|
216
|
+
if (buffer_length == 0) return 0;
|
|
217
|
+
// String.toCharArray automatically turns the last character into
|
|
218
|
+
// a \0, we need the extra space to deal with that annoyance
|
|
219
|
+
return (std::min)(buffer_length - 1, msg->length() + 1);
|
|
215
220
|
}
|
|
216
221
|
|
|
217
222
|
/**
|