@@ -104,16 +104,16 @@ ArduinoIoTCloudTCP::ArduinoIoTCloudTCP()
104104 * PUBLIC MEMBER FUNCTIONS
105105 ******************************************************************************/
106106
107- int ArduinoIoTCloudTCP::begin (ConnectionHandler & connection, String brokerAddress, uint16_t brokerPort)
107+ int ArduinoIoTCloudTCP::begin (ConnectionHandler & connection, bool const enable_watchdog, String brokerAddress, uint16_t brokerPort)
108108{
109109 _connection = &connection;
110110 _brokerAddress = brokerAddress;
111111 _brokerPort = brokerPort;
112112 _time_service.begin (&connection);
113- return begin (_brokerAddress, _brokerPort);
113+ return begin (enable_watchdog, _brokerAddress, _brokerPort);
114114}
115115
116- int ArduinoIoTCloudTCP::begin (String brokerAddress, uint16_t brokerPort)
116+ int ArduinoIoTCloudTCP::begin (bool const enable_watchdog, String brokerAddress, uint16_t brokerPort)
117117{
118118 _brokerAddress = brokerAddress;
119119 _brokerPort = brokerPort;
@@ -275,7 +275,9 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
275275 * call to ArduinoIoTCloudTCP::update() it is wise to
276276 * set a rather large timeout at first.
277277 */
278- Watchdog.enable (SAMD_WATCHDOG_MAX_TIME_ms);
278+ if (enable_watchdog) {
279+ samd_watchdog_enable ();
280+ }
279281#endif /* ARDUINO_ARCH_SAMD */
280282
281283 return 1 ;
@@ -287,7 +289,7 @@ void ArduinoIoTCloudTCP::update()
287289 /* Feed the watchdog. If any of the functions called below
288290 * get stuck than we can at least reset and recover.
289291 */
290- Watchdog. reset ();
292+ samd_watchdog_reset ();
291293#endif /* ARDUINO_ARCH_SAMD */
292294
293295 /* Run through the state machine. */
@@ -546,7 +548,7 @@ int ArduinoIoTCloudTCP::write(String const topic, byte const data[], int const l
546548void ArduinoIoTCloudTCP::onOTARequest ()
547549{
548550#ifdef ARDUINO_ARCH_SAMD
549- Watchdog. reset ();
551+ samd_watchdog_reset ();
550552#endif /* ARDUINO_ARCH_SAMD */
551553
552554 DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s _ota_url = %s" , __FUNCTION__, _ota_url.c_str ());
@@ -557,7 +559,7 @@ void ArduinoIoTCloudTCP::onOTARequest()
557559 WiFiStorage.remove (" /fs/UPDATE.BIN.LZSS.TMP" );
558560
559561#ifdef ARDUINO_ARCH_SAMD
560- Watchdog. reset ();
562+ samd_watchdog_reset ();
561563#endif /* ARDUINO_ARCH_SAMD */
562564
563565 /* Trigger direct download to nina module. */
0 commit comments