@alteriom/painlessmesh 1.6.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/LICENSE +674 -0
  3. package/README.md +434 -0
  4. package/RELEASE_GUIDE.md +419 -0
  5. package/docs/DOCUMENTATION_MIGRATION_PLAN.md +176 -0
  6. package/docs/README.md +71 -0
  7. package/docs/alteriom/overview.md +508 -0
  8. package/docs/api/core-api.md +607 -0
  9. package/docs/architecture/mesh-architecture.md +379 -0
  10. package/docs/architecture/plugin-system.md +517 -0
  11. package/docs/getting-started/first-mesh.md +410 -0
  12. package/docs/getting-started/installation.md +275 -0
  13. package/docs/getting-started/quickstart.md +158 -0
  14. package/docs/improvements/README.md +69 -0
  15. package/docs/troubleshooting/common-issues.md +521 -0
  16. package/docs/troubleshooting/faq.md +473 -0
  17. package/docs/tutorials/basic-examples.md +718 -0
  18. package/docs/wiki/API-Reference.md +246 -0
  19. package/docs/wiki/Complete-Documentation.md +123 -0
  20. package/examples/alteriom/README.md +82 -0
  21. package/examples/alteriom/alteriom.ino +186 -0
  22. package/examples/alteriom/alteriom_sensor_node.ino +184 -0
  23. package/examples/alteriom/alteriom_sensor_package.hpp +128 -0
  24. package/examples/alteriom/improved_sensor_node.ino +246 -0
  25. package/examples/alteriom/platformio.ini +25 -0
  26. package/examples/basic/basic.ino +66 -0
  27. package/examples/basic/platformio.ini +25 -0
  28. package/examples/bridge/bridge.ino +51 -0
  29. package/examples/bridge/platformio.ini +25 -0
  30. package/examples/echoNode/echoNode.ino +33 -0
  31. package/examples/echoNode/platformio.ini +25 -0
  32. package/examples/logClient/logClient.ino +109 -0
  33. package/examples/logClient/platformio.ini +25 -0
  34. package/examples/logServer/logServer.ino +81 -0
  35. package/examples/logServer/platformio.ini +25 -0
  36. package/examples/mqttBridge/mqttBridge.ino +118 -0
  37. package/examples/mqttBridge/platformio.ini +26 -0
  38. package/examples/namedMesh/namedMesh.ino +97 -0
  39. package/examples/namedMesh/platformio.ini +25 -0
  40. package/examples/otaReceiver/otaReceiver.ino +79 -0
  41. package/examples/otaReceiver/platformio.ini +25 -0
  42. package/examples/otaSender/nodemcu32s_connections.JPG +0 -0
  43. package/examples/otaSender/otaSender.ino +151 -0
  44. package/examples/otaSender/platformio.ini +25 -0
  45. package/examples/startHere/platformio.ini +25 -0
  46. package/examples/startHere/startHere.ino +159 -0
  47. package/examples/webServer/platformio.ini +27 -0
  48. package/examples/webServer/webServer.ino +89 -0
  49. package/keywords.txt +49 -0
  50. package/library.json +34 -0
  51. package/library.properties +11 -0
  52. package/package.json +78 -0
  53. package/src/AlteriomPainlessMesh.h +98 -0
  54. package/src/arduino/wifi.hpp +365 -0
  55. package/src/boost/asynctcp.hpp +279 -0
  56. package/src/painlessMesh.h +70 -0
  57. package/src/painlessMeshSTA.cpp +236 -0
  58. package/src/painlessMeshSTA.h +58 -0
  59. package/src/painlessTaskOptions.h +4 -0
  60. package/src/painlessmesh/base64.hpp +111 -0
  61. package/src/painlessmesh/buffer.hpp +229 -0
  62. package/src/painlessmesh/callback.hpp +91 -0
  63. package/src/painlessmesh/configuration.hpp +77 -0
  64. package/src/painlessmesh/connection.hpp +192 -0
  65. package/src/painlessmesh/layout.hpp +188 -0
  66. package/src/painlessmesh/logger.hpp +158 -0
  67. package/src/painlessmesh/memory.hpp +120 -0
  68. package/src/painlessmesh/mesh.hpp +560 -0
  69. package/src/painlessmesh/metrics.hpp +323 -0
  70. package/src/painlessmesh/ntp.hpp +263 -0
  71. package/src/painlessmesh/ota.hpp +553 -0
  72. package/src/painlessmesh/plugin.hpp +188 -0
  73. package/src/painlessmesh/protocol.hpp +813 -0
  74. package/src/painlessmesh/router.hpp +322 -0
  75. package/src/painlessmesh/tcp.hpp +71 -0
  76. package/src/painlessmesh/validation.hpp +239 -0
  77. package/src/plugin/performance.hpp +214 -0
  78. package/src/plugin/remote.hpp +64 -0
  79. package/src/scheduler.cpp +10 -0
  80. package/src/wifi.cpp +2 -0
