@alteriom/painlessmesh 1.8.14 → 1.9.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.
Files changed (208) hide show
  1. package/BRIDGE_TO_INTERNET.md +229 -0
  2. package/CHANGELOG.md +89 -1
  3. package/CONTRIBUTING.md +79 -0
  4. package/README.md +70 -143
  5. package/docs/README.md +1 -0
  6. package/docs/api/shared-gateway.md +1207 -0
  7. package/docs/troubleshooting/common-issues.md +28 -0
  8. package/docs/troubleshooting/faq.md +113 -12
  9. package/examples/basic/test/simulator/CMakeLists.txt +40 -0
  10. package/examples/basic/test/simulator/README.md +149 -0
  11. package/examples/basic/test/simulator/firmware/basic_firmware.hpp +117 -0
  12. package/examples/basic/test/simulator/scenarios/basic_mesh_test.yaml +81 -0
  13. package/examples/bridge/bridge.ino +17 -4
  14. package/examples/bridge_failover/README.md +81 -0
  15. package/examples/bridge_failover/bridge_failover.ino +51 -6
  16. package/examples/sharedGateway/README.md +235 -0
  17. package/examples/{meshCommandNode → sharedGateway}/platformio.ini +3 -2
  18. package/examples/sharedGateway/sharedGateway.ino +303 -0
  19. package/library.json +3 -22
  20. package/library.properties +1 -1
  21. package/package.json +3 -3
  22. package/src/arduino/wifi.hpp +380 -13
  23. package/src/painlessmesh/gateway.hpp +2120 -0
  24. package/src/painlessmesh/mesh.hpp +1034 -6
  25. package/src/painlessmesh/message_tracker.hpp +311 -0
  26. package/src/painlessmesh/protocol.hpp +6 -0
  27. package/DOCUMENTATION_INDEX.md +0 -146
  28. package/docs/API_DESIGN_GUIDELINES.md +0 -414
  29. package/docs/ARDUINO_LIBRARY_MANAGER_SUBMISSION.md +0 -331
  30. package/docs/BOOLEAN_NAMING_CONVENTION.md +0 -235
  31. package/docs/BRIDGE_FAILOVER.md +0 -512
  32. package/docs/BRIDGE_HEALTH_MONITORING.md +0 -293
  33. package/docs/CHANNEL_SYNCHRONIZATION.md +0 -209
  34. package/docs/CREATE_MISSING_RELEASES.md +0 -321
  35. package/docs/DOCUMENTATION_MIGRATION_PLAN.md +0 -176
  36. package/docs/FAQ_VERSION_NUMBERS.md +0 -152
  37. package/docs/IMPLEMENTATION_PLAN_MESH_TOPOLOGY.md +0 -1062
  38. package/docs/MESH_TOPOLOGY_GUIDE.md +0 -992
  39. package/docs/MESH_TOPOLOGY_PROGRESS.md +0 -422
  40. package/docs/MQTT_BRIDGE_COMMANDS.md +0 -894
  41. package/docs/MQTT_BRIDGE_IMPLEMENTATION_SUMMARY.md +0 -324
  42. package/docs/MQTT_COMMAND_SCHEMA_PROPOSAL.md +0 -576
  43. package/docs/MQTT_SCHEMA_COMPLIANCE.md +0 -340
  44. package/docs/MQTT_SCHEMA_PROPOSALS.md +0 -446
  45. package/docs/MQTT_SCHEMA_REVIEW.md +0 -690
  46. package/docs/OTA_COMMANDS_REFERENCE.md +0 -554
  47. package/docs/PHASE1_GUIDE.md +0 -349
  48. package/docs/PHASE2_GUIDE.md +0 -543
  49. package/docs/QUICK_REFERENCE_VERSIONING.md +0 -127
  50. package/docs/RELEASE_AGENT_SUMMARY.md +0 -386
  51. package/docs/SCHEMA_VALIDATION_CHECKLIST.md +0 -222
  52. package/docs/VERSION_MANAGEMENT.md +0 -213
  53. package/docs/archive/DOCUSAURUS_DEPLOYMENT.md +0 -166
  54. package/docs/archive/FEATURE_PROPOSALS.md +0 -337
  55. package/docs/archive/LIBRARY_JSON_FIX.md +0 -98
  56. package/docs/archive/LIBRARY_STRUCTURE_FIX.md +0 -215
  57. package/docs/archive/PHASE1_IMPLEMENTATION.md +0 -325
  58. package/docs/archive/PHASE2_IMPLEMENTATION.md +0 -567
  59. package/docs/archive/RELEASE_SUMMARY.md +0 -173
  60. package/docs/archive/SCONS_BUILD_FIX.md +0 -313
  61. package/docs/archive/TRIGGER_RELEASE.md +0 -280
  62. package/docs/archive/VECTOR_INCLUDE_FIX.md +0 -129
  63. package/docs/archive/ota-and-status-enhancements.md +0 -911
  64. package/docs/archive/ota-status-architecture-diagrams.md +0 -658
  65. package/docs/archive/ota-status-quick-reference.md +0 -284
  66. package/docs/design/.gitkeep +0 -1
  67. package/docs/design/STATION_CREDENTIALS_DESIGN.md +0 -182
  68. package/docs/development/ARDUINO_COMPLIANCE_SUMMARY.md +0 -71
  69. package/docs/development/CODE_REFACTORING_RECOMMENDATIONS.md +0 -1011
  70. package/docs/development/DOCKER_TESTING.md +0 -196
  71. package/docs/development/PLATFORMIO_USAGE.md +0 -180
  72. package/docs/development/TESTING_SUMMARY.md +0 -126
  73. package/docs/development/contributing.md +0 -301
  74. package/docs/development/documentation.md +0 -583
  75. package/docs/features/DIAGNOSTICS_API.md +0 -534
  76. package/docs/implementation/BRIDGE_ARCHITECTURE_IMPLEMENTATION.md +0 -340
  77. package/docs/implementation/BRIDGE_HEALTH_MONITORING_IMPLEMENTATION.md +0 -213
  78. package/docs/implementation/BRIDGE_STATUS_FEATURE.md +0 -635
  79. package/docs/implementation/DIAGNOSTICS_API_IMPLEMENTATION.md +0 -232
  80. package/docs/implementation/IMPLEMENTATION_COMPLETE.md +0 -228
  81. package/docs/implementation/IMPLEMENTATION_NTP_TIME_SYNC.md +0 -325
  82. package/docs/implementation/IMPLEMENTATION_SUMMARY.md +0 -316
  83. package/docs/implementation/MESSAGE_QUEUE_IMPLEMENTATION.md +0 -405
  84. package/docs/implementation/MULTI_BRIDGE_IMPLEMENTATION.md +0 -520
  85. package/docs/implementation/NTP_TIME_SYNC_FEATURE.md +0 -392
  86. package/docs/improvements/FUTURE_PROPOSALS.md +0 -1016
  87. package/docs/improvements/IMPLEMENTATION_HISTORY.md +0 -1091
  88. package/docs/improvements/OTA_STATUS_ENHANCEMENTS.md +0 -709
  89. package/docs/improvements/README.md +0 -212
  90. package/docs/internal/CUSTOM_AGENT_ANALYSIS.md +0 -391
  91. package/docs/internal/ISSUE_65_VERIFICATION.md +0 -947
  92. package/docs/internal/ISSUE_66_CLOSURE.md +0 -249
  93. package/docs/internal/ISSUE_66_STATUS.md +0 -316
  94. package/docs/internal/PR_SUMMARY.md +0 -315
  95. package/docs/internal/REVIEW_SUMMARY.md +0 -332
  96. package/docs/multi-bridge-setup.md +0 -1025
  97. package/docs/platformio-publishing.md +0 -255
  98. package/docs/platformio-setup-summary.md +0 -121
  99. package/docs/releases/ANNOUNCEMENT_v1.8.6.md +0 -63
  100. package/docs/releases/ANNOUNCEMENT_v1.8.7.md +0 -113
  101. package/docs/releases/BRIDGE_STATUS_SELF_REGISTRATION_FIX.md +0 -221
  102. package/docs/releases/FEATURE_HISTORY.md +0 -543
  103. package/docs/releases/GITHUB_RELEASE_v1.8.6.md +0 -71
  104. package/docs/releases/GITHUB_RELEASE_v1.8.7.md +0 -90
  105. package/docs/releases/PATCH_v1.7.2.md +0 -262
  106. package/docs/releases/PATCH_v1.7.3.md +0 -262
  107. package/docs/releases/PATCH_v1.7.4.md +0 -219
  108. package/docs/releases/PHASE1_SUMMARY.md +0 -246
  109. package/docs/releases/PHASE2_SUMMARY.md +0 -499
  110. package/docs/releases/PUBLISH_v1.8.0_INSTRUCTIONS.md +0 -163
  111. package/docs/releases/QUICK_START_RELEASES.md +0 -113
  112. package/docs/releases/RELEASE_CHECKLIST_1.8.10.md +0 -331
  113. package/docs/releases/RELEASE_CHECKLIST_1.8.9.md +0 -207
  114. package/docs/releases/RELEASE_CHECKLIST_v1.7.4.md +0 -253
  115. package/docs/releases/RELEASE_CHECKLIST_v1.7.5.md +0 -315
  116. package/docs/releases/RELEASE_CHECKLIST_v1.7.6.md +0 -389
  117. package/docs/releases/RELEASE_CHECKLIST_v1.8.0.md +0 -331
  118. package/docs/releases/RELEASE_CHECKLIST_v1.8.2.md +0 -309
  119. package/docs/releases/RELEASE_NOTES_1.7.0.md +0 -539
  120. package/docs/releases/RELEASE_NOTES_1.8.10.md +0 -239
  121. package/docs/releases/RELEASE_NOTES_1.8.9.md +0 -213
  122. package/docs/releases/RELEASE_NOTES_v1.8.0.md +0 -685
  123. package/docs/releases/RELEASE_NOTES_v1.8.1.md +0 -221
  124. package/docs/releases/RELEASE_NOTES_v1.8.2.md +0 -421
  125. package/docs/releases/RELEASE_NOTES_v1.8.3.md +0 -292
  126. package/docs/releases/RELEASE_NOTES_v1.8.4.md +0 -277
  127. package/docs/releases/RELEASE_NOTES_v1.8.6.md +0 -205
  128. package/docs/releases/RELEASE_NOTES_v1.8.7.md +0 -184
  129. package/docs/releases/RELEASE_PLAN_v1.7.6.md +0 -816
  130. package/docs/releases/RELEASE_SUMMARY_1.8.10.md +0 -193
  131. package/docs/releases/RELEASE_SUMMARY_v1.7.4.md +0 -276
  132. package/docs/releases/RELEASE_SUMMARY_v1.7.5.md +0 -322
  133. package/docs/releases/RELEASE_SUMMARY_v1.7.6.md +0 -436
  134. package/docs/releases/RELEASE_SUMMARY_v1.7.7.md +0 -391
  135. package/docs/releases/RELEASE_SUMMARY_v1.7.8.md +0 -523
  136. package/docs/releases/RELEASE_SUMMARY_v1.7.9.md +0 -542
  137. package/docs/troubleshooting/ARDUINO_IDE_VERSION_FIX_SUMMARY.md +0 -229
  138. package/docs/troubleshooting/ARDUINO_LIBRARY_NAME_FIX.md +0 -197
  139. package/docs/troubleshooting/CRASH_QUICK_REF.md +0 -93
  140. package/docs/troubleshooting/ESP32_C6_COMPATIBILITY.md +0 -157
  141. package/docs/troubleshooting/FREERTOS_ASSERTION_FAILURE.md +0 -288
  142. package/docs/troubleshooting/FREERTOS_FIX_IMPLEMENTATION.md +0 -267
  143. package/docs/troubleshooting/NPM_PUBLISHING_ISSUE_SUMMARY.md +0 -110
  144. package/docs/troubleshooting/PAINLESSMESH_V1.7.4_COMPILATION_ISSUES.md +0 -547
  145. package/docs/troubleshooting/QUICK_FIX_FREERTOS.md +0 -164
  146. package/docs/troubleshooting/SENSOR_NODE_CONNECTION_CRASH.md +0 -264
  147. package/docs/troubleshooting/station-reconnection-issues.md +0 -172
  148. package/docs/v1.7.7_MQTT_IMPROVEMENTS.md +0 -794
  149. package/docs/wiki/API-Reference.md +0 -246
  150. package/docs/wiki/Complete-Documentation.md +0 -123
  151. package/examples/alteriomImproved/alteriom_sensor_package.hpp +0 -224
  152. package/examples/alteriomImproved/improved_sensor_node.ino +0 -248
  153. package/examples/alteriomImproved/platformio.ini +0 -32
  154. package/examples/alteriomMetricsHealth/alteriom_sensor_package.hpp +0 -796
  155. package/examples/alteriomMetricsHealth/metrics_health_node.ino +0 -429
  156. package/examples/alteriomMetricsHealth/platformio.ini +0 -26
  157. package/examples/alteriomPhase1/alteriom_sensor_package.hpp +0 -224
  158. package/examples/alteriomPhase1/phase1_features.ino +0 -242
  159. package/examples/alteriomPhase1/platformio.ini +0 -26
  160. package/examples/alteriomPhase2/alteriom_sensor_package.hpp +0 -224
  161. package/examples/alteriomPhase2/phase2_features.ino +0 -186
  162. package/examples/alteriomPhase2/platformio.ini +0 -26
  163. package/examples/alteriomSensorNode/alteriom_sensor_node.ino +0 -186
  164. package/examples/alteriomSensorNode/alteriom_sensor_package.hpp +0 -1227
  165. package/examples/alteriomSensorNode/platformio.ini +0 -26
  166. package/examples/bridge/alteriom_sensor_package.hpp +0 -1170
  167. package/examples/bridge/bridge_health_monitoring_example.ino +0 -188
  168. package/examples/bridge/enhanced_mqtt_bridge.hpp +0 -610
  169. package/examples/bridge/enhanced_mqtt_bridge_example.ino +0 -226
  170. package/examples/bridge/mesh_event_publisher.hpp +0 -253
  171. package/examples/bridge/mesh_topology_reporter.hpp +0 -303
  172. package/examples/bridge/mqtt_command_bridge.hpp +0 -459
  173. package/examples/bridge/mqtt_status_bridge.hpp +0 -519
  174. package/examples/bridgeAwareSensorNode/alteriom_sensor_package.hpp +0 -1227
  175. package/examples/bridgeAwareSensorNode/bridgeAwareSensorNode.ino +0 -342
  176. package/examples/bridgeAwareSensorNode/platformio.ini +0 -26
  177. package/examples/diagnosticsExample/diagnosticsExample.ino +0 -171
  178. package/examples/diagnosticsExample/platformio.ini +0 -26
  179. package/examples/echoNode/echoNode.ino +0 -33
  180. package/examples/echoNode/platformio.ini +0 -26
  181. package/examples/meshCommandNode/alteriom_sensor_package.hpp +0 -235
  182. package/examples/meshCommandNode/meshCommandNode.ino +0 -265
  183. package/examples/mqttCommandBridge/alteriom_sensor_package.hpp +0 -235
  184. package/examples/mqttCommandBridge/mesh_event_publisher.hpp +0 -253
  185. package/examples/mqttCommandBridge/mesh_topology_reporter.hpp +0 -303
  186. package/examples/mqttCommandBridge/mqttCommandBridge.ino +0 -254
  187. package/examples/mqttCommandBridge/mqtt_command_bridge.hpp +0 -462
  188. package/examples/mqttCommandBridge/platformio.ini +0 -27
  189. package/examples/mqttStatusBridge/mqttStatusBridge.ino +0 -218
  190. package/examples/mqttStatusBridge/mqtt_status_bridge.hpp +0 -522
  191. package/examples/mqttStatusBridge/platformio.ini +0 -27
  192. package/examples/mqttTopologyTest/README.md +0 -467
  193. package/examples/mqttTopologyTest/mqttTopologyTest.ino +0 -754
  194. package/examples/mqttTopologyTest/platformio.ini +0 -27
  195. package/examples/multi_bridge/README.md +0 -346
  196. package/examples/multi_bridge/primary_bridge.ino +0 -96
  197. package/examples/multi_bridge/regular_node.ino +0 -141
  198. package/examples/multi_bridge/secondary_bridge.ino +0 -111
  199. package/examples/ntpTimeSyncBridge/alteriom_sensor_package.hpp +0 -1383
  200. package/examples/ntpTimeSyncBridge/ntpTimeSyncBridge.ino +0 -86
  201. package/examples/ntpTimeSyncNode/alteriom_sensor_package.hpp +0 -1383
  202. package/examples/ntpTimeSyncNode/ntpTimeSyncNode.ino +0 -109
  203. package/examples/queued_alarms/README.md +0 -390
  204. package/examples/queued_alarms/queued_alarms.ino +0 -265
  205. package/examples/routing_demo/README.md +0 -172
  206. package/examples/routing_demo/routing_demo.ino +0 -102
  207. package/examples/rtcIntegration/README.md +0 -294
  208. package/examples/rtcIntegration/rtcIntegration.ino +0 -210
