File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ RTCZero rtc;
38
38
**************************************************************************************/
39
39
40
40
time_t cvt_time (char const * time);
41
+ unsigned long get_rtc_time ();
42
+ void set_rtc_time (unsigned long time);
41
43
42
44
/* *************************************************************************************
43
45
* CONSTANTS
@@ -274,6 +276,28 @@ time_t cvt_time(char const * time)
274
276
return mktime (&t);
275
277
}
276
278
279
+ unsigned long get_rtc_time () {
280
+ #ifdef ARDUINO_ARCH_SAMD
281
+ return rtc.getEpoch ();
282
+ #elif ARDUINO_ARCH_MBED
283
+ return time (NULL );
284
+ #else
285
+ return EPOCH;
286
+ #endif
287
+ }
288
+
289
+ void set_rtc_time (unsigned long time) {
290
+ #ifdef ARDUINO_ARCH_SAMD
291
+ rtc.setEpoch (time);
292
+ _is_rtc_configured = true ;
293
+ #elif ARDUINO_ARCH_MBED
294
+ set_time (time);
295
+ _is_rtc_configured = true ;
296
+ #else
297
+
298
+ #endif
299
+ }
300
+
277
301
TimeService & ArduinoIoTCloudTimeService () {
278
302
static TimeService _timeService_instance;
279
303
return _timeService_instance;
You can’t perform that action at this time.
0 commit comments