@alteriom/painlessmesh 1.6.1 → 1.7.2

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +380 -143
  2. package/LICENSE +674 -674
  3. package/README.md +477 -434
  4. package/RELEASE_GUIDE.md +504 -418
  5. package/docs/DOCUMENTATION_MIGRATION_PLAN.md +175 -175
  6. package/docs/IMPLEMENTATION_PLAN_MESH_TOPOLOGY.md +1062 -0
  7. package/docs/MESH_TOPOLOGY_GUIDE.md +992 -0
  8. package/docs/MESH_TOPOLOGY_PROGRESS.md +422 -0
  9. package/docs/MQTT_BRIDGE_COMMANDS.md +894 -0
  10. package/docs/MQTT_BRIDGE_IMPLEMENTATION_SUMMARY.md +324 -0
  11. package/docs/MQTT_COMMAND_SCHEMA_PROPOSAL.md +576 -0
  12. package/docs/MQTT_SCHEMA_COMPLIANCE.md +285 -0
  13. package/docs/MQTT_SCHEMA_PROPOSALS.md +446 -0
  14. package/docs/MQTT_SCHEMA_REVIEW.md +690 -0
  15. package/docs/OTA_COMMANDS_REFERENCE.md +554 -0
  16. package/docs/PHASE1_GUIDE.md +349 -0
  17. package/docs/PHASE2_GUIDE.md +543 -0
  18. package/docs/README.md +77 -70
  19. package/docs/SCHEMA_VALIDATION_CHECKLIST.md +222 -0
  20. package/docs/alteriom/overview.md +507 -507
  21. package/docs/api/core-api.md +606 -606
  22. package/docs/architecture/mesh-architecture.md +378 -378
  23. package/docs/architecture/plugin-system.md +516 -516
  24. package/docs/getting-started/first-mesh.md +409 -409
  25. package/docs/getting-started/installation.md +274 -274
  26. package/docs/getting-started/quickstart.md +157 -157
  27. package/docs/improvements/FEATURE_PROPOSALS.md +337 -0
  28. package/docs/improvements/PHASE1_IMPLEMENTATION.md +325 -0
  29. package/docs/improvements/PHASE2_IMPLEMENTATION.md +567 -0
  30. package/docs/improvements/README.md +86 -68
  31. package/docs/improvements/ota-and-status-enhancements.md +911 -0
  32. package/docs/improvements/ota-status-architecture-diagrams.md +658 -0
  33. package/docs/improvements/ota-status-quick-reference.md +284 -0
  34. package/docs/platformio-publishing.md +255 -0
  35. package/docs/platformio-setup-summary.md +121 -0
  36. package/docs/troubleshooting/common-issues.md +520 -520
  37. package/docs/troubleshooting/faq.md +472 -472
  38. package/docs/tutorials/basic-examples.md +717 -717
  39. package/docs/wiki/API-Reference.md +245 -245
  40. package/docs/wiki/Complete-Documentation.md +122 -122
  41. package/examples/alteriom/README.md +139 -81
  42. package/examples/alteriom/alteriom.ino +186 -185
  43. package/examples/alteriom/alteriom_sensor_package.hpp +240 -127
  44. package/examples/alteriom/platformio.ini +24 -24
  45. package/examples/alteriomImproved/alteriom_sensor_package.hpp +224 -0
  46. package/examples/{alteriom → alteriomImproved}/improved_sensor_node.ino +245 -245
  47. package/examples/alteriomImproved/platformio.ini +25 -0
  48. package/examples/alteriomPhase1/alteriom_sensor_package.hpp +224 -0
  49. package/examples/alteriomPhase1/phase1_features.ino +242 -0
  50. package/examples/alteriomPhase1/platformio.ini +25 -0
  51. package/examples/alteriomPhase2/alteriom_sensor_package.hpp +224 -0
  52. package/examples/alteriomPhase2/phase2_features.ino +186 -0
  53. package/examples/alteriomPhase2/platformio.ini +25 -0
  54. package/examples/{alteriom → alteriomSensorNode}/alteriom_sensor_node.ino +183 -183
  55. package/examples/alteriomSensorNode/alteriom_sensor_package.hpp +224 -0
  56. package/examples/alteriomSensorNode/platformio.ini +25 -0
  57. package/examples/basic/basic.ino +66 -66
  58. package/examples/basic/platformio.ini +25 -25
  59. package/examples/bridge/bridge.ino +51 -51
  60. package/examples/bridge/mesh_event_publisher.hpp +253 -0
  61. package/examples/bridge/mesh_topology_reporter.hpp +303 -0
  62. package/examples/bridge/mqtt_command_bridge.hpp +459 -0
  63. package/examples/bridge/mqtt_status_bridge.hpp +519 -0
  64. package/examples/bridge/platformio.ini +25 -25
  65. package/examples/echoNode/echoNode.ino +33 -33
  66. package/examples/echoNode/platformio.ini +25 -25
  67. package/examples/logClient/logClient.ino +109 -109
  68. package/examples/logClient/platformio.ini +25 -25
  69. package/examples/logServer/logServer.ino +81 -81
  70. package/examples/logServer/platformio.ini +25 -25
  71. package/examples/meshCommandNode/alteriom_sensor_package.hpp +235 -0
  72. package/examples/meshCommandNode/meshCommandNode.ino +263 -0
  73. package/examples/meshCommandNode/platformio.ini +25 -0
  74. package/examples/mqttBridge/mqttBridge.ino +118 -118
  75. package/examples/mqttBridge/platformio.ini +26 -26
  76. package/examples/mqttCommandBridge/alteriom_sensor_package.hpp +235 -0
  77. package/examples/mqttCommandBridge/mesh_event_publisher.hpp +253 -0
  78. package/examples/mqttCommandBridge/mesh_topology_reporter.hpp +303 -0
  79. package/examples/mqttCommandBridge/mqttCommandBridge.ino +252 -0
  80. package/examples/mqttCommandBridge/mqtt_command_bridge.hpp +459 -0
  81. package/examples/mqttCommandBridge/platformio.ini +26 -0
  82. package/examples/mqttStatusBridge/mqttStatusBridge.ino +216 -0
  83. package/examples/mqttStatusBridge/mqtt_status_bridge.hpp +522 -0
  84. package/examples/mqttStatusBridge/platformio.ini +26 -0
  85. package/examples/mqttTopologyTest/README.md +467 -0
  86. package/examples/mqttTopologyTest/mqttTopologyTest.ino +748 -0
  87. package/examples/mqttTopologyTest/platformio.ini +26 -0
  88. package/examples/namedMesh/namedMesh.ino +97 -97
  89. package/examples/namedMesh/platformio.ini +25 -25
  90. package/examples/otaReceiver/otaReceiver.ino +79 -79
  91. package/examples/otaReceiver/platformio.ini +25 -25
  92. package/examples/otaSender/otaSender.ino +160 -151
  93. package/examples/otaSender/platformio.ini +25 -25
  94. package/examples/startHere/platformio.ini +25 -25
  95. package/examples/startHere/startHere.ino +159 -159
  96. package/examples/webServer/platformio.ini +27 -27
  97. package/examples/webServer/webServer.ino +89 -89
  98. package/keywords.txt +48 -48
  99. package/library.json +55 -34
  100. package/library.properties +10 -10
  101. package/package.json +86 -78
  102. package/src/AlteriomPainlessMesh.h +97 -97
  103. package/src/arduino/wifi.hpp +365 -365
  104. package/src/boost/asynctcp.hpp +279 -279
  105. package/src/painlessMesh.h +70 -70
  106. package/src/painlessMeshSTA.cpp +236 -236
  107. package/src/painlessMeshSTA.h +58 -58
  108. package/src/painlessTaskOptions.h +4 -4
  109. package/src/painlessmesh/base64.hpp +111 -111
  110. package/src/painlessmesh/buffer.hpp +229 -229
  111. package/src/painlessmesh/callback.hpp +91 -91
  112. package/src/painlessmesh/configuration.hpp +77 -77
  113. package/src/painlessmesh/connection.hpp +192 -192
  114. package/src/painlessmesh/layout.hpp +188 -188
  115. package/src/painlessmesh/logger.hpp +158 -158
  116. package/src/painlessmesh/memory.hpp +119 -119
  117. package/src/painlessmesh/mesh.hpp +761 -560
  118. package/src/painlessmesh/metrics.hpp +322 -322
  119. package/src/painlessmesh/ntp.hpp +263 -263
  120. package/src/painlessmesh/ota.hpp +582 -553
  121. package/src/painlessmesh/plugin.hpp +188 -188
  122. package/src/painlessmesh/protocol.hpp +813 -813
  123. package/src/painlessmesh/router.hpp +322 -322
  124. package/src/painlessmesh/tcp.hpp +71 -71
  125. package/src/painlessmesh/validation.hpp +238 -238
  126. package/src/plugin/performance.hpp +214 -214
  127. package/src/plugin/remote.hpp +64 -64
  128. package/src/scheduler.cpp +10 -10
  129. package/src/wifi.cpp +2 -2
