@@ -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 ){
@@ -187,11 +187,16 @@ bool ArduinoCellular::isConnectedToOperator(){
187
187
return modem.isNetworkConnected ();
188
188
}
189
189
190
- bool ArduinoCellular::connectToGPRS (const char * apn, const char * gprsUser, const char * gprsPass){
190
+ bool ArduinoCellular::connectToGPRS (const char * apn, const char * gprsUser, const char * gprsPass, bool waitForever ){
191
191
if (this ->debugStream != nullptr ){
192
192
this ->debugStream ->println (" Connecting to 4G network..." );
193
193
}
194
194
while (!modem.gprsConnect (apn, gprsUser, gprsPass)) {
195
+
196
+ if (!waitForever) {
197
+ return false ;
198
+ }
199
+
195
200
if (this ->debugStream != nullptr ){
196
201
this ->debugStream ->print (" ." );
197
202
}
@@ -243,7 +248,7 @@ bool ArduinoCellular::awaitNetworkRegistration(bool waitForever){
243
248
this ->debugStream ->println (" Waiting for network registration..." );
244
249
}
245
250
while (!modem.waitForNetwork (waitForNetworkTimeout)) {
246
-
251
+
247
252
if (!waitForever) {
248
253
return false ;
249
254
}
0 commit comments