@@ -44,7 +44,12 @@ void ArduinoCellular::begin() {
4444
4545}
4646
47- bool ArduinoCellular::connect (String apn, String username, String password){
47+ bool ArduinoCellular::connect (String apn, bool wait_forever) {
48+ connect (apn,String (" " ),String (" " ), wait_forever);
49+ }
50+
51+
52+ bool ArduinoCellular::connect (String apn, String username, String password, bool wait_forever){
4853 SimStatus simStatus = getSimStatus ();
4954
5055 if (simStatus == SimStatus::SIM_LOCKED){
@@ -62,7 +67,7 @@ bool ArduinoCellular::connect(String apn, String username, String password){
6267 return false ;
6368 }
6469
65- if (!awaitNetworkRegistration ()){
70+ if (!awaitNetworkRegistration (wait_forever )){
6671 return false ;
6772 }
6873
@@ -225,11 +230,16 @@ bool ArduinoCellular::unlockSIM(String pin){
225230 return modem.simUnlock (pin.c_str ());
226231}
227232
228- bool ArduinoCellular::awaitNetworkRegistration (){
233+ bool ArduinoCellular::awaitNetworkRegistration (bool wait_forever ){
229234 if (this ->debugStream != nullptr ){
230235 this ->debugStream ->println (" Waiting for network registration..." );
231236 }
232237 while (!modem.waitForNetwork (waitForNetworkTimeout)) {
238+
239+ if (!wait_forever) {
240+ return false ;
241+ }
242+
233243 if (this ->debugStream != nullptr ){
234244 this ->debugStream ->print (" ." );
235245 }
0 commit comments