release logbuffer every 10 seconds if not empty

This commit is contained in:
theFeiter 2022-07-11 12:50:52 +02:00
parent 48d2a6f012
commit 92c17d3567
3 changed files with 29 additions and 21 deletions

View File

@ -85,53 +85,59 @@ void setup() {
void loop() {
#ifdef ESPNOWG_DELAY
if (millis() > timeESPNOWG) {
timeESPNOWG += ESPNOWG_DELAY;
if ((millis() - timeESPNOWG) >= ESPNOWG_DELAY) {
timeESPNOWG = millis();
if (lenESPNOWG > 0) releaseESPNOW(0);
}
#endif
#ifdef ESPNOW1_DELAY
if (millis() > timeESPNOW1) {
timeESPNOW1 += ESPNOW1_DELAY;
if ((millis() - timeESPNOW1) >= ESPNOW1_DELAY) {
timeESPNOW1 = millis();
if (lenESPNOW1 > 0) releaseESPNOW(1);
}
#endif
#ifdef ESPNOW2_DELAY
if (millis() > timeESPNOW2) {
timeESPNOW2 += ESPNOW2_DELAY;
if ((millis() - timeESPNOW2) >= ESPNOW2_DELAY) {
timeESPNOW2 = millis();
if (lenESPNOW2 > 0) releaseESPNOW(2);
}
#endif
#ifdef SERIAL_DELAY
if (millis() > timeSERIAL) {
timeSERIAL += SERIAL_DELAY;
if ((millis() - timeSERIAL) >= SERIAL_DELAY) {
timeSERIAL = millis();
if (lenSERIAL > 0) releaseSerial();
}
#endif
#ifdef MQTT_DELAY
if (millis() > timeMQTT) {
timeMQTT += MQTT_DELAY;
if ((millis() - timeMQTT) >= MQTT_DELAY) {
timeMQTT = millis();
if (lenMQTT > 0) releaseMQTT();
}
#endif
#ifdef LORAG_DELAY
if (millis() > timeLORAG) {
timeLORAG += LORAG_DELAY;
if ((millis() - timeLORAG) >= LORAG_DELAY) {
timeLORAG = millis();
if (lenLORAG > 0) releaseLoRa(0);
}
#endif
#ifdef LORA1_DELAY
if (millis() > timeLORA1) {
timeLORA1 += LORA1_DELAY;
if ((millis() - timeLORA1) >= LORA1_DELAY) {
timeLORA1 = millis();
if (lenLORA1 > 0) releaseLoRa(1);
}
#endif
#ifdef LORA2_DELAY
if (millis() > timeLORA2) {
timeLORA2 += 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){
timeLOGBUF = millis();
if (logBufferPos > 0) releaseLogBuffer();
}
#endif
while (UART_IF.available()) {
getSerial();

View File

@ -86,9 +86,10 @@
#define TOPIC_COMMAND "fdrs/command"
// SD card logging config -- Needed only for SD-card logging
#define SD_SS 0 //SD card Chipselect pin (Use a different pins for LoRa and SD)
#define SD_FILENAME "fdrs_log.csv" // length max. 32
// Logging settings
#define LOGBUF_DELAY 10000 // Log Buffer Delay - in milliseconds -- Needed only for SD-card OR internal flash logging
// Internal flash logging config -- Needed only for internal flash logging
#define FS_FILENAME "fdrs_log.csv" // length max. 32
#define SD_SS 0 //SD card Chipselect pin (Use a different pins for LoRa and SD) -- Needed only for SD-card logging
#define SD_FILENAME "fdrs_log.csv" // length max. 32 -- Needed only for SD-card logging
#define FS_FILENAME "fdrs_log.csv" // length max. 32 -- Needed only for internal flash logging

View File

@ -93,6 +93,7 @@ unsigned long last_millis = 0;
unsigned long seconds_since_reset = 0;
char logBuffer[512];
uint16_t logBufferPos = 0; // datatype depends on size of sdBuffer
uint32_t timeLOGBUF = 0;
#endif
DataReading theData[256];