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
Serial.print("Message received from STA " + meshInstance.getEspnowMeshBackend().getSenderMac() + ": ");
54
-
Serial.println(message.substring(1, 101));
53
+
Serial.print("Message received from STA MAC " + meshInstance.getEspnowMeshBackend().getSenderMac() + ": ");
54
+
Serial.println(message.substring(2, 102));
55
55
56
-
String potentialMac = message.substring(1, 13);
57
-
58
-
if (potentialMac > theOneMac) {
59
-
if (theOne) {
60
-
if (useLED) {
61
-
digitalWrite(LED_BUILTIN, HIGH); // Turn LED off (LED is active low)
62
-
}
56
+
String potentialMac = message.substring(2, 14);
63
57
58
+
if (potentialMac >= theOneMac) {
59
+
if (potentialMac > theOneMac) {
64
60
theOne = false;
61
+
theOneMac = potentialMac;
65
62
}
66
63
67
-
theOneMac = potentialMac;
64
+
if (useLED && !theOne) {
65
+
bool ledState = message.charAt(1) == '1';
66
+
digitalWrite(LED_BUILTIN, ledState); // Turn LED on/off (LED is active low)
67
+
}
68
68
69
69
returntrue;
70
70
} else {
@@ -142,6 +142,7 @@ void setup() {
142
142
143
143
int32_t timeOfLastProclamation = -10000;
144
144
voidloop() {
145
+
staticbool ledState = 1;
145
146
staticuint32_t benchmarkCount = 0;
146
147
staticuint32_t loopStart = millis();
147
148
@@ -160,7 +161,10 @@ void loop() {
160
161
if (theOne) {
161
162
if (millis() - timeOfLastProclamation > 10000) {
162
163
uint32_t startTime = millis();
163
-
floodingMesh.broadcast(String(floodingMesh.broadcastMetadataDelimiter()) + theOneMac + " is The One.");
164
+
ledState = ledState ^ bool(benchmarkCount); // Make other nodes' LEDs alternate between on and off once benchmarking begins.
165
+
166
+
// Note: The maximum length of an unencrypted broadcast message is given by floodingMesh.maxUnencryptedMessageSize(). It is around 670 bytes by default.
167
+
floodingMesh.broadcast(String(floodingMesh.broadcastMetadataDelimiter()) + String(ledState) + theOneMac + " is The One.");
0 commit comments