Skip to content

Commit 56de2c1

Browse files
committed
Do not build code not compatible with LORA devices
1 parent 1836f23 commit 56de2c1

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/utility/time/TimeService.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

124126
unsigned 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
138145
bool 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

157165
void 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
239248
bool TimeService::connected()
240249
{
241250
if(_con_hdl == nullptr) {
@@ -247,7 +256,6 @@ bool TimeService::connected()
247256

248257
unsigned 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+
282290
bool TimeService::isTimeValid(unsigned long const time)
283291
{
284292
return (time > EPOCH_AT_COMPILE_TIME);

src/utility/time/TimeService.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* INCLUDE
2323
**************************************************************************************/
2424

25+
#include <AIoTC_Config.h>
2526
#include <Arduino_ConnectionHandler.h>
2627

2728
/**************************************************************************************
@@ -39,7 +40,9 @@ class TimeService
3940
unsigned long getTime();
4041
unsigned long getLocalTime();
4142
void setTimeZoneData(long offset, unsigned long valid_until);
43+
#ifdef HAS_TCP
4244
bool sync();
45+
#endif
4346
void setSyncInterval(unsigned long seconds);
4447

4548
/* Helper function to convert an input String into a UNIX timestamp.
@@ -54,12 +57,15 @@ class TimeService
5457
bool _is_tz_configured;
5558
long _timezone_offset;
5659
unsigned long _timezone_dst_until;
60+
#ifdef HAS_TCP
5761
unsigned long _last_ntp_sync_tick;
5862
unsigned long _ntp_sync_interval_ms;
63+
#endif
5964

65+
#ifdef HAS_TCP
6066
unsigned long getRemoteTime();
6167
bool connected();
62-
static bool isTimeValid(unsigned long const time);
68+
#endif
6369
void initRTC();
6470
void setRTC(unsigned long time);
6571
unsigned long getRTC();

0 commit comments

Comments
 (0)