remove old buffers

pull/136/head
Timm Bogner 2 years ago
parent d85304b604
commit 3513811a7c

@ -86,70 +86,6 @@ void handleCommands()
void loopFDRS()
{
handleCommands();
#ifdef ESPNOWG_DELAY
if ((millis() - timeESPNOWG) >= ESPNOWG_DELAY)
{
timeESPNOWG = millis();
if (lenESPNOWG > 0)
releaseESPNOW(0);
}
#endif
#ifdef ESPNOW1_DELAY
if ((millis() - timeESPNOW1) >= ESPNOW1_DELAY)
{
timeESPNOW1 = millis();
if (lenESPNOW1 > 0)
releaseESPNOW(1);
}
#endif
#ifdef ESPNOW2_DELAY
if ((millis() - timeESPNOW2) >= ESPNOW2_DELAY)
{
timeESPNOW2 = millis();
if (lenESPNOW2 > 0)
releaseESPNOW(2);
}
#endif
#ifdef SERIAL_DELAY
if ((millis() - timeSERIAL) >= SERIAL_DELAY)
{
timeSERIAL = millis();
if (lenSERIAL > 0)
releaseSerial();
}
#endif
#ifdef MQTT_DELAY
if ((millis() - timeMQTT) >= MQTT_DELAY)
{
timeMQTT = millis();
if (lenMQTT > 0)
releaseMQTT();
}
#endif
#ifdef LORAG_DELAY
if ((millis() - timeLORAG) >= LORAG_DELAY)
{
timeLORAG = millis();
if (lenLORAG > 0)
releaseLoRa(0);
}
#endif
#ifdef LORA1_DELAY
if ((millis() - timeLORA1) >= LORA1_DELAY)
{
timeLORA1 = millis();
if (lenLORA1 > 0)
releaseLoRa(1);
}
#endif
#ifdef LORA2_DELAY
if ((millis() - timeLORA2) >= LORA2_DELAY)
{
timeLORA2 = millis();
if (lenLORA2 > 0)
releaseLoRa(2);
}
#endif
#if defined(USE_SD_LOG) || defined(USE_FS_LOG)
if ((millis() - timeLOGBUF) >= LOGBUF_DELAY)
{

@ -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
}

@ -419,7 +419,7 @@ crcResult getLoRa()
void broadcastLoRa()
{
#ifdef USE_LORA
DBG("Buffering LoRa.");
DBG("Sending to LoRa broadcast buffer");
for (int i = 0; i < ln; i++)
{
@ -434,7 +434,7 @@ void broadcastLoRa()
void sendLoRaNbr(uint8_t interface)
{
#ifdef USE_LORA
DBG("Buffering LoRa.");
DBG("Sending to LoRa neighbor buffer");
switch (interface)
{
case 1:

@ -41,10 +41,6 @@
#define FDRS_MQTT_AUTH
#endif // MQTT_AUTH
DataReading MQTTbuffer[256];
uint8_t lenMQTT = 0;
uint32_t timeMQTT = 0;
WiFiClient espClient;
PubSubClient client(espClient);
@ -180,32 +176,3 @@ void sendMQTT()
mqtt_publish((char *)outgoingString.c_str());
#endif // USE_WIFI
}
void bufferMQTT()
{
#ifdef USE_WIFI
DBG("Buffering MQTT.");
for (int i = 0; i < ln; i++)
{
MQTTbuffer[lenMQTT + i] = theData[i];
}
lenMQTT += ln;
#endif // USE_WIFI
}
void releaseMQTT()
{
#ifdef USE_WIFI
DBG("Releasing MQTT.");
DynamicJsonDocument doc(24576);
for (int i = 0; i < lenMQTT; i++)
{
doc[i]["id"] = MQTTbuffer[i].id;
doc[i]["type"] = MQTTbuffer[i].t;
doc[i]["data"] = MQTTbuffer[i].d;
}
String outgoingString;
serializeJson(doc, outgoingString);
mqtt_publish((char *)outgoingString.c_str());
lenMQTT = 0;
#endif // USE_WIFI
}

@ -7,10 +7,6 @@
#endif
DataReading SERIALbuffer[256];
uint8_t lenSERIAL = 0;
uint32_t timeSERIAL = 0;
void getSerial() {
String incomingString;
if (UART_IF.available()){
@ -57,26 +53,3 @@ void sendSerial() {
#endif
}
void bufferSerial() {
DBG("Buffering Serial.");
for (int i = 0; i < ln; i++) {
SERIALbuffer[lenSERIAL + i] = theData[i];
}
lenSERIAL += ln;
//UART_IF.println("SENDSERIAL:" + String(lenSERIAL) + " ");
}
void releaseSerial() {
DBG("Releasing Serial.");
DynamicJsonDocument doc(24576);
for (int i = 0; i < lenSERIAL; i++) {
doc[i]["id"] = SERIALbuffer[i].id;
doc[i]["type"] = SERIALbuffer[i].t;
doc[i]["data"] = SERIALbuffer[i].d;
}
serializeJson(doc, UART_IF);
UART_IF.println();
lenSERIAL = 0;
}

Loading…
Cancel
Save