diff --git a/tools/esp8266/app.cpp b/tools/esp8266/app.cpp index c5989562..f97a6b9d 100644 --- a/tools/esp8266/app.cpp +++ b/tools/esp8266/app.cpp @@ -64,6 +64,13 @@ void app::loop(void) { } } + if(checkTicker(&mNtpRefreshTicker, mNtpRefreshInterval)) { + if(!apActive) { + mTimestamp = mWifi->getNtpTime(); + DPRINTLN(DBG_INFO, "[NTP]: " + getDateTimeStr(mTimestamp)); + } + } + mSys->Radio.loop(); @@ -655,7 +662,10 @@ const char* app::getFieldStateClass(uint8_t fieldId) { void app::resetSystem(void) { mUptimeSecs = 0; mUptimeTicker = 0xffffffff; - mUptimeInterval = 1000; + mUptimeInterval = 1000; // [ms] + + mNtpRefreshTicker = 0xffffffff; + mNtpRefreshInterval = NTP_REFRESH_INTERVAL; // [ms] #ifdef AP_ONLY mTimestamp = 1; diff --git a/tools/esp8266/app.h b/tools/esp8266/app.h index 0ccefe7f..48dbc1ed 100644 --- a/tools/esp8266/app.h +++ b/tools/esp8266/app.h @@ -225,6 +225,8 @@ class app { uint16_t mUptimeInterval; uint32_t mUptimeSecs; uint8_t mHeapStatCnt; + uint32_t mNtpRefreshTicker; + uint32_t mNtpRefreshInterval; bool mWifiSettingsValid; diff --git a/tools/esp8266/config.h b/tools/esp8266/config.h index e27a2e09..ab633f9a 100644 --- a/tools/esp8266/config.h +++ b/tools/esp8266/config.h @@ -72,12 +72,15 @@ // threshold of minimum power on which the inverter is marked as inactive #define INACT_PWR_THRESH 3 -// default ntp server uri +// default NTP server uri #define DEF_NTP_SERVER_NAME "pool.ntp.org" -// default ntp server port +// default NTP server port #define DEF_NTP_PORT 8888 +// NTP refresh interval in ms (default 12h) +#define NTP_REFRESH_INTERVAL 12 * 3600 * 1000 + // default mqtt interval #define MQTT_INTERVAL 60 diff --git a/tools/esp8266/html/h/index_html.h b/tools/esp8266/html/h/index_html.h deleted file mode 100644 index c6f769ce..00000000 --- a/tools/esp8266/html/h/index_html.h +++ /dev/null @@ -1,4 +0,0 @@ -#ifndef __INDEX_HTML_H__ -#define __INDEX_HTML_H__ -const char index_html[] PROGMEM = "
Uptime:
Statistics:
Every {TS}seconds the values are updated
Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/
Check the licenses which are published on https://github.com/grindylow/ahoyas well
Every {TS}seconds the values are updated