From 67b71f583b6d41d798afedfc579d6c1b09ba20da Mon Sep 17 00:00:00 2001 From: samuelbles07 Date: Sat, 7 Dec 2024 05:13:19 +0700 Subject: [PATCH] Add esp32 timestamp to dashboard page Hotfix timestamp off by 17 minutes when set system time --- examples/OneOpenAir/LocalServer.cpp | 6 ++++-- src/AirGradient.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/OneOpenAir/LocalServer.cpp b/examples/OneOpenAir/LocalServer.cpp index 5bdda7c..0a1f6bf 100644 --- a/examples/OneOpenAir/LocalServer.cpp +++ b/examples/OneOpenAir/LocalServer.cpp @@ -120,14 +120,13 @@ void LocalServer::_POST_time(void) { void LocalServer::setFwMode(AgFirmwareMode fwMode) { this->fwMode = fwMode; } String LocalServer::htmlDashboard(String timestamp) { - // TODO: Set timestamp String page = ""; page += ""; page += ""; page += ""; page += " "; page += " "; - page += " Button Layout with Datetime Picker"; + page += " AirGradient Local Storage Mode"; page += " "; page += ""; page += ""; + page += "

"; + page += timestamp; + page += "

"; page += "
"; page += " "; page += "
"; diff --git a/src/AirGradient.cpp b/src/AirGradient.cpp index 014051f..df481d6 100644 --- a/src/AirGradient.cpp +++ b/src/AirGradient.cpp @@ -89,8 +89,9 @@ String AirGradient::deviceId(void) { void AirGradient::setCurrentTime(long epochTime) { // set current day/time struct timeval tv; - tv.tv_sec = epochTime; + tv.tv_sec = epochTime - 1020; // 17 minutes // don't know why it always off by 17 minutes settimeofday(&tv, NULL); + Serial.println(epochTime); Serial.printf("Set current time to %s\n", getCurrentTime().c_str()); }