package/README.md ADDED
@@ -0,0 +1,434 @@
1
+ # AlteriomPainlessMesh
2
+
3
+ > **📚 [Complete Documentation](https://alteriom.github.io/painlessMesh/)** | **📖 [API Reference](https://alteriom.github.io/painlessMesh/#/api/doxygen)** | **🎯 [Examples](https://alteriom.github.io/painlessMesh/#/tutorials/basic-examples)**
4
+
5
+ <div align="center">
6
+
7
+ [![CI/CD Pipeline](https://github.com/Alteriom/painlessMesh/actions/workflows/ci.yml/badge.svg)](https://github.com/Alteriom/painlessMesh/actions/workflows/ci.yml)
8
+ [![Documentation](https://github.com/Alteriom/painlessMesh/actions/workflows/docs.yml/badge.svg)](https://github.com/Alteriom/painlessMesh/actions/workflows/docs.yml)
9
+ [![Release](https://github.com/Alteriom/painlessMesh/actions/workflows/release.yml/badge.svg)](https://github.com/Alteriom/painlessMesh/actions/workflows/release.yml)
10
+ [![GitHub release](https://img.shields.io/github/release/Alteriom/painlessMesh.svg)](https://github.com/Alteriom/painlessMesh/releases)
11
+ [![PlatformIO Registry](https://badges.registry.platformio.org/packages/alteriom/library/painlessMesh.svg)](https://registry.platformio.org/libraries/alteriom/painlessMesh)
12
+ [![Arduino Library Manager](https://img.shields.io/badge/Arduino-Library%20Manager-blue.svg)](https://www.arduino.cc/reference/en/libraries/alteriompainlessmesh/)
13
+
14
+ </div>
15
+
16
+ ## 🌐 Intro to AlteriomPainlessMesh
17
+
18
+ **AlteriomPainlessMesh** is a user-friendly library for creating mesh networks with ESP8266 and ESP32 devices. This **Alteriom fork** extends the original painlessMesh library with specialized packages for IoT sensor networks, device control, and status monitoring.
19
+
20
+ ### 🎯 Alteriom Extensions
21
+
22
+ This fork includes three specialized packages for structured IoT communication:
23
+
24
+ - **`SensorPackage`** (Type 200) - Environmental data collection (temperature, humidity, pressure, battery levels)
25
+ - **`CommandPackage`** (Type 201) - Device control and automation commands
26
+ - **`StatusPackage`** (Type 202) - Health monitoring and system status reporting
27
+
28
+ All packages provide type-safe serialization, automatic JSON conversion, and mesh-wide broadcasting or targeted messaging.
29
+
30
+ ### 🌐 Core Features
31
+
32
+ The library handles routing and network management automatically, so you can focus on your application. It 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. The original version was forked from [easymesh](https://github.com/Coopdis/easyMesh).
33
+
34
+ ### True ad-hoc networking
35
+
36
+ painlessMesh is a true ad-hoc network, meaning that no-planning, central controller, or router is required. Any system of 1 or more nodes will self-organize into fully functional mesh. The maximum size of the mesh is limited (we think) by the amount of memory in the heap that can be allocated to the sub-connections buffer and so should be really quite high.
37
+
38
+ ### JSON based
39
+
40
+ painlessMesh uses JSON objects for all its messaging. There are a couple of reasons for this. First, it makes the code and the messages human readable and painless to understand and second, it makes it painless to integrate painlessMesh with javascript front-ends, web applications, and other apps. Some performance is lost, but I haven’t been running into performance issues yet. Converting to binary messaging would be fairly straight forward if someone wants to contribute.
41
+
42
+ ### Wifi &amp; Networking
43
+
44
+ painlessMesh is designed to be used with Arduino, but it does not use the Arduino WiFi libraries, as we were running into performance issues (primarily latency) with them. Rather the networking is all done using the native esp32 and esp8266 SDK libraries, which are available through the Arduino IDE. Hopefully though, which networking libraries are used won’t matter to most users much as you can just include painlessMesh.h, run the init() and then work the library through the API.
45
+
46
+ ### painlessMesh is not IP networking
47
+
48
+ painlessMesh does not create a TCP/IP network of nodes. Rather each of the nodes is uniquely identified by its 32bit chipId which is retrieved from the esp8266/esp32 using the `system_get_chip_id()` call in the SDK. Every node will have a unique number. Messages can either be broadcast to all the nodes on the mesh, or sent specifically to an individual node which is identified by its `nodeId.
49
+
50
+ ### Limitations and caveats
51
+
52
+ - Try to avoid using `delay()` in your code. To maintain the mesh we need to perform some tasks in the background. Using `delay()` will stop these tasks from happening and can cause the mesh to lose stability/fall apart. Instead, we recommend using [TaskScheduler](http://playground.arduino.cc/Code/TaskScheduler) which is used in `painlessMesh` itself. Documentation can be found [here](https://github.com/arkhipenko/TaskScheduler/wiki/Full-Document). For other examples on how to use the scheduler see the example folder.
53
+ - `painlessMesh` subscribes to WiFi events. Please be aware that as a result `painlessMesh` can be incompatible with user programs/other libraries that try to bind to the same events.
54
+ - Try to be conservative in the number of messages (and especially broadcast messages) you sent per minute. This is to prevent the hardware from overloading. Both esp8266 and esp32 are limited in processing power/memory, making it easy to overload the mesh and destabilize it. And while `painlessMesh` tries to prevent this from happening, it is not always possible to do so.
55
+ - Messages can go missing or be dropped due to high traffic and you can not rely on all messages to be delivered. One suggestion to work around is to resend messages every so often. Even if some go missing, most should go through. Another option is to have your nodes send replies when they receive a message. The sending nodes can the resend the message if they haven’t gotten a reply in a certain amount of time.
56
+
57
+ ## Installation
58
+
59
+ ### Arduino Library Manager
60
+
61
+ This library is **Arduino Library Manager compliant** and can be installed directly from the Arduino IDE:
62
+
63
+ 1. Open Arduino IDE
64
+ 2. Go to **Tools** → **Manage Libraries...**
65
+ 3. Search for **"AlteriomPainlessMesh"**
66
+ 4. Click **Install**
67
+
68
+ The library includes the header file `AlteriomPainlessMesh.h` which provides access to both the core painlessMesh functionality and Alteriom-specific extensions.
69
+
70
+ ### PlatformIO
71
+
72
+ `painlessMesh` is included in both the Arduino Library Manager and the platformio library registry and can easily be installed via either of those methods.
73
+
74
+ ### Dependencies
75
+
76
+ painlessMesh makes use of the following libraries, which can be installed through the Arduino Library Manager
77
+
78
+ - [ArduinoJson](https://github.com/bblanchon/ArduinoJson)
79
+ - [TaskScheduler](https://github.com/arkhipenko/TaskScheduler)
80
+ - [ESPAsyncTCP](https://github.com/me-no-dev/ESPAsyncTCP) (ESP8266)
81
+ - [AsyncTCP](https://github.com/me-no-dev/AsyncTCP) (ESP32)
82
+
83
+ If platformio is used to install the library, then the dependencies will be installed automatically.
84
+
85
+ ## Quick Start with Alteriom Packages
86
+
87
+ ### Basic Sensor Node
88
+
89
+ ```cpp
90
+ #include "painlessMesh.h"
91
+ #include "examples/alteriom/alteriom_sensor_package.hpp"
92
+
93
+ using namespace alteriom;
94
+
95
+ #define MESH_PREFIX "AlteriomMesh"
96
+ #define MESH_PASSWORD "your_password"
97
+ #define MESH_PORT 5555
98
+
99
+ Scheduler userScheduler;
100
+ painlessMesh mesh;
101
+
102
+ void setup() {
103
+ Serial.begin(115200);
104
+ mesh.init(MESH_PREFIX, MESH_PASSWORD, &userScheduler, MESH_PORT);
105
+ mesh.onReceive(&receivedCallback);
106
+ }
107
+
108
+ void loop() {
109
+ mesh.update();
110
+
111
+ // Create and send sensor data
112
+ SensorPackage sensor;
113
+ sensor.temperature = 25.5;
114
+ sensor.humidity = 60.0;
115
+ sensor.sensorId = mesh.getNodeId();
116
+ sensor.timestamp = mesh.getNodeTime();
117
+
118
+ mesh.sendBroadcast(sensor.toJsonString());
119
+ delay(30000); // Send every 30 seconds
120
+ }
121
+
122
+ void receivedCallback(uint32_t from, String& msg) {
123
+ DynamicJsonDocument doc(1024);
124
+ deserializeJson(doc, msg);
125
+
126
+ if (doc["type"] == 200) { // SensorPackage
127
+ SensorPackage sensor(doc.as<JsonObject>());
128
+ Serial.printf("Sensor %u: %.1f°C, %.1f%% RH\n",
129
+ sensor.sensorId, sensor.temperature, sensor.humidity);
130
+ }
131
+ }
132
+ ```
133
+
134
+ ### Package Types
135
+
136
+ | Type | Class | Purpose | Fields |
137
+ |------|-------|---------|--------|
138
+ | 200 | `SensorPackage` | Environmental data | `temperature`, `humidity`, `pressure`, `sensorId`, `timestamp`, `batteryLevel` |
139
+ | 201 | `CommandPackage` | Device control | `command`, `targetDevice`, `parameters`, `commandId` |
140
+ | 202 | `StatusPackage` | Health monitoring | `deviceStatus`, `uptime`, `freeMemory`, `wifiStrength`, `firmwareVersion` |
141
+
142
+ ## Key Features
143
+
144
+ - **🔄 Automatic Mesh Formation** - Nodes discover and connect automatically
145
+ - **📡 Self-Healing Network** - Adapts when nodes join/leave
146
+ - **⏰ Time Synchronization** - Coordinated actions across all nodes
147
+ - **🔀 Smart Routing** - Broadcast, point-to-point, and neighbor messaging
148
+ - **🔌 Plugin System** - Type-safe custom message packages
149
+ - **📱 ESP32 & ESP8266** - Full support for both platforms
150
+ - **🛡️ Memory Efficient** - Optimized for resource-constrained devices
151
+
152
+ ## Examples & Use Cases
153
+
154
+ - **IoT Sensor Networks** - Environmental monitoring, smart agriculture
155
+ - **Home Automation** - Distributed lighting, HVAC control
156
+ - **Industrial Monitoring** - Equipment status, predictive maintenance
157
+ - **Event Coordination** - Synchronized displays, distributed processing
158
+ - **Bridge Networks** - Connect mesh to WiFi/Internet/MQTT
159
+
160
+ ## Getting Help
161
+
162
+ - **[FAQ](docs/troubleshooting/faq.md)** - Common questions and solutions
163
+ - **[GitHub Issues](https://github.com/Alteriom/painlessMesh/issues)** - Bug reports and feature requests
164
+ - **[Community Forum](https://groups.google.com/forum/#!forum/painlessmesh-user)** - Community support
165
+ - **[API Documentation](http://painlessmesh.gitlab.io/painlessMesh/index.html)** - Generated API docs
166
+
167
+ ## Development
168
+
169
+ ### Building from Source
170
+ ```bash
171
+ git clone https://github.com/Alteriom/painlessMesh.git
172
+ cd painlessMesh
173
+ git submodule update --init
174
+ cmake -G Ninja .
175
+ ninja
176
+ run-parts --regex catch_ bin/ # Run tests
177
+ ```
178
+
179
+ ### Requirements
180
+ - **ESP32/ESP8266**: Arduino Core 2.0.0+
181
+ - **Dependencies**: ArduinoJson 6.x, TaskScheduler 3.x
182
+ - **Development**: CMake, Ninja, Boost (for desktop testing)
183
+
184
+ ### CI/CD Pipeline
185
+
186
+ painlessMesh features a state-of-the-art automated CI/CD pipeline:
187
+
188
+ **🔄 Continuous Integration:**
189
+ - Automated builds on gcc/clang with strict warnings
190
+ - Cross-platform testing (Arduino CLI, PlatformIO)
191
+ - Code quality and formatting validation
192
+ - Comprehensive test suite execution
193
+
194
+ **🚀 Automated Releases:**
195
+ - Semantic versioning with automated tagging
196
+ - GitHub Releases with changelog generation
197
+ - Library package distribution
198
+ - Documentation deployment to GitHub Pages
199
+ - Arduino Library Manager & PlatformIO Registry integration
200
+
201
+ **📋 Release Management:**
202
+ ```bash
203
+ # Bump version and prepare release
204
+ ./scripts/bump-version.sh patch # or minor, major
205
+ ./scripts/validate-release.sh # Validate release readiness
206
+
207
+ # Edit CHANGELOG.md, then commit with release prefix
208
+ git commit -am "release: v1.5.7"
209
+ git push origin main # Triggers automated release
210
+ ```
211
+
212
+ See [RELEASE_GUIDE.md](RELEASE_GUIDE.md) for complete release documentation.
213
+
214
+ ## Contributing
215
+
216
+ We try to follow the [git flow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow) development model. Which means that we have a `develop` branch and `master` branch. All development is done under feature branches, which are (when finished) merged into the development branch. When a new version is released we merge the `develop` branch into the `master` branch. For more details see the [CONTRIBUTING](https://gitlab.com/painlessMesh/painlessMesh/blob/master/CONTRIBUTING.md) file.
217
+
218
+ ## Funding
219
+
220
+ If you like the library please consider giving me a tip. This means I will be able to spend more time on developing it.
221
+ You can tip me using ko-fi:
222
+
223
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/U7U21LWO6I)
224
+
225
+ ## 📚 Complete Documentation
226
+
227
+ > **� [Visit the Full Documentation Website](https://alteriom.github.io/painlessMesh/)**
228
+
229
+ ### 🚀 Getting Started
230
+
231
+ **New to AlteriomPainlessMesh?** Start with these essential guides:
232
+
233
+ | Guide | Description | Link |
234
+ |-------|-------------|------|
235
+ | **🎯 Quick Start** | Get your first mesh running in 5 minutes | [📖 Start Here](https://alteriom.github.io/painlessMesh/#/getting-started/quickstart) |
236
+ | **💾 Installation** | Arduino IDE, PlatformIO, and more | [📖 Install Guide](https://alteriom.github.io/painlessMesh/#/getting-started/installation) |
237
+ | **🌐 First Mesh** | Build a real multi-node network | [📖 Build Now](https://alteriom.github.io/painlessMesh/#/getting-started/first-mesh) |
238
+
239
+ ### 📖 API Documentation
240
+
241
+ **Complete reference for all classes, functions, and features:**
242
+
243
+ | Section | Description | Link |
244
+ |---------|-------------|------|
245
+ | **🔧 Core API** | painlessMesh class reference and methods | [📖 Core API](https://alteriom.github.io/painlessMesh/#/api/core-api) |
246
+ | **📦 Doxygen API** | Auto-generated complete API documentation | [📖 Browse API](https://alteriom.github.io/painlessMesh/#/api/doxygen) |
247
+ | **⚙️ Configuration** | All mesh configuration options | [📖 Configure](https://alteriom.github.io/painlessMesh/#/api/configuration) |
248
+ | **🔄 Callbacks** | Event handling and callback patterns | [📖 Events](https://alteriom.github.io/painlessMesh/#/api/callbacks) |
249
+
250
+ ### 🎯 Alteriom Extensions
251
+
252
+ **IoT-ready packages for production applications:**
253
+
254
+ | Package | Purpose | Documentation |
255
+ |---------|---------|---------------|
256
+ | **📊 SensorPackage** | Environmental data collection | [📖 Sensor Docs](https://alteriom.github.io/painlessMesh/#/alteriom/overview) |
257
+ | **⚡ CommandPackage** | Device control and automation | [📖 Command Docs](https://alteriom.github.io/painlessMesh/#/alteriom/overview) |
258
+ | **📈 StatusPackage** | Health monitoring and diagnostics | [📖 Status Docs](https://alteriom.github.io/painlessMesh/#/alteriom/overview) |
259
+
260
+ ### 🏗️ Advanced Topics
261
+
262
+ **Deep dive into architecture and advanced usage:**
263
+
264
+ | Topic | Description | Link |
265
+ |-------|-------------|------|
266
+ | **🌳 Architecture** | How painlessMesh works internally | [📖 Architecture](https://alteriom.github.io/painlessMesh/#/architecture/mesh-architecture) |
267
+ | **🔌 Plugin System** | Create custom message packages | [📖 Plugins](https://alteriom.github.io/painlessMesh/#/architecture/plugin-system) |
268
+ | **🎓 Tutorials** | Step-by-step examples and patterns | [📖 Tutorials](https://alteriom.github.io/painlessMesh/#/tutorials/basic-examples) |
269
+ | **🛠️ Troubleshooting** | Common issues and solutions | [📖 Help](https://alteriom.github.io/painlessMesh/#/troubleshooting/common-issues) |
270
+
271
+ ### 📝 Quick Reference
272
+
273
+ **Bookmark these for daily development:**
274
+
275
+ - **[📋 Class Index](https://alteriom.github.io/painlessMesh/#/api/doxygen/classes)** - All classes with methods
276
+ - **[⚙️ Function Index](https://alteriom.github.io/painlessMesh/#/api/doxygen/functions)** - All functions and globals
277
+ - **[📁 File Structure](https://alteriom.github.io/painlessMesh/#/api/doxygen/files)** - Source code organization
278
+ - **[❓ FAQ](https://alteriom.github.io/painlessMesh/#/troubleshooting/faq)** - Frequently asked questions
279
+
280
+ **📖 Tutorials & Examples:**
281
+ - **[Basic Examples](docs/tutorials/basic-examples.md)** - Essential patterns and techniques
282
+ - **[Custom Packages](docs/tutorials/custom-packages.md)** - Type-safe message handling
283
+ - **[Sensor Networks](docs/tutorials/sensor-networks.md)** - IoT sensor network patterns
284
+
285
+ **🚀 Alteriom Extensions:**
286
+ - **[Alteriom Overview](docs/alteriom/overview.md)** - Production-ready IoT packages
287
+ - **[Sensor Packages](docs/alteriom/sensor-packages.md)** - Environmental monitoring
288
+ - **[Command System](docs/alteriom/command-system.md)** - Device control and automation
289
+
290
+ **🔧 Troubleshooting:**
291
+ - **[Common Issues](docs/troubleshooting/common-issues.md)** - Solutions to frequent problems
292
+ - **[FAQ](docs/troubleshooting/faq.md)** - Frequently asked questions
293
+ - **[Debugging Guide](docs/troubleshooting/debugging.md)** - Tools and techniques
294
+
295
+ **📋 Complete Documentation Index:** [docs/README.md](docs/README.md)
296
+
297
+ ## painlessMesh API Summary
298
+
299
+ Here's a quick API overview. **For complete documentation, see [Core API Reference](docs/api/core-api.md)**
300
+
301
+ ```cpp
302
+ #include "painlessMesh.h"
303
+
304
+ painlessMesh mesh;
305
+ ```
306
+
307
+ ### Member Functions
308
+
309
+ #### void painlessMesh::init(String ssid, String password, uint16_t port = 5555, WiFiMode_t connectMode = WIFI_AP_STA, _auth_mode authmode = AUTH_WPA2_PSK, uint8_t channel = 1, phy_mode_t phymode = PHY_MODE_11G, uint8_t maxtpw = 82, uint8_t hidden = 0, uint8_t maxconn = 4)
310
+
311
+ Add this to your setup() function.
312
+ Initialize the mesh network. This routine does the following things.
313
+
314
+ - Starts a wifi network
315
+ - Begins searching for other wifi networks that are part of the mesh
316
+ - Logs on to the best mesh network node it finds… if it doesn’t find anything, it starts a new search in 5 seconds.
317
+
318
+ `ssid` = the name of your mesh. All nodes share same AP ssid. They are distinguished by BSSID.
319
+ `password` = wifi password to your mesh.
320
+ `port` = the TCP port that you want the mesh server to run on. Defaults to 5555 if not specified.
321
+ [`connectMode`](https://gitlab.com/painlessMesh/painlessMesh/wikis/connect-mode:-WIFI_AP,-WIFI_STA,-WIFI_AP_STA-mode) = switch between WIFI_AP, WIFI_STA and WIFI_AP_STA (default) mode
322
+
323
+ #### void painlessMesh::stop()
324
+
325
+ Stop the node. This will cause the node to disconnect from all other nodes and stop/sending messages.
326
+
327
+ #### void painlessMesh::update( void )
328
+
329
+ Add this to your loop() function
330
+ This routine runs various maintenance tasks... Not super interesting, but things don't work without it.
331
+
332
+ #### void painlessMesh::onReceive( &amp;receivedCallback )
333
+
334
+ Set a callback routine for any messages that are addressed to this node. Callback routine has the following structure.
335
+
336
+ `void receivedCallback( uint32_t from, String &amp;msg )`
337
+
338
+ Every time this node receives a message, this callback routine will the called. “from” is the id of the original sender of the message, and “msg” is a string that contains the message. The message can be anything. A JSON, some other text string, or binary data.
339
+
340
+ #### void painlessMesh::onNewConnection( &amp;newConnectionCallback )
341
+
342
+ This fires every time the local node makes a new connection. The callback has the following structure.
343
+
344
+ `void newConnectionCallback( uint32_t nodeId )`
345
+
346
+ `nodeId` is new connected node ID in the mesh.
347
+
348
+ #### void painlessMesh::onChangedConnections( &amp;changedConnectionsCallback )
349
+
350
+ This fires every time there is a change in mesh topology. Callback has the following structure.
351
+
352
+ `void onChangedConnections()`
353
+
354
+ There are no parameters passed. This is a signal only.
355
+
356
+ #### bool painlessMesh::isConnected( nodeId )
357
+
358
+ Returns if a given node is currently connected to the mesh.
359
+
360
+ `nodeId` is node ID that the request refers to.
361
+
362
+ #### void painlessMesh::onNodeTimeAdjusted( &amp;nodeTimeAdjustedCallback )
363
+
364
+ This fires every time local time is adjusted to synchronize it with mesh time. Callback has the following structure.
365
+
366
+ `void onNodeTimeAdjusted(int32_t offset)`
367
+
368
+ `offset` is the adjustment delta that has been calculated and applied to local clock.
369
+
370
+ #### void onNodeDelayReceived(nodeDelayCallback_t onDelayReceived)
371
+
372
+ This fires when a time delay measurement response is received, after a request was sent. Callback has the following structure.
373
+
374
+ `void onNodeDelayReceived(uint32_t nodeId, int32_t delay)`
375
+
376
+ `nodeId` The node that originated response.
377
+
378
+ `delay` One way network trip delay in microseconds.
379
+
380
+ #### bool painlessMesh::sendBroadcast( String &amp;msg, bool includeSelf = false)
381
+
382
+ Sends msg to every node on the entire mesh network. By default the current node is excluded from receiving the message (`includeSelf = false`). `includeSelf = true` overrides this behavior, causing the `receivedCallback` to be called when sending a broadcast message.
383
+
384
+ returns true if everything works, false if not. Prints an error message to Serial.print, if there is a failure.
385
+
386
+ #### bool painlessMesh::sendSingle(uint32_t dest, String &amp;msg)
387
+
388
+ Sends msg to the node with Id == dest.
389
+
390
+ returns true if everything works, false if not. Prints an error message to Serial.print, if there is a failure.
391
+
392
+ #### String painlessMesh::subConnectionJson()
393
+
394
+ Returns mesh topology in JSON format.
395
+
396
+ #### std::list<uint32_t> painlessMesh::getNodeList()
397
+
398
+ Get a list of all known nodes. This includes nodes that are both directly and indirectly connected to the current node.
399
+
400
+ #### uint32_t painlessMesh::getNodeId( void )
401
+
402
+ Return the chipId of the node that we are running on.
403
+
404
+ #### uint32_t painlessMesh::getNodeTime( void )
405
+
406
+ Returns the mesh timebase microsecond counter. Rolls over 71 minutes from startup of the first node.
407
+
408
+ Nodes try to keep a common time base synchronizing to each other using [an SNTP based protocol](https://gitlab.com/painlessMesh/painlessMesh/wikis/mesh-protocol#time-sync)
409
+
410
+ #### bool painlessMesh::startDelayMeas(uint32_t nodeId)
411
+
412
+ Sends a node a packet to measure network trip delay to that node. Returns true if nodeId is connected to the mesh, false otherwise. After calling this function, user program have to wait to the response in the form of a callback specified by `void painlessMesh::onNodeDelayReceived(nodeDelayCallback_t onDelayReceived)`.
413
+
414
+ nodeDelayCallback_t is a function in the form of `void (uint32_t nodeId, int32_t delay)`.
415
+
416
+ #### void painlessMesh::stationManual( String ssid, String password, uint16_t port, uint8_t *remote_ip )
417
+
418
+ Connects the node to an AP outside the mesh. When specifying a `remote_ip` and `port`, the node opens a TCP connection after establishing the WiFi connection.
419
+
420
+ Note: The mesh must be on the same WiFi channel as the AP.
421
+
422
+ #### void painlessMesh::setDebugMsgTypes( uint16_t types )
423
+
424
+ Change the internal log level. List of types defined in Logger.hpp:
425
+ ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE
426
+
427
+
428
+ # Funding
429
+
430
+ Most development of painlessMesh has been done as a hobby, but some specific features have been funded by the companies listed below:
431
+
432
+ ![Sowillo](https://www.sowillo.com/wp-content/uploads/2019/04/Logo-Sowillo-1.png)
433
+
434
+ [Sowillo](http://sowillo.com/en/)