forked from airgradienthq/arduino
Add esp32 timestamp to dashboard page
Hotfix timestamp off by 17 minutes when set system time
This commit is contained in:
@@ -120,14 +120,13 @@ void LocalServer::_POST_time(void) {
|
|||||||
void LocalServer::setFwMode(AgFirmwareMode fwMode) { this->fwMode = fwMode; }
|
void LocalServer::setFwMode(AgFirmwareMode fwMode) { this->fwMode = fwMode; }
|
||||||
|
|
||||||
String LocalServer::htmlDashboard(String timestamp) {
|
String LocalServer::htmlDashboard(String timestamp) {
|
||||||
// TODO: Set timestamp
|
|
||||||
String page = "";
|
String page = "";
|
||||||
page += "<!DOCTYPE html>";
|
page += "<!DOCTYPE html>";
|
||||||
page += "<html lang=\"en\">";
|
page += "<html lang=\"en\">";
|
||||||
page += "<head>";
|
page += "<head>";
|
||||||
page += " <meta charset=\"UTF-8\">";
|
page += " <meta charset=\"UTF-8\">";
|
||||||
page += " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">";
|
page += " <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">";
|
||||||
page += " <title>Button Layout with Datetime Picker</title>";
|
page += " <title>AirGradient Local Storage Mode</title>";
|
||||||
page += " <style>";
|
page += " <style>";
|
||||||
page += " body {";
|
page += " body {";
|
||||||
page += " font-family: Arial, sans-serif;";
|
page += " font-family: Arial, sans-serif;";
|
||||||
@@ -168,6 +167,9 @@ String LocalServer::htmlDashboard(String timestamp) {
|
|||||||
page += " </style>";
|
page += " </style>";
|
||||||
page += "</head>";
|
page += "</head>";
|
||||||
page += "<body>";
|
page += "<body>";
|
||||||
|
page += " <h1>";
|
||||||
|
page += timestamp;
|
||||||
|
page += " </h1>";
|
||||||
page += " <form action=\"/storage/download\" method=\"GET\">";
|
page += " <form action=\"/storage/download\" method=\"GET\">";
|
||||||
page += " <button type=\"submit\">Download Measurements</button>";
|
page += " <button type=\"submit\">Download Measurements</button>";
|
||||||
page += " </form>";
|
page += " </form>";
|
||||||
|
@@ -89,8 +89,9 @@ String AirGradient::deviceId(void) {
|
|||||||
void AirGradient::setCurrentTime(long epochTime) {
|
void AirGradient::setCurrentTime(long epochTime) {
|
||||||
// set current day/time
|
// set current day/time
|
||||||
struct timeval tv;
|
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);
|
settimeofday(&tv, NULL);
|
||||||
|
Serial.println(epochTime);
|
||||||
Serial.printf("Set current time to %s\n", getCurrentTime().c_str());
|
Serial.printf("Set current time to %s\n", getCurrentTime().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user