3939# define EDGE_CONTROL_WATCHDOG_MAX_TIMEOUT_ms (65536 )
4040#endif /* ARDUINO_ARCH_MBED */
4141
42- #include < Arduino_ConnectionHandler.h>
43-
4442/* *****************************************************************************
4543 * GLOBAL VARIABLES
4644 ******************************************************************************/
@@ -66,24 +64,18 @@ static void samd_watchdog_reset()
6664 }
6765}
6866
69- /* This function is called within the WiFiNINA library when invoking
70- * the method 'connectBearSSL' in order to prevent a premature bite
71- * of the watchdog (max timeout on SAMD is 16 s). wifi_nina_feed...
67+ /* This function is called within the GSMConnectionHandler. mkr_gsm_feed...
7268 * is defined a weak function there and overwritten by this "strong"
7369 * function here.
7470 */
75- #ifndef WIFI_HAS_FEED_WATCHDOG_FUNC
76- void wifi_nina_feed_watchdog ()
77- {
78- samd_watchdog_reset ();
79- }
80- #endif
81-
8271void mkr_gsm_feed_watchdog ()
8372{
8473 samd_watchdog_reset ();
8574}
86-
75+ /* This function is called within the GSMConnectionHandler. mkr_nb_feed...
76+ * is defined a weak function there and overwritten by this "strong"
77+ * function here.
78+ */
8779void mkr_nb_feed_watchdog ()
8880{
8981 samd_watchdog_reset ();
@@ -119,18 +111,26 @@ static void mbed_watchdog_reset()
119111 }
120112}
121113
122- #if defined (ARDUINO_PORTENTA_H7_WIFI_HAS_FEED_WATCHDOG_FUNC)
123- static void mbed_watchdog_enable_network_feed (const bool use_ethernet)
114+ static void mbed_watchdog_enable_network_feed (NetworkAdapter ni)
124115{
116+ if (ni == NetworkAdapter::ETHERNET) {
125117#if defined(BOARD_HAS_ETHERNET)
126- if (use_ethernet) {
127118 Ethernet.setFeedWatchdogFunc (watchdog_reset);
128- } else
129119#endif
120+ }
121+
122+ if (ni == NetworkAdapter::WIFI) {
123+ #if defined(ARDUINO_PORTENTA_H7_WIFI_HAS_FEED_WATCHDOG_FUNC) && defined(BOARD_HAS_WIFI)
130124 WiFi.setFeedWatchdogFunc (watchdog_reset);
125+ #endif
126+ }
131127
132- }
128+ if (ni == NetworkAdapter::CATM1) {
129+ #if defined(BOARD_HAS_CATM1_NBIOT)
130+ GSM.setFeedWatchdogFunc (watchdog_reset);
133131#endif
132+ }
133+ }
134134
135135void mbed_watchdog_trigger_reset ()
136136{
@@ -167,15 +167,17 @@ void watchdog_reset()
167167#endif
168168}
169169
170- void watchdog_enable_network_feed (const bool use_ethernet )
170+ void watchdog_enable_network_feed (NetworkAdapter ni )
171171{
172- #ifdef WIFI_HAS_FEED_WATCHDOG_FUNC
173- (void )use_ethernet;
172+ /* Setup WiFi NINA watchdog feed callback function */
173+ #if defined(ARDUINO_ARCH_SAMD) && defined(WIFI_HAS_FEED_WATCHDOG_FUNC)
174+ (void )ni;
174175 WiFi.setFeedWatchdogFunc (watchdog_reset);
175176#endif
176177
177- #ifdef ARDUINO_PORTENTA_H7_WIFI_HAS_FEED_WATCHDOG_FUNC
178- mbed_watchdog_enable_network_feed (use_ethernet);
178+ /* Setup mbed sockets watchdog feed callback function */
179+ #if defined(ARDUINO_ARCH_MBED)
180+ mbed_watchdog_enable_network_feed (ni);
179181#endif
180182}
181183#endif /* (ARDUINO_ARCH_SAMD) || (ARDUINO_ARCH_MBED) */
0 commit comments