@@ -105,8 +105,10 @@ TimeService::TimeService()
105105, _is_tz_configured(false )
106106, _timezone_offset(0 )
107107, _timezone_dst_until(0 )
108+ #ifdef HAS_TCP
108109, _last_ntp_sync_tick(0 )
109110, _ntp_sync_interval_ms(TIMESERVICE_NTP_SYNC_TIMEOUT_ms)
111+ #endif
110112{
111113
112114}
@@ -123,6 +125,7 @@ void TimeService::begin(ConnectionHandler * con_hdl)
123125
124126unsigned long TimeService::getTime ()
125127{
128+ #ifdef HAS_TCP
126129 /* Check if it's time to sync */
127130 unsigned long const current_tick = millis ();
128131 bool const is_ntp_sync_timeout = (current_tick - _last_ntp_sync_tick) > _ntp_sync_interval_ms;
@@ -133,8 +136,12 @@ unsigned long TimeService::getTime()
133136 /* Read time from RTC */
134137 unsigned long utc = getRTC ();
135138 return isTimeValid (utc) ? utc : EPOCH_AT_COMPILE_TIME;
139+ #else
140+ return EPOCH_AT_COMPILE_TIME;
141+ #endif
136142}
137143
144+ #ifdef HAS_TCP
138145bool TimeService::sync ()
139146{
140147 _is_rtc_configured = false ;
@@ -153,6 +160,7 @@ void TimeService::setSyncInterval(unsigned long seconds)
153160{
154161 _ntp_sync_interval_ms = seconds * 1000 ;
155162}
163+ #endif
156164
157165void TimeService::setTimeZoneData (long offset, unsigned long dst_until)
158166{
@@ -236,6 +244,7 @@ unsigned long TimeService::getTimeFromString(const String& input)
236244 * PRIVATE MEMBER FUNCTIONS
237245 **************************************************************************************/
238246
247+ #ifdef HAS_TCP
239248bool TimeService::connected ()
240249{
241250 if (_con_hdl == nullptr ) {
@@ -247,7 +256,6 @@ bool TimeService::connected()
247256
248257unsigned long TimeService::getRemoteTime ()
249258{
250- #ifndef HAS_LORA
251259 if (connected ()) {
252260 /* At first try to see if a valid time can be obtained
253261 * using the network time available via the connection
@@ -269,8 +277,6 @@ unsigned long TimeService::getRemoteTime()
269277#endif
270278 }
271279
272- #endif /* ifndef HAS_LORA */
273-
274280 /* Return the epoch timestamp at compile time as a last
275281 * line of defense. Otherwise the certificate expiration
276282 * date is wrong and we'll be unable to establish a connection
@@ -279,6 +285,8 @@ unsigned long TimeService::getRemoteTime()
279285 return EPOCH_AT_COMPILE_TIME;
280286}
281287
288+ #endif /* HAS_TCP */
289+
282290bool TimeService::isTimeValid (unsigned long const time)
283291{
284292 return (time > EPOCH_AT_COMPILE_TIME);
0 commit comments