|
|
|
@ -23,18 +23,6 @@ uint8_t incMAC[6];
|
|
|
|
|
uint8_t ESPNOW1[] = {MAC_PREFIX, ESPNOW_NEIGHBOR_1};
|
|
|
|
|
uint8_t ESPNOW2[] = {MAC_PREFIX, ESPNOW_NEIGHBOR_2};
|
|
|
|
|
|
|
|
|
|
#ifdef USE_ESPNOW
|
|
|
|
|
DataReading ESPNOW1buffer[256];
|
|
|
|
|
uint8_t lenESPNOW1 = 0;
|
|
|
|
|
uint32_t timeESPNOW1 = 0;
|
|
|
|
|
DataReading ESPNOW2buffer[256];
|
|
|
|
|
uint8_t lenESPNOW2 = 0;
|
|
|
|
|
uint32_t timeESPNOW2 = 0;
|
|
|
|
|
DataReading ESPNOWGbuffer[256];
|
|
|
|
|
uint8_t lenESPNOWG = 0;
|
|
|
|
|
uint32_t timeESPNOWG = 0;
|
|
|
|
|
#endif // USE_ESPNOW
|
|
|
|
|
|
|
|
|
|
#ifdef USE_ESPNOW
|
|
|
|
|
// Set ESP-NOW send and receive callbacks for either ESP8266 or ESP32
|
|
|
|
|
#if defined(ESP8266)
|
|
|
|
@ -304,101 +292,3 @@ void sendESPNow(uint8_t address)
|
|
|
|
|
#endif // USE_ESPNOW
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bufferESPNOW(uint8_t interface)
|
|
|
|
|
{
|
|
|
|
|
#ifdef USE_ESPNOW
|
|
|
|
|
DBG("Buffering ESP-NOW.");
|
|
|
|
|
|
|
|
|
|
switch (interface)
|
|
|
|
|
{
|
|
|
|
|
case 0:
|
|
|
|
|
for (int i = 0; i < ln; i++)
|
|
|
|
|
{
|
|
|
|
|
ESPNOWGbuffer[lenESPNOWG + i] = theData[i];
|
|
|
|
|
}
|
|
|
|
|
lenESPNOWG += ln;
|
|
|
|
|
break;
|
|
|
|
|
case 1:
|
|
|
|
|
for (int i = 0; i < ln; i++)
|
|
|
|
|
{
|
|
|
|
|
ESPNOW1buffer[lenESPNOW1 + i] = theData[i];
|
|
|
|
|
}
|
|
|
|
|
lenESPNOW1 += ln;
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
for (int i = 0; i < ln; i++)
|
|
|
|
|
{
|
|
|
|
|
ESPNOW2buffer[lenESPNOW2 + i] = theData[i];
|
|
|
|
|
}
|
|
|
|
|
lenESPNOW2 += ln;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // USE_ESPNOW
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void releaseESPNOW(uint8_t interface)
|
|
|
|
|
{
|
|
|
|
|
#ifdef USE_ESPNOW
|
|
|
|
|
DBG("Releasing ESP-NOW.");
|
|
|
|
|
switch (interface)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
|
{
|
|
|
|
|
DataReading thePacket[espnow_size];
|
|
|
|
|
int j = 0;
|
|
|
|
|
for (int i = 0; i < lenESPNOWG; i++)
|
|
|
|
|
{
|
|
|
|
|
if (j > espnow_size)
|
|
|
|
|
{
|
|
|
|
|
j = 0;
|
|
|
|
|
esp_now_send(broadcast_mac, (uint8_t *)&thePacket, sizeof(thePacket));
|
|
|
|
|
}
|
|
|
|
|
thePacket[j] = ESPNOWGbuffer[i];
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
esp_now_send(broadcast_mac, (uint8_t *)&thePacket, j * sizeof(DataReading));
|
|
|
|
|
lenESPNOWG = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 1:
|
|
|
|
|
{
|
|
|
|
|
DataReading thePacket[espnow_size];
|
|
|
|
|
int j = 0;
|
|
|
|
|
for (int i = 0; i < lenESPNOW1; i++)
|
|
|
|
|
{
|
|
|
|
|
if (j > espnow_size)
|
|
|
|
|
{
|
|
|
|
|
j = 0;
|
|
|
|
|
esp_now_send(ESPNOW1, (uint8_t *)&thePacket, sizeof(thePacket));
|
|
|
|
|
}
|
|
|
|
|
thePacket[j] = ESPNOW1buffer[i];
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
esp_now_send(ESPNOW1, (uint8_t *)&thePacket, j * sizeof(DataReading));
|
|
|
|
|
lenESPNOW1 = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2:
|
|
|
|
|
{
|
|
|
|
|
DataReading thePacket[espnow_size];
|
|
|
|
|
int j = 0;
|
|
|
|
|
for (int i = 0; i < lenESPNOW2; i++)
|
|
|
|
|
{
|
|
|
|
|
if (j > espnow_size)
|
|
|
|
|
{
|
|
|
|
|
j = 0;
|
|
|
|
|
esp_now_send(ESPNOW2, (uint8_t *)&thePacket, sizeof(thePacket));
|
|
|
|
|
}
|
|
|
|
|
thePacket[j] = ESPNOW2buffer[i];
|
|
|
|
|
j++;
|
|
|
|
|
}
|
|
|
|
|
esp_now_send(ESPNOW2, (uint8_t *)&thePacket, j * sizeof(DataReading));
|
|
|
|
|
lenESPNOW2 = 0;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // USE_ESPNOW
|
|
|
|
|
}
|
|
|
|
|