@alteriom/painlessmesh 1.7.9 → 1.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +94 -2
- package/README.md +108 -1
- package/docs/BRIDGE_FAILOVER.md +512 -0
- package/docs/BRIDGE_HEALTH_MONITORING.md +293 -0
- package/docs/CREATE_MISSING_RELEASES.md +321 -0
- package/docs/releases/RELEASE_SUMMARY_v1.7.8.md +523 -0
- package/docs/releases/RELEASE_SUMMARY_v1.7.9.md +542 -0
- package/examples/alteriom/alteriom_sensor_package.hpp +213 -0
- package/examples/alteriomSensorNode/alteriom_sensor_package.hpp +1014 -11
- package/examples/basic/basic.ino +6 -2
- package/examples/bridge/bridge.ino +44 -23
- package/examples/bridge/bridge_health_monitoring_example.ino +188 -0
- package/examples/bridgeAwareSensorNode/alteriom_sensor_package.hpp +1227 -0
- package/examples/bridgeAwareSensorNode/bridgeAwareSensorNode.ino +343 -0
- package/examples/bridgeAwareSensorNode/platformio.ini +26 -0
- package/examples/bridge_failover/README.md +358 -0
- package/examples/bridge_failover/bridge_failover.ino +180 -0
- package/examples/bridge_failover/platformio.ini +27 -0
- package/examples/diagnosticsExample/diagnosticsExample.ino +171 -0
- package/examples/diagnosticsExample/platformio.ini +26 -0
- package/examples/ntpTimeSyncBridge/alteriom_sensor_package.hpp +1383 -0
- package/examples/ntpTimeSyncBridge/ntpTimeSyncBridge.ino +81 -0
- package/examples/ntpTimeSyncNode/alteriom_sensor_package.hpp +1383 -0
- package/examples/ntpTimeSyncNode/ntpTimeSyncNode.ino +109 -0
- package/examples/rtcIntegration/README.md +235 -0
- package/examples/rtcIntegration/rtcIntegration.ino +196 -0
- package/library.json +1 -1
- package/library.properties +1 -1
- package/package.json +1 -1
- package/src/arduino/wifi.hpp +572 -0
- package/src/painlessMeshSTA.cpp +63 -0
- package/src/painlessMeshSTA.h +3 -0
- package/src/painlessmesh/mesh.hpp +1127 -4
- package/src/painlessmesh/rtc.hpp +203 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* painlessMesh Diagnostics API Example
|
|
3
|
+
*
|
|
4
|
+
* This example demonstrates the enhanced diagnostics API for bridge operations.
|
|
5
|
+
* It shows how to:
|
|
6
|
+
* - Enable diagnostics tracking
|
|
7
|
+
* - Get bridge status information
|
|
8
|
+
* - Monitor election history
|
|
9
|
+
* - Test bridge connectivity
|
|
10
|
+
* - Generate diagnostic reports
|
|
11
|
+
* - Export topology for visualization
|
|
12
|
+
*
|
|
13
|
+
* Hardware: ESP32 or ESP8266
|
|
14
|
+
*
|
|
15
|
+
* Usage:
|
|
16
|
+
* 1. Upload to multiple devices
|
|
17
|
+
* 2. Configure one device as a bridge (see bridgeExample)
|
|
18
|
+
* 3. Regular nodes will use this diagnostics API to monitor mesh health
|
|
19
|
+
* 4. Open Serial Monitor to see diagnostic information
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
#include "painlessMesh.h"
|
|
23
|
+
|
|
24
|
+
#define MESH_PREFIX "DiagnosticsMesh"
|
|
25
|
+
#define MESH_PASSWORD "diagnostic123"
|
|
26
|
+
#define MESH_PORT 5555
|
|
27
|
+
|
|
28
|
+
Scheduler userScheduler;
|
|
29
|
+
painlessMesh mesh;
|
|
30
|
+
|
|
31
|
+
// Task to periodically print diagnostics
|
|
32
|
+
Task taskPrintDiagnostics(30000, TASK_FOREVER, []() {
|
|
33
|
+
Serial.println("\n" + mesh.getDiagnosticReport());
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Task to test bridge connectivity
|
|
37
|
+
Task taskTestBridge(60000, TASK_FOREVER, []() {
|
|
38
|
+
Serial.println("\n=== Testing Bridge Connectivity ===");
|
|
39
|
+
auto result = mesh.testBridgeConnectivity();
|
|
40
|
+
|
|
41
|
+
if (result.success) {
|
|
42
|
+
Serial.printf("✓ Bridge test PASSED: %s\n", result.message.c_str());
|
|
43
|
+
Serial.printf(" Latency: %u ms\n", result.latencyMs);
|
|
44
|
+
Serial.printf(" Internet available: %s\n", result.internetReachable ? "Yes" : "No");
|
|
45
|
+
} else {
|
|
46
|
+
Serial.printf("✗ Bridge test FAILED: %s\n", result.message.c_str());
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// Task to monitor bridge status
|
|
51
|
+
Task taskMonitorBridge(15000, TASK_FOREVER, []() {
|
|
52
|
+
auto status = mesh.getBridgeStatus();
|
|
53
|
+
|
|
54
|
+
Serial.println("\n=== Bridge Status ===");
|
|
55
|
+
Serial.printf("Node ID: %u\n", mesh.getNodeId());
|
|
56
|
+
Serial.printf("Role: %s\n", status.role.c_str());
|
|
57
|
+
Serial.printf("Is Bridge: %s\n", status.isBridge ? "Yes" : "No");
|
|
58
|
+
Serial.printf("Internet Connected: %s\n", status.internetConnected ? "Yes" : "No");
|
|
59
|
+
|
|
60
|
+
if (status.bridgeNodeId != 0) {
|
|
61
|
+
Serial.printf("Bridge Node: %u (RSSI: %d dBm)\n",
|
|
62
|
+
status.bridgeNodeId, status.bridgeRSSI);
|
|
63
|
+
Serial.printf("Time since bridge change: %u seconds\n",
|
|
64
|
+
status.timeSinceBridgeChange / 1000);
|
|
65
|
+
} else {
|
|
66
|
+
Serial.println("No bridge available");
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// Task to show election history
|
|
71
|
+
Task taskShowElections(120000, TASK_FOREVER, []() {
|
|
72
|
+
auto history = mesh.getElectionHistory();
|
|
73
|
+
|
|
74
|
+
if (history.size() > 0) {
|
|
75
|
+
Serial.println("\n=== Election History ===");
|
|
76
|
+
for (const auto& election : history) {
|
|
77
|
+
Serial.printf("Winner: %u (RSSI: %d dBm, %u candidates) - %s\n",
|
|
78
|
+
election.winnerNodeId, election.winnerRSSI,
|
|
79
|
+
election.candidateCount, election.reason.c_str());
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
// Task to export topology for visualization
|
|
85
|
+
Task taskExportTopology(300000, TASK_FOREVER, []() {
|
|
86
|
+
Serial.println("\n=== Mesh Topology (GraphViz DOT format) ===");
|
|
87
|
+
Serial.println(mesh.exportTopologyDOT());
|
|
88
|
+
Serial.println("Copy above to http://www.webgraphviz.com/ to visualize");
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
void receivedCallback(uint32_t from, String &msg) {
|
|
92
|
+
Serial.printf("Received from %u: %s\n", from, msg.c_str());
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
void newConnectionCallback(uint32_t nodeId) {
|
|
96
|
+
Serial.printf("New Connection: %u\n", nodeId);
|
|
97
|
+
|
|
98
|
+
// Get last bridge change when new node connects
|
|
99
|
+
auto event = mesh.getLastBridgeChange();
|
|
100
|
+
if (event.timestamp > 0) {
|
|
101
|
+
Serial.printf("Last bridge change: %u -> %u (%s)\n",
|
|
102
|
+
event.oldBridgeId, event.newBridgeId, event.reason.c_str());
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
void changedConnectionCallback() {
|
|
107
|
+
Serial.println("Connections changed");
|
|
108
|
+
Serial.printf("Mesh nodes: %d\n", mesh.getNodeList().size());
|
|
109
|
+
|
|
110
|
+
// Show Internet path for this node
|
|
111
|
+
auto path = mesh.getInternetPath(mesh.getNodeId());
|
|
112
|
+
if (path.size() > 0) {
|
|
113
|
+
Serial.print("Path to Internet: ");
|
|
114
|
+
for (auto nodeId : path) {
|
|
115
|
+
Serial.printf("%u -> ", nodeId);
|
|
116
|
+
}
|
|
117
|
+
Serial.println("Internet");
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
void bridgeStatusChangedCallback(uint32_t bridgeNodeId, bool hasInternet) {
|
|
122
|
+
Serial.printf("\n!!! Bridge Status Changed !!!\n");
|
|
123
|
+
Serial.printf("Bridge %u Internet: %s\n",
|
|
124
|
+
bridgeNodeId, hasInternet ? "Connected" : "Disconnected");
|
|
125
|
+
|
|
126
|
+
// Run immediate connectivity test
|
|
127
|
+
auto result = mesh.testBridgeConnectivity();
|
|
128
|
+
Serial.printf("Connectivity test: %s\n", result.message.c_str());
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
void setup() {
|
|
132
|
+
Serial.begin(115200);
|
|
133
|
+
|
|
134
|
+
Serial.println("\n\n=== painlessMesh Diagnostics Example ===");
|
|
135
|
+
Serial.println("Initializing mesh network...");
|
|
136
|
+
|
|
137
|
+
// Initialize mesh
|
|
138
|
+
mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION);
|
|
139
|
+
mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT);
|
|
140
|
+
|
|
141
|
+
// Enable diagnostics tracking
|
|
142
|
+
Serial.println("Enabling diagnostics...");
|
|
143
|
+
mesh.enableDiagnostics(true);
|
|
144
|
+
|
|
145
|
+
// Setup callbacks
|
|
146
|
+
mesh.onReceive(&receivedCallback);
|
|
147
|
+
mesh.onNewConnection(&newConnectionCallback);
|
|
148
|
+
mesh.onChangedConnections(&changedConnectionCallback);
|
|
149
|
+
mesh.onBridgeStatusChanged(&bridgeStatusChangedCallback);
|
|
150
|
+
|
|
151
|
+
// Add diagnostic tasks
|
|
152
|
+
userScheduler.addTask(taskPrintDiagnostics);
|
|
153
|
+
userScheduler.addTask(taskTestBridge);
|
|
154
|
+
userScheduler.addTask(taskMonitorBridge);
|
|
155
|
+
userScheduler.addTask(taskShowElections);
|
|
156
|
+
userScheduler.addTask(taskExportTopology);
|
|
157
|
+
|
|
158
|
+
// Enable tasks
|
|
159
|
+
taskPrintDiagnostics.enable();
|
|
160
|
+
taskTestBridge.enable();
|
|
161
|
+
taskMonitorBridge.enable();
|
|
162
|
+
taskShowElections.enable();
|
|
163
|
+
taskExportTopology.enable();
|
|
164
|
+
|
|
165
|
+
Serial.println("Setup complete!");
|
|
166
|
+
Serial.printf("Node ID: %u\n", mesh.getNodeId());
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
void loop() {
|
|
170
|
+
mesh.update();
|
|
171
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
[platformio]
|
|
2
|
+
src_dir = .
|
|
3
|
+
|
|
4
|
+
[env]
|
|
5
|
+
lib_deps =
|
|
6
|
+
bblanchon/ArduinoJson
|
|
7
|
+
arkhipenko/TaskScheduler
|
|
8
|
+
|
|
9
|
+
lib_ldf_mode = deep+
|
|
10
|
+
[env:esp8266]
|
|
11
|
+
platform = espressif8266
|
|
12
|
+
board = nodemcuv2
|
|
13
|
+
framework = arduino
|
|
14
|
+
lib_extra_dirs = ../../
|
|
15
|
+
lib_deps =
|
|
16
|
+
${env.lib_deps} ; Inherit common dependencies
|
|
17
|
+
esp32async/ESPAsyncTCP@^2.0.0 ; Only for ESP8266
|
|
18
|
+
|
|
19
|
+
[env:esp32]
|
|
20
|
+
platform = espressif32
|
|
21
|
+
board = esp32dev
|
|
22
|
+
framework = arduino
|
|
23
|
+
lib_extra_dirs = ../../
|
|
24
|
+
lib_deps =
|
|
25
|
+
${env.lib_deps} ; Inherit common dependencies
|
|
26
|
+
esp32async/AsyncTCP
|