@alteriom/painlessmesh 2.0.3 → 2.1.1

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.
@@ -37,10 +37,10 @@ enum QueueState {
37
37
  * Contains all metadata needed for reliable message delivery
38
38
  */
39
39
  struct QueuedMessage {
40
- uint32_t id; // Unique message ID
41
- MessagePriority priority; // Message priority level
42
- uint32_t timestamp; // When message was queued (millis)
43
- uint32_t attempts; // Number of send attempts
40
+ uint32_t id = 0; // Unique message ID
41
+ MessagePriority priority = PRIORITY_NORMAL; // Message priority level
42
+ uint32_t timestamp = 0; // When message was queued (millis)
43
+ uint32_t attempts = 0; // Number of send attempts
44
44
  TSTRING payload; // Message content
45
45
  TSTRING destination; // Cloud endpoint/topic (optional metadata)
46
46
 
@@ -298,8 +298,8 @@ public:
298
298
 
299
299
  private:
300
300
  std::vector<QueuedMessage> messages;
301
- uint32_t maxQueueSize;
302
- uint32_t nextMessageId;
301
+ uint32_t maxQueueSize = 1000;
302
+ uint32_t nextMessageId = 1;
303
303
  QueueStats stats;
304
304
  QueueState currentState = QUEUE_EMPTY;
305
305
  queueStateChangedCallback_t stateChangedCallback;
@@ -51,7 +51,7 @@ class Timer {
51
51
  #endif
52
52
  }
53
53
 
54
- uint32_t start_time_;
54
+ uint32_t start_time_ = 0;
55
55
  #ifdef ESP32
56
56
  int64_t start_time_us_ = esp_timer_get_time();
57
57
  #endif
@@ -112,7 +112,7 @@ class Announce : public BroadcastPackage {
112
112
  */
113
113
  bool compressed = false;
114
114
 
115
- size_t noPart;
115
+ size_t noPart = 0;
116
116
 
117
117
  Announce() : BroadcastPackage(10) {}
118
118
 
@@ -39,10 +39,13 @@ namespace plugin {
39
39
 
40
40
  class SinglePackage : public protocol::PackageInterface {
41
41
  public:
42
- uint32_t from;
43
- uint32_t dest;
44
- router::Type routing;
45
- int type;
42
+ // `from` and `dest` are the application's to fill; a package built by
43
+ // the type constructor and sent before they are set addresses node 0,
44
+ // not whatever the stack held.
45
+ uint32_t from = 0;
46
+ uint32_t dest = 0;
47
+ router::Type routing = router::SINGLE;
48
+ int type = 0;
46
49
  int noJsonFields = 4;
47
50
 
48
51
  SinglePackage(int type) : routing(router::SINGLE), type(type) {}
@@ -65,9 +68,9 @@ class SinglePackage : public protocol::PackageInterface {
65
68
 
66
69
  class BroadcastPackage : public protocol::PackageInterface {
67
70
  public:
68
- uint32_t from;
69
- router::Type routing;
70
- int type;
71
+ uint32_t from = 0;
72
+ router::Type routing = router::BROADCAST;
73
+ int type = 0;
71
74
  int noJsonFields = 3;
72
75
 
73
76
  BroadcastPackage(int type) : routing(router::BROADCAST), type(type) {}
@@ -75,6 +75,10 @@ constexpr uint8_t PRIORITY_LOW = 3;
75
75
 
76
76
  class PackageInterface {
77
77
  public:
78
+ // A base with virtual functions destroyed through a derived pointer needs
79
+ // this, and a package held in a shared_ptr is exactly that case (#469);
80
+ // clang refuses the build without it under -Werror.
81
+ virtual ~PackageInterface() = default;
78
82
  virtual JsonObject addTo(JsonObject&& jsonObj) const = 0;
79
83
  #if ARDUINOJSON_VERSION_MAJOR < 7
80
84
  virtual size_t jsonObjectSize() const = 0;
@@ -89,8 +93,8 @@ class PackageInterface {
89
93
  class Single : public PackageInterface {
90
94
  public:
91
95
  int type = SINGLE;
92
- uint32_t from;
93
- uint32_t dest;
96
+ uint32_t from = 0;
97
+ uint32_t dest = 0;
94
98
  TSTRING msg = "";
95
99
  // Non-zero when the sender requested a delivery acknowledgment. Only
96
100
  // serialized when set, so plain sends carry zero overhead.
@@ -273,8 +277,8 @@ class NodeTree : public PackageInterface {
273
277
  class NodeSyncRequest : public NodeTree {
274
278
  public:
275
279
  int type = NODE_SYNC_REQUEST;
276
- uint32_t from;
277
- uint32_t dest;
280
+ uint32_t from = 0;
281
+ uint32_t dest = 0;
278
282
 
279
283
  NodeSyncRequest() {}
280
284
  NodeSyncRequest(uint32_t fromID, uint32_t destID, std::list<NodeTree> subTree,
@@ -351,8 +355,8 @@ struct time_sync_msg_t {
351
355
  class TimeSync : public PackageInterface {
352
356
  public:
353
357
  int type = TIME_SYNC;
354
- uint32_t dest;
355
- uint32_t from;
358
+ uint32_t dest = 0;
359
+ uint32_t from = 0;
356
360
  time_sync_msg_t msg;
357
361
 
358
362
  TimeSync() {}
@@ -192,9 +192,9 @@ class RTCManager {
192
192
  }
193
193
 
194
194
  private:
195
- RTCInterface* rtcInterface;
196
- bool rtcEnabled;
197
- uint32_t lastSyncTime;
195
+ RTCInterface* rtcInterface = nullptr;
196
+ bool rtcEnabled = false;
197
+ uint32_t lastSyncTime = 0;
198
198
  };
199
199
 
200
200
  } // namespace rtc
@@ -53,10 +53,10 @@ class Stats {
53
53
 
54
54
  class PerformancePackage : public plugin::BroadcastPackage {
55
55
  public:
56
- int id = 0; // Can see if we missed values
57
- int time; // Get an idea of the delay, by comparing it with nodetime
58
- int stability; // stability of the sending node
59
- int freeMemory; // memory of the sending node
56
+ int id = 0; // Can see if we missed values
57
+ int time = 0; // Get an idea of the delay, by comparing it with nodetime
58
+ int stability = 0; // stability of the sending node
59
+ int freeMemory = 0; // memory of the sending node
60
60
  #ifdef ESP32
61
61
  TSTRING hardware = "ESP32";
62
62
  #else
@@ -93,7 +93,7 @@ class PerformancePackage : public plugin::BroadcastPackage {
93
93
  /// Numbers to track for each node we receive PerformancePackages from
94
94
  class Track {
95
95
  public:
96
- uint32_t nodeId;
96
+ uint32_t nodeId = 0;
97
97
  TSTRING hardware;
98
98
  uint32_t hits = 0;
99
99
  uint32_t misses = 0;