vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.91k stars 713 forks source link

[SIM800] WaitforNetwork doesn't actually wait for a network connection #25

Closed SRGDamia1 closed 6 years ago

SRGDamia1 commented 7 years ago

When I run waitForNetwork(), I expect that it will and keep trying until a connection is made. But it seems to be making one attempt to get the network status and then just returning false. In the code, I think the for loop of waitForNetwork() should actually be a while loop instead. Am I doing something wrong?

Serial.println(F("Waiting for network..."));  // For debugging
if (!_modem->waitForNetwork()){
  Serial.println("... Connection failed");  // For debugging
} else {
   _modem->gprsConnect(_APN, "", "");
}
SRGDamia1 commented 7 years ago

I'm sorry. I think it's actually an extra return statement. PR issued.

vshymanskyy commented 6 years ago

Fixed. Thank you! See your PR for more comments.