@alteriom/painlessmesh 1.8.2 → 1.8.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 +60 -0
- package/README.md +74 -11
- package/RELEASE_GUIDE.md +57 -16
- package/docs/ARDUINO_LIBRARY_MANAGER_SUBMISSION.md +331 -0
- package/docs/features/DIAGNOSTICS_API.md +534 -0
- package/docs/getting-started/arduino-manual-install.md +313 -0
- package/docs/implementation/BRIDGE_ARCHITECTURE_IMPLEMENTATION.md +340 -0
- package/docs/implementation/BRIDGE_HEALTH_MONITORING_IMPLEMENTATION.md +213 -0
- package/docs/implementation/BRIDGE_STATUS_FEATURE.md +635 -0
- package/docs/implementation/DIAGNOSTICS_API_IMPLEMENTATION.md +232 -0
- package/docs/implementation/IMPLEMENTATION_COMPLETE.md +228 -0
- package/docs/implementation/IMPLEMENTATION_NTP_TIME_SYNC.md +325 -0
- package/docs/implementation/IMPLEMENTATION_SUMMARY.md +316 -0
- package/docs/implementation/MESSAGE_QUEUE_IMPLEMENTATION.md +405 -0
- package/docs/implementation/MULTI_BRIDGE_IMPLEMENTATION.md +520 -0
- package/docs/implementation/NTP_TIME_SYNC_FEATURE.md +392 -0
- package/docs/internal/CUSTOM_AGENT_ANALYSIS.md +391 -0
- package/docs/internal/ISSUE_65_VERIFICATION.md +947 -0
- package/docs/internal/ISSUE_66_CLOSURE.md +249 -0
- package/docs/internal/ISSUE_66_STATUS.md +316 -0
- package/docs/internal/PR_SUMMARY.md +315 -0
- package/docs/internal/REVIEW_SUMMARY.md +332 -0
- package/docs/releases/PUBLISH_v1.8.0_INSTRUCTIONS.md +163 -0
- package/docs/releases/QUICK_START_RELEASES.md +113 -0
- package/docs/releases/RELEASE_CHECKLIST_v1.8.0.md +331 -0
- package/docs/releases/RELEASE_CHECKLIST_v1.8.2.md +309 -0
- package/docs/releases/RELEASE_NOTES_v1.8.0.md +685 -0
- package/docs/releases/RELEASE_NOTES_v1.8.1.md +221 -0
- package/docs/releases/RELEASE_NOTES_v1.8.2.md +421 -0
- package/docs/releases/RELEASE_NOTES_v1.8.3.md +292 -0
- package/docs/releases/RELEASE_NOTES_v1.8.4.md +277 -0
- package/docs/troubleshooting/ARDUINO_IDE_VERSION_FIX_SUMMARY.md +229 -0
- package/docs/troubleshooting/ARDUINO_LIBRARY_NAME_FIX.md +197 -0
- package/docs/troubleshooting/NPM_PUBLISHING_ISSUE_SUMMARY.md +110 -0
- package/docs/troubleshooting/station-reconnection-issues.md +172 -0
- package/examples/bridge_failover/README.md +17 -1
- package/examples/priority/README.md +274 -0
- package/examples/priority/priority_basic_example.ino +115 -0
- package/examples/priority/priority_with_queue.ino +249 -0
- package/examples/routing_demo/README.md +172 -0
- package/examples/routing_demo/routing_demo.ino +102 -0
- package/library.json +1 -1
- package/library.properties +3 -3
- package/package.json +1 -1
- package/src/arduino/wifi.hpp +62 -16
- package/src/painlessMesh.h +15 -0
- package/src/painlessMeshSTA.cpp +7 -1
- package/src/painlessmesh/buffer.hpp +218 -37
- package/src/painlessmesh/connection.hpp +21 -1
- package/src/painlessmesh/mesh.hpp +253 -19
- package/src/painlessmesh/router.hpp +31 -0
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Manual Arduino IDE Installation (ZIP Import)
|
|
2
|
+
|
|
3
|
+
This guide explains how to manually install painlessMesh in Arduino IDE using a ZIP file. This method is useful when:
|
|
4
|
+
- The Arduino Library Manager hasn't indexed the latest version yet
|
|
5
|
+
- You want to test unreleased versions from GitHub
|
|
6
|
+
- You need a specific version that's not in the Library Manager
|
|
7
|
+
|
|
8
|
+
## Quick Start
|
|
9
|
+
|
|
10
|
+
### Method 1: Download Release ZIP
|
|
11
|
+
|
|
12
|
+
1. **Download** the latest release ZIP from:
|
|
13
|
+
- [GitHub Releases](https://github.com/Alteriom/painlessMesh/releases)
|
|
14
|
+
- Look for `painlessMesh-vX.X.X.zip`
|
|
15
|
+
|
|
16
|
+
2. **Install in Arduino IDE**:
|
|
17
|
+
- Open Arduino IDE
|
|
18
|
+
- Go to **Sketch → Include Library → Add .ZIP Library...**
|
|
19
|
+
- Select the downloaded `painlessMesh-vX.X.X.zip` file
|
|
20
|
+
- Wait for "Library installed" message
|
|
21
|
+
|
|
22
|
+
3. **Install Dependencies**:
|
|
23
|
+
- Go to **Sketch → Include Library → Manage Libraries...**
|
|
24
|
+
- Search and install:
|
|
25
|
+
- **ArduinoJson** (v6.21.x or v7.x)
|
|
26
|
+
- **TaskScheduler** (v3.7.0+)
|
|
27
|
+
|
|
28
|
+
4. **Verify Installation**:
|
|
29
|
+
- Go to **File → Examples → painlessMesh**
|
|
30
|
+
- Open any example (e.g., `basic`)
|
|
31
|
+
- Verify it compiles
|
|
32
|
+
|
|
33
|
+
### Method 2: Create ZIP from Repository
|
|
34
|
+
|
|
35
|
+
If you need to create a ZIP file from the repository source:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
# Clone the repository
|
|
39
|
+
git clone https://github.com/Alteriom/painlessMesh.git
|
|
40
|
+
cd painlessMesh
|
|
41
|
+
|
|
42
|
+
# Create Arduino IDE compatible ZIP
|
|
43
|
+
./scripts/create-arduino-zip.sh
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
This creates `dist/painlessMesh-vX.X.X.zip` ready for Arduino IDE import.
|
|
47
|
+
|
|
48
|
+
## What's Included in the ZIP
|
|
49
|
+
|
|
50
|
+
The ZIP file contains:
|
|
51
|
+
- ✅ `src/` - Complete library source code
|
|
52
|
+
- ✅ `examples/` - All Arduino examples (19+ sketches)
|
|
53
|
+
- ✅ `library.properties` - Arduino library metadata
|
|
54
|
+
- ✅ `README.md` - Documentation
|
|
55
|
+
- ✅ `LICENSE` - LGPL-3.0 license
|
|
56
|
+
- ✅ `CHANGELOG.md` - Version history
|
|
57
|
+
- ✅ `keywords.txt` - Syntax highlighting
|
|
58
|
+
|
|
59
|
+
## Directory Structure
|
|
60
|
+
|
|
61
|
+
After installation, the library will be in:
|
|
62
|
+
- **Windows**: `Documents\Arduino\libraries\painlessMesh\`
|
|
63
|
+
- **macOS**: `~/Documents/Arduino/libraries/painlessMesh/`
|
|
64
|
+
- **Linux**: `~/Arduino/libraries/painlessMesh/`
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
painlessMesh/
|
|
68
|
+
├── src/ # Library source files
|
|
69
|
+
│ ├── painlessMesh.h # Main header
|
|
70
|
+
│ ├── painlessmesh/ # Core implementation
|
|
71
|
+
│ └── arduino/ # Arduino-specific code
|
|
72
|
+
├── examples/ # Example sketches
|
|
73
|
+
│ ├── basic/
|
|
74
|
+
│ ├── bridge/
|
|
75
|
+
│ ├── mqtt/
|
|
76
|
+
│ └── ...
|
|
77
|
+
├── library.properties # Library metadata
|
|
78
|
+
├── README.md
|
|
79
|
+
├── LICENSE
|
|
80
|
+
└── keywords.txt
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Creating ZIP Files
|
|
84
|
+
|
|
85
|
+
### Automated Script
|
|
86
|
+
|
|
87
|
+
Use the provided script for consistent ZIP creation:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# From repository root
|
|
91
|
+
./scripts/create-arduino-zip.sh
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Output**: `dist/painlessMesh-vX.X.X.zip`
|
|
95
|
+
|
|
96
|
+
**Features**:
|
|
97
|
+
- ✅ Proper directory structure for Arduino IDE
|
|
98
|
+
- ✅ Includes all required files
|
|
99
|
+
- ✅ Excludes development files (.git, test/, .github/)
|
|
100
|
+
- ✅ Matches GitHub release format
|
|
101
|
+
- ✅ Version number from library.properties
|
|
102
|
+
|
|
103
|
+
### Manual ZIP Creation
|
|
104
|
+
|
|
105
|
+
If you need to create a ZIP manually:
|
|
106
|
+
|
|
107
|
+
1. **Create directory structure**:
|
|
108
|
+
```bash
|
|
109
|
+
mkdir -p painlessMesh-package/painlessMesh
|
|
110
|
+
cd painlessMesh-package/painlessMesh
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
2. **Copy required files**:
|
|
114
|
+
```bash
|
|
115
|
+
# From your painlessMesh repository
|
|
116
|
+
cp -r src examples library.properties README.md LICENSE .
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
3. **Optional additions**:
|
|
120
|
+
```bash
|
|
121
|
+
cp CHANGELOG.md keywords.txt .
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
4. **Create ZIP**:
|
|
125
|
+
```bash
|
|
126
|
+
cd ..
|
|
127
|
+
zip -r painlessMesh-v1.8.3.zip painlessMesh/
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
5. **Important**: The ZIP must contain a folder named `painlessMesh` with the library files inside. Do NOT zip the files directly.
|
|
131
|
+
|
|
132
|
+
## Verification
|
|
133
|
+
|
|
134
|
+
After installation, verify it works:
|
|
135
|
+
|
|
136
|
+
### Test Compilation
|
|
137
|
+
|
|
138
|
+
```cpp
|
|
139
|
+
#include "painlessMesh.h"
|
|
140
|
+
|
|
141
|
+
painlessMesh mesh;
|
|
142
|
+
|
|
143
|
+
void setup() {
|
|
144
|
+
Serial.begin(115200);
|
|
145
|
+
Serial.println("painlessMesh test");
|
|
146
|
+
|
|
147
|
+
mesh.init("TestNetwork", "password", 5555);
|
|
148
|
+
Serial.println("Initialized successfully!");
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
void loop() {
|
|
152
|
+
mesh.update();
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
If this compiles without errors, installation is successful!
|
|
157
|
+
|
|
158
|
+
### Check Examples
|
|
159
|
+
|
|
160
|
+
The examples should appear in:
|
|
161
|
+
**File → Examples → painlessMesh**
|
|
162
|
+
|
|
163
|
+
Available examples:
|
|
164
|
+
- basic - Simple mesh network
|
|
165
|
+
- bridge - Internet bridge mode
|
|
166
|
+
- startHere - Quick start template
|
|
167
|
+
- namedMesh - Named mesh networks
|
|
168
|
+
- And 15+ more examples
|
|
169
|
+
|
|
170
|
+
## Troubleshooting
|
|
171
|
+
|
|
172
|
+
### "Library not found" Error
|
|
173
|
+
|
|
174
|
+
**Problem**: Arduino IDE can't find the library after installation.
|
|
175
|
+
|
|
176
|
+
**Solutions**:
|
|
177
|
+
1. Restart Arduino IDE
|
|
178
|
+
2. Check installation directory:
|
|
179
|
+
- Windows: `Documents\Arduino\libraries\`
|
|
180
|
+
- macOS: `~/Documents/Arduino/libraries/`
|
|
181
|
+
- Linux: `~/Arduino/libraries/`
|
|
182
|
+
3. Verify folder name is exactly `painlessMesh` (case-sensitive on Linux/macOS)
|
|
183
|
+
4. Check that `library.properties` exists in the painlessMesh folder
|
|
184
|
+
|
|
185
|
+
### "No such file or directory" Compilation Error
|
|
186
|
+
|
|
187
|
+
**Problem**: Missing dependency headers like `ArduinoJson.h` or `TaskScheduler.h`.
|
|
188
|
+
|
|
189
|
+
**Solution**:
|
|
190
|
+
Install dependencies via Library Manager:
|
|
191
|
+
1. **Sketch → Include Library → Manage Libraries...**
|
|
192
|
+
2. Search for:
|
|
193
|
+
- **ArduinoJson** → Install version 6.21.x or 7.x
|
|
194
|
+
- **TaskScheduler** → Install version 3.7.0+
|
|
195
|
+
|
|
196
|
+
### Version Mismatch
|
|
197
|
+
|
|
198
|
+
**Problem**: Old version still being used after installing new ZIP.
|
|
199
|
+
|
|
200
|
+
**Solution**:
|
|
201
|
+
1. Delete old version:
|
|
202
|
+
- Go to `Arduino/libraries/` folder
|
|
203
|
+
- Delete `painlessMesh` folder
|
|
204
|
+
2. Restart Arduino IDE
|
|
205
|
+
3. Install new ZIP file
|
|
206
|
+
|
|
207
|
+
### ZIP Structure Error
|
|
208
|
+
|
|
209
|
+
**Problem**: "Invalid library" error when importing ZIP.
|
|
210
|
+
|
|
211
|
+
**Cause**: Incorrect ZIP structure.
|
|
212
|
+
|
|
213
|
+
**Solution**:
|
|
214
|
+
Ensure ZIP contains:
|
|
215
|
+
```
|
|
216
|
+
painlessMesh-v1.8.3.zip
|
|
217
|
+
└── painlessMesh/ ← Must have this folder
|
|
218
|
+
├── src/
|
|
219
|
+
├── examples/
|
|
220
|
+
└── library.properties ← Must have this file
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
**Common mistake**: Zipping files directly without the `painlessMesh` folder.
|
|
224
|
+
|
|
225
|
+
## Comparing with Library Manager
|
|
226
|
+
|
|
227
|
+
| Feature | Manual ZIP Install | Library Manager |
|
|
228
|
+
|---------|-------------------|-----------------|
|
|
229
|
+
| **Latest Version** | ✅ Immediate | ⏱️ 24-48h delay |
|
|
230
|
+
| **Pre-release Testing** | ✅ Yes | ❌ No |
|
|
231
|
+
| **Custom Versions** | ✅ Yes | ❌ No |
|
|
232
|
+
| **Ease of Use** | ⚠️ Manual | ✅ Automatic |
|
|
233
|
+
| **Updates** | ⚠️ Manual | ✅ One-click |
|
|
234
|
+
| **Dependencies** | ⚠️ Manual | ✅ Auto-install |
|
|
235
|
+
|
|
236
|
+
## When to Use Each Method
|
|
237
|
+
|
|
238
|
+
### Use Manual ZIP Installation When:
|
|
239
|
+
- 🔧 Testing unreleased features from GitHub
|
|
240
|
+
- 🚀 Need the absolute latest version immediately
|
|
241
|
+
- 🐛 Testing a bug fix before official release
|
|
242
|
+
- 📦 Library Manager hasn't indexed latest version
|
|
243
|
+
- 🔬 Developing or contributing to painlessMesh
|
|
244
|
+
|
|
245
|
+
### Use Library Manager When:
|
|
246
|
+
- 📱 Installing for the first time
|
|
247
|
+
- 🔄 Need easy updates
|
|
248
|
+
- 👥 Stable production deployments
|
|
249
|
+
- 🎓 Learning or following tutorials
|
|
250
|
+
- 📚 Standard development workflow
|
|
251
|
+
|
|
252
|
+
## Automated Releases
|
|
253
|
+
|
|
254
|
+
The repository automatically creates proper ZIP files on each release:
|
|
255
|
+
|
|
256
|
+
1. **GitHub Actions** workflow builds ZIP on every release
|
|
257
|
+
2. **ZIP file** uploaded to GitHub Releases page
|
|
258
|
+
3. **Format** matches Arduino IDE requirements exactly
|
|
259
|
+
4. **Naming**: `painlessMesh-vX.X.X.zip`
|
|
260
|
+
|
|
261
|
+
Download from: https://github.com/Alteriom/painlessMesh/releases
|
|
262
|
+
|
|
263
|
+
## For Library Maintainers
|
|
264
|
+
|
|
265
|
+
### Creating Release ZIPs
|
|
266
|
+
|
|
267
|
+
The release workflow automatically creates proper ZIP files:
|
|
268
|
+
|
|
269
|
+
```yaml
|
|
270
|
+
# .github/workflows/release.yml
|
|
271
|
+
- name: Prepare library package
|
|
272
|
+
run: |
|
|
273
|
+
mkdir -p package/painlessMesh
|
|
274
|
+
cp -r src examples library.properties README.md LICENSE package/painlessMesh/
|
|
275
|
+
cd package
|
|
276
|
+
zip -r ../painlessMesh-v${{ steps.version.outputs.version }}.zip painlessMesh/
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Script Usage
|
|
280
|
+
|
|
281
|
+
For local testing before release:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
# Create ZIP for current version
|
|
285
|
+
./scripts/create-arduino-zip.sh
|
|
286
|
+
|
|
287
|
+
# Output: dist/painlessMesh-vX.X.X.zip
|
|
288
|
+
# Ready for testing in Arduino IDE
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
### Testing Installation
|
|
292
|
+
|
|
293
|
+
Before releasing:
|
|
294
|
+
|
|
295
|
+
1. Create ZIP with script
|
|
296
|
+
2. Install in fresh Arduino IDE
|
|
297
|
+
3. Test compilation of examples
|
|
298
|
+
4. Verify examples menu shows all sketches
|
|
299
|
+
5. Check dependency resolution
|
|
300
|
+
|
|
301
|
+
## Additional Resources
|
|
302
|
+
|
|
303
|
+
- 📚 [Full Installation Guide](../../website/docs/getting-started/installation.md)
|
|
304
|
+
- 🎯 [Quick Start Tutorial](../../website/docs/getting-started/quickstart.md)
|
|
305
|
+
- 🔧 [PlatformIO Installation](../../website/docs/getting-started/installation.md#platformio-installation)
|
|
306
|
+
- 🐛 [Troubleshooting Guide](../../website/docs/troubleshooting/common-issues.md)
|
|
307
|
+
- 📖 [API Reference](https://alteriom.github.io/painlessMesh/#/api/doxygen)
|
|
308
|
+
|
|
309
|
+
## Questions or Issues?
|
|
310
|
+
|
|
311
|
+
- 💬 [GitHub Discussions](https://github.com/Alteriom/painlessMesh/discussions)
|
|
312
|
+
- 🐛 [Report Issues](https://github.com/Alteriom/painlessMesh/issues)
|
|
313
|
+
- 📚 [Documentation](https://alteriom.github.io/painlessMesh/)
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
# Bridge-Centric Architecture Implementation
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document describes the implementation of the bridge-centric architecture with automatic channel detection for painlessMesh, as specified in issue #XX.
|
|
6
|
+
|
|
7
|
+
## Implementation Summary
|
|
8
|
+
|
|
9
|
+
### New Features
|
|
10
|
+
|
|
11
|
+
#### 1. `initAsBridge()` Method
|
|
12
|
+
|
|
13
|
+
**Location:** `src/arduino/wifi.hpp`
|
|
14
|
+
|
|
15
|
+
**Purpose:** Simplifies bridge node setup by automatically detecting router channel and configuring mesh accordingly.
|
|
16
|
+
|
|
17
|
+
**Signature:**
|
|
18
|
+
```cpp
|
|
19
|
+
void initAsBridge(TSTRING meshSSID, TSTRING meshPassword,
|
|
20
|
+
TSTRING routerSSID, TSTRING routerPassword,
|
|
21
|
+
Scheduler *baseScheduler, uint16_t port = 5555)
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
**Behavior:**
|
|
25
|
+
1. Connects to router in STA mode
|
|
26
|
+
2. Waits up to 30 seconds for connection
|
|
27
|
+
3. Detects router's WiFi channel using `WiFi.channel()`
|
|
28
|
+
4. Falls back to channel 1 if connection fails
|
|
29
|
+
5. Initializes mesh on detected channel
|
|
30
|
+
6. Re-establishes router connection using `stationManual()`
|
|
31
|
+
7. Automatically sets node as root (`setRoot(true)`)
|
|
32
|
+
8. Sets mesh as containing root (`setContainsRoot(true)`)
|
|
33
|
+
9. Provides comprehensive logging at each step
|
|
34
|
+
|
|
35
|
+
#### 2. `scanForMeshChannel()` Helper Function
|
|
36
|
+
|
|
37
|
+
**Location:** `src/painlessMeshSTA.cpp`, `src/painlessMeshSTA.h`
|
|
38
|
+
|
|
39
|
+
**Purpose:** Scans all WiFi channels to find a specific mesh SSID.
|
|
40
|
+
|
|
41
|
+
**Signature:**
|
|
42
|
+
```cpp
|
|
43
|
+
static uint8_t scanForMeshChannel(TSTRING meshSSID, bool meshHidden)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**Behavior:**
|
|
47
|
+
1. Performs WiFi scan on all channels (channel parameter = 0)
|
|
48
|
+
2. Iterates through scan results looking for matching SSID
|
|
49
|
+
3. Supports hidden networks (empty SSID matches when hidden flag is set)
|
|
50
|
+
4. Returns channel number if found, 0 if not found
|
|
51
|
+
5. Cleans up scan results with `WiFi.scanDelete()`
|
|
52
|
+
6. Provides detailed logging
|
|
53
|
+
|
|
54
|
+
**Platform Support:**
|
|
55
|
+
- ESP32: Uses `WiFi.scanNetworks(false, meshHidden, false, 300U, 0)`
|
|
56
|
+
- ESP8266: Uses `WiFi.scanNetworks(false, meshHidden, 0)`
|
|
57
|
+
|
|
58
|
+
#### 3. Auto Channel Detection for Regular Nodes
|
|
59
|
+
|
|
60
|
+
**Location:** `src/painlessMeshSTA.cpp` (enhanced `stationScan()`)
|
|
61
|
+
|
|
62
|
+
**Purpose:** Allows regular nodes to automatically find and join mesh on any channel.
|
|
63
|
+
|
|
64
|
+
**Behavior:**
|
|
65
|
+
- When `channel=0` is passed to `init()`, triggers auto-detection
|
|
66
|
+
- Calls `scanForMeshChannel()` to find mesh
|
|
67
|
+
- Updates mesh channel if found
|
|
68
|
+
- Falls back to channel 1 if mesh not found
|
|
69
|
+
- Only runs once at initialization
|
|
70
|
+
|
|
71
|
+
**Usage:**
|
|
72
|
+
```cpp
|
|
73
|
+
mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT, WIFI_AP_STA, 0);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Technical Details
|
|
77
|
+
|
|
78
|
+
### Channel Detection Algorithm
|
|
79
|
+
|
|
80
|
+
```
|
|
81
|
+
Bridge Node (initAsBridge):
|
|
82
|
+
1. WiFi.disconnect()
|
|
83
|
+
2. WiFi.mode(WIFI_STA)
|
|
84
|
+
3. WiFi.begin(routerSSID, routerPassword)
|
|
85
|
+
4. Wait for connection (30s timeout)
|
|
86
|
+
5. If connected:
|
|
87
|
+
- detectedChannel = WiFi.channel()
|
|
88
|
+
6. Else:
|
|
89
|
+
- detectedChannel = 1 (fallback)
|
|
90
|
+
7. init(meshSSID, meshPassword, ..., detectedChannel)
|
|
91
|
+
8. stationManual(routerSSID, routerPassword)
|
|
92
|
+
9. setRoot(true), setContainsRoot(true)
|
|
93
|
+
|
|
94
|
+
Regular Node (channel=0):
|
|
95
|
+
1. scanForMeshChannel(meshSSID, hidden)
|
|
96
|
+
2. If found:
|
|
97
|
+
- mesh->_meshChannel = detectedChannel
|
|
98
|
+
3. Else:
|
|
99
|
+
- mesh->_meshChannel = 1 (fallback)
|
|
100
|
+
4. Continue with normal stationScan()
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Error Handling
|
|
104
|
+
|
|
105
|
+
#### Router Connection Failure
|
|
106
|
+
- **Timeout:** 30 seconds
|
|
107
|
+
- **Fallback:** Channel 1
|
|
108
|
+
- **Logging:** Error message indicating failure
|
|
109
|
+
- **Behavior:** Mesh still initializes, but on default channel
|
|
110
|
+
|
|
111
|
+
#### Mesh Not Found (Regular Nodes)
|
|
112
|
+
- **Fallback:** Channel 1
|
|
113
|
+
- **Logging:** Info message about fallback
|
|
114
|
+
- **Behavior:** Node creates mesh on channel 1 or waits for mesh to appear
|
|
115
|
+
|
|
116
|
+
### Memory Considerations
|
|
117
|
+
|
|
118
|
+
**Bridge Initialization:**
|
|
119
|
+
- Temporary WiFi connection during setup
|
|
120
|
+
- No additional persistent memory usage
|
|
121
|
+
- Scan results cleaned up immediately
|
|
122
|
+
|
|
123
|
+
**Channel Scanning:**
|
|
124
|
+
- Temporary scan results buffer
|
|
125
|
+
- Cleared with `WiFi.scanDelete()`
|
|
126
|
+
- No memory leaks
|
|
127
|
+
|
|
128
|
+
### Timing Considerations
|
|
129
|
+
|
|
130
|
+
**Bridge Initialization:**
|
|
131
|
+
- Router connection: Up to 30 seconds
|
|
132
|
+
- Total initialization time: ~35-40 seconds worst case
|
|
133
|
+
- Can be optimized by reducing timeout if needed
|
|
134
|
+
|
|
135
|
+
**Regular Node Auto-Detection:**
|
|
136
|
+
- Single scan of all channels: ~5-10 seconds
|
|
137
|
+
- Only happens once at startup
|
|
138
|
+
- Subsequent scans use detected channel
|
|
139
|
+
|
|
140
|
+
## Backward Compatibility
|
|
141
|
+
|
|
142
|
+
### No Breaking Changes
|
|
143
|
+
|
|
144
|
+
All existing code continues to work:
|
|
145
|
+
|
|
146
|
+
```cpp
|
|
147
|
+
// Old code - still works
|
|
148
|
+
mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT, WIFI_AP_STA, 6);
|
|
149
|
+
mesh.stationManual(ROUTER_SSID, ROUTER_PASSWORD);
|
|
150
|
+
mesh.setRoot(true);
|
|
151
|
+
|
|
152
|
+
// New code - simplified
|
|
153
|
+
mesh.initAsBridge(MESH_PREFIX, MESH_PASSWORD, ROUTER_SSID, ROUTER_PASSWORD, &userScheduler);
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### Migration Path
|
|
157
|
+
|
|
158
|
+
Users can migrate incrementally:
|
|
159
|
+
1. Keep existing bridge code working
|
|
160
|
+
2. Update bridge nodes to use `initAsBridge()` when convenient
|
|
161
|
+
3. Update regular nodes to use `channel=0` for auto-detection
|
|
162
|
+
4. No rush - both approaches work simultaneously
|
|
163
|
+
|
|
164
|
+
## Testing
|
|
165
|
+
|
|
166
|
+
### Test Coverage
|
|
167
|
+
|
|
168
|
+
**Automated Tests:**
|
|
169
|
+
- ✅ All existing unit tests pass (500+ assertions)
|
|
170
|
+
- ✅ No regressions detected
|
|
171
|
+
- ✅ Build system validates compilation
|
|
172
|
+
|
|
173
|
+
**Manual Testing Required:**
|
|
174
|
+
- 🔲 Bridge on router channel 1, nodes join successfully
|
|
175
|
+
- 🔲 Bridge on router channel 6, nodes join successfully
|
|
176
|
+
- 🔲 Bridge on router channel 11, nodes join successfully
|
|
177
|
+
- 🔲 Bridge fails to connect to router, uses channel 1
|
|
178
|
+
- 🔲 Regular node can't find mesh, falls back to channel 1
|
|
179
|
+
- 🔲 Hidden network support
|
|
180
|
+
- 🔲 Multiple nodes joining sequentially
|
|
181
|
+
- 🔲 Reconnection after bridge reboot
|
|
182
|
+
- 🔲 Reconnection after router reboot
|
|
183
|
+
|
|
184
|
+
### Test Scenarios
|
|
185
|
+
|
|
186
|
+
#### Scenario 1: Basic Bridge Operation
|
|
187
|
+
```
|
|
188
|
+
1. Setup bridge node with initAsBridge()
|
|
189
|
+
2. Setup 2-3 regular nodes with channel=0
|
|
190
|
+
3. Verify all nodes join mesh
|
|
191
|
+
4. Verify mesh channel matches router channel
|
|
192
|
+
5. Verify bridge has Internet connectivity
|
|
193
|
+
6. Verify messages flow through mesh
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
#### Scenario 2: Router Connection Failure
|
|
197
|
+
```
|
|
198
|
+
1. Setup bridge node with invalid router credentials
|
|
199
|
+
2. Verify bridge falls back to channel 1
|
|
200
|
+
3. Verify mesh still forms
|
|
201
|
+
4. Verify error logging is clear
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
#### Scenario 3: Hidden Network
|
|
205
|
+
```
|
|
206
|
+
1. Configure router as hidden SSID
|
|
207
|
+
2. Setup bridge with initAsBridge()
|
|
208
|
+
3. Verify bridge detects hidden router channel
|
|
209
|
+
4. Setup regular nodes with channel=0 and hidden=true
|
|
210
|
+
5. Verify nodes find and join hidden mesh
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Known Limitations
|
|
214
|
+
|
|
215
|
+
### Current Implementation
|
|
216
|
+
|
|
217
|
+
1. **Single Bridge Only:** Architecture assumes one bridge node
|
|
218
|
+
2. **2.4GHz Only:** Works on channels 1-13 (standard WiFi b/g/n)
|
|
219
|
+
3. **No 5GHz Support:** Limited by ESP32/ESP8266 hardware
|
|
220
|
+
4. **Blocking Initialization:** Bridge init blocks for up to 30 seconds
|
|
221
|
+
|
|
222
|
+
### Future Enhancements
|
|
223
|
+
|
|
224
|
+
1. **Multi-Bridge Support:** Load balancing between multiple bridges
|
|
225
|
+
2. **Async Initialization:** Non-blocking bridge setup
|
|
226
|
+
3. **Channel Change Detection:** Auto-restart if router changes channel
|
|
227
|
+
4. **Callback Notifications:** Events for channel detection, connection status
|
|
228
|
+
5. **Configurable Timeout:** User-specified timeout for router connection
|
|
229
|
+
|
|
230
|
+
## Performance Impact
|
|
231
|
+
|
|
232
|
+
### Bridge Node
|
|
233
|
+
- **Initialization Time:** +30s worst case (router connection timeout)
|
|
234
|
+
- **Memory Usage:** No additional runtime overhead
|
|
235
|
+
- **CPU Usage:** Minimal, only during initialization
|
|
236
|
+
|
|
237
|
+
### Regular Nodes
|
|
238
|
+
- **Initialization Time:** +5-10s (one-time channel scan)
|
|
239
|
+
- **Memory Usage:** No additional runtime overhead
|
|
240
|
+
- **CPU Usage:** Minimal, only during initialization
|
|
241
|
+
|
|
242
|
+
### Network Performance
|
|
243
|
+
- **No runtime impact** - Channel detection only happens at startup
|
|
244
|
+
- **Mesh operation** - Identical to manual configuration after init
|
|
245
|
+
|
|
246
|
+
## Documentation Updates
|
|
247
|
+
|
|
248
|
+
### Files Modified
|
|
249
|
+
- ✅ `README.md` - Added bridge quick start section
|
|
250
|
+
- ✅ `BRIDGE_TO_INTERNET.md` - Complete rewrite with new approach
|
|
251
|
+
- ✅ `CHANGELOG.md` - Release notes for v1.7.8+
|
|
252
|
+
- ✅ `examples/bridge/bridge.ino` - Updated to use `initAsBridge()`
|
|
253
|
+
- ✅ `examples/basic/basic.ino` - Shows auto-detection
|
|
254
|
+
- 🔲 API documentation (Doxygen comments in headers)
|
|
255
|
+
- 🔲 Wiki pages (if applicable)
|
|
256
|
+
|
|
257
|
+
### Documentation Quality
|
|
258
|
+
- Clear code examples
|
|
259
|
+
- Expected output logs
|
|
260
|
+
- Troubleshooting sections
|
|
261
|
+
- Migration guide
|
|
262
|
+
- Best practices
|
|
263
|
+
|
|
264
|
+
## Security Considerations
|
|
265
|
+
|
|
266
|
+
### Password Handling
|
|
267
|
+
- Passwords stored in SRAM during setup
|
|
268
|
+
- Not persisted to flash (WiFi.persistent(false))
|
|
269
|
+
- Cleared after connection established
|
|
270
|
+
|
|
271
|
+
### Network Security
|
|
272
|
+
- No changes to WiFi security model
|
|
273
|
+
- Inherits WPA2 security from WiFi stack
|
|
274
|
+
- No new attack vectors introduced
|
|
275
|
+
|
|
276
|
+
### Code Safety
|
|
277
|
+
- Input validation on SSID/password strings
|
|
278
|
+
- Timeout handling prevents infinite loops
|
|
279
|
+
- Fallback behavior prevents bricked devices
|
|
280
|
+
|
|
281
|
+
## Code Quality
|
|
282
|
+
|
|
283
|
+
### Static Analysis
|
|
284
|
+
- ✅ Compiles without warnings
|
|
285
|
+
- ✅ Follows existing code style
|
|
286
|
+
- ✅ Matches repository conventions
|
|
287
|
+
- ✅ No memory leaks detected
|
|
288
|
+
|
|
289
|
+
### Code Review Checklist
|
|
290
|
+
- ✅ Clear, self-documenting function names
|
|
291
|
+
- ✅ Comprehensive inline comments
|
|
292
|
+
- ✅ Error handling at all levels
|
|
293
|
+
- ✅ Logging for debugging
|
|
294
|
+
- ✅ Platform-specific code properly ifdef'd
|
|
295
|
+
- ✅ No magic numbers (all constants defined)
|
|
296
|
+
|
|
297
|
+
## Release Checklist
|
|
298
|
+
|
|
299
|
+
### Pre-Release
|
|
300
|
+
- ✅ Code implementation complete
|
|
301
|
+
- ✅ Documentation updated
|
|
302
|
+
- ✅ CHANGELOG updated
|
|
303
|
+
- ✅ Examples updated
|
|
304
|
+
- ✅ Backward compatibility verified
|
|
305
|
+
- ✅ All automated tests pass
|
|
306
|
+
- 🔲 Manual testing complete
|
|
307
|
+
- 🔲 Code review approved
|
|
308
|
+
- 🔲 Security scan clean
|
|
309
|
+
|
|
310
|
+
### Release
|
|
311
|
+
- 🔲 Version number bumped
|
|
312
|
+
- 🔲 Git tag created
|
|
313
|
+
- 🔲 Release notes published
|
|
314
|
+
- 🔲 Arduino Library Manager updated
|
|
315
|
+
- 🔲 PlatformIO Registry updated
|
|
316
|
+
- 🔲 NPM package published
|
|
317
|
+
|
|
318
|
+
### Post-Release
|
|
319
|
+
- 🔲 Monitor issue tracker for bugs
|
|
320
|
+
- 🔲 Update documentation based on feedback
|
|
321
|
+
- 🔲 Create migration guide if needed
|
|
322
|
+
|
|
323
|
+
## References
|
|
324
|
+
|
|
325
|
+
- Issue #XX: Feature request for bridge-centric architecture
|
|
326
|
+
- PR #XX: Implementation pull request
|
|
327
|
+
- `BRIDGE_TO_INTERNET.md`: User-facing bridge documentation
|
|
328
|
+
- `README.md`: Quick start guide
|
|
329
|
+
|
|
330
|
+
## Contributors
|
|
331
|
+
|
|
332
|
+
- Implementation: GitHub Copilot (@copilot)
|
|
333
|
+
- Architecture Design: Based on feedback from @woodlist
|
|
334
|
+
- Review: @sparck75
|
|
335
|
+
|
|
336
|
+
---
|
|
337
|
+
|
|
338
|
+
**Document Version:** 1.0
|
|
339
|
+
**Last Updated:** 2025-11-08
|
|
340
|
+
**Status:** Implementation Complete, Testing Pending
|