@alteriom/painlessmesh 1.6.1 → 1.7.3
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 +435 -144
- package/LICENSE +674 -674
- package/README.md +491 -434
- package/RELEASE_GUIDE.md +504 -418
- package/docs/DOCUMENTATION_MIGRATION_PLAN.md +175 -175
- package/docs/IMPLEMENTATION_PLAN_MESH_TOPOLOGY.md +1062 -0
- package/docs/MESH_TOPOLOGY_GUIDE.md +992 -0
- package/docs/MESH_TOPOLOGY_PROGRESS.md +422 -0
- package/docs/MQTT_BRIDGE_COMMANDS.md +894 -0
- package/docs/MQTT_BRIDGE_IMPLEMENTATION_SUMMARY.md +324 -0
- package/docs/MQTT_COMMAND_SCHEMA_PROPOSAL.md +576 -0
- package/docs/MQTT_SCHEMA_COMPLIANCE.md +285 -0
- package/docs/MQTT_SCHEMA_PROPOSALS.md +446 -0
- package/docs/MQTT_SCHEMA_REVIEW.md +690 -0
- package/docs/OTA_COMMANDS_REFERENCE.md +554 -0
- package/docs/PHASE1_GUIDE.md +349 -0
- package/docs/PHASE2_GUIDE.md +543 -0
- package/docs/README.md +130 -71
- package/docs/SCHEMA_VALIDATION_CHECKLIST.md +222 -0
- package/docs/alteriom/overview.md +507 -507
- package/docs/api/core-api.md +606 -606
- package/docs/architecture/mesh-architecture.md +378 -378
- package/docs/architecture/plugin-system.md +516 -516
- package/docs/archive/DOCUSAURUS_DEPLOYMENT.md +166 -0
- package/docs/archive/FEATURE_PROPOSALS.md +337 -0
- package/docs/archive/LIBRARY_JSON_FIX.md +98 -0
- package/docs/archive/LIBRARY_STRUCTURE_FIX.md +215 -0
- package/docs/archive/PHASE1_IMPLEMENTATION.md +325 -0
- package/docs/archive/PHASE2_IMPLEMENTATION.md +567 -0
- package/docs/archive/RELEASE_SUMMARY.md +173 -0
- package/docs/archive/SCONS_BUILD_FIX.md +313 -0
- package/docs/archive/TRIGGER_RELEASE.md +280 -0
- package/docs/archive/VECTOR_INCLUDE_FIX.md +129 -0
- package/docs/archive/ota-and-status-enhancements.md +911 -0
- package/docs/archive/ota-status-architecture-diagrams.md +658 -0
- package/docs/archive/ota-status-quick-reference.md +284 -0
- package/docs/development/ARDUINO_COMPLIANCE_SUMMARY.md +71 -0
- package/docs/development/CODE_REFACTORING_RECOMMENDATIONS.md +1011 -0
- package/docs/development/DOCKER_TESTING.md +196 -0
- package/docs/development/PLATFORMIO_USAGE.md +180 -0
- package/docs/development/TESTING_SUMMARY.md +126 -0
- package/docs/development/contributing.md +301 -0
- package/docs/development/documentation.md +583 -0
- package/docs/getting-started/first-mesh.md +409 -409
- package/docs/getting-started/installation.md +274 -274
- package/docs/getting-started/quickstart.md +157 -157
- package/docs/improvements/FUTURE_PROPOSALS.md +1016 -0
- package/docs/improvements/IMPLEMENTATION_HISTORY.md +1091 -0
- package/docs/improvements/OTA_STATUS_ENHANCEMENTS.md +709 -0
- package/docs/improvements/README.md +212 -69
- package/docs/platformio-publishing.md +255 -0
- package/docs/platformio-setup-summary.md +121 -0
- package/docs/releases/FEATURE_HISTORY.md +543 -0
- package/docs/releases/PATCH_v1.7.3.md +262 -0
- package/docs/releases/PHASE1_SUMMARY.md +246 -0
- package/docs/releases/PHASE2_SUMMARY.md +499 -0
- package/docs/releases/RELEASE_NOTES_1.7.0.md +539 -0
- package/docs/troubleshooting/common-issues.md +520 -520
- package/docs/troubleshooting/debugging.md +455 -0
- package/docs/troubleshooting/faq.md +472 -472
- package/docs/tutorials/basic-examples.md +717 -717
- package/docs/wiki/API-Reference.md +245 -245
- package/docs/wiki/Complete-Documentation.md +122 -122
- package/examples/alteriom/README.md +139 -81
- package/examples/alteriom/alteriom.ino +186 -185
- package/examples/alteriom/alteriom_sensor_package.hpp +240 -127
- package/examples/alteriom/platformio.ini +24 -24
- package/examples/alteriomImproved/alteriom_sensor_package.hpp +224 -0
- package/examples/{alteriom → alteriomImproved}/improved_sensor_node.ino +245 -245
- package/examples/alteriomImproved/platformio.ini +25 -0
- package/examples/alteriomPhase1/alteriom_sensor_package.hpp +224 -0
- package/examples/alteriomPhase1/phase1_features.ino +242 -0
- package/examples/alteriomPhase1/platformio.ini +25 -0
- package/examples/alteriomPhase2/alteriom_sensor_package.hpp +224 -0
- package/examples/alteriomPhase2/phase2_features.ino +186 -0
- package/examples/alteriomPhase2/platformio.ini +25 -0
- package/examples/{alteriom → alteriomSensorNode}/alteriom_sensor_node.ino +183 -183
- package/examples/alteriomSensorNode/alteriom_sensor_package.hpp +224 -0
- package/examples/alteriomSensorNode/platformio.ini +25 -0
- package/examples/basic/basic.ino +66 -66
- package/examples/basic/platformio.ini +25 -25
- package/examples/bridge/bridge.ino +51 -51
- package/examples/bridge/mesh_event_publisher.hpp +253 -0
- package/examples/bridge/mesh_topology_reporter.hpp +303 -0
- package/examples/bridge/mqtt_command_bridge.hpp +459 -0
- package/examples/bridge/mqtt_status_bridge.hpp +519 -0
- package/examples/bridge/platformio.ini +25 -25
- package/examples/echoNode/echoNode.ino +33 -33
- package/examples/echoNode/platformio.ini +25 -25
- package/examples/logClient/logClient.ino +109 -109
- package/examples/logClient/platformio.ini +25 -25
- package/examples/logServer/logServer.ino +81 -81
- package/examples/logServer/platformio.ini +25 -25
- package/examples/meshCommandNode/alteriom_sensor_package.hpp +235 -0
- package/examples/meshCommandNode/meshCommandNode.ino +263 -0
- package/examples/meshCommandNode/platformio.ini +25 -0
- package/examples/mqttBridge/mqttBridge.ino +118 -118
- package/examples/mqttBridge/platformio.ini +26 -26
- package/examples/mqttCommandBridge/alteriom_sensor_package.hpp +235 -0
- package/examples/mqttCommandBridge/mesh_event_publisher.hpp +253 -0
- package/examples/mqttCommandBridge/mesh_topology_reporter.hpp +303 -0
- package/examples/mqttCommandBridge/mqttCommandBridge.ino +252 -0
- package/examples/mqttCommandBridge/mqtt_command_bridge.hpp +459 -0
- package/examples/mqttCommandBridge/platformio.ini +26 -0
- package/examples/mqttStatusBridge/mqttStatusBridge.ino +216 -0
- package/examples/mqttStatusBridge/mqtt_status_bridge.hpp +522 -0
- package/examples/mqttStatusBridge/platformio.ini +26 -0
- package/examples/mqttTopologyTest/README.md +467 -0
- package/examples/mqttTopologyTest/mqttTopologyTest.ino +748 -0
- package/examples/mqttTopologyTest/platformio.ini +26 -0
- package/examples/namedMesh/namedMesh.ino +97 -97
- package/examples/namedMesh/platformio.ini +25 -25
- package/examples/otaReceiver/otaReceiver.ino +79 -79
- package/examples/otaReceiver/platformio.ini +25 -25
- package/examples/otaSender/otaSender.ino +160 -151
- package/examples/otaSender/platformio.ini +25 -25
- package/examples/startHere/platformio.ini +25 -25
- package/examples/startHere/startHere.ino +159 -159
- package/examples/webServer/platformio.ini +27 -27
- package/examples/webServer/webServer.ino +89 -89
- package/keywords.txt +48 -48
- package/library.json +55 -34
- package/library.properties +10 -10
- package/package.json +86 -78
- package/src/AlteriomPainlessMesh.h +97 -97
- package/src/arduino/wifi.hpp +365 -365
- package/src/boost/asynctcp.hpp +279 -279
- package/src/painlessMesh.h +70 -70
- package/src/painlessMeshSTA.cpp +236 -236
- package/src/painlessMeshSTA.h +58 -58
- package/src/painlessTaskOptions.h +4 -4
- package/src/painlessmesh/base64.hpp +111 -111
- package/src/painlessmesh/buffer.hpp +229 -229
- package/src/painlessmesh/callback.hpp +91 -91
- package/src/painlessmesh/configuration.hpp +77 -77
- package/src/painlessmesh/connection.hpp +192 -192
- package/src/painlessmesh/layout.hpp +188 -188
- package/src/painlessmesh/logger.hpp +158 -158
- package/src/painlessmesh/memory.hpp +119 -119
- package/src/painlessmesh/mesh.hpp +761 -560
- package/src/painlessmesh/metrics.hpp +322 -322
- package/src/painlessmesh/ntp.hpp +263 -263
- package/src/painlessmesh/ota.hpp +582 -553
- package/src/painlessmesh/plugin.hpp +188 -188
- package/src/painlessmesh/protocol.hpp +813 -813
- package/src/painlessmesh/router.hpp +338 -322
- package/src/painlessmesh/tcp.hpp +71 -71
- package/src/painlessmesh/validation.hpp +238 -238
- package/src/plugin/performance.hpp +214 -214
- package/src/plugin/remote.hpp +64 -64
- package/src/scheduler.cpp +10 -10
- package/src/wifi.cpp +2 -2
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
# Debugging Guide
|
|
2
|
+
|
|
3
|
+
This guide provides tools and techniques for debugging painlessMesh applications.
|
|
4
|
+
|
|
5
|
+
## Debug Message Types
|
|
6
|
+
|
|
7
|
+
painlessMesh includes a built-in debugging system that lets you control which types of messages are logged.
|
|
8
|
+
|
|
9
|
+
### Setting Debug Message Types
|
|
10
|
+
|
|
11
|
+
```cpp
|
|
12
|
+
#include "painlessMesh.h"
|
|
13
|
+
|
|
14
|
+
painlessMesh mesh;
|
|
15
|
+
|
|
16
|
+
void setup() {
|
|
17
|
+
Serial.begin(115200);
|
|
18
|
+
|
|
19
|
+
// Set which message types to display
|
|
20
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION);
|
|
21
|
+
|
|
22
|
+
// Initialize mesh
|
|
23
|
+
mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT);
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Available Debug Message Types
|
|
28
|
+
|
|
29
|
+
| Type | Description |
|
|
30
|
+
|------|-------------|
|
|
31
|
+
| `ERROR` | Critical errors and failures |
|
|
32
|
+
| `STARTUP` | Initialization and startup messages |
|
|
33
|
+
| `CONNECTION` | Connection and disconnection events |
|
|
34
|
+
| `SYNC` | Time synchronization messages |
|
|
35
|
+
| `COMMUNICATION` | Message sending/receiving |
|
|
36
|
+
| `GENERAL` | General informational messages |
|
|
37
|
+
| `MSG_TYPES` | Message type information |
|
|
38
|
+
| `REMOTE` | Remote node messages |
|
|
39
|
+
| `APPLICATION` | Application-level messages |
|
|
40
|
+
| `DEBUG` | Detailed debugging information |
|
|
41
|
+
|
|
42
|
+
### Common Debug Configurations
|
|
43
|
+
|
|
44
|
+
**Minimal (Production):**
|
|
45
|
+
|
|
46
|
+
```cpp
|
|
47
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Standard (Development):**
|
|
51
|
+
|
|
52
|
+
```cpp
|
|
53
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION);
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Verbose (Troubleshooting):**
|
|
57
|
+
|
|
58
|
+
```cpp
|
|
59
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION | SYNC | COMMUNICATION);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Full Debug (Deep Dive):**
|
|
63
|
+
|
|
64
|
+
```cpp
|
|
65
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION | SYNC |
|
|
66
|
+
COMMUNICATION | GENERAL | MSG_TYPES |
|
|
67
|
+
REMOTE | APPLICATION | DEBUG);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Common Debugging Scenarios
|
|
71
|
+
|
|
72
|
+
### 1. Nodes Not Connecting
|
|
73
|
+
|
|
74
|
+
**Symptoms:**
|
|
75
|
+
|
|
76
|
+
- Nodes don't appear in `mesh.getNodeList()`
|
|
77
|
+
- `onNewConnection` callback never fires
|
|
78
|
+
- Mesh appears to run but no communication
|
|
79
|
+
|
|
80
|
+
**Debugging Steps:**
|
|
81
|
+
|
|
82
|
+
```cpp
|
|
83
|
+
// Enable connection debugging
|
|
84
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION | SYNC);
|
|
85
|
+
|
|
86
|
+
void setup() {
|
|
87
|
+
Serial.begin(115200);
|
|
88
|
+
|
|
89
|
+
// Add connection callbacks
|
|
90
|
+
mesh.onNewConnection([](uint32_t nodeId) {
|
|
91
|
+
Serial.printf("New connection: %u\n", nodeId);
|
|
92
|
+
Serial.printf("Total nodes: %d\n", mesh.getNodeList().size());
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
mesh.onChangedConnections([]() {
|
|
96
|
+
Serial.printf("Connections changed. Current nodes: %d\n",
|
|
97
|
+
mesh.getNodeList().size());
|
|
98
|
+
auto nodes = mesh.getNodeList();
|
|
99
|
+
for (auto node : nodes) {
|
|
100
|
+
Serial.printf(" - Node: %u\n", node);
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
mesh.onDroppedConnection([](uint32_t nodeId) {
|
|
105
|
+
Serial.printf("Lost connection: %u\n", nodeId);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
**Common Causes:**
|
|
111
|
+
|
|
112
|
+
- Mismatched `MESH_PREFIX` or `MESH_PASSWORD`
|
|
113
|
+
- Different `MESH_PORT` values
|
|
114
|
+
- Wi-Fi channel conflicts
|
|
115
|
+
- Power supply issues (voltage drops during connection)
|
|
116
|
+
- Too many nodes (exceeds platform limits)
|
|
117
|
+
|
|
118
|
+
### 2. Messages Not Received
|
|
119
|
+
|
|
120
|
+
**Symptoms:**
|
|
121
|
+
|
|
122
|
+
- `mesh.sendBroadcast()` or `mesh.sendSingle()` returns true but messages not received
|
|
123
|
+
- `onReceive` callback never fires
|
|
124
|
+
|
|
125
|
+
**Debugging Steps:**
|
|
126
|
+
|
|
127
|
+
```cpp
|
|
128
|
+
// Enable communication debugging
|
|
129
|
+
mesh.setDebugMsgTypes(ERROR | COMMUNICATION | MSG_TYPES);
|
|
130
|
+
|
|
131
|
+
void setup() {
|
|
132
|
+
Serial.begin(115200);
|
|
133
|
+
|
|
134
|
+
mesh.onReceive([](uint32_t from, String& msg) {
|
|
135
|
+
Serial.printf("Received from %u: %s\n", from, msg.c_str());
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Add send status checking
|
|
139
|
+
if (mesh.sendBroadcast(msg)) {
|
|
140
|
+
Serial.println("Broadcast sent successfully");
|
|
141
|
+
} else {
|
|
142
|
+
Serial.println("ERROR: Broadcast failed to send");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Common Causes:**
|
|
148
|
+
|
|
149
|
+
- Message buffer overflow (message too large)
|
|
150
|
+
- Network congestion (too many messages)
|
|
151
|
+
- JSON parsing errors (malformed messages)
|
|
152
|
+
- Node ID mismatch for `sendSingle()`
|
|
153
|
+
- Memory constraints on receiving node
|
|
154
|
+
|
|
155
|
+
### 3. Time Synchronization Issues
|
|
156
|
+
|
|
157
|
+
**Symptoms:**
|
|
158
|
+
|
|
159
|
+
- `mesh.getNodeTime()` returns unexpected values
|
|
160
|
+
- Time-dependent features not working
|
|
161
|
+
- `onNodeTimeAdjusted` fires frequently
|
|
162
|
+
|
|
163
|
+
**Debugging Steps:**
|
|
164
|
+
|
|
165
|
+
```cpp
|
|
166
|
+
// Enable time sync debugging
|
|
167
|
+
mesh.setDebugMsgTypes(ERROR | SYNC);
|
|
168
|
+
|
|
169
|
+
void setup() {
|
|
170
|
+
Serial.begin(115200);
|
|
171
|
+
|
|
172
|
+
mesh.onNodeTimeAdjusted([](int32_t offset) {
|
|
173
|
+
Serial.printf("Time adjusted by: %d microseconds\n", offset);
|
|
174
|
+
Serial.printf("Current mesh time: %u\n", mesh.getNodeTime());
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
// Periodically check time
|
|
178
|
+
Task checkTime(TASK_SECOND * 10, TASK_FOREVER, []() {
|
|
179
|
+
Serial.printf("Mesh time: %u, System: %u\n",
|
|
180
|
+
mesh.getNodeTime(), micros());
|
|
181
|
+
});
|
|
182
|
+
userScheduler.addTask(checkTime);
|
|
183
|
+
checkTime.enable();
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 4. Memory Issues
|
|
188
|
+
|
|
189
|
+
**Symptoms:**
|
|
190
|
+
|
|
191
|
+
- Random crashes or reboots
|
|
192
|
+
- Mesh stops responding
|
|
193
|
+
- `heap_caps_check_integrity` failures on ESP32
|
|
194
|
+
|
|
195
|
+
**Debugging Steps:**
|
|
196
|
+
|
|
197
|
+
```cpp
|
|
198
|
+
void setup() {
|
|
199
|
+
Serial.begin(115200);
|
|
200
|
+
|
|
201
|
+
// Monitor free memory
|
|
202
|
+
Task memoryCheck(TASK_SECOND * 5, TASK_FOREVER, []() {
|
|
203
|
+
Serial.printf("Free heap: %u bytes\n", ESP.getFreeHeap());
|
|
204
|
+
#ifdef ESP32
|
|
205
|
+
Serial.printf("Free PSRAM: %u bytes\n", ESP.getFreePsram());
|
|
206
|
+
Serial.printf("Largest free block: %u bytes\n",
|
|
207
|
+
heap_caps_get_largest_free_block(MALLOC_CAP_8BIT));
|
|
208
|
+
#endif
|
|
209
|
+
});
|
|
210
|
+
userScheduler.addTask(memoryCheck);
|
|
211
|
+
memoryCheck.enable();
|
|
212
|
+
}
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**Memory Optimization Tips:**
|
|
216
|
+
|
|
217
|
+
- Use `String` sparingly, prefer `const char*`
|
|
218
|
+
- Limit broadcast message frequency
|
|
219
|
+
- Reduce node count for ESP8266
|
|
220
|
+
- Clear unused tasks from scheduler
|
|
221
|
+
- Use `F()` macro for string literals
|
|
222
|
+
|
|
223
|
+
### 5. OTA Update Failures
|
|
224
|
+
|
|
225
|
+
**Symptoms:**
|
|
226
|
+
|
|
227
|
+
- OTA updates don't start
|
|
228
|
+
- Updates fail partway through
|
|
229
|
+
- Nodes become unresponsive during update
|
|
230
|
+
|
|
231
|
+
**Debugging Steps:**
|
|
232
|
+
|
|
233
|
+
```cpp
|
|
234
|
+
// Enable OTA debugging
|
|
235
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP | COMMUNICATION);
|
|
236
|
+
|
|
237
|
+
void setup() {
|
|
238
|
+
Serial.begin(115200);
|
|
239
|
+
|
|
240
|
+
// Add OTA callbacks if using broadcast OTA
|
|
241
|
+
mesh.onOTAProgress([](size_t progress, size_t total) {
|
|
242
|
+
Serial.printf("OTA Progress: %u/%u bytes (%.1f%%)\n",
|
|
243
|
+
progress, total, (progress * 100.0) / total);
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
mesh.onOTAComplete([]() {
|
|
247
|
+
Serial.println("OTA Update Complete - Rebooting...");
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
mesh.onOTAError([](int error) {
|
|
251
|
+
Serial.printf("OTA Error: %d\n", error);
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
**Common Causes:**
|
|
257
|
+
|
|
258
|
+
- Insufficient flash memory
|
|
259
|
+
- Power interruption during update
|
|
260
|
+
- Network instability
|
|
261
|
+
- Firmware size exceeds partition size
|
|
262
|
+
- Memory fragmentation
|
|
263
|
+
|
|
264
|
+
## Debugging Tools
|
|
265
|
+
|
|
266
|
+
### 1. Serial Monitor
|
|
267
|
+
|
|
268
|
+
**Arduino IDE:**
|
|
269
|
+
|
|
270
|
+
- Tools → Serial Monitor
|
|
271
|
+
- Set baud rate to 115200
|
|
272
|
+
- Enable newline and carriage return
|
|
273
|
+
|
|
274
|
+
**PlatformIO:**
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
pio device monitor --baud 115200
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
**Screen (Linux/Mac):**
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
screen /dev/ttyUSB0 115200
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### 2. Network Analyzer
|
|
287
|
+
|
|
288
|
+
**Wireshark:**
|
|
289
|
+
|
|
290
|
+
- Capture Wi-Fi traffic to see mesh packets
|
|
291
|
+
- Filter by ESP32/ESP8266 MAC addresses
|
|
292
|
+
- Analyze packet timing and retransmissions
|
|
293
|
+
|
|
294
|
+
### 3. Mesh Topology Visualization
|
|
295
|
+
|
|
296
|
+
For MQTT-enabled setups:
|
|
297
|
+
|
|
298
|
+
- Use MQTT Explorer to view mesh topology
|
|
299
|
+
- Monitor `alteriom/mesh/topology` topic
|
|
300
|
+
- Visualize node connections and status
|
|
301
|
+
|
|
302
|
+
### 4. Remote Logging
|
|
303
|
+
|
|
304
|
+
**Log Server Example:**
|
|
305
|
+
|
|
306
|
+
```cpp
|
|
307
|
+
// On one node, set up as log server
|
|
308
|
+
mesh.onReceive([](uint32_t from, String& msg) {
|
|
309
|
+
DynamicJsonDocument doc(1024);
|
|
310
|
+
deserializeJson(doc, msg);
|
|
311
|
+
|
|
312
|
+
if (doc["type"] == "log") {
|
|
313
|
+
Serial.printf("[%u] %s\n", from, doc["msg"].as<const char*>());
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
// On other nodes, send logs
|
|
318
|
+
void logToServer(const char* message) {
|
|
319
|
+
DynamicJsonDocument doc(256);
|
|
320
|
+
doc["type"] = "log";
|
|
321
|
+
doc["msg"] = message;
|
|
322
|
+
|
|
323
|
+
String msg;
|
|
324
|
+
serializeJson(doc, msg);
|
|
325
|
+
mesh.sendBroadcast(msg);
|
|
326
|
+
}
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Performance Profiling
|
|
330
|
+
|
|
331
|
+
### Measure Message Latency
|
|
332
|
+
|
|
333
|
+
```cpp
|
|
334
|
+
uint32_t sendTime = 0;
|
|
335
|
+
|
|
336
|
+
void sendMessage() {
|
|
337
|
+
DynamicJsonDocument doc(256);
|
|
338
|
+
doc["type"] = "ping";
|
|
339
|
+
doc["timestamp"] = mesh.getNodeTime();
|
|
340
|
+
|
|
341
|
+
String msg;
|
|
342
|
+
serializeJson(doc, msg);
|
|
343
|
+
|
|
344
|
+
sendTime = millis();
|
|
345
|
+
mesh.sendBroadcast(msg);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
void onMessageReceived(uint32_t from, String& msg) {
|
|
349
|
+
DynamicJsonDocument doc(256);
|
|
350
|
+
deserializeJson(doc, msg);
|
|
351
|
+
|
|
352
|
+
if (doc["type"] == "ping") {
|
|
353
|
+
uint32_t latency = millis() - sendTime;
|
|
354
|
+
Serial.printf("Ping latency: %u ms\n", latency);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
### Monitor Task Execution
|
|
360
|
+
|
|
361
|
+
```cpp
|
|
362
|
+
void setup() {
|
|
363
|
+
// Enable TaskScheduler debugging
|
|
364
|
+
userScheduler.enableAll();
|
|
365
|
+
|
|
366
|
+
Task debugTask(TASK_SECOND * 10, TASK_FOREVER, []() {
|
|
367
|
+
Serial.printf("Active tasks: %d\n", userScheduler.size());
|
|
368
|
+
// List all tasks
|
|
369
|
+
for (auto task = userScheduler.getFirstTask();
|
|
370
|
+
task != nullptr;
|
|
371
|
+
task = task->getNext()) {
|
|
372
|
+
Serial.printf(" Task ID: %d, Enabled: %d\n",
|
|
373
|
+
task->getId(), task->isEnabled());
|
|
374
|
+
}
|
|
375
|
+
});
|
|
376
|
+
userScheduler.addTask(debugTask);
|
|
377
|
+
debugTask.enable();
|
|
378
|
+
}
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
## Best Practices
|
|
382
|
+
|
|
383
|
+
1. **Start Minimal:** Enable only ERROR and STARTUP for initial testing
|
|
384
|
+
2. **Add Incrementally:** Add more debug types as needed
|
|
385
|
+
3. **Use Callbacks:** Implement all mesh callbacks to catch events
|
|
386
|
+
4. **Monitor Memory:** Regularly check free heap, especially on ESP8266
|
|
387
|
+
5. **Test Incrementally:** Test with 2 nodes before scaling to larger networks
|
|
388
|
+
6. **Power Management:** Ensure stable power supply during debugging
|
|
389
|
+
7. **Version Control:** Use consistent firmware versions across all nodes
|
|
390
|
+
8. **Document Issues:** Keep notes on error patterns and solutions
|
|
391
|
+
|
|
392
|
+
## Advanced Debugging
|
|
393
|
+
|
|
394
|
+
### Enable TaskScheduler Debug Mode
|
|
395
|
+
|
|
396
|
+
```cpp
|
|
397
|
+
// Add to top of sketch BEFORE including headers
|
|
398
|
+
#define _TASK_DEBUG
|
|
399
|
+
|
|
400
|
+
#include <TaskScheduler.h>
|
|
401
|
+
#include "painlessMesh.h"
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Enable ArduinoJson Debug
|
|
405
|
+
|
|
406
|
+
```cpp
|
|
407
|
+
#define ARDUINOJSON_DEBUG 1
|
|
408
|
+
#include <ArduinoJson.h>
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### ESP32 Core Debug Level
|
|
412
|
+
|
|
413
|
+
In `platformio.ini`:
|
|
414
|
+
|
|
415
|
+
```ini
|
|
416
|
+
build_flags =
|
|
417
|
+
-DCORE_DEBUG_LEVEL=5 ; 0=None, 5=Verbose
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
## Troubleshooting Checklist
|
|
421
|
+
|
|
422
|
+
- [ ] All nodes use same MESH_PREFIX, MESH_PASSWORD, MESH_PORT
|
|
423
|
+
- [ ] Serial baud rate set to 115200
|
|
424
|
+
- [ ] Debug messages enabled for relevant types
|
|
425
|
+
- [ ] Callbacks implemented (onReceive, onNewConnection, etc.)
|
|
426
|
+
- [ ] Free heap monitored (especially on ESP8266)
|
|
427
|
+
- [ ] Power supply stable (2A+ recommended)
|
|
428
|
+
- [ ] Firmware versions consistent across nodes
|
|
429
|
+
- [ ] JSON messages properly formatted
|
|
430
|
+
- [ ] Message sizes within limits (< 1KB recommended)
|
|
431
|
+
- [ ] Network not oversaturated (reasonable message frequency)
|
|
432
|
+
|
|
433
|
+
## Getting Help
|
|
434
|
+
|
|
435
|
+
If you're still experiencing issues:
|
|
436
|
+
|
|
437
|
+
1. **Search Existing Issues:** Check [GitHub Issues](https://github.com/Alteriom/painlessMesh/issues)
|
|
438
|
+
2. **Community Forum:** Post on [painlessMesh Discussions](https://github.com/Alteriom/painlessMesh/discussions)
|
|
439
|
+
3. **Include Details:**
|
|
440
|
+
- Hardware (ESP32/ESP8266 model)
|
|
441
|
+
- Firmware version
|
|
442
|
+
- Number of nodes
|
|
443
|
+
- Debug output
|
|
444
|
+
- Minimal reproducible example
|
|
445
|
+
4. **Check Documentation:**
|
|
446
|
+
- [Common Issues](common-issues.md)
|
|
447
|
+
- [FAQ](faq.md)
|
|
448
|
+
- [API Reference](../api/core-api.md)
|
|
449
|
+
|
|
450
|
+
## See Also
|
|
451
|
+
|
|
452
|
+
- [Common Issues](common-issues.md) - Known problems and solutions
|
|
453
|
+
- [FAQ](faq.md) - Frequently asked questions
|
|
454
|
+
- [Performance Optimization](../architecture/mesh-architecture.md) - Scaling best practices
|
|
455
|
+
- [MQTT Bridge Commands](../MQTT_BRIDGE_COMMANDS.md) - MQTT debugging
|