diff --git a/src/Arduino_GSMConnectionHandler.cpp b/src/Arduino_GSMConnectionHandler.cpp index 67afa14f..fd65ba9c 100644 --- a/src/Arduino_GSMConnectionHandler.cpp +++ b/src/Arduino_GSMConnectionHandler.cpp @@ -29,6 +29,18 @@ static int const GSM_TIMEOUT = 30000; +/****************************************************************************** + FUNCTION DEFINITION + ******************************************************************************/ + +__attribute__((weak)) void mkr_gsm_feed_watchdog() +{ + /* This function can be overwritten by a "strong" implementation + * in a higher level application, such as the ArduinoIoTCloud + * firmware stack. + */ +} + /****************************************************************************** CTOR/DTOR ******************************************************************************/ @@ -58,15 +70,21 @@ unsigned long GSMConnectionHandler::getTime() NetworkConnectionState GSMConnectionHandler::update_handleInit() { + mkr_gsm_feed_watchdog(); + if (_gsm.begin(_pin) != GSM_READY) { Debug.print(DBG_ERROR, F("SIM not present or wrong PIN")); return NetworkConnectionState::ERROR; } + mkr_gsm_feed_watchdog(); + Debug.print(DBG_INFO, F("SIM card ok")); _gsm.setTimeout(GSM_TIMEOUT); + mkr_gsm_feed_watchdog(); + GSM3_NetworkStatus_t const network_status = _gprs.attachGPRS(_apn, _login, _pass, true); Debug.print(DBG_DEBUG, F("GPRS.attachGPRS(): %d"), network_status); if (network_status == GSM3_NetworkStatus_t::ERROR) diff --git a/src/Arduino_NBConnectionHandler.cpp b/src/Arduino_NBConnectionHandler.cpp index a4d8765b..8c747edf 100644 --- a/src/Arduino_NBConnectionHandler.cpp +++ b/src/Arduino_NBConnectionHandler.cpp @@ -29,6 +29,18 @@ static int const NB_TIMEOUT = 30000; +/****************************************************************************** + FUNCTION DEFINITION + ******************************************************************************/ + +__attribute__((weak)) void mkr_nb_feed_watchdog() +{ + /* This function can be overwritten by a "strong" implementation + * in a higher level application, such as the ArduinoIoTCloud + * firmware stack. + */ +} + /****************************************************************************** CTOR/DTOR ******************************************************************************/ @@ -69,6 +81,8 @@ unsigned long NBConnectionHandler::getTime() NetworkConnectionState NBConnectionHandler::update_handleInit() { + mkr_nb_feed_watchdog(); + if (_nb.begin(_pin, _apn, _login, _pass) == NB_READY) { Debug.print(DBG_INFO, F("SIM card ok"));