Skip to content

Commit cd04eef

Browse files
committed
Pass function for feeding the watchdog via public API.
Requires arduino-libraries/WiFiNINA#182.
1 parent 679118c commit cd04eef

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

src/utility/watchdog/Watchdog.cpp

+17-12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
# define NANO_RP2040_WATCHDOG_MAX_TIMEOUT_ms (32760)
3939
#endif /* ARDUINO_ARCH_MBED */
4040

41+
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_NANO_RP2040_CONNECT)
42+
# include <WiFiNINA.h>
43+
#endif
44+
4145
/******************************************************************************
4246
* GLOBAL VARIABLES
4347
******************************************************************************/
@@ -53,6 +57,14 @@ void samd_watchdog_enable()
5357
{
5458
is_watchdog_enabled = true;
5559
Watchdog.enable(SAMD_WATCHDOG_MAX_TIME_ms);
60+
#if defined(ARDUINO_SAMD_MKRWIFI1010) || defined(ARDUINO_SAMD_NANO_33_IOT)
61+
/* This function is called within the WiFiNINA library when invoking
62+
* the method 'connectBearSSL' in order to prevent a premature bite
63+
* of the watchdog (max timeout on SAMD is 16 s) as well as during various
64+
* calls to 'begin'.
65+
*/
66+
WiFi.setFeedWatchdogFunc(samd_watchdog_reset);
67+
#endif
5668
}
5769

5870
void samd_watchdog_reset()
@@ -62,17 +74,6 @@ void samd_watchdog_reset()
6274
}
6375
}
6476

65-
/* This function is called within the WiFiNINA library when invoking
66-
* the method 'connectBearSSL' in order to prevent a premature bite
67-
* of the watchdog (max timeout on SAMD is 16 s). wifi_nina_feed...
68-
* is defined a weak function there and overwritten by this "strong"
69-
* function here.
70-
*/
71-
void wifi_nina_feed_watchdog()
72-
{
73-
samd_watchdog_reset();
74-
}
75-
7677
void mkr_gsm_feed_watchdog()
7778
{
7879
samd_watchdog_reset();
@@ -100,8 +101,12 @@ void mbed_watchdog_enable()
100101
is_watchdog_enabled = true;
101102
}
102103
else {
103-
DEBUG_WARNING("%s: watchdog could not be enabled", __FUNCTION__);
104+
DEBUG_ERROR("%s: watchdog could not be enabled", __FUNCTION__);
104105
}
106+
107+
#if defined(ARDUINO_NANO_RP2040_CONNECT)
108+
WiFi.setFeedWatchdogFunc(mbed_watchdog_reset);
109+
#endif
105110
}
106111

107112
void mbed_watchdog_reset()

0 commit comments

Comments
 (0)