From d8317daf83333c59252029cda7d112b737f5f320 Mon Sep 17 00:00:00 2001 From: theFeiter Date: Fri, 8 Jul 2022 11:33:46 +0200 Subject: [PATCH] this just fixed the write speed issue --- FDRS_Gateway/fdrs_functions.h | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/FDRS_Gateway/fdrs_functions.h b/FDRS_Gateway/fdrs_functions.h index 512d078..17e5047 100644 --- a/FDRS_Gateway/fdrs_functions.h +++ b/FDRS_Gateway/fdrs_functions.h @@ -180,17 +180,13 @@ void sendSD(const char filename[32]) { DBG("Logging to SD card."); File logfile = SD.open(filename, FILE_WRITE); for (int i = 0; i < ln; i++) { + char linebuf[32]; #ifdef USE_WIFI - logfile.print(timeClient.getEpochTime()); + sprintf(linebuf, "%ld,%d,%d,%g",timeClient.getEpochTime(),theData[i].id,theData[i].t,theData[i].d); #else - logfile.print(seconds_since_reset); + sprintf(linebuf, "%ld,%d,%d,%g",seconds_since_reset,theData[i].id,theData[i].t,theData[i].d); #endif - logfile.print(","); - logfile.print(theData[i].id); - logfile.print(","); - logfile.print(theData[i].t); - logfile.print(","); - logfile.println(theData[i].d); + logfile.println(linebuf); } logfile.close(); #endif @@ -200,17 +196,13 @@ void sendFS(const char filename[32]) { DBG("Logging to internal flash."); File logfile = LittleFS.open(filename, "a"); for (int i = 0; i < ln; i++) { + char linebuf[32]; #ifdef USE_WIFI - logfile.print(timeClient.getEpochTime()); + sprintf(linebuf, "%ld,%d,%d,%g",timeClient.getEpochTime(),theData[i].id,theData[i].t,theData[i].d); #else - logfile.print(seconds_since_reset); + sprintf(linebuf, "%ld,%d,%d,%g",seconds_since_reset,theData[i].id,theData[i].t,theData[i].d); #endif - logfile.print(","); - logfile.print(theData[i].id); - logfile.print(","); - logfile.print(theData[i].t); - logfile.print(","); - logfile.println(theData[i].d); + logfile.println(linebuf); } logfile.close(); #endif