@alteriom/painlessmesh 1.9.5 → 1.9.7

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.
@@ -0,0 +1,283 @@
1
+ # Connecting External Devices to painlessMesh Bridge
2
+
3
+ This guide explains how to connect external devices (phones, computers, test equipment) to a painlessMesh bridge node's WiFi Access Point for debugging and testing purposes.
4
+
5
+ ## Overview
6
+
7
+ Each painlessMesh node operates in AP+STA mode, broadcasting a WiFi Access Point (AP) with the mesh SSID. External devices can connect to this AP, though they typically don't get internet access (unless using shared gateway mode).
8
+
9
+ ## When to Connect External Devices
10
+
11
+ You might want to connect external devices to the mesh AP when:
12
+ - Debugging mesh connectivity issues
13
+ - Running diagnostic tools (ping, network scanners)
14
+ - Testing DHCP configuration
15
+ - Monitoring mesh traffic
16
+ - Developing custom mesh applications
17
+
18
+ ## Connection Details
19
+
20
+ ### Basic Information
21
+
22
+ | Setting | Value |
23
+ |---------|-------|
24
+ | **SSID** | Your `MESH_PREFIX` value (e.g., "FishFarmMesh", "whateverYouLike") |
25
+ | **Password** | Your `MESH_PASSWORD` value (e.g., "securepass", "somethingSneaky") |
26
+ | **Security** | WPA2-PSK |
27
+ | **IP Range** | 10.x.x.x/24 (automatically assigned via DHCP) |
28
+ | **Gateway** | 10.x.x.1 (the bridge node itself) |
29
+ | **DNS** | 10.x.x.1 (the bridge node) |
30
+
31
+ ### Node-Specific IP Addressing
32
+
33
+ Each mesh node gets a unique IP address based on its Node ID:
34
+ ```
35
+ IP = 10.(NodeID >> 8).(NodeID & 0xFF).1
36
+ ```
37
+
38
+ Example: If Node ID is `0x1A2B`, the AP IP would be `10.26.43.1`
39
+
40
+ Connected clients receive IPs in the same subnet, typically starting from `.2`
41
+
42
+ ## Connection Limits
43
+
44
+ The number of devices that can connect simultaneously depends on the platform:
45
+
46
+ | Platform | Max Connections | Notes |
47
+ |----------|----------------|-------|
48
+ | **ESP32** | 10 (default) | Configurable via `MAX_CONN` |
49
+ | **ESP8266** | 4 (default) | Configurable via `MAX_CONN` |
50
+
51
+ **Important**: Mesh nodes also count toward this limit! If 3 mesh nodes are connected to a bridge, only 7 slots remain for external devices on ESP32 (or 1 on ESP8266).
52
+
53
+ ## Step-by-Step Connection Guide
54
+
55
+ ### 1. Verify Bridge is Running
56
+
57
+ Check the serial output for these messages:
58
+ ```
59
+ init(): Mesh channel set to X
60
+ apInit(): AP configured - SSID: YourMeshName, Channel: X, IP: 10.x.x.1
61
+ apInit(): AP active - Max connections: 10
62
+ ```
63
+
64
+ ### 2. Connect Your Device
65
+
66
+ #### On Android:
67
+ 1. Open WiFi settings
68
+ 2. Look for network with your MESH_PREFIX name
69
+ 3. Enter your MESH_PASSWORD
70
+ 4. Wait for connection (may take 5-10 seconds)
71
+ 5. Check IP address (should be 10.x.x.x)
72
+
73
+ #### On Windows 11:
74
+ 1. Click WiFi icon in system tray
75
+ 2. Find network with your MESH_PREFIX name
76
+ 3. Click "Connect"
77
+ 4. Enter your MESH_PASSWORD
78
+ 5. Open Command Prompt and run `ipconfig` to verify IP
79
+
80
+ #### On macOS:
81
+ 1. Click WiFi icon in menu bar
82
+ 2. Select network with your MESH_PREFIX name
83
+ 3. Enter your MESH_PASSWORD
84
+ 4. Open Terminal and run `ifconfig` to verify IP
85
+
86
+ #### On Linux:
87
+ 1. Use NetworkManager GUI or command line:
88
+ ```bash
89
+ nmcli device wifi connect "FishFarmMesh" password "securepass"
90
+ ```
91
+ 2. Verify connection:
92
+ ```bash
93
+ ip addr show
94
+ ```
95
+
96
+ ### 3. Test Connectivity
97
+
98
+ Once connected, test basic connectivity:
99
+
100
+ ```bash
101
+ # Ping the bridge/gateway
102
+ ping 10.x.x.1
103
+
104
+ # Check if you got an IP via DHCP
105
+ # Windows: ipconfig
106
+ # Linux/Mac: ifconfig or ip addr
107
+
108
+ # Try to reach other mesh nodes (if you know their IPs)
109
+ ping 10.y.y.1
110
+ ```
111
+
112
+ ## Troubleshooting
113
+
114
+ ### Can't See the SSID
115
+
116
+ **Possible Causes:**
117
+ 1. Bridge hasn't finished initializing (wait 10-15 seconds after boot)
118
+ 2. Channel conflict with nearby WiFi networks
119
+ 3. WiFi range issue
120
+ 4. AP not properly started
121
+
122
+ **Solutions:**
123
+ 1. Check serial output for "AP configured" message
124
+ 2. Ensure `CONNECTION` debug level is enabled:
125
+ ```cpp
126
+ mesh.setDebugMsgTypes(ERROR | STARTUP | CONNECTION);
127
+ ```
128
+ 3. Try power cycling the bridge
129
+ 4. Check if the AP is hidden:
130
+ ```cpp
131
+ // In your sketch, ensure:
132
+ mesh.init(MESH_PREFIX, MESH_PASSWORD, &scheduler, MESH_PORT,
133
+ WIFI_AP_STA, channel, 0); // 0 = not hidden
134
+ ```
135
+
136
+ ### Can Connect But Don't Get IP Address
137
+
138
+ **Possible Causes:**
139
+ 1. DHCP server not initialized
140
+ 2. Too many devices connected (limit reached)
141
+ 3. IP conflict
142
+ 4. WiFi stack timing issue
143
+
144
+ **Solutions:**
145
+ 1. Disconnect and reconnect after 10 seconds
146
+ 2. Check serial output for connection count
147
+ 3. Try rebooting the bridge node
148
+ 4. Ensure you're using the latest painlessMesh version with DHCP fixes
149
+
150
+ ### Connection Drops Frequently
151
+
152
+ **Possible Causes:**
153
+ 1. Channel change during mesh discovery
154
+ 2. Weak signal strength
155
+ 3. Network congestion
156
+ 4. Too many mesh topology changes
157
+
158
+ **Solutions:**
159
+ 1. This is normal during initial mesh formation when channels are being discovered
160
+ 2. After 30-60 seconds, the mesh should stabilize on one channel
161
+ 3. Move closer to the bridge node
162
+ 4. Use a fixed channel if you know your router's channel:
163
+ ```cpp
164
+ mesh.init(MESH_PREFIX, MESH_PASSWORD, &scheduler, MESH_PORT,
165
+ WIFI_AP_STA, 6); // Force channel 6
166
+ ```
167
+
168
+ ### Can't Access Internet
169
+
170
+ **This is expected behavior!** Regular mesh nodes don't provide internet routing by default.
171
+
172
+ **Options for Internet Access:**
173
+
174
+ 1. **Use Shared Gateway Mode**: All nodes connect to router
175
+ ```cpp
176
+ mesh.initAsSharedGateway(MESH_PREFIX, MESH_PASSWORD,
177
+ ROUTER_SSID, ROUTER_PASSWORD,
178
+ &scheduler, MESH_PORT);
179
+ ```
180
+
181
+ 2. **Connect to the Router**: Connect your device to the router WiFi instead, then communicate with mesh nodes via the bridge
182
+
183
+ 3. **Custom Routing**: Implement custom NAT/routing on the bridge (advanced)
184
+
185
+ ## Advanced: Using with Test Tools
186
+
187
+ ### ESPping or Similar Tools
188
+
189
+ If you're using tools like ESPping (https://github.com/dvarrel/ESPping) to debug mesh connectivity:
190
+
191
+ 1. Connect the test device to the mesh AP
192
+ 2. You'll get an IP in the 10.x.x.x range
193
+ 3. You can now ping mesh nodes directly:
194
+ ```bash
195
+ ping 10.x.x.1 # The bridge you're connected to
196
+ ```
197
+ 4. To find other mesh nodes, check the bridge's serial output for their IPs
198
+
199
+ ### Network Scanners
200
+
201
+ Tools like `nmap`, `arp-scan`, or Android apps like "Network Analyzer" can help:
202
+
203
+ ```bash
204
+ # Scan the mesh network
205
+ sudo nmap -sn 10.x.x.0/24
206
+
207
+ # Or use arp-scan
208
+ sudo arp-scan --interface=wlan0 10.x.x.0/24
209
+ ```
210
+
211
+ ### Packet Analysis
212
+
213
+ If you need to capture mesh traffic:
214
+
215
+ 1. Connect your computer to the mesh AP
216
+ 2. Use Wireshark or tcpdump to capture packets
217
+ 3. Filter for TCP port 5555 (default mesh port)
218
+ ```
219
+ tcp.port == 5555
220
+ ```
221
+
222
+ ## Example Debug Session
223
+
224
+ Here's a complete example of connecting and debugging:
225
+
226
+ ```bash
227
+ # 1. Connect to mesh AP
228
+ nmcli device wifi connect "FishFarmMesh" password "securepass"
229
+
230
+ # 2. Check your IP
231
+ ip addr show wlan0
232
+ # Should show: inet 10.26.43.2/24
233
+
234
+ # 3. Ping the gateway (bridge)
235
+ ping -c 3 10.26.43.1
236
+ # Should get replies
237
+
238
+ # 4. Check DHCP lease
239
+ cat /var/lib/NetworkManager/dhclient-*.lease
240
+ # Shows lease details from 10.26.43.1
241
+
242
+ # 5. Scan for other mesh nodes
243
+ sudo nmap -sn 10.0.0.0/8 --exclude 10.26.43.2
244
+ # May find other nodes on 10.x.x.1 addresses
245
+
246
+ # 6. Try connecting to mesh TCP port
247
+ nc -v 10.26.43.1 5555
248
+ # Should connect if node is accepting connections
249
+ ```
250
+
251
+ ## Security Considerations
252
+
253
+ ### Important Warnings
254
+
255
+ 1. **Don't use weak passwords**: The mesh password protects your entire network
256
+ 2. **Change default credentials**: Always change from example values like "whateverYouLike"
257
+ 3. **No internet isolation**: External devices on mesh AP can potentially communicate with all mesh nodes
258
+ 4. **Production vs. Debug**: Consider disabling external connections in production:
259
+ ```cpp
260
+ // Limit max connections to only mesh nodes
261
+ mesh.init(MESH_PREFIX, MESH_PASSWORD, &scheduler, MESH_PORT,
262
+ WIFI_AP_STA, channel, 0, 4); // Max 4 on ESP8266
263
+ ```
264
+
265
+ ### Best Practices
266
+
267
+ 1. **Use strong passwords**: At least 8 characters, mixed case, numbers
268
+ 2. **Monitor connections**: Log when devices connect/disconnect
269
+ 3. **Implement timeouts**: Automatically disconnect idle external devices
270
+ 4. **Network segmentation**: Use VLANs if possible for mesh vs. debug traffic
271
+
272
+ ## Related Documentation
273
+
274
+ - [Bridge Setup Guide](../BRIDGE_TO_INTERNET.md)
275
+ - [Shared Gateway Mode](../api/shared-gateway.md)
276
+ - [Common Issues](common-issues.md)
277
+ - [ESP32-C6 Compatibility](ESP32_C6_COMPATIBILITY.md)
278
+
279
+ ## Changelog
280
+
281
+ - **Unreleased**: Initial documentation for external device connections
282
+ - Added DHCP server initialization fixes for ESP32
283
+ - Improved AP restart timing for channel changes
@@ -16,6 +16,29 @@
16
16
  // - Enables nodes to implement failover and queueing logic
