Skip to content

Commit dd5ec81

Browse files
committed
propagate waitForever flag to connectToGPRS
1 parent 8efd7f4 commit dd5ec81

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/ArduinoCellular.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ bool ArduinoCellular::connect(String apn, String username, String password, bool
7878
return true;
7979
}
8080

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)){
8282
auto response = this->sendATCommand("+QIDNSCFG=1,\"8.8.8.8\",\"8.8.4.4\"");
8383

8484
if(response.indexOf("OK") != -1){
@@ -187,11 +187,16 @@ bool ArduinoCellular::isConnectedToOperator(){
187187
return modem.isNetworkConnected();
188188
}
189189

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){
191191
if(this->debugStream != nullptr){
192192
this->debugStream->println("Connecting to 4G network...");
193193
}
194194
while(!modem.gprsConnect(apn, gprsUser, gprsPass)) {
195+
196+
if(!waitForever) {
197+
return false;
198+
}
199+
195200
if(this->debugStream != nullptr){
196201
this->debugStream->print(".");
197202
}
@@ -243,7 +248,7 @@ bool ArduinoCellular::awaitNetworkRegistration(bool waitForever){
243248
this->debugStream->println("Waiting for network registration...");
244249
}
245250
while (!modem.waitForNetwork(waitForNetworkTimeout)) {
246-
251+
247252
if(!waitForever) {
248253
return false;
249254
}

src/ArduinoCellular.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ class ArduinoCellular {
276276
SimStatus getSimStatus();
277277

278278
private:
279-
bool connectToGPRS(const char * apn, const char * gprsUser, const char * gprsPass);
280-
279+
bool connectToGPRS(const char * apn, const char * gprsUser, const char * gprsPass, bool waitForever = true);
281280

282281
/**
283282
* @brief Waits for network registration. (Blocking call)

0 commit comments

Comments
 (0)