@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.
- package/BRIDGE_TO_INTERNET.md +229 -0
- package/CHANGELOG.md +89 -1
- package/CONTRIBUTING.md +79 -0
- package/README.md +70 -143
- package/docs/README.md +1 -0
- package/docs/api/shared-gateway.md +1207 -0
- package/docs/troubleshooting/common-issues.md +28 -0
- package/docs/troubleshooting/faq.md +113 -12
- package/examples/basic/test/simulator/CMakeLists.txt +40 -0
- package/examples/basic/test/simulator/README.md +149 -0
- package/examples/basic/test/simulator/firmware/basic_firmware.hpp +117 -0
- package/examples/basic/test/simulator/scenarios/basic_mesh_test.yaml +81 -0
- package/examples/bridge/bridge.ino +17 -4
- package/examples/bridge_failover/README.md +81 -0
- package/examples/bridge_failover/bridge_failover.ino +51 -6
- package/examples/sharedGateway/README.md +235 -0
- package/examples/{meshCommandNode → sharedGateway}/platformio.ini +3 -2
- package/examples/sharedGateway/sharedGateway.ino +303 -0
- package/library.json +3 -22
- package/library.properties +1 -1
- package/package.json +3 -3
- package/src/arduino/wifi.hpp +380 -13
- package/src/painlessmesh/gateway.hpp +2120 -0
- package/src/painlessmesh/mesh.hpp +1034 -6
- package/src/painlessmesh/message_tracker.hpp +311 -0
- package/src/painlessmesh/protocol.hpp +6 -0
- package/DOCUMENTATION_INDEX.md +0 -146
- package/docs/API_DESIGN_GUIDELINES.md +0 -414
- package/docs/ARDUINO_LIBRARY_MANAGER_SUBMISSION.md +0 -331
- package/docs/BOOLEAN_NAMING_CONVENTION.md +0 -235
- package/docs/BRIDGE_FAILOVER.md +0 -512
- package/docs/BRIDGE_HEALTH_MONITORING.md +0 -293
- package/docs/CHANNEL_SYNCHRONIZATION.md +0 -209
- package/docs/CREATE_MISSING_RELEASES.md +0 -321
- package/docs/DOCUMENTATION_MIGRATION_PLAN.md +0 -176
- package/docs/FAQ_VERSION_NUMBERS.md +0 -152
- package/docs/IMPLEMENTATION_PLAN_MESH_TOPOLOGY.md +0 -1062
- package/docs/MESH_TOPOLOGY_GUIDE.md +0 -992
- package/docs/MESH_TOPOLOGY_PROGRESS.md +0 -422
- package/docs/MQTT_BRIDGE_COMMANDS.md +0 -894
- package/docs/MQTT_BRIDGE_IMPLEMENTATION_SUMMARY.md +0 -324
- package/docs/MQTT_COMMAND_SCHEMA_PROPOSAL.md +0 -576
- package/docs/MQTT_SCHEMA_COMPLIANCE.md +0 -340
- package/docs/MQTT_SCHEMA_PROPOSALS.md +0 -446
- package/docs/MQTT_SCHEMA_REVIEW.md +0 -690
- package/docs/OTA_COMMANDS_REFERENCE.md +0 -554
- package/docs/PHASE1_GUIDE.md +0 -349
- package/docs/PHASE2_GUIDE.md +0 -543
- package/docs/QUICK_REFERENCE_VERSIONING.md +0 -127
- package/docs/RELEASE_AGENT_SUMMARY.md +0 -386
- package/docs/SCHEMA_VALIDATION_CHECKLIST.md +0 -222
- package/docs/VERSION_MANAGEMENT.md +0 -213
- package/docs/archive/DOCUSAURUS_DEPLOYMENT.md +0 -166
- package/docs/archive/FEATURE_PROPOSALS.md +0 -337
- package/docs/archive/LIBRARY_JSON_FIX.md +0 -98
- package/docs/archive/LIBRARY_STRUCTURE_FIX.md +0 -215
- package/docs/archive/PHASE1_IMPLEMENTATION.md +0 -325
- package/docs/archive/PHASE2_IMPLEMENTATION.md +0 -567
- package/docs/archive/RELEASE_SUMMARY.md +0 -173
- package/docs/archive/SCONS_BUILD_FIX.md +0 -313
- package/docs/archive/TRIGGER_RELEASE.md +0 -280
- package/docs/archive/VECTOR_INCLUDE_FIX.md +0 -129
- package/docs/archive/ota-and-status-enhancements.md +0 -911
- package/docs/archive/ota-status-architecture-diagrams.md +0 -658
- package/docs/archive/ota-status-quick-reference.md +0 -284
- package/docs/design/.gitkeep +0 -1
- package/docs/design/STATION_CREDENTIALS_DESIGN.md +0 -182
- package/docs/development/ARDUINO_COMPLIANCE_SUMMARY.md +0 -71
- package/docs/development/CODE_REFACTORING_RECOMMENDATIONS.md +0 -1011
- package/docs/development/DOCKER_TESTING.md +0 -196
- package/docs/development/PLATFORMIO_USAGE.md +0 -180
- package/docs/development/TESTING_SUMMARY.md +0 -126
- package/docs/development/contributing.md +0 -301
- package/docs/development/documentation.md +0 -583
- package/docs/features/DIAGNOSTICS_API.md +0 -534
- package/docs/implementation/BRIDGE_ARCHITECTURE_IMPLEMENTATION.md +0 -340
- package/docs/implementation/BRIDGE_HEALTH_MONITORING_IMPLEMENTATION.md +0 -213
- package/docs/implementation/BRIDGE_STATUS_FEATURE.md +0 -635
- package/docs/implementation/DIAGNOSTICS_API_IMPLEMENTATION.md +0 -232
- package/docs/implementation/IMPLEMENTATION_COMPLETE.md +0 -228
- package/docs/implementation/IMPLEMENTATION_NTP_TIME_SYNC.md +0 -325
- package/docs/implementation/IMPLEMENTATION_SUMMARY.md +0 -316
- package/docs/implementation/MESSAGE_QUEUE_IMPLEMENTATION.md +0 -405
- package/docs/implementation/MULTI_BRIDGE_IMPLEMENTATION.md +0 -520
- package/docs/implementation/NTP_TIME_SYNC_FEATURE.md +0 -392
- package/docs/improvements/FUTURE_PROPOSALS.md +0 -1016
- package/docs/improvements/IMPLEMENTATION_HISTORY.md +0 -1091
- package/docs/improvements/OTA_STATUS_ENHANCEMENTS.md +0 -709
- package/docs/improvements/README.md +0 -212
- package/docs/internal/CUSTOM_AGENT_ANALYSIS.md +0 -391
- package/docs/internal/ISSUE_65_VERIFICATION.md +0 -947
- package/docs/internal/ISSUE_66_CLOSURE.md +0 -249
- package/docs/internal/ISSUE_66_STATUS.md +0 -316
- package/docs/internal/PR_SUMMARY.md +0 -315
- package/docs/internal/REVIEW_SUMMARY.md +0 -332
- package/docs/multi-bridge-setup.md +0 -1025
- package/docs/platformio-publishing.md +0 -255
- package/docs/platformio-setup-summary.md +0 -121
- package/docs/releases/ANNOUNCEMENT_v1.8.6.md +0 -63
- package/docs/releases/ANNOUNCEMENT_v1.8.7.md +0 -113
- package/docs/releases/BRIDGE_STATUS_SELF_REGISTRATION_FIX.md +0 -221
- package/docs/releases/FEATURE_HISTORY.md +0 -543
- package/docs/releases/GITHUB_RELEASE_v1.8.6.md +0 -71
- package/docs/releases/GITHUB_RELEASE_v1.8.7.md +0 -90
- package/docs/releases/PATCH_v1.7.2.md +0 -262
- package/docs/releases/PATCH_v1.7.3.md +0 -262
- package/docs/releases/PATCH_v1.7.4.md +0 -219
- package/docs/releases/PHASE1_SUMMARY.md +0 -246
- package/docs/releases/PHASE2_SUMMARY.md +0 -499
- package/docs/releases/PUBLISH_v1.8.0_INSTRUCTIONS.md +0 -163
- package/docs/releases/QUICK_START_RELEASES.md +0 -113
- package/docs/releases/RELEASE_CHECKLIST_1.8.10.md +0 -331
- package/docs/releases/RELEASE_CHECKLIST_1.8.9.md +0 -207
- package/docs/releases/RELEASE_CHECKLIST_v1.7.4.md +0 -253
- package/docs/releases/RELEASE_CHECKLIST_v1.7.5.md +0 -315
- package/docs/releases/RELEASE_CHECKLIST_v1.7.6.md +0 -389
- package/docs/releases/RELEASE_CHECKLIST_v1.8.0.md +0 -331
- package/docs/releases/RELEASE_CHECKLIST_v1.8.2.md +0 -309
- package/docs/releases/RELEASE_NOTES_1.7.0.md +0 -539
- package/docs/releases/RELEASE_NOTES_1.8.10.md +0 -239
- package/docs/releases/RELEASE_NOTES_1.8.9.md +0 -213
- package/docs/releases/RELEASE_NOTES_v1.8.0.md +0 -685
- package/docs/releases/RELEASE_NOTES_v1.8.1.md +0 -221
- package/docs/releases/RELEASE_NOTES_v1.8.2.md +0 -421
- package/docs/releases/RELEASE_NOTES_v1.8.3.md +0 -292
- package/docs/releases/RELEASE_NOTES_v1.8.4.md +0 -277
- package/docs/releases/RELEASE_NOTES_v1.8.6.md +0 -205
- package/docs/releases/RELEASE_NOTES_v1.8.7.md +0 -184
- package/docs/releases/RELEASE_PLAN_v1.7.6.md +0 -816
- package/docs/releases/RELEASE_SUMMARY_1.8.10.md +0 -193
- package/docs/releases/RELEASE_SUMMARY_v1.7.4.md +0 -276
- package/docs/releases/RELEASE_SUMMARY_v1.7.5.md +0 -322
- package/docs/releases/RELEASE_SUMMARY_v1.7.6.md +0 -436
- package/docs/releases/RELEASE_SUMMARY_v1.7.7.md +0 -391
- package/docs/releases/RELEASE_SUMMARY_v1.7.8.md +0 -523
- package/docs/releases/RELEASE_SUMMARY_v1.7.9.md +0 -542
- package/docs/troubleshooting/ARDUINO_IDE_VERSION_FIX_SUMMARY.md +0 -229
- package/docs/troubleshooting/ARDUINO_LIBRARY_NAME_FIX.md +0 -197
- package/docs/troubleshooting/CRASH_QUICK_REF.md +0 -93
- package/docs/troubleshooting/ESP32_C6_COMPATIBILITY.md +0 -157
- package/docs/troubleshooting/FREERTOS_ASSERTION_FAILURE.md +0 -288
- package/docs/troubleshooting/FREERTOS_FIX_IMPLEMENTATION.md +0 -267
- package/docs/troubleshooting/NPM_PUBLISHING_ISSUE_SUMMARY.md +0 -110
- package/docs/troubleshooting/PAINLESSMESH_V1.7.4_COMPILATION_ISSUES.md +0 -547
- package/docs/troubleshooting/QUICK_FIX_FREERTOS.md +0 -164
- package/docs/troubleshooting/SENSOR_NODE_CONNECTION_CRASH.md +0 -264
- package/docs/troubleshooting/station-reconnection-issues.md +0 -172
- package/docs/v1.7.7_MQTT_IMPROVEMENTS.md +0 -794
- package/docs/wiki/API-Reference.md +0 -246
- package/docs/wiki/Complete-Documentation.md +0 -123
- package/examples/alteriomImproved/alteriom_sensor_package.hpp +0 -224
- package/examples/alteriomImproved/improved_sensor_node.ino +0 -248
- package/examples/alteriomImproved/platformio.ini +0 -32
- package/examples/alteriomMetricsHealth/alteriom_sensor_package.hpp +0 -796
- package/examples/alteriomMetricsHealth/metrics_health_node.ino +0 -429
- package/examples/alteriomMetricsHealth/platformio.ini +0 -26
- package/examples/alteriomPhase1/alteriom_sensor_package.hpp +0 -224
- package/examples/alteriomPhase1/phase1_features.ino +0 -242
- package/examples/alteriomPhase1/platformio.ini +0 -26
- package/examples/alteriomPhase2/alteriom_sensor_package.hpp +0 -224
- package/examples/alteriomPhase2/phase2_features.ino +0 -186
- package/examples/alteriomPhase2/platformio.ini +0 -26
- package/examples/alteriomSensorNode/alteriom_sensor_node.ino +0 -186
- package/examples/alteriomSensorNode/alteriom_sensor_package.hpp +0 -1227
- package/examples/alteriomSensorNode/platformio.ini +0 -26
- package/examples/bridge/alteriom_sensor_package.hpp +0 -1170
- package/examples/bridge/bridge_health_monitoring_example.ino +0 -188
- package/examples/bridge/enhanced_mqtt_bridge.hpp +0 -610
- package/examples/bridge/enhanced_mqtt_bridge_example.ino +0 -226
- package/examples/bridge/mesh_event_publisher.hpp +0 -253
- package/examples/bridge/mesh_topology_reporter.hpp +0 -303
- package/examples/bridge/mqtt_command_bridge.hpp +0 -459
- package/examples/bridge/mqtt_status_bridge.hpp +0 -519
- package/examples/bridgeAwareSensorNode/alteriom_sensor_package.hpp +0 -1227
- package/examples/bridgeAwareSensorNode/bridgeAwareSensorNode.ino +0 -342
- package/examples/bridgeAwareSensorNode/platformio.ini +0 -26
- package/examples/diagnosticsExample/diagnosticsExample.ino +0 -171
- package/examples/diagnosticsExample/platformio.ini +0 -26
- package/examples/echoNode/echoNode.ino +0 -33
- package/examples/echoNode/platformio.ini +0 -26
- package/examples/meshCommandNode/alteriom_sensor_package.hpp +0 -235
- package/examples/meshCommandNode/meshCommandNode.ino +0 -265
- package/examples/mqttCommandBridge/alteriom_sensor_package.hpp +0 -235
- package/examples/mqttCommandBridge/mesh_event_publisher.hpp +0 -253
- package/examples/mqttCommandBridge/mesh_topology_reporter.hpp +0 -303
- package/examples/mqttCommandBridge/mqttCommandBridge.ino +0 -254
- package/examples/mqttCommandBridge/mqtt_command_bridge.hpp +0 -462
- package/examples/mqttCommandBridge/platformio.ini +0 -27
- package/examples/mqttStatusBridge/mqttStatusBridge.ino +0 -218
- package/examples/mqttStatusBridge/mqtt_status_bridge.hpp +0 -522
- package/examples/mqttStatusBridge/platformio.ini +0 -27
- package/examples/mqttTopologyTest/README.md +0 -467
- package/examples/mqttTopologyTest/mqttTopologyTest.ino +0 -754
- package/examples/mqttTopologyTest/platformio.ini +0 -27
- package/examples/multi_bridge/README.md +0 -346
- package/examples/multi_bridge/primary_bridge.ino +0 -96
- package/examples/multi_bridge/regular_node.ino +0 -141
- package/examples/multi_bridge/secondary_bridge.ino +0 -111
- package/examples/ntpTimeSyncBridge/alteriom_sensor_package.hpp +0 -1383
- package/examples/ntpTimeSyncBridge/ntpTimeSyncBridge.ino +0 -86
- package/examples/ntpTimeSyncNode/alteriom_sensor_package.hpp +0 -1383
- package/examples/ntpTimeSyncNode/ntpTimeSyncNode.ino +0 -109
- package/examples/queued_alarms/README.md +0 -390
- package/examples/queued_alarms/queued_alarms.ino +0 -265
- package/examples/routing_demo/README.md +0 -172
- package/examples/routing_demo/routing_demo.ino +0 -102
- package/examples/rtcIntegration/README.md +0 -294
- package/examples/rtcIntegration/rtcIntegration.ino +0 -210
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
# Bridge Health Monitoring & Metrics Collection
|
|
2
|
-
|
|
3
|
-
## Overview
|
|
4
|
-
|
|
5
|
-
The Bridge Health Monitoring feature provides comprehensive operational visibility into bridge health, connectivity quality, and performance metrics. This is essential for production deployments, troubleshooting, and capacity planning.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
9
|
-
✅ **Connectivity Metrics** - Track uptime, internet connectivity, and disconnection events
|
|
10
|
-
✅ **Signal Quality** - Monitor WiFi signal strength (RSSI) statistics
|
|
11
|
-
✅ **Traffic Metrics** - Measure bytes and messages transmitted/received
|
|
12
|
-
✅ **Performance Metrics** - Calculate latency and packet loss
|
|
13
|
-
✅ **JSON Export** - Easy integration with monitoring tools
|
|
14
|
-
✅ **Prometheus Support** - Export metrics for Prometheus scraping
|
|
15
|
-
✅ **Periodic Callbacks** - Automated metric collection and reporting
|
|
16
|
-
|
|
17
|
-
## API Reference
|
|
18
|
-
|
|
19
|
-
### BridgeHealthMetrics Structure
|
|
20
|
-
|
|
21
|
-
```cpp
|
|
22
|
-
struct BridgeHealthMetrics {
|
|
23
|
-
// Connectivity
|
|
24
|
-
uint32_t uptimeSeconds; // Total uptime in seconds
|
|
25
|
-
uint32_t internetUptimeSeconds; // Time with Internet connection
|
|
26
|
-
uint32_t totalDisconnects; // Number of disconnection events
|
|
27
|
-
uint32_t currentUptime; // Current uptime in milliseconds
|
|
28
|
-
|
|
29
|
-
// Signal Quality
|
|
30
|
-
int8_t currentRSSI; // Current WiFi signal strength (dBm)
|
|
31
|
-
int8_t avgRSSI; // Average signal strength
|
|
32
|
-
int8_t minRSSI; // Minimum observed signal strength
|
|
33
|
-
int8_t maxRSSI; // Maximum observed signal strength
|
|
34
|
-
|
|
35
|
-
// Traffic
|
|
36
|
-
uint64_t bytesRx; // Total bytes received
|
|
37
|
-
uint64_t bytesTx; // Total bytes transmitted
|
|
38
|
-
uint32_t messagesRx; // Total messages received
|
|
39
|
-
uint32_t messagesTx; // Total messages transmitted
|
|
40
|
-
uint32_t messagesQueued; // Messages currently queued
|
|
41
|
-
uint32_t messagesDropped; // Messages that failed to send
|
|
42
|
-
|
|
43
|
-
// Performance
|
|
44
|
-
uint32_t avgLatencyMs; // Average message latency
|
|
45
|
-
uint8_t packetLossPercent; // Packet loss percentage (0-100)
|
|
46
|
-
uint32_t meshNodeCount; // Number of nodes in mesh
|
|
47
|
-
};
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
### Methods
|
|
51
|
-
|
|
52
|
-
#### getBridgeHealthMetrics()
|
|
53
|
-
|
|
54
|
-
Get current health metrics snapshot.
|
|
55
|
-
|
|
56
|
-
```cpp
|
|
57
|
-
BridgeHealthMetrics metrics = mesh.getBridgeHealthMetrics();
|
|
58
|
-
|
|
59
|
-
Serial.printf("Uptime: %u s\n", metrics.uptimeSeconds);
|
|
60
|
-
Serial.printf("Messages RX: %u\n", metrics.messagesRx);
|
|
61
|
-
Serial.printf("Avg Latency: %u ms\n", metrics.avgLatencyMs);
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
#### resetHealthMetrics()
|
|
65
|
-
|
|
66
|
-
Reset all counters to zero. Useful for periodic monitoring windows.
|
|
67
|
-
|
|
68
|
-
```cpp
|
|
69
|
-
mesh.resetHealthMetrics();
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
**Note:** This resets counters (messages, bytes, disconnects) but keeps current state metrics (RSSI, node count).
|
|
73
|
-
|
|
74
|
-
#### getHealthMetricsJSON()
|
|
75
|
-
|
|
76
|
-
Export metrics as JSON string for easy integration.
|
|
77
|
-
|
|
78
|
-
```cpp
|
|
79
|
-
String json = mesh.getHealthMetricsJSON();
|
|
80
|
-
mqttClient.publish("bridge/metrics", json.c_str());
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
**JSON Format:**
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"connectivity": {
|
|
87
|
-
"uptimeSeconds": 3600,
|
|
88
|
-
"internetUptimeSeconds": 3540,
|
|
89
|
-
"totalDisconnects": 2,
|
|
90
|
-
"currentUptime": 3600000
|
|
91
|
-
},
|
|
92
|
-
"signalQuality": {
|
|
93
|
-
"currentRSSI": -65,
|
|
94
|
-
"avgRSSI": -68,
|
|
95
|
-
"minRSSI": -75,
|
|
96
|
-
"maxRSSI": -60
|
|
97
|
-
},
|
|
98
|
-
"traffic": {
|
|
99
|
-
"bytesRx": 1048576,
|
|
100
|
-
"bytesTx": 524288,
|
|
101
|
-
"messagesRx": 1234,
|
|
102
|
-
"messagesTx": 567,
|
|
103
|
-
"messagesQueued": 0,
|
|
104
|
-
"messagesDropped": 5
|
|
105
|
-
},
|
|
106
|
-
"performance": {
|
|
107
|
-
"avgLatencyMs": 45,
|
|
108
|
-
"packetLossPercent": 1,
|
|
109
|
-
"meshNodeCount": 8
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
#### onHealthMetricsUpdate()
|
|
115
|
-
|
|
116
|
-
Register a periodic callback for automated monitoring.
|
|
117
|
-
|
|
118
|
-
```cpp
|
|
119
|
-
mesh.onHealthMetricsUpdate([](BridgeHealthMetrics metrics) {
|
|
120
|
-
// Process metrics
|
|
121
|
-
Serial.printf("Nodes: %u, Latency: %u ms\n",
|
|
122
|
-
metrics.meshNodeCount, metrics.avgLatencyMs);
|
|
123
|
-
}, 60000); // Every 60 seconds
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
## Integration Examples
|
|
127
|
-
|
|
128
|
-
### MQTT Publishing
|
|
129
|
-
|
|
130
|
-
```cpp
|
|
131
|
-
#include <PubSubClient.h>
|
|
132
|
-
|
|
133
|
-
WiFiClient espClient;
|
|
134
|
-
PubSubClient mqttClient(espClient);
|
|
135
|
-
|
|
136
|
-
void metricsCallback(BridgeHealthMetrics metrics) {
|
|
137
|
-
if (mqttClient.connected()) {
|
|
138
|
-
String json = mesh.getHealthMetricsJSON();
|
|
139
|
-
mqttClient.publish("bridge/metrics", json.c_str());
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
void setup() {
|
|
144
|
-
// ... mesh setup ...
|
|
145
|
-
mesh.onHealthMetricsUpdate(metricsCallback, 60000);
|
|
146
|
-
}
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
### Prometheus Exporter
|
|
150
|
-
|
|
151
|
-
```cpp
|
|
152
|
-
#include <ESPAsyncWebServer.h>
|
|
153
|
-
|
|
154
|
-
AsyncWebServer server(80);
|
|
155
|
-
|
|
156
|
-
String exportPrometheus() {
|
|
157
|
-
auto metrics = mesh.getBridgeHealthMetrics();
|
|
158
|
-
|
|
159
|
-
String output = "";
|
|
160
|
-
output += "# HELP bridge_uptime_seconds Bridge uptime\n";
|
|
161
|
-
output += "# TYPE bridge_uptime_seconds counter\n";
|
|
162
|
-
output += "bridge_uptime_seconds " + String(metrics.uptimeSeconds) + "\n";
|
|
163
|
-
|
|
164
|
-
output += "# HELP bridge_rssi_dbm WiFi signal strength\n";
|
|
165
|
-
output += "# TYPE bridge_rssi_dbm gauge\n";
|
|
166
|
-
output += "bridge_rssi_dbm " + String(metrics.currentRSSI) + "\n";
|
|
167
|
-
|
|
168
|
-
// Add more metrics...
|
|
169
|
-
|
|
170
|
-
return output;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
void setup() {
|
|
174
|
-
// ... mesh setup ...
|
|
175
|
-
|
|
176
|
-
server.on("/metrics", HTTP_GET, [](AsyncWebServerRequest *request){
|
|
177
|
-
request->send(200, "text/plain", exportPrometheus());
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
server.begin();
|
|
181
|
-
}
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
### Grafana Dashboard
|
|
185
|
-
|
|
186
|
-
Use the Prometheus exporter above with Grafana to create monitoring dashboards:
|
|
187
|
-
|
|
188
|
-
1. Configure Prometheus to scrape your bridge node: `http://bridge-ip/metrics`
|
|
189
|
-
2. Import metrics into Grafana
|
|
190
|
-
3. Create panels for:
|
|
191
|
-
- Uptime and availability
|
|
192
|
-
- Signal strength trends
|
|
193
|
-
- Traffic throughput
|
|
194
|
-
- Latency and packet loss
|
|
195
|
-
- Mesh topology changes
|
|
196
|
-
|
|
197
|
-
### Cloud Logging (AWS CloudWatch, Azure Monitor, etc.)
|
|
198
|
-
|
|
199
|
-
```cpp
|
|
200
|
-
void metricsCallback(BridgeHealthMetrics metrics) {
|
|
201
|
-
String json = mesh.getHealthMetricsJSON();
|
|
202
|
-
|
|
203
|
-
// Send to CloudWatch
|
|
204
|
-
httpClient.post("/cloudwatch", json);
|
|
205
|
-
|
|
206
|
-
// Send to Azure Monitor
|
|
207
|
-
httpClient.post("/azure-monitor", json);
|
|
208
|
-
}
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
## Use Cases
|
|
212
|
-
|
|
213
|
-
### Production Monitoring
|
|
214
|
-
|
|
215
|
-
Monitor bridge health in production deployments:
|
|
216
|
-
- Track uptime and availability
|
|
217
|
-
- Detect connectivity issues early
|
|
218
|
-
- Analyze signal quality trends
|
|
219
|
-
- Capacity planning based on traffic patterns
|
|
220
|
-
|
|
221
|
-
### Troubleshooting
|
|
222
|
-
|
|
223
|
-
Debug network issues:
|
|
224
|
-
- Identify sources of packet loss
|
|
225
|
-
- Locate signal strength problems
|
|
226
|
-
- Diagnose latency spikes
|
|
227
|
-
- Track disconnection patterns
|
|
228
|
-
|
|
229
|
-
### Performance Optimization
|
|
230
|
-
|
|
231
|
-
Optimize mesh performance:
|
|
232
|
-
- Analyze traffic patterns
|
|
233
|
-
- Identify bottlenecks
|
|
234
|
-
- Optimize node placement based on RSSI
|
|
235
|
-
- Fine-tune routing strategies
|
|
236
|
-
|
|
237
|
-
## Best Practices
|
|
238
|
-
|
|
239
|
-
### Monitoring Intervals
|
|
240
|
-
|
|
241
|
-
- **Development:** 10-30 seconds for rapid feedback
|
|
242
|
-
- **Production:** 60-300 seconds to reduce overhead
|
|
243
|
-
- **Critical Systems:** 30-60 seconds with alerting
|
|
244
|
-
|
|
245
|
-
### Metric Storage
|
|
246
|
-
|
|
247
|
-
- Use time-series databases (InfluxDB, Prometheus)
|
|
248
|
-
- Retain raw metrics for 7-30 days
|
|
249
|
-
- Aggregate to hourly/daily for long-term storage
|
|
250
|
-
- Set up automated retention policies
|
|
251
|
-
|
|
252
|
-
### Alerting
|
|
253
|
-
|
|
254
|
-
Set up alerts for:
|
|
255
|
-
- Packet loss > 5%
|
|
256
|
-
- Latency > 200ms
|
|
257
|
-
- Signal strength < -80 dBm
|
|
258
|
-
- Frequent disconnections (> 3/hour)
|
|
259
|
-
- Node count drops
|
|
260
|
-
|
|
261
|
-
### Resource Management
|
|
262
|
-
|
|
263
|
-
On ESP8266 (limited RAM):
|
|
264
|
-
- Use longer intervals (120-300 seconds)
|
|
265
|
-
- Minimize callback complexity
|
|
266
|
-
- Consider offloading processing to gateway
|
|
267
|
-
|
|
268
|
-
On ESP32 (more RAM):
|
|
269
|
-
- Can use shorter intervals (30-60 seconds)
|
|
270
|
-
- More sophisticated processing possible
|
|
271
|
-
- Support multiple monitoring integrations
|
|
272
|
-
|
|
273
|
-
## Example: Complete Monitoring Setup
|
|
274
|
-
|
|
275
|
-
See `examples/bridge/bridge_health_monitoring_example.ino` for a complete working example with:
|
|
276
|
-
- Periodic metrics logging
|
|
277
|
-
- MQTT integration
|
|
278
|
-
- Prometheus export endpoint
|
|
279
|
-
- Manual metrics queries
|
|
280
|
-
|
|
281
|
-
## Version History
|
|
282
|
-
|
|
283
|
-
- **v1.8.0** - Initial release
|
|
284
|
-
- Basic metrics collection
|
|
285
|
-
- JSON export
|
|
286
|
-
- Periodic callbacks
|
|
287
|
-
- MQTT and Prometheus examples
|
|
288
|
-
|
|
289
|
-
## See Also
|
|
290
|
-
|
|
291
|
-
- [Bridge Architecture](BRIDGE_ARCHITECTURE_IMPLEMENTATION.md)
|
|
292
|
-
- [Bridge Status Feature](BRIDGE_STATUS_FEATURE.md)
|
|
293
|
-
- [MQTT Bridge Examples](../examples/bridge/)
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
# Channel Synchronization in painlessMesh
|
|
2
|
-
|
|
3
|
-
## Problem Statement
|
|
4
|
-
|
|
5
|
-
When a mesh network operates on one channel and a node promotes to bridge via election, it may connect to a router operating on a different channel. This creates a channel mismatch where:
|
|
6
|
-
|
|
7
|
-
1. Bridge node switches to router's channel (e.g., channel 6)
|
|
8
|
-
2. Other mesh nodes remain on original channel (e.g., channel 1)
|
|
9
|
-
3. Bridge takeover announcements sent on new channel are not heard by nodes on old channel
|
|
10
|
-
4. Nodes cannot find the mesh network and become isolated
|
|
11
|
-
|
|
12
|
-
## Solution Overview
|
|
13
|
-
|
|
14
|
-
The solution has two complementary parts:
|
|
15
|
-
|
|
16
|
-
### Part 1: Automatic Channel Re-detection
|
|
17
|
-
|
|
18
|
-
Nodes automatically detect when they can't find the mesh on their current channel and trigger a full channel scan to locate it.
|
|
19
|
-
|
|
20
|
-
**Implementation:** `src/painlessMeshSTA.cpp` and `src/painlessMeshSTA.h`
|
|
21
|
-
|
|
22
|
-
**Key Components:**
|
|
23
|
-
- `consecutiveEmptyScans` counter tracks scans with no mesh nodes found
|
|
24
|
-
- `EMPTY_SCAN_THRESHOLD` constant (6 scans) determines when to trigger re-scan
|
|
25
|
-
- Full channel scan using `scanForMeshChannel()` when threshold reached
|
|
26
|
-
- Automatic channel update and AP restart when mesh found on different channel
|
|
27
|
-
|
|
28
|
-
**Flow:**
|
|
29
|
-
```
|
|
30
|
-
1. Node scans on current channel (e.g., channel 1)
|
|
31
|
-
2. Finds no mesh nodes → increment consecutiveEmptyScans
|
|
32
|
-
3. Repeat for EMPTY_SCAN_THRESHOLD scans (~30 seconds with fast scanning)
|
|
33
|
-
4. Trigger scanForMeshChannel() to scan ALL channels (1-13)
|
|
34
|
-
5. If mesh found on different channel:
|
|
35
|
-
a. Update mesh->_meshChannel to detected channel
|
|
36
|
-
b. Restart AP on new channel
|
|
37
|
-
c. Reset consecutiveEmptyScans counter
|
|
38
|
-
6. Continue normal scanning on new channel
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
**Safeguards:**
|
|
42
|
-
- Only triggers when WiFi.status() != WL_CONNECTED (not when stably connected)
|
|
43
|
-
- Only triggers when channel > 0 (channel 0 already means auto-detect)
|
|
44
|
-
- Resets counter when mesh nodes are found (prevents false triggers)
|
|
45
|
-
|
|
46
|
-
### Part 2: Dual-Channel Takeover Announcements
|
|
47
|
-
|
|
48
|
-
Bridge promotion sends takeover announcements on both the old and new channels to ensure all nodes are notified.
|
|
49
|
-
|
|
50
|
-
**Implementation:** `src/arduino/wifi.hpp` in `promoteToBridge()` method
|
|
51
|
-
|
|
52
|
-
**Flow:**
|
|
53
|
-
```
|
|
54
|
-
1. Node wins bridge election
|
|
55
|
-
2. Send takeover announcement on CURRENT channel (e.g., channel 1)
|
|
56
|
-
→ Nodes still on channel 1 receive this announcement
|
|
57
|
-
3. Wait 1 second for announcement to propagate
|
|
58
|
-
4. Stop mesh and reinitialize as bridge via initAsBridge()
|
|
59
|
-
→ Connects to router, detects router's channel (e.g., channel 6)
|
|
60
|
-
→ Initializes mesh on channel 6
|
|
61
|
-
5. Schedule follow-up takeover announcement on NEW channel (channel 6)
|
|
62
|
-
→ Sent 3 seconds after initialization
|
|
63
|
-
→ Nodes that switched to channel 6 receive this announcement
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
**Benefits:**
|
|
67
|
-
- Early announcement notifies nodes on old channel before bridge switches
|
|
68
|
-
- Delayed announcement notifies nodes that switched early or quickly found new channel
|
|
69
|
-
- Ensures complete mesh awareness regardless of node timing
|
|
70
|
-
|
|
71
|
-
## Expected Behavior
|
|
72
|
-
|
|
73
|
-
### Scenario: Bridge Promotion with Channel Change
|
|
74
|
-
|
|
75
|
-
**Setup:**
|
|
76
|
-
- Node1: Regular mesh node on channel 1
|
|
77
|
-
- Node2: Regular mesh node on channel 1 (weak router signal)
|
|
78
|
-
- Router: Operating on channel 6
|
|
79
|
-
|
|
80
|
-
**Sequence:**
|
|
81
|
-
1. Node2 starts mesh on channel 1 (default, no router connection)
|
|
82
|
-
2. Node1 joins mesh on channel 1
|
|
83
|
-
3. Node1 wins bridge election (better router signal)
|
|
84
|
-
4. Node1 sends "Becoming bridge" announcement on channel 1
|
|
85
|
-
5. Node2 receives announcement
|
|
86
|
-
6. Node1 connects to router on channel 6, initializes mesh on channel 6
|
|
87
|
-
7. Node1 sends follow-up "I'm the bridge" announcement on channel 6
|
|
88
|
-
8. Node2 can't find mesh on channel 1 for 6 consecutive scans
|
|
89
|
-
9. Node2 triggers full channel scan, finds mesh on channel 6
|
|
90
|
-
10. Node2 updates to channel 6, restarts AP on channel 6
|
|
91
|
-
11. Node2 reconnects to Node1 on channel 6
|
|
92
|
-
12. Mesh network is now unified on channel 6
|
|
93
|
-
|
|
94
|
-
**Timeline:**
|
|
95
|
-
- T+0s: Node1 wins election, sends announcement on channel 1
|
|
96
|
-
- T+1s: Node1 stops mesh on channel 1
|
|
97
|
-
- T+2s: Node1 initializes mesh on channel 6
|
|
98
|
-
- T+5s: Node1 sends follow-up announcement on channel 6
|
|
99
|
-
- T+30s: Node2 can't find mesh on channel 1 (fast scanning)
|
|
100
|
-
- T+30s: Node2 triggers channel re-scan
|
|
101
|
-
- T+31s: Node2 finds mesh on channel 6
|
|
102
|
-
- T+32s: Node2 restarts AP on channel 6
|
|
103
|
-
- T+35s: Node2 reconnects to mesh on channel 6
|
|
104
|
-
|
|
105
|
-
## Configuration
|
|
106
|
-
|
|
107
|
-
### Adjusting Re-scan Threshold
|
|
108
|
-
|
|
109
|
-
The `EMPTY_SCAN_THRESHOLD` is defined in `src/painlessMeshSTA.h`:
|
|
110
|
-
|
|
111
|
-
```cpp
|
|
112
|
-
static const uint16_t EMPTY_SCAN_THRESHOLD = 6; // ~30 seconds at default SCAN_INTERVAL
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
**Trade-offs:**
|
|
116
|
-
- **Lower value** (e.g., 3): Faster channel detection, but more susceptible to false triggers
|
|
117
|
-
- **Higher value** (e.g., 10): More stable, but slower response to channel changes
|
|
118
|
-
|
|
119
|
-
### Scan Timing
|
|
120
|
-
|
|
121
|
-
Default scan intervals defined in `src/painlessmesh/configuration.hpp`:
|
|
122
|
-
|
|
123
|
-
```cpp
|
|
124
|
-
#define SCAN_INTERVAL 30 * TASK_SECOND // AP scan period in ms
|
|
125
|
-
```
|
|
126
|
-
|
|
127
|
-
When no mesh nodes found, scanning switches to fast mode:
|
|
128
|
-
```cpp
|
|
129
|
-
task.setInterval(0.5 * SCAN_INTERVAL); // 15 seconds
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
With EMPTY_SCAN_THRESHOLD=6 and fast scanning:
|
|
133
|
-
- Time to trigger re-scan: 6 × 15s = 90 seconds (~1.5 minutes)
|
|
134
|
-
|
|
135
|
-
## Debugging
|
|
136
|
-
|
|
137
|
-
### Log Messages
|
|
138
|
-
|
|
139
|
-
**Channel Re-detection:**
|
|
140
|
-
```
|
|
141
|
-
CONNECTION: connectToAP(): No mesh nodes found for 6 scans, triggering channel re-detection
|
|
142
|
-
CONNECTION: scanForMeshChannel(): Scanning all channels for mesh 'YourMesh'...
|
|
143
|
-
CONNECTION: scanForMeshChannel(): Found mesh on channel 6 (RSSI: -45)
|
|
144
|
-
CONNECTION: connectToAP(): Mesh found on different channel 6 (was 1), updating...
|
|
145
|
-
CONNECTION: connectToAP(): Restarting AP from channel 1 to channel 6
|
|
146
|
-
CONNECTION: connectToAP(): AP restarted on channel 6
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
**Bridge Promotion:**
|
|
150
|
-
```
|
|
151
|
-
STARTUP: === Becoming Bridge Node ===
|
|
152
|
-
STARTUP: Sending takeover announcement on current channel before switching...
|
|
153
|
-
STARTUP: ✓ Takeover announcement sent on channel 1
|
|
154
|
-
STARTUP: Step 1: Connecting to router YourRouter...
|
|
155
|
-
STARTUP: ✓ Router connected on channel 6
|
|
156
|
-
STARTUP: Step 2: Initializing mesh on channel 6...
|
|
157
|
-
STARTUP: ✓ Bridge promotion complete on channel 6
|
|
158
|
-
STARTUP: Sending follow-up takeover announcement on new channel 6
|
|
159
|
-
STARTUP: ✓ Follow-up takeover announcement sent
|
|
160
|
-
```
|
|
161
|
-
|
|
162
|
-
### Common Issues
|
|
163
|
-
|
|
164
|
-
**Issue:** Nodes don't switch channels
|
|
165
|
-
- **Check:** Ensure `channel=0` in init() for auto-detection
|
|
166
|
-
- **Check:** Verify nodes are not connected via stationManual() to router
|
|
167
|
-
- **Check:** Increase log level to see scanning activity
|
|
168
|
-
|
|
169
|
-
**Issue:** Channel switching takes too long
|
|
170
|
-
- **Solution:** Reduce EMPTY_SCAN_THRESHOLD in painlessMeshSTA.h
|
|
171
|
-
- **Trade-off:** May increase false triggers during temporary network instability
|
|
172
|
-
|
|
173
|
-
**Issue:** Bridge promotion doesn't work
|
|
174
|
-
- **Check:** Verify router credentials are configured
|
|
175
|
-
- **Check:** Ensure router has good signal strength (> -80 dBm)
|
|
176
|
-
- **Check:** Confirm router is on a valid channel (1-13 for 2.4GHz)
|
|
177
|
-
|
|
178
|
-
## Testing
|
|
179
|
-
|
|
180
|
-
### Manual Testing Procedure
|
|
181
|
-
|
|
182
|
-
1. Setup two ESP32/ESP8266 nodes with painlessMesh
|
|
183
|
-
2. Configure router on channel 6
|
|
184
|
-
3. Start both nodes without router credentials (will use channel 1)
|
|
185
|
-
4. Configure one node with router credentials and trigger election
|
|
186
|
-
5. Monitor serial output for channel switching messages
|
|
187
|
-
6. Verify both nodes eventually operate on channel 6
|
|
188
|
-
7. Verify mesh connectivity is maintained
|
|
189
|
-
|
|
190
|
-
### Expected Results
|
|
191
|
-
|
|
192
|
-
- Bridge node switches to router channel within 5 seconds
|
|
193
|
-
- Non-bridge nodes detect channel change within 90 seconds
|
|
194
|
-
- All nodes reconnect on new channel
|
|
195
|
-
- No loss of mesh connectivity (except during transition)
|
|
196
|
-
|
|
197
|
-
## Related Files
|
|
198
|
-
|
|
199
|
-
- `src/painlessMeshSTA.h` - StationScan class definition with channel re-detection
|
|
200
|
-
- `src/painlessMeshSTA.cpp` - Channel re-detection implementation
|
|
201
|
-
- `src/arduino/wifi.hpp` - Bridge promotion with dual announcements
|
|
202
|
-
- `test/catch/catch_channel_resync.cpp` - Unit tests for channel synchronization
|
|
203
|
-
- `BRIDGE_TO_INTERNET.md` - Bridge setup documentation
|
|
204
|
-
|
|
205
|
-
## References
|
|
206
|
-
|
|
207
|
-
- Issue #137: Bridge takeover announcements not heard across channels
|
|
208
|
-
- WiFi channels: 1-13 for 2.4GHz (channels 12-13 restricted in some regions)
|
|
209
|
-
- ESP32/ESP8266 can only operate on one channel at a time in AP+STA mode
|