Skip to content

Commit cb39907

Browse files
committed
Do not store EPOCH_AT_COMPILE_TIME into the RTC
1 parent d5a676a commit cb39907

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/utility/time/TimeService.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,25 @@ unsigned long TimeService::getTime()
7979
#ifdef ARDUINO_ARCH_SAMD
8080
if(!_is_rtc_configured)
8181
{
82-
rtc.setEpoch(getRemoteTime());
83-
_is_rtc_configured = true;
82+
unsigned long utc = getRemoteTime();
83+
if(EPOCH_AT_COMPILE_TIME != utc)
84+
{
85+
rtc.setEpoch(utc);
86+
_is_rtc_configured = true;
87+
}
88+
return utc;
8489
}
8590
return rtc.getEpoch();
8691
#elif ARDUINO_ARCH_MBED
8792
if(!_is_rtc_configured)
8893
{
89-
set_time(getRemoteTime());
90-
_is_rtc_configured = true;
94+
unsigned long utc = getRemoteTime();
95+
if(EPOCH_AT_COMPILE_TIME != utc)
96+
{
97+
set_time(utc);
98+
_is_rtc_configured = true;
99+
}
100+
return utc;
91101
}
92102
return time(NULL);
93103
#else

0 commit comments

Comments
 (0)