@alteriom/painlessmesh 1.9.2 → 1.9.4

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 CHANGED
@@ -5,6 +5,31 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.9.4] - 2025-12-03
9
+
10
+ ### Fixed
11
+
12
+ - **TCP Server Initialization Order** (#219) - Fixed TCP connection error -14 when mesh nodes connect to bridge
13
+ - **Root Cause**: TCP server was being initialized before the AP interface was configured in `init()`, causing it to bind incorrectly and reject incoming connections from mesh nodes
14
+ - **Symptom**: Regular mesh nodes could discover the bridge AP and get an IP, but TCP connections failed with error -14 (connection refused)
15
+ - **Solution**: Reordered initialization in `init()` to start TCP server after AP is configured:
16
+ - `eventHandleInit()` → `apInit(nodeId)` → `tcpServerInit()` (previously tcpServerInit was first)
17
+ - Added 100ms stabilization delay in `initAsBridge()` and `initAsSharedGateway()` after mesh init
18
+ - **Impact**: Fixes `sendToInternet` not working because nodes couldn't establish mesh connections to the bridge
19
+
20
+ ## [1.9.3] - 2025-12-02
21
+
22
+ ### Fixed
23
+
24
+ - **sendToInternet Example Compilation** - Fixed two compilation errors in the sendToInternet example:
25
+ - Added missing `addTask(callback, delay)` overload in mesh.hpp for one-shot delayed tasks
26
+ - Fixed `sendWithPriority` template functions in router.hpp to use `Variant(&package)` instead of `Variant(package)`, enabling proper construction from any PackageInterface-derived class including GatewayDataPackage
27
+ - **Impact**: The sendToInternet example now compiles correctly with Arduino IDE
28
+
29
+ ### Added
30
+
31
+ - **sendToInternet Example** - Added to library.json examples list for better discoverability
32
+
8
33
  ## [1.9.2] - 2025-12-01
9
34
 
10
35
  ### Changed
package/library.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "type": "git",
7
7
  "url": "https://github.com/Alteriom/painlessMesh"
8
8
  },
9
- "version": "1.9.2",
9
+ "version": "1.9.4",
10
10
  "frameworks": [
11
11
  "arduino"
12
12
  ],
@@ -88,6 +88,7 @@
88
88
  "examples/otaReceiver/otaReceiver.ino",
89
89
  "examples/otaSender/otaSender.ino",
90
90
  "examples/priority/priority_basic_example.ino",
91
+ "examples/sendToInternet/sendToInternet.ino",
91
92
  "examples/sharedGateway/sharedGateway.ino",
92
93
  "examples/startHere/startHere.ino",
93
94
  "examples/webServer/webServer.ino"
@@ -1,5 +1,5 @@
1
1
  name=Alteriom PainlessMesh
2
- version=1.9.2
2
+ version=1.9.4
3
3
  author=Coopdis,Scotty Franzyshen,Edwin van Leeuwen,Germán Martín,Maximilian Schwarz,Doanh Doanh,Alteriom
4
4
  maintainer=Alteriom
5
5
  sentence=A painless way to setup a mesh with ESP8266 and ESP32 devices with Alteriom extensions
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alteriom/painlessmesh",
3
- "version": "1.9.2",
3
+ "version": "1.9.4",
4
4
  "description": "painlessMesh is a user-friendly library for creating mesh networks with ESP8266 and ESP32 devices. This Alteriom fork includes additional packages for sensor data (SensorPackage), device commands (CommandPackage), and status monitoring (StatusPackage). It handles routing and network management automatically, so you can focus on your application. The library uses JSON-based messaging and syncs time across all nodes, making it ideal for coordinated behaviour like synchronized light displays or sensor networks reporting to a central node.",
5
5
  "keywords": [
6
6
  "arduino",
@@ -270,7 +270,6 @@ class Mesh : public painlessmesh::Mesh<Connection> {
270
270
  }
271
271
  });
272
272
 
273
- tcpServerInit();
274
273
  eventHandleInit();
275
274
 
276
275
  _apIp = IPAddress(0, 0, 0, 0);
