Skip to content

Commit

Permalink
Merge pull request #14 from pennam/wdog
Browse files Browse the repository at this point in the history
Allow watchdog kick while waiting for network
  • Loading branch information
cristidragomir97 authored May 9, 2024
2 parents 2051e29 + 8691251 commit 8503873
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ArduinoCellular.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@


#include "ArduinoCellular.h"
#if defined(ARDUINO_ARCH_MBED)
#include "Watchdog.h"
#endif

unsigned long ArduinoCellular::getTime() {
int year, month, day, hour, minute, second;
Expand Down Expand Up @@ -217,12 +220,17 @@ bool ArduinoCellular::awaitNetworkRegistration(){
if(this->debugStream != nullptr){
this->debugStream->println("Waiting for network registration...");
}
while (!modem.waitForNetwork()) {
while (!modem.waitForNetwork(waitForNetworkTimeout)) {
if(this->debugStream != nullptr){
this->debugStream->print(".");
}
#if defined(ARDUINO_ARCH_MBED)
if(mbed::Watchdog::get_instance().is_running()) {
mbed::Watchdog::get_instance().kick();
}
#endif
delay(2000);
}
}
return true;
}

Expand Down
2 changes: 2 additions & 0 deletions src/ArduinoCellular.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ class ArduinoCellular {
Stream* debugStream = nullptr; /**< The stream to be used for printing debugging messages. */

static unsigned long getTime(); /** Callback for getting the current time as an unix timestamp. */

static constexpr unsigned long waitForNetworkTimeout = 20000L; /**< Maximum wait time for network registration (In milliseconds). */
};


Expand Down

0 comments on commit 8503873

Please sign in to comment.