17
17
  //
18
18
  // For more details, see BRIDGE_TO_INTERNET.md
19
+ //
20
+ // EXTERNAL DEVICE CONNECTIONS:
21
+ // ----------------------------
22
+ // External devices (phones, computers) can connect to the bridge's WiFi
23
+ // AP for debugging and testing purposes. The AP will broadcast the mesh
24
+ // SSID (e.g., "whateverYouLike") with the configured password.
25
+ //
26
+ // Connection details:
27
+ // - SSID: Your MESH_PREFIX value
28
+ // - Password: Your MESH_PASSWORD value
29
+ // - IP Range: 10.x.x.x (automatically assigned via DHCP)
30
+ // - Gateway: 10.x.x.1 (the bridge node itself)
31
+ //
32
+ // Note: ESP32 AP mode supports up to 10 concurrent connections by default,
33
+ // ESP8266 supports up to 4. If mesh nodes are already connected, fewer
34
+ // slots will be available for external devices.
35
+ //
36
+ // Troubleshooting external connections:
37
+ // 1. Ensure the bridge has successfully initialized (check serial output)
38
+ // 2. Wait a few seconds after boot for the AP to fully start
39
+ // 3. Check for channel conflicts with other WiFi networks
40
+ // 4. Try forgetting the network on your device and reconnecting
41
+ // 5. Monitor serial output with CONNECTION debug level enabled
19
42
  //************************************************************
