From b04d242f209d5f1ac477b7946c8ceb05ad6aaa8c Mon Sep 17 00:00:00 2001 From: Hendrik Langer Date: Fri, 9 Aug 2019 18:13:18 +0200 Subject: [PATCH] ntp time --- src/main.cpp | 11 ++++++++++- src/network/XD0OTA.cpp | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c97cab7..179b777 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -201,6 +201,13 @@ void wifiConnect() { } } +bool obtain_time() { + ESP_LOGI(TAG, "syncing time"); + configTzTime("CET-1CEST,M3.5.0/2,M10.5.0/3", "de.pool.ntp.org"); + struct tm timeinfo; + return getLocalTime(&timeinfo, 5000); +} + void helloWorld() { const char HelloWorld[] = "IchbinsBens!"; @@ -747,6 +754,7 @@ void setup() // wakeup not caused by deep sleep display.clearScreen(); display.refresh(); + lastDisplayRefresh = getTimestamp(); helloWorld(); display.powerOff(); } else { @@ -760,10 +768,11 @@ void setup() wifiConnect(); WiFi.waitForConnectResult(); - //displayIcoPartial(ico_wifi16, display.width()-20, y_offset+0, ico_wifi16_width, ico_wifi16_height); + displayIcoPartial(ico_wifi16, display.width()-20, y_offset+0, ico_wifi16_width, ico_wifi16_height); if (wakeup_reason == ESP_SLEEP_WAKEUP_UNDEFINED || bootCount == 1) { // wakeup not caused by deep sleep + obtain_time(); ESP_LOGD(TAG, "trying to fetch over-the-air update"); if (WiFi.status() == WL_CONNECTED) { ota.update(); diff --git a/src/network/XD0OTA.cpp b/src/network/XD0OTA.cpp index 5793034..ef5ca85 100644 --- a/src/network/XD0OTA.cpp +++ b/src/network/XD0OTA.cpp @@ -57,7 +57,7 @@ String XD0OTA::getUpdateURL(String file, String extension) { } void XD0OTA::update(void) { - setClock(); + //setClock(); // try device specific image first String fwURL = getUpdateURL(getMAC(), ".bin");