fix timestamp in SD logging

This commit is contained in:
cyberman54 2022-02-26 20:04:09 +01:00
parent 42aa481c70
commit d35a5c6708

View File

@ -244,17 +244,19 @@ void sdcardWriteData(uint16_t noWifi, uint16_t noBle,
if (!useSDCard) if (!useSDCard)
return; return;
char tempBuffer[20 + 1]; char timeBuffer[20 + 1];
time_t t = time(NULL); time_t t = time(NULL);
struct tm tt; struct tm tt;
gmtime_r(&t, &tt); // make UTC timestamp gmtime_r(&t, &tt); // make UTC timestamp
strftime(timeBuffer, sizeof(timeBuffer), "%FT%TZ", &tt);
#if (HAS_SDS011) #if (HAS_SDS011)
sdsStatus_t sds; sdsStatus_t sds;
#endif #endif
ESP_LOGI(TAG, "writing data to SD-card"); 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); fprintf(data_file, ",%d,%d", noWifi, noBle);
#if (defined BAT_MEASURE_ADC || defined HAS_PMU) #if (defined BAT_MEASURE_ADC || defined HAS_PMU)
fprintf(data_file, ",%d", voltage); fprintf(data_file, ",%d", voltage);