20
43
  #include "painlessMesh.h"
21
44
 
@@ -5,6 +5,30 @@
5
5
  // When the primary bridge loses Internet connectivity, nodes automatically
6
6
  // hold an election to select a new bridge based on router signal strength.
7
7
  //
8
+ // EXTERNAL DEVICE CONNECTIONS FOR DEBUGGING:
9
+ // -------------------------------------------
10
+ // You can connect phones, computers, or test devices to the mesh network
11
+ // for debugging purposes. The bridge node broadcasts the mesh SSID as a
12
+ // WiFi Access Point.
13
+ //
14
+ // Connection details:
15
+ // - SSID: "FishFarmMesh" (or your MESH_PREFIX value)
16
+ // - Password: "securepass" (or your MESH_PASSWORD value)
17
+ // - IP Range: 10.x.x.x/24 (automatically assigned via DHCP)
18
+ // - Gateway: 10.x.x.1 (the bridge node itself)
19
+ //
20
+ // Important notes:
21
+ // 1. ESP32 supports up to 10 concurrent AP connections (ESP8266: 4)
22
+ // 2. Each mesh node connection uses one slot, leaving fewer for external devices
23
+ // 3. After boot, wait 5-10 seconds for the AP to fully initialize
24
+ // 4. If you can't connect, try these troubleshooting steps:
25
+ // - Check serial output for "AP configured" message
26
+ // - Verify the channel matches (bridge auto-detects router's channel)
27
+ // - Forget the network on your device and reconnect
28
+ // - Check for WiFi channel conflicts with other networks
29
+ // 5. External devices get DHCP but have no internet routing by default
30
+ // (they can only communicate with the mesh network itself)
31
+ //
8
32
  // IMPORTANT - UNDERSTANDING INTERNET CONNECTIVITY:
