@@ -270,7 +270,7 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
270
270
* call to ArduinoIoTCloudTCP::update() it is wise to
271
271
* set a rather large timeout at first.
272
272
*/
273
- Watchdog.enable (120 * 1000 );
273
+ Watchdog.enable (SAMD_WATCHDOG_MAX_TIME_ms );
274
274
#endif /* ARDUINO_ARCH_SAMD */
275
275
276
276
return 1 ;
@@ -279,15 +279,6 @@ int ArduinoIoTCloudTCP::begin(String brokerAddress, uint16_t brokerPort)
279
279
void ArduinoIoTCloudTCP::update ()
280
280
{
281
281
#ifdef ARDUINO_ARCH_SAMD
282
- /* Now that we are within the regularly called function
283
- * ArduinoIoTCloudTCP::update() it's a wise idea to reduce
284
- * the watchdog timeout to a smaller amount of time.
285
- */
286
- static bool is_watchdog_set = false ;
287
- if (!is_watchdog_set) {
288
- Watchdog.enable (30 * 1000 );
289
- is_watchdog_set = true ;
290
- }
291
282
/* Feed the watchdog. If any of the functions called below
292
283
* get stuck than we can at least reset and recover.
293
284
*/
@@ -549,13 +540,21 @@ int ArduinoIoTCloudTCP::write(String const topic, byte const data[], int const l
549
540
#if OTA_ENABLED
550
541
void ArduinoIoTCloudTCP::onOTARequest ()
551
542
{
543
+ #ifdef ARDUINO_ARCH_SAMD
544
+ Watchdog.reset ();
545
+ #endif /* ARDUINO_ARCH_SAMD */
546
+
552
547
DEBUG_VERBOSE (" ArduinoIoTCloudTCP::%s _ota_url = %s" , __FUNCTION__, _ota_url.c_str ());
553
548
554
549
#if OTA_STORAGE_SNU
555
550
/* Just to be safe delete any remains from previous updates. */
556
551
WiFiStorage.remove (" /fs/UPDATE.BIN.LZSS" );
557
552
WiFiStorage.remove (" /fs/UPDATE.BIN.LZSS.TMP" );
558
553
554
+ #ifdef ARDUINO_ARCH_SAMD
555
+ Watchdog.reset ();
556
+ #endif /* ARDUINO_ARCH_SAMD */
557
+
559
558
/* Trigger direct download to nina module. */
560
559
uint8_t nina_ota_err_code = 0 ;
561
560
if (!WiFiStorage.downloadOTA (_ota_url.c_str (), &nina_ota_err_code))
0 commit comments