@@ -105,8 +105,10 @@ TimeService::TimeService()
105
105
, _is_tz_configured(false )
106
106
, _timezone_offset(0 )
107
107
, _timezone_dst_until(0 )
108
+ #ifdef HAS_TCP
108
109
, _last_ntp_sync_tick(0 )
109
110
, _ntp_sync_interval_ms(TIMESERVICE_NTP_SYNC_TIMEOUT_ms)
111
+ #endif
110
112
{
111
113
112
114
}
@@ -123,6 +125,7 @@ void TimeService::begin(ConnectionHandler * con_hdl)
123
125
124
126
unsigned long TimeService::getTime ()
125
127
{
128
+ #ifdef HAS_TCP
126
129
/* Check if it's time to sync */
127
130
unsigned long const current_tick = millis ();
128
131
bool const is_ntp_sync_timeout = (current_tick - _last_ntp_sync_tick) > _ntp_sync_interval_ms;
@@ -133,8 +136,12 @@ unsigned long TimeService::getTime()
133
136
/* Read time from RTC */
134
137
unsigned long utc = getRTC ();
135
138
return isTimeValid (utc) ? utc : EPOCH_AT_COMPILE_TIME;
139
+ #else
140
+ return EPOCH_AT_COMPILE_TIME;
141
+ #endif
136
142
}
137
143
144
+ #ifdef HAS_TCP
138
145
bool TimeService::sync ()
139
146
{
140
147
_is_rtc_configured = false ;
@@ -153,6 +160,7 @@ void TimeService::setSyncInterval(unsigned long seconds)
153
160
{
154
161
_ntp_sync_interval_ms = seconds * 1000 ;
155
162
}
163
+ #endif
156
164
157
165
void TimeService::setTimeZoneData (long offset, unsigned long dst_until)
158
166
{
@@ -236,6 +244,7 @@ unsigned long TimeService::getTimeFromString(const String& input)
236
244
* PRIVATE MEMBER FUNCTIONS
237
245
**************************************************************************************/
238
246
247
+ #ifdef HAS_TCP
239
248
bool TimeService::connected ()
240
249
{
241
250
if (_con_hdl == nullptr ) {
@@ -247,7 +256,6 @@ bool TimeService::connected()
247
256
248
257
unsigned long TimeService::getRemoteTime ()
249
258
{
250
- #ifndef HAS_LORA
251
259
if (connected ()) {
252
260
/* At first try to see if a valid time can be obtained
253
261
* using the network time available via the connection
@@ -269,8 +277,6 @@ unsigned long TimeService::getRemoteTime()
269
277
#endif
270
278
}
271
279
272
- #endif /* ifndef HAS_LORA */
273
-
274
280
/* Return the epoch timestamp at compile time as a last
275
281
* line of defense. Otherwise the certificate expiration
276
282
* date is wrong and we'll be unable to establish a connection
@@ -279,6 +285,8 @@ unsigned long TimeService::getRemoteTime()
279
285
return EPOCH_AT_COMPILE_TIME;
280
286
}
281
287
288
+ #endif /* HAS_TCP */
289
+
282
290
bool TimeService::isTimeValid (unsigned long const time)
283
291
{
284
292
return (time > EPOCH_AT_COMPILE_TIME);
0 commit comments