9
33
  // ================================================
10
34
  // The mesh.hasInternetConnection() method checks if a GATEWAY (bridge) node
@@ -15,6 +39,9 @@
15
39
  //
16
40
  // To send data to the Internet from a regular node:
17
41
  // 1. Use mesh.sendToInternet() to route through a gateway
42
+ // - Call mesh.enableSendToInternet() on the sending node after mesh.init()
43
+ // - Bridge nodes (this example) do NOT need enableSendToInternet() - they route automatically
44
+ // - See examples/sendToInternet/sendToInternet.ino for complete usage
18
45
  // 2. Use initAsSharedGateway() so all nodes have router access
19
46
  // NOTE: initAsSharedGateway() requires ROUTER credentials:
20
47
  // mesh.initAsSharedGateway(MESH_PREFIX, MESH_PASSWORD,
@@ -24,9 +24,27 @@
24
24
  // - Smart home sensors reporting to home automation servers
25
25
  //
26
26
  // Prerequisites:
27
- // - At least one node must be a bridge/gateway with Internet access
28
- // - OR use initAsSharedGateway() so all nodes have Internet
29
- // - Enable sendToInternet() after mesh.init(): mesh.enableSendToInternet()
27
+ //
28
+ // 1. GATEWAY SETUP (Choose one approach):
29
+ //
30
+ // Option A - Dedicated Bridge (Recommended):
31
+ // - Use initAsBridge() on ONE node (see examples/bridge/bridge.ino)
32
+ // - The bridge node automatically handles Internet routing
33
+ //
34
+ // Option B - Shared Gateway (All nodes have router access):
35
+ // - Use initAsSharedGateway() on ALL nodes (see examples/sharedGateway/sharedGateway.ino)
36
+ // - Requires ROUTER_SSID and ROUTER_PASSWORD on every node
37
+ // - All nodes connect directly to the router for Internet access
38
+ //
39
+ // Option C - Failover Bridge (High Availability):
40
+ // - Use bridge_failover example unchanged (see examples/bridge_failover/bridge_failover.ino)
41
+ // - Automatically elects backup bridges if primary fails
42
+ // - Works as-is without any modifications needed!
43
+ //
44
+ // 2. SENDING NODE SETUP:
45
+ // - Call mesh.enableSendToInternet() AFTER mesh.init() on nodes that will SEND requests
46
+ // - Bridge nodes do NOT need to call enableSendToInternet() - they route automatically
47
+ // - This example shows how to enable it in the setup() function below
30
48
  //
