25
25
26
26
#include " NTPUtils.h"
27
27
28
+ #include " ../../AIoTC_Config.h"
29
+
28
30
/* *************************************************************************************
29
31
* GLOBAL VARIABLES
30
32
**************************************************************************************/
@@ -77,7 +79,7 @@ void TimeService::begin(ConnectionHandler * con_hdl)
77
79
unsigned long TimeService::getTime ()
78
80
{
79
81
unsigned long time = EPOCH_AT_COMPILE_TIME;
80
-
82
+ # ifndef HAS_LORA
81
83
if (_is_rtc_configured) {
82
84
return get_rtc_time ();
83
85
}
@@ -91,6 +93,13 @@ unsigned long TimeService::getTime()
91
93
_is_rtc_configured = true ;
92
94
}
93
95
return time ;
96
+ #else
97
+ if (!_is_rtc_configured) {
98
+ set_rtc_time (time );
99
+ _is_rtc_configured = true ;
100
+ }
101
+ return get_rtc_time ();
102
+ #endif
94
103
}
95
104
96
105
void TimeService::setTimeZoneData (long offset, unsigned long dst_until)
@@ -180,6 +189,7 @@ unsigned long TimeService::getTimeFromString(const String& input)
180
189
* PRIVATE MEMBER FUNCTIONS
181
190
**************************************************************************************/
182
191
192
+ #ifndef HAS_LORA
183
193
bool TimeService::isConnected ()
184
194
{
185
195
if (_con_hdl == nullptr ) {
@@ -191,9 +201,6 @@ bool TimeService::isConnected()
191
201
192
202
unsigned long TimeService::getRemoteTime ()
193
203
{
194
- #include " ../../AIoTC_Config.h"
195
- #ifndef HAS_LORA
196
-
197
204
/* At first try to see if a valid time can be obtained
198
205
* using the network time available via the connection
199
206
* handler.
@@ -213,15 +220,14 @@ unsigned long TimeService::getRemoteTime()
213
220
}
214
221
#endif
215
222
216
- #endif /* ifndef HAS_LORA */
217
-
218
223
/* Return the epoch timestamp at compile time as a last
219
224
* line of defense. Otherwise the certificate expiration
220
225
* date is wrong and we'll be unable to establish a connection
221
226
* to the server.
222
227
*/
223
228
return EPOCH_AT_COMPILE_TIME;
224
229
}
230
+ #endif /* ifndef HAS_LORA */
225
231
226
232
bool TimeService::isTimeValid (unsigned long const time)
227
233
{
0 commit comments