@alteriom/painlessmesh 1.6.1 → 1.7.2

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 (129) hide show
  1. package/CHANGELOG.md +380 -143
  2. package/LICENSE +674 -674
  3. package/README.md +477 -434
  4. package/RELEASE_GUIDE.md +504 -418
  5. package/docs/DOCUMENTATION_MIGRATION_PLAN.md +175 -175
  6. package/docs/IMPLEMENTATION_PLAN_MESH_TOPOLOGY.md +1062 -0
  7. package/docs/MESH_TOPOLOGY_GUIDE.md +992 -0
  8. package/docs/MESH_TOPOLOGY_PROGRESS.md +422 -0
  9. package/docs/MQTT_BRIDGE_COMMANDS.md +894 -0
  10. package/docs/MQTT_BRIDGE_IMPLEMENTATION_SUMMARY.md +324 -0
  11. package/docs/MQTT_COMMAND_SCHEMA_PROPOSAL.md +576 -0
  12. package/docs/MQTT_SCHEMA_COMPLIANCE.md +285 -0
  13. package/docs/MQTT_SCHEMA_PROPOSALS.md +446 -0
  14. package/docs/MQTT_SCHEMA_REVIEW.md +690 -0
  15. package/docs/OTA_COMMANDS_REFERENCE.md +554 -0
  16. package/docs/PHASE1_GUIDE.md +349 -0
  17. package/docs/PHASE2_GUIDE.md +543 -0
  18. package/docs/README.md +77 -70
  19. package/docs/SCHEMA_VALIDATION_CHECKLIST.md +222 -0
  20. package/docs/alteriom/overview.md +507 -507
  21. package/docs/api/core-api.md +606 -606
  22. package/docs/architecture/mesh-architecture.md +378 -378
  23. package/docs/architecture/plugin-system.md +516 -516
  24. package/docs/getting-started/first-mesh.md +409 -409
  25. package/docs/getting-started/installation.md +274 -274
  26. package/docs/getting-started/quickstart.md +157 -157
  27. package/docs/improvements/FEATURE_PROPOSALS.md +337 -0
  28. package/docs/improvements/PHASE1_IMPLEMENTATION.md +325 -0
  29. package/docs/improvements/PHASE2_IMPLEMENTATION.md +567 -0
  30. package/docs/improvements/README.md +86 -68
  31. package/docs/improvements/ota-and-status-enhancements.md +911 -0
  32. package/docs/improvements/ota-status-architecture-diagrams.md +658 -0
  33. package/docs/improvements/ota-status-quick-reference.md +284 -0
  34. package/docs/platformio-publishing.md +255 -0
  35. package/docs/platformio-setup-summary.md +121 -0
  36. package/docs/troubleshooting/common-issues.md +520 -520
  37. package/docs/troubleshooting/faq.md +472 -472
  38. package/docs/tutorials/basic-examples.md +717 -717
  39. package/docs/wiki/API-Reference.md +245 -245
  40. package/docs/wiki/Complete-Documentation.md +122 -122
  41. package/examples/alteriom/README.md +139 -81
  42. package/examples/alteriom/alteriom.ino +186 -185
  43. package/examples/alteriom/alteriom_sensor_package.hpp +240 -127
  44. package/examples/alteriom/platformio.ini +24 -24
  45. package/examples/alteriomImproved/alteriom_sensor_package.hpp +224 -0
  46. package/examples/{alteriom → alteriomImproved}/improved_sensor_node.ino +245 -245
  47. package/examples/alteriomImproved/platformio.ini +25 -0
  48. package/examples/alteriomPhase1/alteriom_sensor_package.hpp +224 -0
  49. package/examples/alteriomPhase1/phase1_features.ino +242 -0
  50. package/examples/alteriomPhase1/platformio.ini +25 -0
  51. package/examples/alteriomPhase2/alteriom_sensor_package.hpp +224 -0
  52. package/examples/alteriomPhase2/phase2_features.ino +186 -0
  53. package/examples/alteriomPhase2/platformio.ini +25 -0
  54. package/examples/{alteriom → alteriomSensorNode}/alteriom_sensor_node.ino +183 -183
  55. package/examples/alteriomSensorNode/alteriom_sensor_package.hpp +224 -0
  56. package/examples/alteriomSensorNode/platformio.ini +25 -0
  57. package/examples/basic/basic.ino +66 -66
  58. package/examples/basic/platformio.ini +25 -25
  59. package/examples/bridge/bridge.ino +51 -51
  60. package/examples/bridge/mesh_event_publisher.hpp +253 -0
  61. package/examples/bridge/mesh_topology_reporter.hpp +303 -0
  62. package/examples/bridge/mqtt_command_bridge.hpp +459 -0
  63. package/examples/bridge/mqtt_status_bridge.hpp +519 -0
  64. package/examples/bridge/platformio.ini +25 -25
  65. package/examples/echoNode/echoNode.ino +33 -33
  66. package/examples/echoNode/platformio.ini +25 -25
  67. package/examples/logClient/logClient.ino +109 -109
  68. package/examples/logClient/platformio.ini +25 -25
  69. package/examples/logServer/logServer.ino +81 -81
  70. package/examples/logServer/platformio.ini +25 -25
  71. package/examples/meshCommandNode/alteriom_sensor_package.hpp +235 -0
  72. package/examples/meshCommandNode/meshCommandNode.ino +263 -0
  73. package/examples/meshCommandNode/platformio.ini +25 -0
  74. package/examples/mqttBridge/mqttBridge.ino +118 -118
  75. package/examples/mqttBridge/platformio.ini +26 -26
  76. package/examples/mqttCommandBridge/alteriom_sensor_package.hpp +235 -0
  77. package/examples/mqttCommandBridge/mesh_event_publisher.hpp +253 -0
  78. package/examples/mqttCommandBridge/mesh_topology_reporter.hpp +303 -0
  79. package/examples/mqttCommandBridge/mqttCommandBridge.ino +252 -0
  80. package/examples/mqttCommandBridge/mqtt_command_bridge.hpp +459 -0
  81. package/examples/mqttCommandBridge/platformio.ini +26 -0
  82. package/examples/mqttStatusBridge/mqttStatusBridge.ino +216 -0
  83. package/examples/mqttStatusBridge/mqtt_status_bridge.hpp +522 -0
  84. package/examples/mqttStatusBridge/platformio.ini +26 -0
  85. package/examples/mqttTopologyTest/README.md +467 -0
  86. package/examples/mqttTopologyTest/mqttTopologyTest.ino +748 -0
  87. package/examples/mqttTopologyTest/platformio.ini +26 -0
  88. package/examples/namedMesh/namedMesh.ino +97 -97
  89. package/examples/namedMesh/platformio.ini +25 -25
  90. package/examples/otaReceiver/otaReceiver.ino +79 -79
  91. package/examples/otaReceiver/platformio.ini +25 -25
  92. package/examples/otaSender/otaSender.ino +160 -151
  93. package/examples/otaSender/platformio.ini +25 -25
  94. package/examples/startHere/platformio.ini +25 -25
  95. package/examples/startHere/startHere.ino +159 -159
  96. package/examples/webServer/platformio.ini +27 -27
  97. package/examples/webServer/webServer.ino +89 -89
  98. package/keywords.txt +48 -48
  99. package/library.json +55 -34
  100. package/library.properties +10 -10
  101. package/package.json +86 -78
  102. package/src/AlteriomPainlessMesh.h +97 -97
  103. package/src/arduino/wifi.hpp +365 -365
  104. package/src/boost/asynctcp.hpp +279 -279
  105. package/src/painlessMesh.h +70 -70
  106. package/src/painlessMeshSTA.cpp +236 -236
  107. package/src/painlessMeshSTA.h +58 -58
  108. package/src/painlessTaskOptions.h +4 -4
  109. package/src/painlessmesh/base64.hpp +111 -111
  110. package/src/painlessmesh/buffer.hpp +229 -229
  111. package/src/painlessmesh/callback.hpp +91 -91
  112. package/src/painlessmesh/configuration.hpp +77 -77
  113. package/src/painlessmesh/connection.hpp +192 -192
  114. package/src/painlessmesh/layout.hpp +188 -188
  115. package/src/painlessmesh/logger.hpp +158 -158
  116. package/src/painlessmesh/memory.hpp +119 -119
  117. package/src/painlessmesh/mesh.hpp +761 -560
  118. package/src/painlessmesh/metrics.hpp +322 -322
  119. package/src/painlessmesh/ntp.hpp +263 -263
  120. package/src/painlessmesh/ota.hpp +582 -553
  121. package/src/painlessmesh/plugin.hpp +188 -188
  122. package/src/painlessmesh/protocol.hpp +813 -813
  123. package/src/painlessmesh/router.hpp +322 -322
  124. package/src/painlessmesh/tcp.hpp +71 -71
  125. package/src/painlessmesh/validation.hpp +238 -238
  126. package/src/plugin/performance.hpp +214 -214
  127. package/src/plugin/remote.hpp +64 -64
  128. package/src/scheduler.cpp +10 -10
  129. package/src/wifi.cpp +2 -2
