From 8d448533c737803f2fc623d782b192ff36cd2d0e Mon Sep 17 00:00:00 2001 From: Gunnar Skjold Date: Mon, 19 Dec 2022 18:36:04 +0100 Subject: [PATCH] Fixed config export for esp32 --- src/AmsDataStorage.cpp | 26 +++++++++++++------------- src/AmsToMqttBridge.ino | 2 +- src/EnergyAccounting.cpp | 4 ++-- src/entsoe/EntsoeApi.cpp | 2 +- src/web/AmsWebServer.cpp | 8 ++++---- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/AmsDataStorage.cpp b/src/AmsDataStorage.cpp index 091eef04..5031f2e1 100644 --- a/src/AmsDataStorage.cpp +++ b/src/AmsDataStorage.cpp @@ -21,7 +21,7 @@ bool AmsDataStorage::update(AmsData* data) { } time_t now = time(nullptr); - if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Time is: %lld\n", (int64_t) now); + if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Time is: %lu\n", (int32_t) now); if(tz == NULL) { if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Timezone is missing\n"); return false; @@ -30,18 +30,18 @@ bool AmsDataStorage::update(AmsData* data) { if(data->getMeterTimestamp() > BUILD_EPOCH) { now = data->getMeterTimestamp(); if(debugger->isActive(RemoteDebug::DEBUG)) { - debugger->printf("(AmsDataStorage) Using meter timestamp, which is: %lld\n", (int64_t) now); + debugger->printf("(AmsDataStorage) Using meter timestamp, which is: %lu\n", (int32_t) now); } } else if(data->getPackageTimestamp() > BUILD_EPOCH) { now = data->getPackageTimestamp(); if(debugger->isActive(RemoteDebug::DEBUG)) { - debugger->printf("(AmsDataStorage) Using package timestamp, which is: %lld\n", (int64_t) now); + debugger->printf("(AmsDataStorage) Using package timestamp, which is: %lu\n", (int32_t) now); } } } if(now < BUILD_EPOCH) { if(debugger->isActive(RemoteDebug::VERBOSE)) { - debugger->printf("(AmsDataStorage) Invalid time: %lld\n", (int64_t) now); + debugger->printf("(AmsDataStorage) Invalid time: %lu\n", (int32_t) now); } return false; } @@ -63,7 +63,7 @@ bool AmsDataStorage::update(AmsData* data) { return true; } else { if(debugger->isActive(RemoteDebug::DEBUG)) { - debugger->printf("(AmsDataStorage) Last day update: %lld\n", (int64_t) day.lastMeterReadTime); + debugger->printf("(AmsDataStorage) Last day update: %lu\n", (int32_t) day.lastMeterReadTime); } tmElements_t last; breakTime(day.lastMeterReadTime, last); @@ -86,7 +86,7 @@ bool AmsDataStorage::update(AmsData* data) { month.lastMeterReadTime = now; } else { if(debugger->isActive(RemoteDebug::DEBUG)) { - debugger->printf("(AmsDataStorage) Last month update: %lld\n", (int64_t) month.lastMeterReadTime); + debugger->printf("(AmsDataStorage) Last month update: %lu\n", (int32_t) month.lastMeterReadTime); } tmElements_t last; breakTime(tz->toLocal(month.lastMeterReadTime), last); @@ -156,7 +156,7 @@ bool AmsDataStorage::update(AmsData* data) { setHourExport(last.Hour, exp); if(debugger->isActive(RemoteDebug::INFO)) { - debugger->printf("(AmsDataStorage) Estimated usage for hour %u: %.1f - %.1f (%lld)\n", last.Hour, imp, exp, (int64_t) cur); + debugger->printf("(AmsDataStorage) Estimated usage for hour %u: %.1f - %.1f (%lu)\n", last.Hour, imp, exp, (int32_t) cur); } day.activeImport += imp; @@ -199,7 +199,7 @@ bool AmsDataStorage::update(AmsData* data) { breakTime(tz->toLocal(month.lastMeterReadTime), last); month.lastMeterReadTime = month.lastMeterReadTime - (last.Hour * 3600) - (last.Minute * 60) - last.Second; if(debugger->isActive(RemoteDebug::DEBUG)) { - debugger->printf("(AmsDataStorage) Last month read after resetting to midnight: %lld\n", (int64_t) month.lastMeterReadTime); + debugger->printf("(AmsDataStorage) Last month read after resetting to midnight: %lu\n", (int32_t) month.lastMeterReadTime); } float hrs = (now - month.lastMeterReadTime) / 3600.0; @@ -224,7 +224,7 @@ bool AmsDataStorage::update(AmsData* data) { setDayExport(last.Day, exp); if(debugger->isActive(RemoteDebug::INFO)) { - debugger->printf("(AmsDataStorage) Estimated usage for day %u: %.1f - %.1f (%lld)\n", last.Day, imp, exp, (int64_t) cur); + debugger->printf("(AmsDataStorage) Estimated usage for day %u: %.1f - %.1f (%lu)\n", last.Day, imp, exp, (int32_t) cur); } month.activeImport += imp; @@ -383,11 +383,11 @@ bool AmsDataStorage::isDayHappy() { tmElements_t tm, last; if(now < day.lastMeterReadTime) { - if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Day %lld < %lld\n", (int64_t) now, (int64_t) day.lastMeterReadTime); + if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Day %lu < %lu\n", (int32_t) now, (int32_t) day.lastMeterReadTime); return false; } if(now-day.lastMeterReadTime > 3600) { - if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Day %lld - %lld > 3600\n", (int64_t) now, (int64_t) day.lastMeterReadTime); + if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Day %lu - %lu > 3600\n", (int32_t) now, (int32_t) day.lastMeterReadTime); return false; } breakTime(tz->toLocal(now), tm); @@ -411,11 +411,11 @@ bool AmsDataStorage::isMonthHappy() { tmElements_t tm, last; if(now < month.lastMeterReadTime) { - if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Month %lld < %lld\n", (int64_t) now, (int64_t) month.lastMeterReadTime); + if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Month %lu < %lu\n", (int32_t) now, (int32_t) month.lastMeterReadTime); return false; } if(now-month.lastMeterReadTime > 86400) { - if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Month %lld - %lld > 3600\n", (int64_t) now, (int64_t) month.lastMeterReadTime); + if(debugger->isActive(RemoteDebug::VERBOSE)) debugger->printf("(AmsDataStorage) Month %lu - %lu > 3600\n", (int32_t) now, (int32_t) month.lastMeterReadTime); return false; } breakTime(tz->toLocal(now), tm); diff --git a/src/AmsToMqttBridge.ino b/src/AmsToMqttBridge.ino index 75cf5ffe..c900330e 100644 --- a/src/AmsToMqttBridge.ino +++ b/src/AmsToMqttBridge.ino @@ -1391,7 +1391,7 @@ void MQTT_connect() { #if defined(ESP8266) if(mqttSecureClient) { time_t epoch = time(nullptr); - debugD("Setting NTP time %lld for secure MQTT connection", epoch); + debugD("Setting NTP time %lu for secure MQTT connection", epoch); mqttSecureClient->setX509Time(epoch); } #endif diff --git a/src/EnergyAccounting.cpp b/src/EnergyAccounting.cpp index 4b311e8b..6ba7cd44 100644 --- a/src/EnergyAccounting.cpp +++ b/src/EnergyAccounting.cpp @@ -42,7 +42,7 @@ bool EnergyAccounting::update(AmsData* amsData) { if(!init) { currentHour = local.Hour; currentDay = local.Day; - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing data at %lld\n", (int64_t) now); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing data at %lu\n", (int32_t) now); if(!load()) { if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EnergyAccounting) Unable to load existing data\n"); data = { 4, local.Month, @@ -63,7 +63,7 @@ bool EnergyAccounting::update(AmsData* amsData) { } if(!initPrice && eapi != NULL && eapi->getValueForHour(0) != ENTSOE_NO_VALUE) { - if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing prices at %lld\n", (int64_t) now); + if(debugger->isActive(RemoteDebug::DEBUG)) debugger->printf("(EnergyAccounting) Initializing prices at %lu\n", (int32_t) now); calcDayCost(); } diff --git a/src/entsoe/EntsoeApi.cpp b/src/entsoe/EntsoeApi.cpp index 922220a2..bc8bf07b 100644 --- a/src/entsoe/EntsoeApi.cpp +++ b/src/entsoe/EntsoeApi.cpp @@ -110,7 +110,7 @@ bool EntsoeApi::loop() { currentDay = tm.Day; return false; } else if(now > midnightMillis && currentDay != tm.Day) { - if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Rotating price objects at %lld\n", t); + if(debugger->isActive(RemoteDebug::INFO)) debugger->printf("(EntsoeApi) Rotating price objects at %lu\n", t); if(today != NULL) delete today; if(tomorrow != NULL) { today = tomorrow; diff --git a/src/web/AmsWebServer.cpp b/src/web/AmsWebServer.cpp index 6c9b2630..00899897 100644 --- a/src/web/AmsWebServer.cpp +++ b/src/web/AmsWebServer.cpp @@ -2306,9 +2306,9 @@ void AmsWebServer::configFileDownload() { if(ds != NULL) { DayDataPoints day = ds->getDayData(); - server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("dayplot %d %lld %lu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"), + server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("dayplot %d %lu %lu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"), day.version, - (int64_t) day.lastMeterReadTime, + (int32_t) day.lastMeterReadTime, day.activeImport, ds->getHourImport(0), ds->getHourImport(1), @@ -2368,9 +2368,9 @@ void AmsWebServer::configFileDownload() { } MonthDataPoints month = ds->getMonthData(); - server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("monthplot %d %lld %lu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"), + server.sendContent(buf, snprintf_P(buf, BufferSize, PSTR("monthplot %d %lu %lu %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d"), month.version, - (int64_t) month.lastMeterReadTime, + (int32_t) month.lastMeterReadTime, month.activeImport, ds->getDayImport(1), ds->getDayImport(2),