Skip to content

Commit eb53f8b

Browse files
committed
Fix build for MKRWAN boards
1 parent b445fd7 commit eb53f8b

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/utility/time/TimeService.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
#include "NTPUtils.h"
2727

28+
#include "../../AIoTC_Config.h"
29+
2830
/**************************************************************************************
2931
* GLOBAL VARIABLES
3032
**************************************************************************************/
@@ -77,7 +79,7 @@ void TimeService::begin(ConnectionHandler * con_hdl)
7779
unsigned long TimeService::getTime()
7880
{
7981
unsigned long time = EPOCH_AT_COMPILE_TIME;
80-
82+
#ifndef HAS_LORA
8183
if(_is_rtc_configured) {
8284
return get_rtc_time();
8385
}
@@ -91,6 +93,13 @@ unsigned long TimeService::getTime()
9193
_is_rtc_configured = true;
9294
}
9395
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
94103
}
95104

96105
void TimeService::setTimeZoneData(long offset, unsigned long dst_until)
@@ -180,6 +189,7 @@ unsigned long TimeService::getTimeFromString(const String& input)
180189
* PRIVATE MEMBER FUNCTIONS
181190
**************************************************************************************/
182191

192+
#ifndef HAS_LORA
183193
bool TimeService::isConnected()
184194
{
185195
if(_con_hdl == nullptr) {
@@ -191,9 +201,6 @@ bool TimeService::isConnected()
191201

192202
unsigned long TimeService::getRemoteTime()
193203
{
194-
#include "../../AIoTC_Config.h"
195-
#ifndef HAS_LORA
196-
197204
/* At first try to see if a valid time can be obtained
198205
* using the network time available via the connection
199206
* handler.
@@ -213,15 +220,14 @@ unsigned long TimeService::getRemoteTime()
213220
}
214221
#endif
215222

216-
#endif /* ifndef HAS_LORA */
217-
218223
/* Return the epoch timestamp at compile time as a last
219224
* line of defense. Otherwise the certificate expiration
220225
* date is wrong and we'll be unable to establish a connection
221226
* to the server.
222227
*/
223228
return EPOCH_AT_COMPILE_TIME;
224229
}
230+
#endif /* ifndef HAS_LORA */
225231

226232
bool TimeService::isTimeValid(unsigned long const time)
227233
{

src/utility/time/TimeService.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
#include <mbed_rtc_time.h>
3333
#endif
3434

35+
#include "../../AIoTC_Config.h"
36+
3537
/**************************************************************************************
3638
* CLASS DECLARATION
3739
**************************************************************************************/
@@ -61,8 +63,11 @@ class TimeService
6163
long _timezone_offset;
6264
unsigned long _timezone_dst_until;
6365

66+
#ifndef HAS_LORA
6467
unsigned long getRemoteTime();
6568
bool isConnected();
69+
#endif
70+
6671
static bool isTimeValid(unsigned long const time);
6772

6873
};

0 commit comments

Comments
 (0)