31
49
  // For Callmebot WhatsApp API:
32
50
  // - Get your API key from https://www.callmebot.com/blog/free-api-whatsapp-messages/
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.5",
9
+ "version": "1.9.7",
10
10
  "frameworks": [
11
11
  "arduino"
12
12
  ],
@@ -1,5 +1,5 @@
1
1
  name=Alteriom PainlessMesh
2
- version=1.9.5
2
+ version=1.9.7
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.5",
3
+ "version": "1.9.7",
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",
@@ -39,11 +39,11 @@
39
39
  "url": "https://github.com/Alteriom/painlessMesh/issues"
40
40
  },
41
41
  "devDependencies": {
42
- "@alteriom/mqtt-schema": "^0.7.3",
43
- "@eslint/js": "^9.0.0",
42
+ "@alteriom/mqtt-schema": "^0.8.0",
43
+ "@eslint/js": "^9.39.1",
44
44
  "ajv": "^8.17.1",
45
45
  "ajv-formats": "^3.0.1",
46
- "prettier": "^3.0.0"
46
+ "prettier": "^3.7.4"
47
47
  },
48
48
  "scripts": {
49
49
  "test": "run-parts --regex catch_ bin/ || echo 'Tests completed'",
@@ -29,10 +29,10 @@
29
29
  /**
30
30
  * @brief AlteriomPainlessMesh library version information
31
31
  */
32
- #define ALTERIOM_PAINLESS_MESH_VERSION "1.8.13"
32
+ #define ALTERIOM_PAINLESS_MESH_VERSION "1.9.7"
33
33
  #define ALTERIOM_PAINLESS_MESH_VERSION_MAJOR 1
34
- #define ALTERIOM_PAINLESS_MESH_VERSION_MINOR 8
35
- #define ALTERIOM_PAINLESS_MESH_VERSION_PATCH 13
34
+ #define ALTERIOM_PAINLESS_MESH_VERSION_MINOR 9
35
+ #define ALTERIOM_PAINLESS_MESH_VERSION_PATCH 7
36
36
 
37
37
  /**
38
38
  * @brief Library description and usage information