@@ -78,7 +78,7 @@ bool ArduinoCellular::connect(String apn, String username, String password, bool
78
78
return true ;
79
79
}
80
80
81
- if (connectToGPRS (apn.c_str (), username.c_str (), password.c_str ())){
81
+ if (connectToGPRS (apn.c_str (), username.c_str (), password.c_str (), waitForever )){
82
82
auto response = this ->sendATCommand (" +QIDNSCFG=1,\" 8.8.8.8\" ,\" 8.8.4.4\" " );
83
83
84
84
if (response.indexOf (" OK" ) != -1 ){
@@ -196,11 +196,16 @@ bool ArduinoCellular::isConnectedToOperator(){
196
196
return modem.isNetworkConnected ();
197
197
}
198
198
199
- bool ArduinoCellular::connectToGPRS (const char * apn, const char * gprsUser, const char * gprsPass){
199
+ bool ArduinoCellular::connectToGPRS (const char * apn, const char * gprsUser, const char * gprsPass, bool waitForever ){
200
200
if (this ->debugStream != nullptr ){
201
201
this ->debugStream ->println (" Connecting to 4G network..." );
202
202
}
203
203
while (!modem.gprsConnect (apn, gprsUser, gprsPass)) {
204
+
205
+ if (!waitForever) {
206
+ return false ;
207
+ }
208
+
204
209
if (this ->debugStream != nullptr ){
205
210
this ->debugStream ->print (" ." );
206
211
}
@@ -252,7 +257,7 @@ bool ArduinoCellular::awaitNetworkRegistration(bool waitForever){
252
257
this ->debugStream ->println (" Waiting for network registration..." );
253
258
}
254
259
while (!modem.waitForNetwork (waitForNetworkTimeout)) {
255
-
260
+
256
261
if (!waitForever) {
257
262
return false ;
258
263
}
0 commit comments