ntp attempt#2

This commit is contained in:
2023-09-17 20:50:01 +02:00
parent 3012bdd3be
commit 3fc594b824
6 changed files with 100 additions and 90 deletions

View File

@@ -9,6 +9,9 @@ Timezone myTZ(CEST, CET);
TimeChangeRule *tcr;
bool timeIsSet()
{
return RTC_present;
@@ -26,17 +29,18 @@ void printDateTime(time_t t, const char *tz)
time_t getLocalTime()
{
if(!getWifiStatus) return 0;
time_t utc = getNtpTime();
time_t local = myTZ.toLocal(utc, &tcr);
printDateTime(local,tcr -> abbrev);
printDateTime(utc,"UTC");
return local;
return utc;
}
void initClock()
{
initNTP();
initWifi();
}
void loopClock()
@@ -45,6 +49,7 @@ void loopClock()
{
if(!NTPinit && getWifiStatus())
{
initNTP();
setSyncProvider(getLocalTime);
setSyncInterval(300);
NTPinit = true;