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
result = esp_now_send(remoteMac, (uint8_t *)&espnowData, strlen(espnowData)); // Send packet to a specific peer
79
-
80
-
if (result == ESP_OK)
81
-
Serial.println("Sent with success"); // We will always get a success with broadcastMac packets, presumably because they do not have delivery confirmation.
82
-
else
83
-
Serial.println("Error sending the data");
84
-
}
85
-
86
72
if (Serial.available())
87
73
{
88
74
byte incoming = Serial.read();
@@ -91,6 +77,31 @@ void loop()
91
77
Serial.println("Reset");
92
78
ESP.restart();
93
79
}
80
+
elseif (incoming == 'a')
81
+
{
82
+
Serial.println("Adding peer to list");
83
+
espnowAddPeer(remoteMac); // Register a remote address to deliver data to
84
+
}
85
+
elseif (incoming == 'b')
86
+
{
87
+
Serial.println("Adding broadcast to list");
88
+
espnowAddPeer(broadcastMac); // Register a remote address to deliver data to
89
+
}
90
+
elseif (incoming == 'c')
91
+
{
92
+
Serial.println("Clearing broadcast list");
93
+
espnowClearPeerList();
94
+
}
95
+
elseif (incoming == '1')
96
+
{
97
+
Serial.println("Send to peer list");
98
+
espnowSendMessage(0); // Send packet to all peers on the list, excluding broadcast peer.
99
+
}
100
+
elseif (incoming == '2')
101
+
{
102
+
Serial.println("Send via broadcast");
103
+
espnowSendMessage(broadcastMac);// Send packet over broadcast
sprintf(espnowData, "This is test #: %d", packetCounter++);
130
+
131
+
esp_err_t result = esp_now_send(sendToMac, (uint8_t *)&espnowData, sizeof(espnowData)); // Send packet to a specific peer
132
+
133
+
if (result == ESP_OK)
134
+
Serial.println("Sent with success"); // We will always get a success with broadcastMac packets, presumably because they do not have delivery confirmation.
135
+
else
136
+
Serial.println("Error sending the data");
137
+
}
138
+
139
+
voidespnowClearPeerList()
140
+
{
141
+
// if (esp_now_is_peer_exist(broadcastMac))
142
+
// {
143
+
// status = espNowRemovePeer(broadcastMac);
144
+
// if (status != ESP_OK)
145
+
// Serial.printf("ERROR: Failed to delete broadcast peer, status: %d\r\n", status);
0 commit comments