@@ -80,6 +80,7 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
80
80
* PUBLIC MEMBER FUNCTIONS
81
81
******************************************************************************/
82
82
83
+ #if CONNECTION_HANDLER_ENABLED
83
84
int ArduinoIoTCloudTCP::begin (ConnectionHandler& connection, bool const enableWatchdog, String brokerAddress, uint16_t brokerPort, bool autoReconnect)
84
85
{
85
86
_connection = &connection;
@@ -89,6 +90,7 @@ int ArduinoIoTCloudTCP::begin(ConnectionHandler& connection, bool const enableWa
89
90
return begin (_connection->getClient (), _connection->getUDP (), enableWatchdog, brokerAddress, brokerPort, autoReconnect);
90
91
#endif
91
92
}
93
+ #endif
92
94
93
95
int ArduinoIoTCloudTCP::begin (Client& brokerClient, Client& otaClient, UDP& ntpClient, bool const enableWatchdog, String brokerAddress, uint16_t brokerPort, bool autoReconnect)
94
96
{
@@ -342,8 +344,13 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Init()
342
344
_otaTLSClient.begin (_otaClient);
343
345
#endif
344
346
347
+ #if CONNECTION_HANDLER_ENABLED
345
348
/* Setup TimeService */
346
- _time_service.begin (_connection);
349
+ if (_connection != nullptr ) {
350
+ _time_service.begin (_connection);
351
+ } else
352
+ #endif
353
+ _time_service.begin (_ntpClient);
347
354
348
355
/* Since we do not control what code the user inserts
349
356
* between ArduinoIoTCloudTCP::begin() and the first
@@ -354,8 +361,12 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Init()
354
361
if (_enableWatchdog) {
355
362
/* Initialize watchdog hardware */
356
363
watchdog_enable ();
357
- /* Setup callbacks to feed the watchdog during offloaded network operations (connection/download)*/
358
- watchdog_enable_network_feed (_connection->getInterface ());
364
+ #if CONNECTION_HANDLER_ENABLED
365
+ if (_connection != nullptr ) {
366
+ /* Setup callbacks to feed the watchdog during offloaded network operations (connection/download)*/
367
+ watchdog_enable_network_feed (_connection->getInterface ());
368
+ }
369
+ #endif
359
370
}
360
371
#endif
361
372
@@ -364,13 +375,20 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Init()
364
375
365
376
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy ()
366
377
{
367
- if (_connection->check () == NetworkConnectionState::CONNECTED)
368
- {
369
- if (!_connection_attempt.isRetry () || (_connection_attempt.isRetry () && _connection_attempt.isExpired ()))
370
- return State::SyncTime;
378
+ #if CONNECTION_HANDLER_ENABLED
379
+ if (_connection == nullptr ) {
380
+ return State::SyncTime;
371
381
}
372
382
383
+ if (_connection->check () == NetworkConnectionState::CONNECTED) {
384
+ if (!_connection_attempt.isRetry () || (_connection_attempt.isRetry () && _connection_attempt.isExpired ())) {
385
+ return State::SyncTime;
386
+ }
387
+ }
373
388
return State::ConnectPhy;
389
+ #else
390
+ return State::SyncTime;
391
+ #endif
374
392
}
375
393
376
394
ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime ()
0 commit comments