From d35a5c67080f8f07bed88b68bd7763e41a61f565 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Sat, 26 Feb 2022 20:04:09 +0100 Subject: [PATCH] fix timestamp in SD logging --- src/sdcard.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/sdcard.cpp b/src/sdcard.cpp index 51b4d9a0..a6d66a7d 100644 --- a/src/sdcard.cpp +++ b/src/sdcard.cpp @@ -244,17 +244,19 @@ void sdcardWriteData(uint16_t noWifi, uint16_t noBle, if (!useSDCard) return; - char tempBuffer[20 + 1]; + char timeBuffer[20 + 1]; time_t t = time(NULL); struct tm tt; gmtime_r(&t, &tt); // make UTC timestamp + strftime(timeBuffer, sizeof(timeBuffer), "%FT%TZ", &tt); #if (HAS_SDS011) sdsStatus_t sds; #endif ESP_LOGI(TAG, "writing data to SD-card"); - fprintf(data_file, "%FT%TZ", &tt); + + fprintf(data_file, "%s", timeBuffer); fprintf(data_file, ",%d,%d", noWifi, noBle); #if (defined BAT_MEASURE_ADC || defined HAS_PMU) fprintf(data_file, ",%d", voltage);