@@ -99,7 +99,7 @@ static time_t const EPOCH = 0;
9999 * CTOR/DTOR
100100 **************************************************************************************/
101101
102- TimeService::TimeService ()
102+ TimeServiceClass::TimeServiceClass ()
103103: _con_hdl(nullptr )
104104, _is_rtc_configured(false )
105105, _is_tz_configured(false )
@@ -116,7 +116,7 @@ TimeService::TimeService()
116116 * PUBLIC MEMBER FUNCTIONS
117117 **************************************************************************************/
118118
119- void TimeService ::begin (ConnectionHandler * con_hdl)
119+ void TimeServiceClass ::begin (ConnectionHandler * con_hdl)
120120{
121121 _con_hdl = con_hdl;
122122 initRTC ();
@@ -125,7 +125,7 @@ void TimeService::begin(ConnectionHandler * con_hdl)
125125#endif
126126}
127127
128- unsigned long TimeService ::getTime ()
128+ unsigned long TimeServiceClass ::getTime ()
129129{
130130 /* Check if it's time to sync */
131131 unsigned long const current_tick = millis ();
@@ -139,12 +139,12 @@ unsigned long TimeService::getTime()
139139 return isTimeValid (utc) ? utc : EPOCH_AT_COMPILE_TIME;
140140}
141141
142- void TimeService ::setTime (unsigned long time)
142+ void TimeServiceClass ::setTime (unsigned long time)
143143{
144144 setRTC (time);
145145}
146146
147- bool TimeService ::sync ()
147+ bool TimeServiceClass ::sync ()
148148{
149149 _is_rtc_configured = false ;
150150
@@ -170,29 +170,29 @@ bool TimeService::sync()
170170 return _is_rtc_configured;
171171}
172172
173- void TimeService ::setSyncInterval (unsigned long seconds)
173+ void TimeServiceClass ::setSyncInterval (unsigned long seconds)
174174{
175175 _sync_interval_ms = seconds * 1000 ;
176176}
177177
178- void TimeService ::setSyncFunction (syncTimeFunctionPtr sync_func)
178+ void TimeServiceClass ::setSyncFunction (syncTimeFunctionPtr sync_func)
179179{
180180 if (sync_func) {
181181 _sync_func = sync_func;
182182 }
183183}
184184
185- void TimeService ::setTimeZoneData (long offset, unsigned long dst_until)
185+ void TimeServiceClass ::setTimeZoneData (long offset, unsigned long dst_until)
186186{
187187 if (_timezone_offset != offset || _timezone_dst_until != dst_until) {
188- DEBUG_DEBUG (" TimeService ::%s offset: %d dst_unitl %ul" , __FUNCTION__, offset, dst_until);
188+ DEBUG_DEBUG (" TimeServiceClass ::%s offset: %d dst_unitl %ul" , __FUNCTION__, offset, dst_until);
189189 _timezone_offset = offset;
190190 _timezone_dst_until = dst_until;
191191 _is_tz_configured = true ;
192192 }
193193}
194194
195- unsigned long TimeService ::getLocalTime ()
195+ unsigned long TimeServiceClass ::getLocalTime ()
196196{
197197 unsigned long utc = getTime ();
198198 if (_is_tz_configured) {
@@ -202,7 +202,7 @@ unsigned long TimeService::getLocalTime()
202202 }
203203}
204204
205- unsigned long TimeService ::getTimeFromString (const String& input)
205+ unsigned long TimeServiceClass ::getTimeFromString (const String& input)
206206{
207207 struct tm t =
208208 {
@@ -224,29 +224,29 @@ unsigned long TimeService::getTimeFromString(const String& input)
224224 static const int expected_parameters = 6 ;
225225
226226 if (input == nullptr || input.length () != expected_length) {
227- DEBUG_ERROR (" TimeService ::%s invalid input length" , __FUNCTION__);
227+ DEBUG_ERROR (" TimeServiceClass ::%s invalid input length" , __FUNCTION__);
228228 return 0 ;
229229 }
230230
231231 int scanned_parameters = sscanf (input.c_str (), " %d %s %d %d:%d:%d" , &year, s_month, &day, &hour, &min, &sec);
232232
233233 if (scanned_parameters != expected_parameters) {
234- DEBUG_ERROR (" TimeService ::%s invalid input parameters number" , __FUNCTION__);
234+ DEBUG_ERROR (" TimeServiceClass ::%s invalid input parameters number" , __FUNCTION__);
235235 return 0 ;
236236 }
237237
238238 char * s_month_position = strstr (month_names, s_month);
239239
240240 if (s_month_position == nullptr || strlen (s_month) != 3 ) {
241- DEBUG_ERROR (" TimeService ::%s invalid month name, use %s" , __FUNCTION__, month_names);
241+ DEBUG_ERROR (" TimeServiceClass ::%s invalid month name, use %s" , __FUNCTION__, month_names);
242242 return 0 ;
243243 }
244244
245245 month = (s_month_position - month_names) / 3 ;
246246
247247 if (month < 0 || month > 11 || day < 1 || day > 31 || year < 1900 || hour < 0 ||
248248 hour > 24 || min < 0 || min > 60 || sec < 0 || sec > 60 ) {
249- DEBUG_ERROR (" TimeService ::%s invalid date values" , __FUNCTION__);
249+ DEBUG_ERROR (" TimeServiceClass ::%s invalid date values" , __FUNCTION__);
250250 return 0 ;
251251 }
252252
@@ -265,7 +265,7 @@ unsigned long TimeService::getTimeFromString(const String& input)
265265 **************************************************************************************/
266266
267267#ifdef HAS_TCP
268- bool TimeService ::connected ()
268+ bool TimeServiceClass ::connected ()
269269{
270270 if (_con_hdl == nullptr ) {
271271 return false ;
@@ -274,7 +274,7 @@ bool TimeService::connected()
274274 }
275275}
276276
277- unsigned long TimeService ::getRemoteTime ()
277+ unsigned long TimeServiceClass ::getRemoteTime ()
278278{
279279 if (connected ()) {
280280 /* At first try to see if a valid time can be obtained
@@ -307,12 +307,12 @@ unsigned long TimeService::getRemoteTime()
307307
308308#endif /* HAS_TCP */
309309
310- bool TimeService ::isTimeValid (unsigned long const time)
310+ bool TimeServiceClass ::isTimeValid (unsigned long const time)
311311{
312312 return (time > EPOCH_AT_COMPILE_TIME);
313313}
314314
315- void TimeService ::initRTC ()
315+ void TimeServiceClass ::initRTC ()
316316{
317317#if defined (ARDUINO_ARCH_SAMD)
318318 samd_initRTC ();
@@ -329,7 +329,7 @@ void TimeService::initRTC()
329329#endif
330330}
331331
332- void TimeService ::setRTC (unsigned long time)
332+ void TimeServiceClass ::setRTC (unsigned long time)
333333{
334334#if defined (ARDUINO_ARCH_SAMD)
335335 samd_setRTC (time);
@@ -346,7 +346,7 @@ void TimeService::setRTC(unsigned long time)
346346#endif
347347}
348348
349- unsigned long TimeService ::getRTC ()
349+ unsigned long TimeServiceClass ::getRTC ()
350350{
351351#if defined (ARDUINO_ARCH_SAMD)
352352 return samd_getRTC ();
@@ -483,7 +483,8 @@ unsigned long esp8266_getRTC()
483483}
484484#endif
485485
486- TimeService & ArduinoIoTCloudTimeService () {
487- static TimeService _timeService_instance;
488- return _timeService_instance;
489- }
486+ /* *****************************************************************************
487+ * EXTERN DEFINITION
488+ ******************************************************************************/
489+
490+ TimeServiceClass TimeService;
0 commit comments