esp32 + ota + doublereset

This commit is contained in:
2023-09-27 14:09:52 +02:00
parent 3fc594b824
commit 31fea83a3a
17 changed files with 1516 additions and 483 deletions

View File

@@ -1,17 +1,14 @@
#include "clock.h"
bool RTC_present;
bool NTPinit = false;
// Central European Time (Frankfurt, Paris)
bool RTC_present = false;
bool provider_Set = false;
// // Central European Time (Frankfurt, Paris)
TimeChangeRule CEST = {"CEST", Last, Sun, Mar, 2, 120}; // Central European Summer Time
TimeChangeRule CET = {"CET ", Last, Sun, Oct, 3, 60}; // Central European Standard Time
Timezone myTZ(CEST, CET);
TimeChangeRule *tcr;
bool timeIsSet()
{
return RTC_present;
@@ -29,31 +26,34 @@ void printDateTime(time_t t, const char *tz)
time_t getLocalTime()
{
if(!getWifiStatus) return 0;
time_t utc = getNtpTime();
if(!getWifiStatus()) return 0;
time_t utc;
time(&utc);
time_t local = myTZ.toLocal(utc, &tcr);
printDateTime(local,tcr -> abbrev);
printDateTime(utc,"UTC");
return utc;
return local;
}
void initClock()
{
initWifi();
getLocalTime();
}
void loopClock()
{
if(getWifiStatus())
if(getWifiStatus())
{
if(!NTPinit && getWifiStatus())
if(getWifiStatus() & !provider_Set)
{
initNTP();
setSyncProvider(getLocalTime);
setSyncInterval(300);
NTPinit = true;
setSyncInterval(10);
provider_Set = true;
log_i("timesync provider set");
}
RTC_present = timeStatus ? timeSet: true, false;
}
else