@alteriom/painlessmesh 1.7.8 → 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.
Files changed (59) hide show
  1. package/CHANGELOG.md +139 -3
  2. package/README.md +114 -4
  3. package/RELEASE_GUIDE.md +57 -8
  4. package/docs/BRIDGE_FAILOVER.md +512 -0
  5. package/docs/BRIDGE_HEALTH_MONITORING.md +293 -0
  6. package/docs/CREATE_MISSING_RELEASES.md +321 -0
  7. package/docs/README.md +2 -1
  8. package/docs/RELEASE_AGENT_SUMMARY.md +386 -0
  9. package/docs/releases/RELEASE_SUMMARY_v1.7.8.md +523 -0
  10. package/docs/releases/RELEASE_SUMMARY_v1.7.9.md +542 -0
  11. package/docs/troubleshooting/ESP32_C6_COMPATIBILITY.md +157 -0
  12. package/docs/troubleshooting/common-issues.md +28 -0
  13. package/examples/alteriom/alteriom_sensor_package.hpp +233 -1
  14. package/examples/alteriom/platformio.ini +1 -1
  15. package/examples/alteriomImproved/platformio.ini +1 -1
  16. package/examples/alteriomMetricsHealth/metrics_health_node.ino +18 -7
  17. package/examples/alteriomMetricsHealth/platformio.ini +1 -1
  18. package/examples/alteriomPhase1/platformio.ini +1 -1
  19. package/examples/alteriomPhase2/platformio.ini +1 -1
  20. package/examples/alteriomSensorNode/alteriom_sensor_package.hpp +1014 -11
  21. package/examples/alteriomSensorNode/platformio.ini +1 -1
  22. package/examples/basic/basic.ino +6 -2
  23. package/examples/basic/platformio.ini +1 -1
  24. package/examples/bridge/alteriom_sensor_package.hpp +1170 -0
  25. package/examples/bridge/bridge.ino +44 -23
  26. package/examples/bridge/bridge_health_monitoring_example.ino +188 -0
  27. package/examples/bridge/enhanced_mqtt_bridge.hpp +1 -1
  28. package/examples/bridge/mqtt_command_bridge.hpp +2 -2
  29. package/examples/bridge/platformio.ini +2 -1
  30. package/examples/bridgeAwareSensorNode/alteriom_sensor_package.hpp +1227 -0
  31. package/examples/bridgeAwareSensorNode/bridgeAwareSensorNode.ino +343 -0
  32. package/examples/bridgeAwareSensorNode/platformio.ini +26 -0
  33. package/examples/bridge_failover/README.md +358 -0
  34. package/examples/bridge_failover/bridge_failover.ino +180 -0
  35. package/examples/bridge_failover/platformio.ini +27 -0
  36. package/examples/diagnosticsExample/diagnosticsExample.ino +171 -0
  37. package/examples/diagnosticsExample/platformio.ini +26 -0
  38. package/examples/echoNode/platformio.ini +1 -1
  39. package/examples/logClient/platformio.ini +1 -1
  40. package/examples/logServer/platformio.ini +1 -1
  41. package/examples/mqttStatusBridge/platformio.ini +1 -1
  42. package/examples/namedMesh/platformio.ini +1 -1
  43. package/examples/ntpTimeSyncBridge/alteriom_sensor_package.hpp +1383 -0
  44. package/examples/ntpTimeSyncBridge/ntpTimeSyncBridge.ino +81 -0
  45. package/examples/ntpTimeSyncNode/alteriom_sensor_package.hpp +1383 -0
  46. package/examples/ntpTimeSyncNode/ntpTimeSyncNode.ino +109 -0
  47. package/examples/otaReceiver/platformio.ini +1 -1
  48. package/examples/rtcIntegration/README.md +235 -0
  49. package/examples/rtcIntegration/rtcIntegration.ino +196 -0
  50. package/examples/startHere/platformio.ini +1 -1
  51. package/examples/webServer/platformio.ini +1 -1
  52. package/library.json +93 -53
  53. package/library.properties +1 -1
  54. package/package.json +2 -2
  55. package/src/arduino/wifi.hpp +581 -0
  56. package/src/painlessMeshSTA.cpp +68 -0
  57. package/src/painlessMeshSTA.h +3 -0
  58. package/src/painlessmesh/mesh.hpp +1127 -4
  59. package/src/painlessmesh/rtc.hpp +203 -0