@@ -1,27 +0,0 @@
1
- [platformio]
2
- src_dir = .
3
-
4
- [env]
5
- lib_deps =
6
- bblanchon/ArduinoJson
7
- arkhipenko/TaskScheduler
8
- knolleary/PubSubClient
9
-
10
- lib_ldf_mode = deep+
11
- [env:esp8266]
12
- platform = espressif8266
13
- board = nodemcuv2
14
- framework = arduino
15
- lib_extra_dirs = ../../
16
- lib_deps =
17
- ${env.lib_deps} ; Inherit common dependencies
18
- esp32async/ESPAsyncTCP@^2.0.0 ; Only for ESP8266
19
-
20
- [env:esp32]
21
- platform = espressif32
22
- board = esp32dev
23
- framework = arduino
24
- lib_extra_dirs = ../../
25
- lib_deps =
26
- ${env.lib_deps} ; Inherit common dependencies
27
- esp32async/AsyncTCP
@@ -1,346 +0,0 @@
1
- # Multi-Bridge Example
2
-
3
- This example demonstrates advanced multi-bridge coordination for high-availability mesh networks with multiple simultaneous Internet gateways.
4
-
5
- ## Overview
6
-
7
- In a multi-bridge deployment, multiple nodes act as bridges to the Internet simultaneously. This provides:
8
-
9
- - **High Availability**: Zero downtime during failover
10
- - **Load Balancing**: Distribute traffic across multiple uplinks
11
- - **Geographic Distribution**: Bridges in different locations
12
- - **Redundancy**: Multiple paths to Internet
13
-
14
- ## Architecture
15
-
16
- ```
17
- Internet Connection A → Primary Bridge (Priority 10)
18
- ↓
19
- Mesh Network
20
- ↓
21
- Internet Connection B → Secondary Bridge (Priority 5)
22
- ↓
23
- Regular Nodes
24
- ```
25
-
26
- ## Files
27
-
28
- - **primary_bridge.ino** - Primary bridge with highest priority (10)
29
- - **secondary_bridge.ino** - Secondary bridge for redundancy (priority 5)
30
- - **regular_node.ino** - Regular mesh node that uses bridges
31
-
32
- ## How It Works
33
-
34
- ### Bridge Priority
35
-
36
- Bridges are assigned priorities (1-10):
37
- - **10 = Primary**: Handles all traffic when available
38
- - **5 = Secondary**: Hot standby, takes over if primary fails
39
- - **1 = Standby**: Only used if all higher priority bridges fail
40
-
41
- ### Bridge Selection Strategies
42
-
43
- 1. **PRIORITY_BASED** (default): Always use highest priority available bridge
44
- 2. **ROUND_ROBIN**: Distribute load evenly across all bridges
45
- 3. **BEST_SIGNAL**: Use bridge with best WiFi signal strength
46
-
47
- ### Coordination Protocol
48
-
49
- Bridges exchange coordination messages (Type 613) containing:
50
- - Priority level
51
- - Current role (primary/secondary/standby)
52
- - Load percentage
53
- - List of known peer bridges
54
-
55
- Regular nodes track all bridges and automatically select the best one based on the configured strategy.
56
-
57
- ## Setup Instructions
58
-
59
- ### Hardware Required
60
-
61
- - 3+ ESP32 or ESP8266 devices
62
- - 1-2 WiFi routers with Internet connection
63
- - USB cables for programming
64
-
65
- ### Configuration
66
-
67
- #### Primary Bridge
68
- 1. Flash `primary_bridge.ino` to first ESP32
69
- 2. Configure router credentials:
70
- ```cpp
71
- #define ROUTER_SSID "YourPrimaryRouter"
72
- #define ROUTER_PASSWORD "routerpass"
73
- ```
74
- 3. Priority is set to 10 (highest)
75
-
76
- #### Secondary Bridge
77
- 1. Flash `secondary_bridge.ino` to second ESP32
78
- 2. Configure router credentials (can be same or different router):
79
- ```cpp
80
- #define ROUTER_SSID "YourSecondaryRouter"
81
- #define ROUTER_PASSWORD "routerpass2"
82
- ```
83
- 3. Priority is set to 5 (secondary)
84
-
85
- #### Regular Nodes
86
- 1. Flash `regular_node.ino` to remaining ESP32 devices
87
- 2. No router credentials needed
88
- 3. They automatically discover and use bridges
89
-
90
- ### Testing
91
-
92
- #### Normal Operation
93
- 1. Power on primary bridge - should connect to router
94
- 2. Power on secondary bridge - should connect to router
95
- 3. Power on regular nodes - should join mesh
96
- 4. Regular nodes should prefer primary bridge (priority 10)
97
-
98
- #### Failover Test
99
- 1. Disconnect primary bridge from power
100
- 2. Regular nodes should detect loss within 60 seconds
101
- 3. Regular nodes should automatically switch to secondary bridge
102
- 4. No data loss or interruption
103
-
104
- #### Load Balancing Test (Round-Robin)
105
- 1. On regular nodes, change strategy:
106
- ```cpp
107
- mesh.setBridgeSelectionStrategy(painlessMesh::ROUND_ROBIN);
108
- ```
109
- 2. Messages should alternate between bridges
110
-
111
- ## Bridge Selection Strategies
112
-
113
- ### Priority-Based (Default)
114
-
115
- Best for most deployments. Uses highest priority bridge available.
116
-
117
- ```cpp
118
- mesh.setBridgeSelectionStrategy(painlessMesh::PRIORITY_BASED);
119
- ```
120
-
121
- **When to use:**
122
- - Production systems needing predictable routing
123
- - When you have primary and backup Internet connections
124
- - Clear preference for one connection over another
125
-
126
- ### Round-Robin Load Balancing
127
-
128
- Distributes traffic evenly across all bridges.
129
-
130
- ```cpp
131
- mesh.setBridgeSelectionStrategy(painlessMesh::ROUND_ROBIN);
132
- ```
133
-
134
- **When to use:**
135
- - High traffic scenarios
136
- - Multiple equal-quality Internet connections
137
- - Load distribution is important
138
-
139
- ### Best Signal
140
-
141
- Always uses bridge with strongest WiFi signal.
142
-
143
- ```cpp
144
- mesh.setBridgeSelectionStrategy(painlessMesh::BEST_SIGNAL);
145
- ```
146
-
147
- **When to use:**
148
- - Large mesh networks
149
- - Nodes move around
150
- - Signal strength affects performance significantly
151
-
152
- ## API Reference
153
-
154
- ### Multi-Bridge Configuration
155
-
156
- ```cpp
157
- // Enable multi-bridge mode
158
- mesh.enableMultiBridge(true);
159
-
160
- // Set selection strategy
161
- mesh.setBridgeSelectionStrategy(painlessMesh::PRIORITY_BASED);
162
- mesh.setBridgeSelectionStrategy(painlessMesh::ROUND_ROBIN);
163
- mesh.setBridgeSelectionStrategy(painlessMesh::BEST_SIGNAL);
164
-
165
- // Set max concurrent bridges (default: 2, max: 5)
166
- mesh.setMaxBridges(3);
167
- ```
168
-
169
- ### Bridge Initialization
170
-
171
- ```cpp
172
- // Initialize as bridge with priority
173
- mesh.initAsBridge(meshSSID, meshPassword,
174
- routerSSID, routerPassword,
175
- &scheduler, port, priority);
176
- ```
177
-
178
- ### Bridge Discovery
179
-
180
- ```cpp
181
- // Get list of active bridge node IDs
182
- std::vector<uint32_t> bridges = mesh.getActiveBridges();
183
-
184
- // Get recommended bridge for next message
185
- uint32_t bridgeId = mesh.getRecommendedBridge();
186
-
187
- // Manually select bridge for next transmission
188
- mesh.selectBridge(bridgeId);
189
-
190
- // Check if multi-bridge is enabled
191
- bool enabled = mesh.isMultiBridgeEnabled();
192
- ```
193
-
194
- ## Expected Output
195
-
196
- ### Primary Bridge
197
- ```
198
- === Multi-Bridge: PRIMARY BRIDGE ===
199
-
200
- === Bridge Mode Initialization (Priority: 10, Role: primary) ===
201
- ✓ Router connected on channel 6
202
- ✓ Router IP: 192.168.1.100
203
- Bridge coordination enabled (priority: 10, role: primary)
204
-
205
- === Primary Bridge Status ===
206
- Node ID: 123456
207
- Connected Nodes: 3
208
- Active Bridges: 2
209
- - Bridge: 123456 (ME)
210
- - Bridge: 789012
211
- Recommended Bridge: 123456
212
- ```
213
-
214
- ### Secondary Bridge
215
- ```
216
- === Multi-Bridge: SECONDARY BRIDGE ===
217
-
218
- === Bridge Mode Initialization (Priority: 5, Role: secondary) ===
219
- ✓ Router connected on channel 6
220
- ✓ Router IP: 192.168.1.101
221
- Bridge coordination enabled (priority: 5, role: secondary)
222
-
223
- === Secondary Bridge Status ===
224
- Node ID: 789012
225
- Connected Nodes: 3
226
- Active Bridges: 2
227
- - Bridge: 123456
228
- - Bridge: 789012 (ME)
229
- Recommended Bridge: 123456
230
- ✓ Standby mode - primary bridge is active
231
- ```
232
-
233
- ### Regular Node
234
- ```
235
- === Multi-Bridge: REGULAR NODE ===
236
-
237
- === Network Status ===
238
- Node ID: 456789
239
- Connected Nodes: 4
240
- Active Bridges: 2
241
- - Bridge: 123456
242
- - Bridge: 789012
243
- Internet Available: YES
244
-
245
- --- Sending Sensor Data ---
246
- Recommended Bridge: 123456
247
- Message: Temperature: 22.3°C, Humidity: 45.2%
248
- ✓ Sent to bridge
249
- ```
250
-
251
- ## Troubleshooting
252
-
253
- ### No Bridges Found
254
-
255
- **Symptoms**: `Active Bridges: 0`
256
-
257
- **Solutions**:
258
- - Verify bridge nodes are powered on
259
- - Check router credentials are correct
260
- - Ensure bridges successfully connected to router
261
- - Check all devices use same MESH_PREFIX and MESH_PASSWORD
262
-
263
- ### Bridges Not Coordinating
264
-
265
- **Symptoms**: Bridges don't see each other
266
-
267
- **Solutions**:
268
- - Verify `enableMultiBridge(true)` is called on all bridges
269
- - Check mesh connectivity between bridges
270
- - Look for "Bridge coordination" messages in logs
271
- - Ensure bridges are on same mesh network
272
-
273
- ### Failover Not Working
274
-
275
- **Symptoms**: No automatic switch to secondary
276
-
277
- **Solutions**:
278
- - Check `mesh.onBridgeStatusChanged()` callback is registered
279
- - Verify secondary bridge has Internet connection
280
- - Ensure bridge status broadcasts are enabled
281
- - Check 60-second timeout hasn't been exceeded
282
-
283
- ### Wrong Bridge Selected
284
-
285
- **Symptoms**: Secondary used instead of primary
286
-
287
- **Solutions**:
288
- - Verify priorities are correct (primary=10, secondary=5)
289
- - Check strategy is PRIORITY_BASED
290
- - Ensure primary bridge has Internet connection
291
- - Look for priority values in coordination messages
292
-
293
- ## Advanced Configuration
294
-
295
- ### Three or More Bridges
296
-
297
- ```cpp
298
- // Bridge 1: Primary (priority 10)
299
- mesh.initAsBridge(ssid, pass, router1, pass1, &sched, port, 10);
300
-
301
- // Bridge 2: Secondary (priority 7)
302
- mesh.initAsBridge(ssid, pass, router2, pass2, &sched, port, 7);
303
-
304
- // Bridge 3: Tertiary (priority 3)
305
- mesh.initAsBridge(ssid, pass, router3, pass3, &sched, port, 3);
306
- ```
307
-
308
- ### Geographic Distribution
309
-
310
- Use when mesh spans multiple buildings:
311
-
312
- ```
313
- Building A: Bridge1 (priority 10) → Internet A
314
- Building B: Bridge2 (priority 10) → Internet B
315
- ```
316
-
317
- Both bridges have same priority, nodes use closest one (BEST_SIGNAL strategy).
318
-
319
- ### Traffic Shaping (Future)
320
-
321
- Route different message types to different bridges:
322
-
323
- ```cpp
324
- // Coming in future release
325
- mesh.setBridgeSelectionStrategy(mesh.TRAFFIC_TYPE);
326
- mesh.routeTrafficType(ALARM_MESSAGE, bridge1);
327
- mesh.routeTrafficType(SENSOR_DATA, bridge2);
328
- ```
329
-
330
- ## Dependencies
331
-
332
- - Issue #63: Bridge Status Broadcast ✅ (IMPLEMENTED)
333
- - Issue #64: Bridge Failover ✅ (IMPLEMENTED)
334
- - Issue #65: Multi-Bridge Coordination ✅ (THIS FEATURE)
335
-
336
- ## Related Examples
337
-
338
- - `examples/bridge/` - Basic single bridge setup
339
- - `examples/bridge_failover/` - Single bridge with automatic failover
340
- - `examples/bridgeAwareSensorNode/` - Node that checks bridge status
341
-
342
- ## Further Reading
343
-
344
- - [Bridge Architecture Documentation](../../BRIDGE_TO_INTERNET.md)
345
- - [Bridge Health Monitoring](../../BRIDGE_HEALTH_MONITORING_IMPLEMENTATION.md)
346
- - [painlessMesh Wiki](https://gitlab.com/painlessMesh/painlessMesh/-/wikis/home)
@@ -1,96 +0,0 @@
1
- //************************************************************
2
- // Multi-Bridge Example: Primary Bridge Node
3
- //
4
- // This example demonstrates a primary bridge (priority 10) in a
5
- // multi-bridge deployment. Use with secondary_bridge.ino for
6
- // redundancy and load balancing.
7
- //
8
- // Features demonstrated:
9
- // - Primary bridge with highest priority
10
- // - Multi-bridge coordination
11
- // - Load reporting and bridge discovery
12
- // - Automatic role management
13
- //************************************************************
14
-
15
- #include "painlessMesh.h"
16
-
17
- #define MESH_PREFIX "MultiBridgeMesh"
18
- #define MESH_PASSWORD "meshpassword"
19
- #define MESH_PORT 5555
20
-
21
- // Primary router connection (high-speed Internet)
22
- #define ROUTER_SSID "PrimaryRouter"
23
- #define ROUTER_PASSWORD "routerpass"
24
-
25
- Scheduler userScheduler;
26
- painlessMesh mesh;
27
-
28
- // Task to display bridge coordination status
29
- Task taskBridgeStatus(10000, TASK_FOREVER, [](){
30
- Serial.println("\n=== Primary Bridge Status ===");
31
- Serial.printf("Node ID: %u\n", mesh.getNodeId());
32
- Serial.printf("Connected Nodes: %d\n", mesh.getNodeList().size());
33
-
34
- // Show all active bridges in the mesh
35
- auto activeBridges = mesh.getActiveBridges();
36
- Serial.printf("Active Bridges: %d\n", activeBridges.size());
37
- for (auto bridgeId : activeBridges) {
38
- Serial.printf(" - Bridge: %u%s\n", bridgeId,
39
- (bridgeId == mesh.getNodeId()) ? " (ME)" : "");
40
- }
41
-
42
- // Show recommended bridge for next message
43
- uint32_t recommended = mesh.getRecommendedBridge();
44
- Serial.printf("Recommended Bridge: %u\n", recommended);
45
- Serial.println("=============================\n");
46
- });
47
-
48
- void receivedCallback(uint32_t from, String& msg) {
49
- Serial.printf("Received from %u: %s\n", from, msg.c_str());
50
- }
51
-
52
- void newConnectionCallback(uint32_t nodeId) {
53
- Serial.printf("New Connection, nodeId = %u\n", nodeId);
54
- }
55
-
56
- void changedConnectionCallback() {
57
- Serial.printf("Changed connections. Node count: %d\n", mesh.getNodeList().size());
58
- }
59
-
60
- void setup() {
61
- Serial.begin(115200);
62
- delay(2000);
63
-
64
- Serial.println("\n\n=== Multi-Bridge: PRIMARY BRIDGE ===\n");
65
-
66
- // Initialize mesh as primary bridge with priority 10 (highest)
67
- mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION);
68
-
69
- // Enable multi-bridge coordination mode
70
- mesh.enableMultiBridge(true);
71
-
72
- // Set bridge selection strategy (PRIORITY_BASED is default)
73
- mesh.setBridgeSelectionStrategy(painlessMesh::PRIORITY_BASED);
74
-
75
- // Initialize as bridge with priority 10 (primary)
76
- mesh.initAsBridge(MESH_PREFIX, MESH_PASSWORD,
77
- ROUTER_SSID, ROUTER_PASSWORD,
78
- &userScheduler, MESH_PORT, 10); // Priority 10 = Primary
79
-
80
- mesh.onReceive(&receivedCallback);
81
- mesh.onNewConnection(&newConnectionCallback);
82
- mesh.onChangedConnections(&changedConnectionCallback);
83
-
84
- // Add status reporting task
85
- userScheduler.addTask(taskBridgeStatus);
86
- taskBridgeStatus.enable();
87
-
88
- Serial.println("\n=== Primary Bridge Ready ===");
89
- Serial.println("This node is the PRIMARY bridge (Priority 10)");
90
- Serial.println("It will be preferred for all mesh traffic");
91
- Serial.println("If it fails, the secondary bridge will take over automatically\n");
92
- }
93
-
94
- void loop() {
95
- mesh.update();
96
- }
@@ -1,141 +0,0 @@
1
- //************************************************************
2
- // Multi-Bridge Example: Regular Node
3
- //
4
- // This example demonstrates a regular mesh node in a multi-bridge
5
- // network. The node automatically discovers and uses available bridges
6
- // for Internet connectivity.
7
- //
8
- // Features demonstrated:
9
- // - Automatic bridge discovery
10
- // - Bridge selection awareness
11
- // - Message routing to best available bridge
12
- // - Failover handling
13
- //************************************************************
14
-
15
- #include "painlessMesh.h"
16
-
17
- #define MESH_PREFIX "MultiBridgeMesh"
18
- #define MESH_PASSWORD "meshpassword"
19
- #define MESH_PORT 5555
20
-
21
- Scheduler userScheduler;
22
- painlessMesh mesh;
23
-
24
- // Simulated sensor data
25
- float temperature = 22.5;
26
- float humidity = 45.0;
27
-
28
- // Task to send sensor data
29
- Task taskSendMessage(5000, TASK_FOREVER, [](){
30
- // Simulate sensor readings
31
- temperature += (random(-10, 10) / 10.0);
32
- humidity += (random(-50, 50) / 10.0);
33
-
34
- String msg = "Temperature: " + String(temperature, 1) + "°C, Humidity: " + String(humidity, 1) + "%";
35
-
36
- Serial.println("\n--- Sending Sensor Data ---");
37
-
38
- // Get recommended bridge
39
- uint32_t recommendedBridge = mesh.getRecommendedBridge();
40
-
41
- if (recommendedBridge != 0) {
42
- Serial.printf("Recommended Bridge: %u\n", recommendedBridge);
43
- Serial.printf("Message: %s\n", msg.c_str());
44
-
45
- // Send to specific bridge
46
- mesh.sendSingle(recommendedBridge, msg);
47
- Serial.println("✓ Sent to bridge");
48
- } else {
49
- Serial.println("⚠️ No bridge available!");
50
- Serial.println("Message queued for later delivery");
51
- // In production, you would queue this message
52
- }
53
- Serial.println("---------------------------\n");
54
- });
55
-
56
- // Task to display network status
57
- Task taskNetworkStatus(15000, TASK_FOREVER, [](){
58
- Serial.println("\n=== Network Status ===");
59
- Serial.printf("Node ID: %u\n", mesh.getNodeId());
60
- Serial.printf("Connected Nodes: %d\n", mesh.getNodeList().size());
61
-
62
- // Show all active bridges
63
- auto activeBridges = mesh.getActiveBridges();
64
- Serial.printf("Active Bridges: %d\n", activeBridges.size());
65
-
66
- if (activeBridges.empty()) {
67
- Serial.println(" ⚠️ NO BRIDGES AVAILABLE");
68
- } else {
69
- for (auto bridgeId : activeBridges) {
70
- Serial.printf(" - Bridge: %u\n", bridgeId);
71
- }
72
- }
73
-
74
- // Check Internet connectivity
75
- bool hasInternet = mesh.hasInternetConnection();
76
- Serial.printf("Internet Available: %s\n", hasInternet ? "YES" : "NO");
77
-
78
- Serial.println("======================\n");
79
- });
80
-
81
- void receivedCallback(uint32_t from, String& msg) {
82
- Serial.printf("📨 Received from %u: %s\n", from, msg.c_str());
83
- }
84
-
85
- void newConnectionCallback(uint32_t nodeId) {
86
- Serial.printf("🔗 New Connection: %u\n", nodeId);
87
- }
88
-
89
- void changedConnectionCallback() {
90
- Serial.printf("🔄 Connections changed. Total nodes: %d\n", mesh.getNodeList().size());
91
- }
92
-
93
- void bridgeStatusCallback(uint32_t bridgeNodeId, bool hasInternet) {
94
- Serial.printf("\n🌉 Bridge Status Update: Bridge %u - Internet %s\n",
95
- bridgeNodeId, hasInternet ? "CONNECTED" : "OFFLINE");
96
-
97
- if (hasInternet) {
98
- Serial.println("✓ Internet connection available");
99
- } else {
100
- Serial.println("⚠️ Bridge lost Internet - checking for alternatives...");
101
-
102
- auto activeBridges = mesh.getActiveBridges();
103
- if (activeBridges.empty()) {
104
- Serial.println("⚠️ No alternative bridges available!");
105
- } else {
106
- Serial.printf("✓ %d alternative bridge(s) available\n", activeBridges.size());
107
- }
108
- }
109
- }
110
-
111
- void setup() {
112
- Serial.begin(115200);
113
- delay(2000);
114
-
115
- Serial.println("\n\n=== Multi-Bridge: REGULAR NODE ===\n");
116
-
117
- // Initialize as regular mesh node
118
- mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION);
119
-
120
- mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT);
121
-
122
- mesh.onReceive(&receivedCallback);
123
- mesh.onNewConnection(&newConnectionCallback);
124
- mesh.onChangedConnections(&changedConnectionCallback);
125
- mesh.onBridgeStatusChanged(&bridgeStatusCallback);
126
-
127
- // Add tasks
128
- userScheduler.addTask(taskSendMessage);
129
- userScheduler.addTask(taskNetworkStatus);
130
- taskSendMessage.enable();
131
- taskNetworkStatus.enable();
132
-
133
- Serial.println("\n=== Regular Node Ready ===");
134
- Serial.println("This node will automatically discover and use available bridges");
135
- Serial.println("In multi-bridge mode, it will use the highest priority bridge");
136
- Serial.println("If primary fails, it automatically switches to secondary\n");
137
- }
138
-
139
- void loop() {
140
- mesh.update();
141
- }