@@ -80,6 +80,7 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
8080 * PUBLIC MEMBER FUNCTIONS
8181 ******************************************************************************/
8282
83+ #if CONNECTION_HANDLER_ENABLED
8384int ArduinoIoTCloudTCP::begin (ConnectionHandler& connection, bool const enableWatchdog, String brokerAddress, uint16_t brokerPort, bool autoReconnect)
8485{
8586 _connection = &connection;
@@ -89,6 +90,7 @@ int ArduinoIoTCloudTCP::begin(ConnectionHandler& connection, bool const enableWa
8990 return begin (_connection->getClient (), _connection->getUDP (), enableWatchdog, brokerAddress, brokerPort, autoReconnect);
9091#endif
9192}
93+ #endif
9294
9395int ArduinoIoTCloudTCP::begin (Client& brokerClient, Client& otaClient, UDP& ntpClient, bool const enableWatchdog, String brokerAddress, uint16_t brokerPort, bool autoReconnect)
9496{
@@ -342,8 +344,13 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Init()
342344 _otaTLSClient.begin (_otaClient);
343345#endif
344346
347+ #if CONNECTION_HANDLER_ENABLED
345348 /* 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);
347354
348355 /* Since we do not control what code the user inserts
349356 * between ArduinoIoTCloudTCP::begin() and the first
@@ -354,8 +361,12 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Init()
354361 if (_enableWatchdog) {
355362 /* Initialize watchdog hardware */
356363 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
359370 }
360371#endif
361372
@@ -364,13 +375,20 @@ ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_Init()
364375
365376ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_ConnectPhy ()
366377{
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;
371381 }
372382
383+ if (_connection->check () == NetworkConnectionState::CONNECTED) {
384+ if (!_connection_attempt.isRetry () || (_connection_attempt.isRetry () && _connection_attempt.isExpired ())) {
385+ return State::SyncTime;
386+ }
387+ }
373388 return State::ConnectPhy;
389+ #else
390+ return State::SyncTime;
391+ #endif
374392}
375393
376394ArduinoIoTCloudTCP::State ArduinoIoTCloudTCP::handle_SyncTime ()
0 commit comments