From 8170a7b4bca1186c916b99506d3a4b75b09d2c26 Mon Sep 17 00:00:00 2001 From: Robert van den Breemen Date: Tue, 19 Oct 2021 20:52:13 +0200 Subject: [PATCH] using native configTime and some --- OTGW-firmware.h | 2 ++ networkStuff.h | 9 +++++++-- settingStuff.ino | 2 +- version.h | 18 +++++++++--------- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/OTGW-firmware.h b/OTGW-firmware.h index 0a30b87..85f97f1 100644 --- a/OTGW-firmware.h +++ b/OTGW-firmware.h @@ -11,8 +11,10 @@ #include //#include // https://github.com/ropg/ezTime + #include #include + #include // https://github.com/jandrassy/TelnetStream/commit/1294a9ee5cc9b1f7e51005091e351d60c8cddecf #include // https://arduinojson.org/ #include "Wire.h" diff --git a/networkStuff.h b/networkStuff.h index 0b982f6..1cbd9c4 100644 --- a/networkStuff.h +++ b/networkStuff.h @@ -196,6 +196,7 @@ if (!settingNTPenable) return; case TIME_NOTSET: case TIME_NEEDSYNC: NtpLastSync = time(nullptr); //remember last sync + DebugTln("Start time syncing"); startNTP(); NtpStatus = TIME_WAITFORSYNC; break; @@ -203,21 +204,25 @@ if (!settingNTPenable) return; if ((time(nullptr)>0) || (time(nullptr) >= NtpLastSync)) { NtpLastSync = time(nullptr); //remember last sync + DebugTf("Timezone lookup for [%s]\r\n", CSTR(settingNTPtimezone)); auto myTz = manager.createForZoneName(CSTR(settingNTPtimezone)); + if (myTz.isError()){ - DebugTf("Error: Timezone Invalid/Not Found: [%s]", CSTR(settingNTPtimezone)); + DebugTf("Error: Timezone Invalid/Not Found: [%s]\r\n", CSTR(settingNTPtimezone)); settingNTPtimezone = NTP_DEFAULT_TIMEZONE; myTz = manager.createForZoneName(CSTR(settingNTPtimezone)); //try with default Timezone instead - } + } else DebugTln("Timezone lookup: successful"); auto myTime = ZonedDateTime::forUnixSeconds(NtpLastSync, myTz); setTime(myTime.hour(), myTime.minute(), myTime.second(), myTime.day(), myTime.month(), myTime.year()); NtpStatus = TIME_SYNC; + DebugTln("Time synced!"); } break; case TIME_SYNC: if ((time(nullptr)-NtpLastSync) > NTP_RESYNC_TIME){ //when xx seconds have passed, resync using NTP + DebugTln("Time resync needed"); NtpStatus = TIME_NEEDSYNC; } break; diff --git a/settingStuff.ino b/settingStuff.ino index 3b7fd35..3fdd92d 100644 --- a/settingStuff.ino +++ b/settingStuff.ino @@ -207,7 +207,7 @@ void updateSetting(const char *field, const char *newValue) if (stricmp(field, "NTPenable")==0) settingNTPenable = EVALBOOLEAN(newValue); if (stricmp(field, "NTPhostname")==0) { settingNTPhostname = String(newValue); - startNTP(); + startNTP(); } if (stricmp(field, "NTPtimezone")==0) { settingNTPtimezone = String(newValue); diff --git a/version.h b/version.h index c38657b..275ab36 100644 --- a/version.h +++ b/version.h @@ -2,15 +2,15 @@ #define _VERSION_MAJOR 0 #define _VERSION_MINOR 8 #define _VERSION_PATCH 7 -#define _VERSION_BUILD 1120 -#define _VERSION_GITHASH "45b51f2" +#define _VERSION_BUILD 1127 +#define _VERSION_GITHASH "99dd717" #define _VERSION_PRERELEASE beta -#define _VERSION_DATE "16-10-2021" -#define _VERSION_TIME "21:12:55" +#define _VERSION_DATE "19-10-2021" +#define _VERSION_TIME "20:49:31" #define _SEMVER_CORE "0.8.7" -#define _SEMVER_BUILD "0.8.7+1120" -#define _SEMVER_GITHASH "0.8.7+45b51f2" -#define _SEMVER_FULL "0.8.7-beta+45b51f2" -#define _SEMVER_NOBUILD "0.8.7-beta (16-10-2021)" -#define _VERSION "0.8.7-beta+45b51f2 (16-10-2021)" +#define _SEMVER_BUILD "0.8.7+1127" +#define _SEMVER_GITHASH "0.8.7+99dd717" +#define _SEMVER_FULL "0.8.7-beta+99dd717" +#define _SEMVER_NOBUILD "0.8.7-beta (19-10-2021)" +#define _VERSION "0.8.7-beta+99dd717 (19-10-2021)" //The version information is created automatically, more information here: https://github.com/rvdbreemen/autoinc-semver