@@ -1,159 +1,159 @@
1
- //************************************************************
2
- // this is a simple example that uses the easyMesh library
3
- //
4
- // 1. blinks led once for every node on the mesh
5
- // 2. blink cycle repeats every BLINK_PERIOD
6
- // 3. sends a silly message to every node on the mesh at a random time between 1 and 5 seconds
7
- // 4. prints anything it receives to Serial.print
8
- //
9
- //
10
- //************************************************************
11
- #include <painlessMesh.h>
12
-
13
- // some gpio pin that is connected to an LED...
14
- // on my rig, this is 2, change to the right number of your LED.
15
- #ifndef LED
16
- #ifdef LED_BUILTIN
17
- #define LED LED_BUILTIN
18
- #else
19
- #define LED 2
20
- #endif
21
- #endif
22
-
23
- #define BLINK_PERIOD 3000 // milliseconds until cycle repeat
24
- #define BLINK_DURATION 100 // milliseconds LED is on for
25
-
26
- #define MESH_SSID "whateverYouLike"
27
- #define MESH_PASSWORD "somethingSneaky"
28
- #define MESH_PORT 5555
29
-
30
- // Prototypes
31
- void sendMessage();
32
- void receivedCallback(uint32_t from, String & msg);
33
- void newConnectionCallback(uint32_t nodeId);
34
- void changedConnectionCallback();
35
- void nodeTimeAdjustedCallback(int32_t offset);
36
- void delayReceivedCallback(uint32_t from, int32_t delay);
37
-
38
- Scheduler userScheduler; // to control your personal task
39
- painlessMesh mesh;
40
-
41
- bool calc_delay = false;
42
- SimpleList<uint32_t> nodes;
43
-
44
- void sendMessage() ; // Prototype
45
- Task taskSendMessage( TASK_SECOND * 1, TASK_FOREVER, &sendMessage ); // start with a one second interval
46
-
47
- // Task to blink the number of nodes
48
- Task blinkNoNodes;
49
- bool onFlag = false;
50
-
51
- void setup() {
52
- Serial.begin(115200);
53
-
54
- pinMode(LED, OUTPUT);
55
-
56
- mesh.setDebugMsgTypes(ERROR | DEBUG); // set before init() so that you can see error messages
57
-
58
- mesh.init(MESH_SSID, MESH_PASSWORD, &userScheduler, MESH_PORT);
59
- mesh.onReceive(&receivedCallback);
60
- mesh.onNewConnection(&newConnectionCallback);
61
- mesh.onChangedConnections(&changedConnectionCallback);
62
- mesh.onNodeTimeAdjusted(&nodeTimeAdjustedCallback);
63
- mesh.onNodeDelayReceived(&delayReceivedCallback);
64
-
65
- userScheduler.addTask( taskSendMessage );
66
- taskSendMessage.enable();
67
-
68
- blinkNoNodes.set(BLINK_PERIOD, (mesh.getNodeList().size() + 1) * 2, []() {
69
- // If on, switch off, else switch on
70
- if (onFlag)
71
- onFlag = false;
72
- else
73
- onFlag = true;
74
- blinkNoNodes.delay(BLINK_DURATION);
75
-
76
- if (blinkNoNodes.isLastIteration()) {
77
- // Finished blinking. Reset task for next run
78
- // blink number of nodes (including this node) times
79
- blinkNoNodes.setIterations((mesh.getNodeList().size() + 1) * 2);
80
- // Calculate delay based on current mesh time and BLINK_PERIOD
81
- // This results in blinks between nodes being synced
82
- blinkNoNodes.enableDelayed(BLINK_PERIOD -
83
- (mesh.getNodeTime() % (BLINK_PERIOD*1000))/1000);
84
- }
85
- });
86
- userScheduler.addTask(blinkNoNodes);
87
- blinkNoNodes.enable();
88
-
89
- randomSeed(analogRead(A0));
90
- }
91
-
92
- void loop() {
93
- mesh.update();
94
- digitalWrite(LED, !onFlag);
95
- }
96
-
97
- void sendMessage() {
98
- String msg = "Hello from node ";
99
- msg += mesh.getNodeId();
100
- msg += " myFreeMemory: " + String(ESP.getFreeHeap());
101
- mesh.sendBroadcast(msg);
102
-
103
- if (calc_delay) {
104
- SimpleList<uint32_t>::iterator node = nodes.begin();
105
- while (node != nodes.end()) {
106
- mesh.startDelayMeas(*node);
107
- node++;
108
- }
109
- calc_delay = false;
110
- }
111
-
112
- Serial.printf("Sending message: %s\n", msg.c_str());
113
-
114
- taskSendMessage.setInterval( random(TASK_SECOND * 1, TASK_SECOND * 5)); // between 1 and 5 seconds
115
- }
116
-
117
-
118
- void receivedCallback(uint32_t from, String & msg) {
119
- Serial.printf("startHere: Received from %u msg=%s\n", from, msg.c_str());
120
- }
121
-
122
- void newConnectionCallback(uint32_t nodeId) {
123
- // Reset blink task
124
- onFlag = false;
125
- blinkNoNodes.setIterations((mesh.getNodeList().size() + 1) * 2);
126
- blinkNoNodes.enableDelayed(BLINK_PERIOD - (mesh.getNodeTime() % (BLINK_PERIOD*1000))/1000);
127
-
128
- Serial.printf("--> startHere: New Connection, nodeId = %u\n", nodeId);
129
- Serial.printf("--> startHere: New Connection, %s\n", mesh.subConnectionJson(true).c_str());
130
- }
131
-
132
- void changedConnectionCallback() {
133
- Serial.printf("Changed connections\n");
134
- // Reset blink task
135
- onFlag = false;
136
- blinkNoNodes.setIterations((mesh.getNodeList().size() + 1) * 2);
137
- blinkNoNodes.enableDelayed(BLINK_PERIOD - (mesh.getNodeTime() % (BLINK_PERIOD*1000))/1000);
138
-
139
- nodes = mesh.getNodeList();
140
-
141
- Serial.printf("Num nodes: %d\n", nodes.size());
142
- Serial.printf("Connection list:");
143
-
144
- SimpleList<uint32_t>::iterator node = nodes.begin();
145
- while (node != nodes.end()) {
146
- Serial.printf(" %u", *node);
147
- node++;
148
- }
149
- Serial.println();
150
- calc_delay = true;
151
- }
152
-
153
- void nodeTimeAdjustedCallback(int32_t offset) {
154
- Serial.printf("Adjusted time %u. Offset = %d\n", mesh.getNodeTime(), offset);
155
- }
156
-
157
- void delayReceivedCallback(uint32_t from, int32_t delay) {
158
- Serial.printf("Delay to node %u is %d us\n", from, delay);
159
- }
1
+ //************************************************************
2
+ // this is a simple example that uses the easyMesh library
3
+ //
4
+ // 1. blinks led once for every node on the mesh
5
+ // 2. blink cycle repeats every BLINK_PERIOD
6
+ // 3. sends a silly message to every node on the mesh at a random time between 1 and 5 seconds
7
+ // 4. prints anything it receives to Serial.print
8
+ //
9
+ //
10
+ //************************************************************
11
+ #include <painlessMesh.h>
12
+
13
+ // some gpio pin that is connected to an LED...
14
+ // on my rig, this is 2, change to the right number of your LED.
15
+ #ifndef LED
16
+ #ifdef LED_BUILTIN
17
+ #define LED LED_BUILTIN
18
+ #else
19
+ #define LED 2
20
+ #endif
21
+ #endif
22
+
23
+ #define BLINK_PERIOD 3000 // milliseconds until cycle repeat
24
+ #define BLINK_DURATION 100 // milliseconds LED is on for
25
+
26
+ #define MESH_SSID "whateverYouLike"
27
+ #define MESH_PASSWORD "somethingSneaky"
28
+ #define MESH_PORT 5555
29
+
30
+ // Prototypes
31
+ void sendMessage();
32
+ void receivedCallback(uint32_t from, String & msg);
33
+ void newConnectionCallback(uint32_t nodeId);
34
+ void changedConnectionCallback();
35
+ void nodeTimeAdjustedCallback(int32_t offset);
36
+ void delayReceivedCallback(uint32_t from, int32_t delay);
37
+
38
+ Scheduler userScheduler; // to control your personal task
39
+ painlessMesh mesh;
40
+
41
+ bool calc_delay = false;
42
+ SimpleList<uint32_t> nodes;
43
+
44
+ void sendMessage() ; // Prototype
45
+ Task taskSendMessage( TASK_SECOND * 1, TASK_FOREVER, &sendMessage ); // start with a one second interval
46
+
47
+ // Task to blink the number of nodes
48
+ Task blinkNoNodes;
49
+ bool onFlag = false;
50
+
51
+ void setup() {
52
+ Serial.begin(115200);
53
+
54
+ pinMode(LED, OUTPUT);
55
+
56
+ mesh.setDebugMsgTypes(ERROR | DEBUG); // set before init() so that you can see error messages
57
+
58
+ mesh.init(MESH_SSID, MESH_PASSWORD, &userScheduler, MESH_PORT);
59
+ mesh.onReceive(&receivedCallback);
60
+ mesh.onNewConnection(&newConnectionCallback);
61
+ mesh.onChangedConnections(&changedConnectionCallback);
62
+ mesh.onNodeTimeAdjusted(&nodeTimeAdjustedCallback);
63
+ mesh.onNodeDelayReceived(&delayReceivedCallback);
64
+
65
+ userScheduler.addTask( taskSendMessage );
66
+ taskSendMessage.enable();
67
+
68
+ blinkNoNodes.set(BLINK_PERIOD, (mesh.getNodeList().size() + 1) * 2, []() {
69
+ // If on, switch off, else switch on
70
+ if (onFlag)
71
+ onFlag = false;
72
+ else
73
+ onFlag = true;
74
+ blinkNoNodes.delay(BLINK_DURATION);
75
+
76
+ if (blinkNoNodes.isLastIteration()) {
77
+ // Finished blinking. Reset task for next run
78
+ // blink number of nodes (including this node) times
79
+ blinkNoNodes.setIterations((mesh.getNodeList().size() + 1) * 2);
80
+ // Calculate delay based on current mesh time and BLINK_PERIOD
81
+ // This results in blinks between nodes being synced
82
+ blinkNoNodes.enableDelayed(BLINK_PERIOD -
83
+ (mesh.getNodeTime() % (BLINK_PERIOD*1000))/1000);
84
+ }
85
+ });
86
+ userScheduler.addTask(blinkNoNodes);
87
+ blinkNoNodes.enable();
88
+
89
+ randomSeed(analogRead(A0));
90
+ }
91
+
92
+ void loop() {
93
+ mesh.update();
94
+ digitalWrite(LED, !onFlag);
95
+ }
96
+
97
+ void sendMessage() {
98
+ String msg = "Hello from node ";
99
+ msg += mesh.getNodeId();
100
+ msg += " myFreeMemory: " + String(ESP.getFreeHeap());
101
+ mesh.sendBroadcast(msg);
102
+
103
+ if (calc_delay) {
104
+ SimpleList<uint32_t>::iterator node = nodes.begin();
105
+ while (node != nodes.end()) {
106
+ mesh.startDelayMeas(*node);
107
+ node++;
108
+ }
109
+ calc_delay = false;
110
+ }
111
+
112
+ Serial.printf("Sending message: %s\n", msg.c_str());
113
+
114
+ taskSendMessage.setInterval( random(TASK_SECOND * 1, TASK_SECOND * 5)); // between 1 and 5 seconds
115
+ }
116
+
117
+
118
+ void receivedCallback(uint32_t from, String & msg) {
119
+ Serial.printf("startHere: Received from %u msg=%s\n", from, msg.c_str());
120
+ }
121
+
122
+ void newConnectionCallback(uint32_t nodeId) {
123
+ // Reset blink task
124
+ onFlag = false;
125
+ blinkNoNodes.setIterations((mesh.getNodeList().size() + 1) * 2);
126
+ blinkNoNodes.enableDelayed(BLINK_PERIOD - (mesh.getNodeTime() % (BLINK_PERIOD*1000))/1000);
127
+
128
+ Serial.printf("--> startHere: New Connection, nodeId = %u\n", nodeId);
129
+ Serial.printf("--> startHere: New Connection, %s\n", mesh.subConnectionJson(true).c_str());
130
+ }
131
+
132
+ void changedConnectionCallback() {
133
+ Serial.printf("Changed connections\n");
134
+ // Reset blink task
135
+ onFlag = false;
136
+ blinkNoNodes.setIterations((mesh.getNodeList().size() + 1) * 2);
137
+ blinkNoNodes.enableDelayed(BLINK_PERIOD - (mesh.getNodeTime() % (BLINK_PERIOD*1000))/1000);
138
+
139
+ nodes = mesh.getNodeList();
140
+
141
+ Serial.printf("Num nodes: %d\n", nodes.size());
142
+ Serial.printf("Connection list:");
143
+
144
+ SimpleList<uint32_t>::iterator node = nodes.begin();
145
+ while (node != nodes.end()) {
146
+ Serial.printf(" %u", *node);
147
+ node++;
148
+ }
149
+ Serial.println();
150
+ calc_delay = true;
151
+ }
152
+
153
+ void nodeTimeAdjustedCallback(int32_t offset) {
154
+ Serial.printf("Adjusted time %u. Offset = %d\n", mesh.getNodeTime(), offset);
155
+ }
156
+
157
+ void delayReceivedCallback(uint32_t from, int32_t delay) {
158
+ Serial.printf("Delay to node %u is %d us\n", from, delay);
159
+ }
@@ -1,27 +1,27 @@
1
- [platformio]
2
- src_dir = .
3
-
4
- [env]
5
- lib_deps =
6
- bblanchon/ArduinoJson
7
- arkhipenko/TaskScheduler
8
- esp32async/ESPAsyncWebServer
9
-
10
- [env:esp8266]
11
- platform = espressif8266
12
- board = nodemcuv2
13
- framework = arduino
14
- lib_extra_dirs = ../../
15
- lib_deps =
16
- ${env.lib_deps} ; Inherit common dependencies
17
- esp32async/ESPAsyncTCP ; Only for ESP8266
18
-
19
- [env:esp32]
20
- platform = espressif32
21
- board = esp32dev
22
- framework = arduino
23
- lib_extra_dirs = ../../
24
- lib_deps =
25
- ${env.lib_deps} ; Inherit common dependencies
26
- esp32async/AsyncTCP
27
- AsyncWebServer
1
+ [platformio]
2
+ src_dir = .
3
+
4
+ [env]
5
+ lib_deps =
6
+ bblanchon/ArduinoJson
7
+ arkhipenko/TaskScheduler
8
+ esp32async/ESPAsyncWebServer
9
+
10
+ [env:esp8266]
11
+ platform = espressif8266
12
+ board = nodemcuv2
13
+ framework = arduino
14
+ lib_extra_dirs = ../../
15
+ lib_deps =
16
+ ${env.lib_deps} ; Inherit common dependencies
17
+ esp32async/ESPAsyncTCP ; Only for ESP8266
18
+
19
+ [env:esp32]
20
+ platform = espressif32
21
+ board = esp32dev
22
+ framework = arduino
23
+ lib_extra_dirs = ../../
24
+ lib_deps =
25
+ ${env.lib_deps} ; Inherit common dependencies
26
+ esp32async/AsyncTCP
27
+ AsyncWebServer
@@ -1,89 +1,89 @@
1
- //************************************************************
2
- // this is a simple example that uses the painlessMesh library to
3
- // connect to a another network and broadcast message from a webpage to the edges of the mesh network.
4
- // This sketch can be extended further using all the abilities of the AsyncWebserver library (WS, events, ...)
5
- // for more details
6
- // https://gitlab.com/painlessMesh/painlessMesh/wikis/bridge-between-mesh-and-another-network
7
- // for more details about my version
8
- // https://gitlab.com/Assassynv__V/painlessMesh
9
- // and for more details about the AsyncWebserver library
10
- // https://github.com/me-no-dev/ESPAsyncWebServer
11
- //************************************************************
12
-
13
- #include "IPAddress.h"
14
- #include "painlessMesh.h"
15
-
16
- #ifdef ESP8266
17
- #include "Hash.h"
18
- #include <ESPAsyncTCP.h>
19
- #else
20
- #include <AsyncTCP.h>
21
- #endif
22
- #include <ESPAsyncWebServer.h>
23
-
24
- #define MESH_PREFIX "whateverYouLike"
25
- #define MESH_PASSWORD "somethingSneaky"
26
- #define MESH_PORT 5555
27
-
28
- #define STATION_SSID "mySSID"
29
- #define STATION_PASSWORD "myPASSWORD"
30
-
31
- #define HOSTNAME "HTTP_BRIDGE"
32
-
33
- // Prototype
34
- void receivedCallback( const uint32_t &from, const String &msg );
35
- IPAddress getlocalIP();
36
-
37
- painlessMesh mesh;
38
- AsyncWebServer server(80);
39
- IPAddress myIP(0,0,0,0);
40
- IPAddress myAPIP(0,0,0,0);
41
-
42
- void setup() {
43
- Serial.begin(115200);
44
-
45
- mesh.setDebugMsgTypes( ERROR | STARTUP | CONNECTION ); // set before init() so that you can see startup messages
46
-
47
- // Channel set to 6. Make sure to use the same channel for your mesh and for you other
48
- // network (STATION_SSID)
49
- mesh.init( MESH_PREFIX, MESH_PASSWORD, MESH_PORT, WIFI_AP_STA, 6 );
50
- mesh.onReceive(&receivedCallback);
51
-
52
- mesh.stationManual(STATION_SSID, STATION_PASSWORD);
53
- mesh.setHostname(HOSTNAME);
54
-
55
- // Bridge node, should (in most cases) be a root node. See [the wiki](https://gitlab.com/painlessMesh/painlessMesh/wikis/Possible-challenges-in-mesh-formation) for some background
56
- mesh.setRoot(true);
57
- // This node and all other nodes should ideally know the mesh contains a root, so call this on all nodes
58
- mesh.setContainsRoot(true);
59
-
60
- myAPIP = IPAddress(mesh.getAPIP());
61
- Serial.println("My AP IP is " + myAPIP.toString());
62
-
63
- //Async webserver
64
- server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
65
- request->send(200, "text/html", "<form>Text to Broadcast<br><input type='text' name='BROADCAST'><br><br><input type='submit' value='Submit'></form>");
66
- if (request->hasArg("BROADCAST")){
67
- String msg = request->arg("BROADCAST");
68
- mesh.sendBroadcast(msg);
69
- }
70
- });
71
- server.begin();
72
-
73
- }
74
-
75
- void loop() {
76
- mesh.update();
77
- if(myIP != getlocalIP()){
78
- myIP = getlocalIP();
79
- Serial.println("My IP is " + myIP.toString());
80
- }
81
- }
82
-
83
- void receivedCallback( const uint32_t &from, const String &msg ) {
84
- Serial.printf("bridge: Received from %u msg=%s\n", from, msg.c_str());
85
- }
86
-
87
- IPAddress getlocalIP() {
88
- return IPAddress(mesh.getStationIP());
89
- }
1
+ //************************************************************
2
+ // this is a simple example that uses the painlessMesh library to
3
+ // connect to a another network and broadcast message from a webpage to the edges of the mesh network.
4
+ // This sketch can be extended further using all the abilities of the AsyncWebserver library (WS, events, ...)
5
+ // for more details
6
+ // https://gitlab.com/painlessMesh/painlessMesh/wikis/bridge-between-mesh-and-another-network
7
+ // for more details about my version
8
+ // https://gitlab.com/Assassynv__V/painlessMesh
9
+ // and for more details about the AsyncWebserver library
10
+ // https://github.com/me-no-dev/ESPAsyncWebServer
11
+ //************************************************************
12
+
13
+ #include "IPAddress.h"
14
+ #include "painlessMesh.h"
15
+
16
+ #ifdef ESP8266
17
+ #include "Hash.h"
18
+ #include <ESPAsyncTCP.h>
19
+ #else
20
+ #include <AsyncTCP.h>
21
+ #endif
22
+ #include <ESPAsyncWebServer.h>
23
+
24
+ #define MESH_PREFIX "whateverYouLike"
25
+ #define MESH_PASSWORD "somethingSneaky"
26
+ #define MESH_PORT 5555
27
+
28
+ #define STATION_SSID "mySSID"
29
+ #define STATION_PASSWORD "myPASSWORD"
30
+
31
+ #define HOSTNAME "HTTP_BRIDGE"
32
+
33
+ // Prototype
34
+ void receivedCallback( const uint32_t &from, const String &msg );
35
+ IPAddress getlocalIP();
36
+
37
+ painlessMesh mesh;
38
+ AsyncWebServer server(80);
39
+ IPAddress myIP(0,0,0,0);
40
+ IPAddress myAPIP(0,0,0,0);
41
+
42
+ void setup() {
43
+ Serial.begin(115200);
44
+
45
+ mesh.setDebugMsgTypes( ERROR | STARTUP | CONNECTION ); // set before init() so that you can see startup messages
46
+
47
+ // Channel set to 6. Make sure to use the same channel for your mesh and for you other
48
+ // network (STATION_SSID)
49
+ mesh.init( MESH_PREFIX, MESH_PASSWORD, MESH_PORT, WIFI_AP_STA, 6 );
50
+ mesh.onReceive(&receivedCallback);
51
+
52
+ mesh.stationManual(STATION_SSID, STATION_PASSWORD);
53
+ mesh.setHostname(HOSTNAME);
54
+
55
+ // Bridge node, should (in most cases) be a root node. See [the wiki](https://gitlab.com/painlessMesh/painlessMesh/wikis/Possible-challenges-in-mesh-formation) for some background
56
+ mesh.setRoot(true);
57
+ // This node and all other nodes should ideally know the mesh contains a root, so call this on all nodes
58
+ mesh.setContainsRoot(true);
59
+
60
+ myAPIP = IPAddress(mesh.getAPIP());
61
+ Serial.println("My AP IP is " + myAPIP.toString());
62
+
63
+ //Async webserver
64
+ server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){
65
+ request->send(200, "text/html", "<form>Text to Broadcast<br><input type='text' name='BROADCAST'><br><br><input type='submit' value='Submit'></form>");
66
+ if (request->hasArg("BROADCAST")){
67
+ String msg = request->arg("BROADCAST");
68
+ mesh.sendBroadcast(msg);
69
+ }
70
+ });
71
+ server.begin();
72
+
73
+ }
74
+
75
+ void loop() {
76
+ mesh.update();
77
+ if(myIP != getlocalIP()){
78
+ myIP = getlocalIP();
79
+ Serial.println("My IP is " + myIP.toString());
80
+ }
81
+ }
82
+
83
+ void receivedCallback( const uint32_t &from, const String &msg ) {
84
+ Serial.printf("bridge: Received from %u msg=%s\n", from, msg.c_str());
85
+ }
86
+
87
+ IPAddress getlocalIP() {
88
+ return IPAddress(mesh.getStationIP());
89
+ }
package/keywords.txt CHANGED
@@ -1,49 +1,49 @@
1
- # painlessMesh library keywords
2
-
3
- # Classes (KEYWORD1)
4
- painlessMesh KEYWORD1
5
- Scheduler KEYWORD1
6
- Task KEYWORD1
7
-
8
- # Methods and Functions (KEYWORD2)
9
- init KEYWORD2
10
- update KEYWORD2
11
- sendBroadcast KEYWORD2
12
- sendSingle KEYWORD2
13
- onReceive KEYWORD2
14
- onNewConnection KEYWORD2
15
- onChangedConnections KEYWORD2
16
- onNodeTimeAdjusted KEYWORD2
17
- getNodeList KEYWORD2
18
- getNodeId KEYWORD2
19
- getNodeTime KEYWORD2
20
- setDebugMsgTypes KEYWORD2
21
- subConnectionJson KEYWORD2
22
- asNodeTree KEYWORD2
23
-
24
- # Alteriom Extensions (KEYWORD1)
25
- SensorPackage KEYWORD1
26
- CommandPackage KEYWORD1
27
- StatusPackage KEYWORD1
28
-
29
- # Alteriom Methods (KEYWORD2)
30
- addTo KEYWORD2
31
- jsonObjectSize KEYWORD2
32
-
33
- # Constants (LITERAL1)
34
- MESH_PREFIX LITERAL1
35
- MESH_PASSWORD LITERAL1
36
- MESH_PORT LITERAL1
37
- TASK_SECOND LITERAL1
38
- TASK_MINUTE LITERAL1
39
- TASK_HOUR LITERAL1
40
- TASK_FOREVER LITERAL1
41
- ERROR LITERAL1
42
- STARTUP LITERAL1
43
- CONNECTION LITERAL1
44
- SYNC LITERAL1
45
- COMMUNICATION LITERAL1
46
- GENERAL LITERAL1
47
- MSG_TYPES LITERAL1
48
- REMOTE LITERAL1
1
+ # painlessMesh library keywords
2
+
3
+ # Classes (KEYWORD1)
4
+ painlessMesh KEYWORD1
5
+ Scheduler KEYWORD1
6
+ Task KEYWORD1
7
+
8
+ # Methods and Functions (KEYWORD2)
9
+ init KEYWORD2
10
+ update KEYWORD2
11
+ sendBroadcast KEYWORD2
12
+ sendSingle KEYWORD2
13
+ onReceive KEYWORD2
14
+ onNewConnection KEYWORD2
15
+ onChangedConnections KEYWORD2
16
+ onNodeTimeAdjusted KEYWORD2
17
+ getNodeList KEYWORD2
18
+ getNodeId KEYWORD2
19
+ getNodeTime KEYWORD2
20
+ setDebugMsgTypes KEYWORD2
21
+ subConnectionJson KEYWORD2
22
+ asNodeTree KEYWORD2
23
+
24
+ # Alteriom Extensions (KEYWORD1)
25
+ SensorPackage KEYWORD1
26
+ CommandPackage KEYWORD1
27
+ StatusPackage KEYWORD1
28
+
29
+ # Alteriom Methods (KEYWORD2)
30
+ addTo KEYWORD2
31
+ jsonObjectSize KEYWORD2
32
+
33
+ # Constants (LITERAL1)
34
+ MESH_PREFIX LITERAL1
35
+ MESH_PASSWORD LITERAL1
36
+ MESH_PORT LITERAL1
37
+ TASK_SECOND LITERAL1
38
+ TASK_MINUTE LITERAL1
39
+ TASK_HOUR LITERAL1
40
+ TASK_FOREVER LITERAL1
41
+ ERROR LITERAL1
42
+ STARTUP LITERAL1
43
+ CONNECTION LITERAL1
44
+ SYNC LITERAL1
45
+ COMMUNICATION LITERAL1
46
+ GENERAL LITERAL1
47
+ MSG_TYPES LITERAL1
48
+ REMOTE LITERAL1
49
49
  DEBUG LITERAL1