@@ -0,0 +1,446 @@
1
+ # MQTT Schema Proposals for painlessMesh Topics
2
+
3
+ ## Overview
4
+
5
+ This document originally proposed schema extensions to @alteriom/mqtt-schema to support painlessMesh mesh network monitoring topics.
6
+
7
+ ## Status: ✅ ALL PROPOSALS OFFICIALLY INCLUDED IN v0.4.0!
8
+
9
+ All three proposed schemas have been officially included in **@alteriom/mqtt-schema@0.4.0**!
10
+
11
+ **Official Schemas (as of v0.4.0):**
12
+ - ✅ `mesh/status/metrics` - Uses `gateway_metrics.schema.json` v1
13
+ - ✅ `mesh/status/nodes` - Uses `mesh_node_list.schema.json` v1 (officially included!)
14
+ - ✅ `mesh/status/topology` - Uses `mesh_topology.schema.json` v1 (officially included!)
15
+ - ✅ `mesh/status/alerts` - Uses `mesh_alert.schema.json` v1 (officially included!)
16
+ - ✅ `mesh/status/node/{id}` - Uses `sensor_status.schema.json` v1
17
+
18
+ **All painlessMesh MQTT topics are now 100% compliant with official @alteriom/mqtt-schema@0.4.0!**
19
+
20
+ ---
21
+
22
+ ## Historical Proposals (Now Official)
23
+
24
+ The following sections document the original proposals that were successfully included in v0.4.0.
25
+
26
+ ## Proposed Schema 1: mesh_node_list.schema.json
27
+
28
+ **Purpose:** Report list of active nodes in the mesh network
29
+
30
+ **Topic:** `mesh/status/nodes`
31
+
32
+ **Proposed Schema:**
33
+ ```json
34
+ {
35
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
36
+ "$id": "https://schemas.alteriom.io/mqtt/v1/mesh_node_list.schema.json",
37
+ "title": "Mesh Node List v1",
38
+ "allOf": [{"$ref": "envelope.schema.json"}],
39
+ "type": "object",
40
+ "required": ["nodes"],
41
+ "properties": {
42
+ "nodes": {
43
+ "type": "array",
44
+ "items": {
45
+ "type": "object",
46
+ "required": ["node_id"],
47
+ "properties": {
48
+ "node_id": {
49
+ "type": "string",
50
+ "description": "Unique node identifier"
51
+ },
52
+ "status": {
53
+ "type": "string",
54
+ "enum": ["online", "offline", "unreachable"],
55
+ "description": "Current node status"
56
+ },
57
+ "last_seen": {
58
+ "type": "string",
59
+ "format": "date-time",
60
+ "description": "Last communication timestamp"
61
+ },
62
+ "signal_strength": {
63
+ "type": "integer",
64
+ "minimum": -200,
65
+ "maximum": 0,
66
+ "description": "Signal strength in dBm"
67
+ }
68
+ },
69
+ "additionalProperties": true
70
+ }
71
+ },
72
+ "node_count": {
73
+ "type": "integer",
74
+ "minimum": 0,
75
+ "description": "Total number of nodes"
76
+ },
77
+ "mesh_id": {
78
+ "type": "string",
79
+ "description": "Mesh network identifier"
80
+ }
81
+ },
82
+ "additionalProperties": true
83
+ }
84
+ ```
85
+
86
+ **Example Message:**
87
+ ```json
88
+ {
89
+ "schema_version": 1,
90
+ "device_id": "gateway-001",
91
+ "device_type": "gateway",
92
+ "timestamp": "2024-10-11T18:00:00Z",
93
+ "firmware_version": "2.1.0",
94
+ "nodes": [
95
+ {
96
+ "node_id": "123456",
97
+ "status": "online",
98
+ "last_seen": "2024-10-11T18:00:00Z",
99
+ "signal_strength": -45
100
+ },
101
+ {
102
+ "node_id": "789012",
103
+ "status": "online",
104
+ "last_seen": "2024-10-11T17:59:58Z",
105
+ "signal_strength": -62
106
+ }
107
+ ],
108
+ "node_count": 2,
109
+ "mesh_id": "AlteriomMesh"
110
+ }
111
+ ```
112
+
113
+ ---
114
+
115
+ ## Proposed Schema 2: mesh_topology.schema.json
116
+
117
+ **Purpose:** Report mesh network topology (connections between nodes)
118
+
119
+ **Topic:** `mesh/status/topology`
120
+
121
+ **Proposed Schema:**
122
+ ```json
123
+ {
124
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
125
+ "$id": "https://schemas.alteriom.io/mqtt/v1/mesh_topology.schema.json",
126
+ "title": "Mesh Network Topology v1",
127
+ "allOf": [{"$ref": "envelope.schema.json"}],
128
+ "type": "object",
129
+ "required": ["connections"],
130
+ "properties": {
131
+ "connections": {
132
+ "type": "array",
133
+ "items": {
134
+ "type": "object",
135
+ "required": ["from_node", "to_node"],
136
+ "properties": {
137
+ "from_node": {
138
+ "type": "string",
139
+ "description": "Source node ID"
140
+ },
141
+ "to_node": {
142
+ "type": "string",
143
+ "description": "Destination node ID"
144
+ },
145
+ "link_quality": {
146
+ "type": "number",
147
+ "minimum": 0,
148
+ "maximum": 1,
149
+ "description": "Link quality score (0-1)"
150
+ },
151
+ "latency_ms": {
152
+ "type": "integer",
153
+ "minimum": 0,
154
+ "description": "Link latency in milliseconds"
155
+ },
156
+ "hop_count": {
157
+ "type": "integer",
158
+ "minimum": 1,
159
+ "description": "Number of hops in path"
160
+ }
161
+ },
162
+ "additionalProperties": true
163
+ }
164
+ },
165
+ "root_node": {
166
+ "type": "string",
167
+ "description": "Root node ID (gateway/bridge)"
168
+ },
169
+ "total_connections": {
170
+ "type": "integer",
171
+ "minimum": 0,
172
+ "description": "Total number of connections"
173
+ }
174
+ },
175
+ "additionalProperties": true
176
+ }
177
+ ```
178
+
179
+ **Example Message:**
180
+ ```json
181
+ {
182
+ "schema_version": 1,
183
+ "device_id": "gateway-001",
184
+ "device_type": "gateway",
185
+ "timestamp": "2024-10-11T18:00:00Z",
186
+ "firmware_version": "2.1.0",
187
+ "connections": [
188
+ {
189
+ "from_node": "123456",
190
+ "to_node": "gateway-001",
191
+ "link_quality": 0.95,
192
+ "latency_ms": 12,
193
+ "hop_count": 1
194
+ },
195
+ {
196
+ "from_node": "789012",
197
+ "to_node": "123456",
198
+ "link_quality": 0.82,
199
+ "latency_ms": 25,
200
+ "hop_count": 2
201
+ }
202
+ ],
203
+ "root_node": "gateway-001",
204
+ "total_connections": 2
205
+ }
206
+ ```
207
+
208
+ ---
209
+
210
+ ## Proposed Schema 3: mesh_alert.schema.json
211
+
212
+ **Purpose:** Report alerts and warnings from mesh network
213
+
214
+ **Topic:** `mesh/status/alerts`
215
+
216
+ **Proposed Schema:**
217
+ ```json
218
+ {
219
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
220
+ "$id": "https://schemas.alteriom.io/mqtt/v1/mesh_alert.schema.json",
221
+ "title": "Mesh Network Alert v1",
222
+ "allOf": [{"$ref": "envelope.schema.json"}],
223
+ "type": "object",
224
+ "required": ["alerts"],
225
+ "properties": {
226
+ "alerts": {
227
+ "type": "array",
228
+ "items": {
229
+ "type": "object",
230
+ "required": ["alert_type", "severity", "message"],
231
+ "properties": {
232
+ "alert_type": {
233
+ "type": "string",
234
+ "enum": [
235
+ "low_memory",
236
+ "node_offline",
237
+ "connection_lost",
238
+ "high_latency",
239
+ "packet_loss",
240
+ "firmware_mismatch",
241
+ "configuration_error",
242
+ "security_warning",
243
+ "other"
244
+ ],
245
+ "description": "Type of alert"
246
+ },
247
+ "severity": {
248
+ "type": "string",
249
+ "enum": ["critical", "warning", "info"],
250
+ "description": "Alert severity level"
251
+ },
252
+ "message": {
253
+ "type": "string",
254
+ "description": "Human-readable alert message"
255
+ },
256
+ "node_id": {
257
+ "type": "string",
258
+ "description": "Related node ID (if applicable)"
259
+ },
260
+ "metric_value": {
261
+ "type": "number",
262
+ "description": "Related metric value (if applicable)"
263
+ },
264
+ "threshold": {
265
+ "type": "number",
266
+ "description": "Threshold that triggered alert"
267
+ },
268
+ "alert_id": {
269
+ "type": "string",
270
+ "description": "Unique alert identifier"
271
+ }
272
+ },
273
+ "additionalProperties": true
274
+ }
275
+ },
276
+ "alert_count": {
277
+ "type": "integer",
278
+ "minimum": 0,
279
+ "description": "Total number of active alerts"
280
+ }
281
+ },
282
+ "additionalProperties": true
283
+ }
284
+ ```
285
+
286
+ **Example Message:**
287
+ ```json
288
+ {
289
+ "schema_version": 1,
290
+ "device_id": "gateway-001",
291
+ "device_type": "gateway",
292
+ "timestamp": "2024-10-11T18:00:00Z",
293
+ "firmware_version": "2.1.0",
294
+ "alerts": [
295
+ {
296
+ "alert_type": "low_memory",
297
+ "severity": "warning",
298
+ "message": "Node 123456 has low free memory",
299
+ "node_id": "123456",
300
+ "metric_value": 15.2,
301
+ "threshold": 20.0,
302
+ "alert_id": "alert-001"
303
+ },
304
+ {
305
+ "alert_type": "node_offline",
306
+ "severity": "critical",
307
+ "message": "Node 345678 is unreachable",
308
+ "node_id": "345678",
309
+ "alert_id": "alert-002"
310
+ }
311
+ ],
312
+ "alert_count": 2
313
+ }
314
+ ```
315
+
316
+ ---
317
+
318
+ ## Existing Schema Usage: Per-Node Status
319
+
320
+ **Topic:** `mesh/status/node/{id}`
321
+
322
+ **Use Existing:** `sensor_status.schema.json` (already in @alteriom/mqtt-schema v1)
323
+
324
+ **Implementation:**
325
+ ```json
326
+ {
327
+ "schema_version": 1,
328
+ "device_id": "123456",
329
+ "device_type": "sensor",
330
+ "timestamp": "2024-10-11T18:00:00Z",
331
+ "firmware_version": "2.1.0",
332
+ "status": "online",
333
+ "battery_level": 85,
334
+ "signal_strength": -45
335
+ }
336
+ ```
337
+
338
+ ---
339
+
340
+ ## Implementation Priority
341
+
342
+ ### Phase 2A (Immediate - Use Existing Schemas)
343
+
344
+ 1. **Per-Node Status** (`mesh/status/node/{id}`)
345
+ - ✅ Use existing `sensor_status.schema.json`
346
+ - Implement immediately with schema v1 compliance
347
+ - Each mesh node publishes its own status
348
+
349
+ ### Phase 2B (Near-term - Needs Schema Proposal)
350
+
351
+ 2. **Node List** (`mesh/status/nodes`)
352
+ - Propose `mesh_node_list.schema.json` to @alteriom/mqtt-schema
353
+ - Implement once schema accepted
354
+ - Gateway publishes aggregated node list
355
+
356
+ 3. **Alerts** (`mesh/status/alerts`)
357
+ - Propose `mesh_alert.schema.json` to @alteriom/mqtt-schema
358
+ - Implement once schema accepted
359
+ - Gateway publishes active alerts
360
+
361
+ 4. **Topology** (`mesh/status/topology`)
362
+ - Propose `mesh_topology.schema.json` to @alteriom/mqtt-schema
363
+ - Implement once schema accepted
364
+ - Gateway publishes network structure
365
+
366
+ ---
367
+
368
+ ## Benefits of Schema Compliance
369
+
370
+ **For All Topics:**
371
+ - ✅ Interoperability across Alteriom ecosystem
372
+ - ✅ TypeScript type definitions available
373
+ - ✅ Automated validation with ajv
374
+ - ✅ Consistent message format
375
+ - ✅ Forward compatibility
376
+ - ✅ Professional monitoring tool integration
377
+
378
+ **For Mesh Networks:**
379
+ - ✅ Standardized node reporting
380
+ - ✅ Centralized alert management
381
+ - ✅ Network topology visualization
382
+ - ✅ Multi-mesh aggregation support
383
+ - ✅ Historical data analysis
384
+
385
+ ---
386
+
387
+ ## Next Steps
388
+
389
+ ### For @alteriom/mqtt-schema Package Maintainers:
390
+
391
+ 1. **Review Proposed Schemas:**
392
+ - `mesh_node_list.schema.json`
393
+ - `mesh_topology.schema.json`
394
+ - `mesh_alert.schema.json`
395
+
396
+ 2. **Provide Feedback:**
397
+ - Suggest modifications to align with Alteriom standards
398
+ - Confirm field names and types
399
+ - Validate against operational requirements
400
+
401
+ 3. **Add to Package:**
402
+ - Include in next @alteriom/mqtt-schema release (v0.4.0+)
403
+ - Update validation rules
404
+ - Add TypeScript type definitions
405
+
406
+ ### For painlessMesh Implementation:
407
+
408
+ 1. **Immediate (Phase 2A):**
409
+ - ✅ Implement per-node status with `sensor_status.schema.json`
410
+ - ✅ Each node publishes to `mesh/status/node/{id}`
411
+ - ✅ Use existing envelope fields and status enum
412
+
413
+ 2. **Near-term (Phase 2B):**
414
+ - Implement proposed schemas (with "x-" prefix if needed before official acceptance)
415
+ - Create validation examples
416
+ - Document integration patterns
417
+
418
+ 3. **Long-term:**
419
+ - Migrate to official schemas once added to @alteriom/mqtt-schema
420
+ - Remove "x-" prefix from schema IDs
421
+ - Update documentation
422
+
423
+ ---
424
+
425
+ ## Schema Proposal Format
426
+
427
+ **For submission to @alteriom/mqtt-schema:**
428
+
429
+ ```json
430
+ {
431
+ "title": "Schema Name",
432
+ "version": "1.0.0",
433
+ "rationale": "Why this schema is needed",
434
+ "use_cases": ["Use case 1", "Use case 2"],
435
+ "schema": { /* JSON Schema */ },
436
+ "examples": [ /* Example messages */ ],
437
+ "validation_notes": "Special validation requirements"
438
+ }
439
+ ```
440
+
441
+ ---
442
+
443
+ **Document Version:** 1.0
444
+ **Date:** October 2024
445
+ **Status:** Proposal for @alteriom/mqtt-schema maintainers
446
+ **Contact:** painlessMesh contributors