@@ -0,0 +1,203 @@
1
+ #ifndef _PAINLESS_MESH_RTC_HPP_
2
+ #define _PAINLESS_MESH_RTC_HPP_
3
+
4
+ #include "Arduino.h"
5
+ #include "painlessmesh/logger.hpp"
6
+
7
+ extern painlessmesh::logger::LogClass Log;
8
+
9
+ namespace painlessmesh {
10
+ namespace rtc {
11
+
12
+ /**
13
+ * RTC module types supported by painlessMesh
14
+ */
15
+ enum RTCType {
16
+ RTC_NONE = 0,
17
+ RTC_DS3231 = 1,
18
+ RTC_DS1307 = 2,
19
+ RTC_PCF8523 = 3,
20
+ RTC_PCF8563 = 4,
21
+ RTC_ESP32_INTERNAL = 5
22
+ };
23
+
24
+ /**
25
+ * Abstract RTC interface for painlessMesh
26
+ *
27
+ * Users should implement this interface for their specific RTC hardware
28
+ * and pass an instance to mesh.enableRTC()
29
+ */
30
+ class RTCInterface {
31
+ public:
32
+ virtual ~RTCInterface() {}
33
+
34
+ /**
35
+ * Initialize the RTC hardware
36
+ *
37
+ * @return true if initialization successful, false otherwise
38
+ */
39
+ virtual bool begin() = 0;
40
+
41
+ /**
42
+ * Check if RTC is available and responding
43
+ *
44
+ * @return true if RTC is working, false otherwise
45
+ */
46
+ virtual bool isAvailable() = 0;
47
+
48
+ /**
49
+ * Get current Unix timestamp from RTC
50
+ *
51
+ * @return Unix timestamp (seconds since 1970-01-01 00:00:00 UTC)
52
+ */
53
+ virtual uint32_t getUnixTime() = 0;
54
+
55
+ /**
56
+ * Set RTC time from Unix timestamp
57
+ *
58
+ * @param timestamp Unix timestamp to set
59
+ * @return true if successful, false otherwise
60
+ */
61
+ virtual bool setUnixTime(uint32_t timestamp) = 0;
62
+
63
+ /**
64
+ * Get RTC type identifier
65
+ *
66
+ * @return RTCType enum value
67
+ */
68
+ virtual RTCType getType() = 0;
69
+ };
70
+
71
+ /**
72
+ * RTC manager class for mesh integration
73
+ *
74
+ * Handles RTC time synchronization and fallback to mesh time
75
+ */
76
+ class RTCManager {
77
+ public:
78
+ RTCManager() : rtcInterface(nullptr), rtcEnabled(false), lastSyncTime(0) {}
79
+
80
+ /**
81
+ * Enable RTC with a user-provided interface
82
+ *
83
+ * @param interface Pointer to RTCInterface implementation
84
+ * @return true if RTC initialized successfully, false otherwise
85
+ */
86
+ bool enable(RTCInterface* interface) {
87
+ if (!interface) {
88
+ Log(logger::ERROR, "RTCManager::enable() - NULL interface provided\n");
89
+ return false;
90
+ }
91
+
92
+ rtcInterface = interface;
93
+
94
+ if (!rtcInterface->begin()) {
95
+ Log(logger::ERROR, "RTCManager::enable() - RTC initialization failed\n");
96
+ rtcInterface = nullptr;
97
+ return false;
98
+ }
99
+
100
+ if (!rtcInterface->isAvailable()) {
101
+ Log(logger::ERROR, "RTCManager::enable() - RTC not available\n");
102
+ rtcInterface = nullptr;
103
+ return false;
104
+ }
105
+
106
+ rtcEnabled = true;
107
+ Log(logger::GENERAL, "RTCManager::enable() - RTC type %d enabled successfully\n",
108
+ rtcInterface->getType());
109
+ return true;
110
+ }
111
+
112
+ /**
113
+ * Disable RTC
114
+ */
115
+ void disable() {
116
+ rtcEnabled = false;
117
+ rtcInterface = nullptr;
118
+ Log(logger::GENERAL, "RTCManager::disable() - RTC disabled\n");
119
+ }
120
+
121
+ /**
122
+ * Check if RTC is enabled and available
123
+ *
124
+ * @return true if RTC can be used, false otherwise
125
+ */
126
+ bool isEnabled() const {
127
+ return rtcEnabled && rtcInterface != nullptr && rtcInterface->isAvailable();
128
+ }
129
+
130
+ /**
131
+ * Get current time from RTC
132
+ *
133
+ * @return Unix timestamp, or 0 if RTC unavailable
134
+ */
135
+ uint32_t getTime() {
136
+ if (!isEnabled()) {
137
+ return 0;
138
+ }
139
+ return rtcInterface->getUnixTime();
140
+ }
141
+
142
+ /**
143
+ * Sync RTC time from NTP/Internet source
144
+ *
145
+ * @param ntpTimestamp Unix timestamp from NTP source
146
+ * @return true if sync successful, false otherwise
147
+ */
148
+ bool syncFromNTP(uint32_t ntpTimestamp) {
149
+ if (!isEnabled()) {
150
+ Log(logger::ERROR, "RTCManager::syncFromNTP() - RTC not enabled\n");
151
+ return false;
152
+ }
153
+
154
+ if (ntpTimestamp == 0) {
155
+ Log(logger::ERROR, "RTCManager::syncFromNTP() - Invalid timestamp\n");
156
+ return false;
157
+ }
158
+
159
+ if (!rtcInterface->setUnixTime(ntpTimestamp)) {
160
+ Log(logger::ERROR, "RTCManager::syncFromNTP() - Failed to set RTC time\n");
161
+ return false;
162
+ }
163
+
164
+ lastSyncTime = millis();
165
+ Log(logger::GENERAL, "RTCManager::syncFromNTP() - RTC synced to %u\n",
166
+ ntpTimestamp);
167
+ return true;
168
+ }
169
+
170
+ /**
171
+ * Get time since last RTC sync
172
+ *
173
+ * @return Milliseconds since last sync, or 0 if never synced
174
+ */
175
+ uint32_t getTimeSinceLastSync() const {
176
+ if (lastSyncTime == 0) {
177
+ return 0;
178
+ }
179
+ return millis() - lastSyncTime;
180
+ }
181
+
182
+ /**
183
+ * Get RTC type
184
+ *
185
+ * @return RTCType enum, or RTC_NONE if disabled
186
+ */
187
+ RTCType getType() const {
188
+ if (!isEnabled()) {
189
+ return RTC_NONE;
190
+ }
191
+ return rtcInterface->getType();
192
+ }
193
+
194
+ private:
195
+ RTCInterface* rtcInterface;
196
+ bool rtcEnabled;
197
+ uint32_t lastSyncTime;
198
+ };
199
+
200
+ } // namespace rtc
201
+ } // namespace painlessmesh
202
+
203
+ #endif // _PAINLESS_MESH_RTC_HPP_