Skip to content

Commit 8503873

Browse files
Merge pull request #14 from pennam/wdog
Allow watchdog kick while waiting for network
2 parents 2051e29 + 8691251 commit 8503873

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

Diff for: src/ArduinoCellular.cpp

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22

33
#include "ArduinoCellular.h"
4+
#if defined(ARDUINO_ARCH_MBED)
5+
#include "Watchdog.h"
6+
#endif
47

58
unsigned long ArduinoCellular::getTime() {
69
int year, month, day, hour, minute, second;
@@ -217,12 +220,17 @@ bool ArduinoCellular::awaitNetworkRegistration(){
217220
if(this->debugStream != nullptr){
218221
this->debugStream->println("Waiting for network registration...");
219222
}
220-
while (!modem.waitForNetwork()) {
223+
while (!modem.waitForNetwork(waitForNetworkTimeout)) {
221224
if(this->debugStream != nullptr){
222225
this->debugStream->print(".");
223226
}
227+
#if defined(ARDUINO_ARCH_MBED)
228+
if(mbed::Watchdog::get_instance().is_running()) {
229+
mbed::Watchdog::get_instance().kick();
230+
}
231+
#endif
224232
delay(2000);
225-
}
233+
}
226234
return true;
227235
}
228236

Diff for: src/ArduinoCellular.h

+2
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ class ArduinoCellular {
289289
Stream* debugStream = nullptr; /**< The stream to be used for printing debugging messages. */
290290

291291
static unsigned long getTime(); /** Callback for getting the current time as an unix timestamp. */
292+
293+
static constexpr unsigned long waitForNetworkTimeout = 20000L; /**< Maximum wait time for network registration (In milliseconds). */
292294
};
293295

294296

0 commit comments

Comments
 (0)