You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Add working FloodingMesh. Unencrypted broadcasts should work well, but are untested in large mesh networks. Encrypted broadcast support is currently experimental.
- Add BroadcastTransmissionRedundancy and related functionality to reduce the transmission loss during broadcasts. Broadcast transmissions are now re-transmitted once per default. Broadcast throughput halved per default.
- Add getSenderAPMac method.
- Add FloodingMesh example in the HelloMesh.ino file.
- Improve JSON identifier names.
- Improve comments.
- Improve documentation.
constchar exampleMeshName[] PROGMEM = "MeshNode_";// The name of the mesh network. Used as prefix for the node SSID and to find other network nodes in the example networkFilter and broadcastFilter functions below.
18
+
constchar exampleWiFiPassword[] PROGMEM = "ChangeThisWiFiPassword_TODO";// The password has to be min 8 and max 64 characters long, otherwise an AP which uses it will not be found during scans.
19
19
20
-
unsignedint requestNumber = 0;
21
-
unsignedint responseNumber = 0;
20
+
// A custom encryption key is required when using encrypted ESP-NOW transmissions. There is always a default Kok set, but it can be replaced if desired.
21
+
// All ESP-NOW keys below must match in an encrypted connection pair for encrypted communication to be possible.
22
+
uint8_t espnowEncryptionKey[16] = {0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x33, 0x44, // This is the key for encrypting transmissions.
23
+
0x33, 0x44, 0x33, 0x44, 0x33, 0x44, 0x32, 0x11
24
+
};
25
+
uint8_t espnowHashKey[16] = {0xEF, 0x44, 0x33, 0x0C, 0x33, 0x44, 0xFE, 0x44, // This is the secret key used for HMAC during encrypted connection requests.
pinMode(LED_BUILTIN, OUTPUT); // Initialize the LED_BUILTIN pin as an output
137
+
digitalWrite(LED_BUILTIN, LOW); // Turn LED on (LED is active low)
138
+
}
139
+
140
+
floodingMeshDelay(5000); // Give some time for user to start the nodes
125
141
}
126
142
127
-
int32_ttimeOfLastScan = -10000;
143
+
int32_ttimeOfLastProclamation = -10000;
128
144
voidloop() {
129
-
if (millis() - timeOfLastScan > 3000// Give other nodes some time to connect between data transfers.
130
-
|| (WiFi.status() != WL_CONNECTED && millis() - timeOfLastScan > 2000)) { // Scan for networks with two second intervals when not already connected.
131
-
String request = String(F("Hello world request #")) + String(requestNumber) + String(F(" from ")) + meshNode.getMeshName() + meshNode.getNodeID() + String(F("."));
132
-
meshNode.attemptTransmission(request, false);
133
-
timeOfLastScan = millis();
134
-
135
-
// One way to check how attemptTransmission worked out
136
-
if (ESP8266WiFiMesh::latestTransmissionSuccessful()) {
137
-
Serial.println(F("Transmission successful."));
145
+
staticuint32_t benchmarkCount = 0;
146
+
staticuint32_t loopStart = millis();
147
+
148
+
// The floodingMeshDelay() method performs all the background operations for the FloodingMesh (via FloodingMesh::performMeshMaintainance()).
149
+
// It is recommended to place one of these methods in the beginning of the loop(), unless there is a need to put them elsewhere.
150
+
// Among other things, the method cleans up old ESP-NOW log entries (freeing up RAM) and forwards received mesh messages.
151
+
// Note that depending on the amount of messages to forward and their length, this method can take tens or even hundreds of milliseconds to complete.
152
+
// More intense transmission activity and less frequent calls to performMeshMaintainance will likely cause the method to take longer to complete, so plan accordingly.
153
+
floodingMeshDelay(1);
154
+
155
+
if (theOne) {
156
+
if (millis() - timeOfLastProclamation > 10000) {
157
+
uint32_t startTime = millis();
158
+
floodingMesh.broadcast(String(floodingMesh.broadcastMetadataDelimiter()) + theOneMac + " is The One.");
0 commit comments