@@ -44,7 +44,12 @@ void ArduinoCellular::begin() {
44
44
45
45
}
46
46
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){
48
53
SimStatus simStatus = getSimStatus ();
49
54
50
55
if (simStatus == SimStatus::SIM_LOCKED){
@@ -62,7 +67,7 @@ bool ArduinoCellular::connect(String apn, String username, String password){
62
67
return false ;
63
68
}
64
69
65
- if (!awaitNetworkRegistration ()){
70
+ if (!awaitNetworkRegistration (wait_forever )){
66
71
return false ;
67
72
}
68
73
@@ -225,11 +230,16 @@ bool ArduinoCellular::unlockSIM(String pin){
225
230
return modem.simUnlock (pin.c_str ());
226
231
}
227
232
228
- bool ArduinoCellular::awaitNetworkRegistration (){
233
+ bool ArduinoCellular::awaitNetworkRegistration (bool wait_forever ){
229
234
if (this ->debugStream != nullptr ){
230
235
this ->debugStream ->println (" Waiting for network registration..." );
231
236
}
232
237
while (!modem.waitForNetwork (waitForNetworkTimeout)) {
238
+
239
+ if (!wait_forever) {
240
+ return false ;
241
+ }
242
+
233
243
if (this ->debugStream != nullptr ){
234
244
this ->debugStream ->print (" ." );
235
245
}
0 commit comments