@@ -278,6 +277,12 @@ class Mesh : public painlessmesh::Mesh<Connection> {
278
277
  if (connectMode & WIFI_AP) {
279
278
  apInit(nodeId); // setup AP
280
279
  }
280
+
281
+ // Initialize TCP server AFTER AP is configured
282
+ // This ensures the network interfaces are ready when the server starts
283
+ // Fixes TCP connection error -14 when nodes try to connect to bridge
284
+ tcpServerInit();
285
+
281
286
  if (connectMode & WIFI_STA) {
282
287
  this->initStation();
283
288
  }
@@ -394,6 +399,10 @@ class Mesh : public painlessmesh::Mesh<Connection> {
394
399
  init(meshSSID, meshPassword, baseScheduler, port, WIFI_AP_STA,
395
400
  detectedChannel, 0, MAX_CONN);
396
401
 
402
+ // Allow network stack to stabilize after AP and TCP server initialization
403
+ // This prevents TCP connection errors (-14) when nodes connect
404
+ delay(100);
405
+
397
406
  Log(STARTUP, "Step 3: Establishing bridge connection...\n");
398
407
 
399
408
  // Step 3: Re-establish router connection using stationManual
@@ -565,6 +574,10 @@ class Mesh : public painlessmesh::Mesh<Connection> {
565
574
  this->setScheduler(userScheduler);
566
575
  init(meshPrefix, meshPassword, port, WIFI_AP_STA, detectedChannel, 0, MAX_CONN);
567
576
 
577
+ // Allow network stack to stabilize after AP and TCP server initialization
578
+ // This prevents TCP connection errors (-14) when nodes connect
579
+ delay(100);
580
+
568
581
  Log(STARTUP, "Step 3: Establishing router connection in shared gateway mode...\n");
569
582
 
570
583
  // Step 3: Establish router connection using stationManual
@@ -3038,6 +3038,19 @@ class Mesh : public ntp::MeshTime, public plugin::PackageHandler<T> {
3038
3038
  return plugin::PackageHandler<T>::addTask((*this->mScheduler), aCallback);
3039
3039
  }
3040
3040
 
3041
+ /**
3042
+ * Add a one-shot delayed task
3043
+ *
3044
+ * @param aCallback Function to call after the delay
3045
+ * @param delayMs Delay in milliseconds before executing the callback
3046
+ * @return Shared pointer to the task
3047
+ */
3048
+ inline std::shared_ptr<Task> addTask(std::function<void()> aCallback,
3049
+ unsigned long delayMs) {
3050
+ return plugin::PackageHandler<T>::addTask((*this->mScheduler), delayMs,
3051
+ TASK_ONCE, aCallback);
3052
+ }
3053
+
3041
3054
  ~Mesh() {
3042
3055
  this->stop();
3043
3056
  if (!isExternalScheduler) delete mScheduler;
@@ -67,7 +67,7 @@ bool send(protocol::Variant&& variant, std::shared_ptr<U> conn,
67
67
  // New priority-level send functions (0-3 priority levels)
68
68
  template <class T, class U>
69
69
  bool sendWithPriority(T& package, std::shared_ptr<U> conn, uint8_t priorityLevel) {
70
- painlessmesh::protocol::Variant variant(package);
70
+ painlessmesh::protocol::Variant variant(&package);
71
71
  TSTRING msg;
72
72
  variant.printTo(msg);
73
73
  return conn->addMessageWithPriority(msg, priorityLevel);
@@ -75,7 +75,7 @@ bool sendWithPriority(T& package, std::shared_ptr<U> conn, uint8_t priorityLevel
75
75
 
76
76
  template <class T, class U>
77
77
  bool sendWithPriority(T&& package, std::shared_ptr<U> conn, uint8_t priorityLevel) {
78
- painlessmesh::protocol::Variant variant(package);
78
+ painlessmesh::protocol::Variant variant(&package);
79
79
  TSTRING msg;
80
80
  variant.printTo(msg);
81
81
  return conn->addMessageWithPriority(msg, priorityLevel);