|
|
|
@ -119,7 +119,7 @@ int find_espnow_peer()
|
|
|
|
|
{
|
|
|
|
|
if (peer_list[i].last_seen == 0)
|
|
|
|
|
{
|
|
|
|
|
// DBG("Using peer entry " + String(i));
|
|
|
|
|
DBG1("Using peer entry " + String(i));
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -127,7 +127,7 @@ int find_espnow_peer()
|
|
|
|
|
{
|
|
|
|
|
if ((millis() - peer_list[i].last_seen) >= PEER_TIMEOUT)
|
|
|
|
|
{
|
|
|
|
|
// DBG("Recycling peer entry " + String(i));
|
|
|
|
|
DBG1("Recycling peer entry " + String(i));
|
|
|
|
|
esp_now_del_peer(peer_list[i].mac);
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
@ -140,18 +140,18 @@ int find_espnow_peer()
|
|
|
|
|
// Returns the index of the peer list array element that contains the provided MAC address, -1 if not found
|
|
|
|
|
int getFDRSPeer(uint8_t *mac)
|
|
|
|
|
{
|
|
|
|
|
// DBG("Getting peer #");
|
|
|
|
|
DBG1("Getting peer #");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
|
{
|
|
|
|
|
if (memcmp(mac, &peer_list[i].mac, 6) == 0)
|
|
|
|
|
{
|
|
|
|
|
DBG("Peer is entry #" + String(i));
|
|
|
|
|
DBG1("Peer is entry #" + String(i));
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DBG("Couldn't find peer");
|
|
|
|
|
DBG1("Couldn't find peer");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -162,7 +162,7 @@ void add_espnow_peer()
|
|
|
|
|
if (peer_num == -1) // if the device isn't registered
|
|
|
|
|
{
|
|
|
|
|
int open_peer = find_espnow_peer(); // find open spot in peer_list
|
|
|
|
|
DBG("New device will be registered as " + String(open_peer));
|
|
|
|
|
DBG1("New device will be registered as " + String(open_peer));
|
|
|
|
|
memcpy(&peer_list[open_peer].mac, &incMAC, 6); // save MAC to open spot
|
|
|
|
|
peer_list[open_peer].last_seen = millis();
|
|
|
|
|
#if defined(ESP32)
|
|
|
|
@ -186,7 +186,7 @@ void add_espnow_peer()
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBG("Refreshing existing peer registration");
|
|
|
|
|
DBG1("Refreshing existing peer registration");
|
|
|
|
|
peer_list[peer_num].last_seen = millis();
|
|
|
|
|
|
|
|
|
|
SystemPacket sys_packet = {.cmd = cmd_add, .param = PEER_TIMEOUT};
|
|
|
|
|