Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCPConnect timeout #1

Closed
geologic opened this issue May 16, 2017 · 5 comments
Closed

TCPConnect timeout #1

geologic opened this issue May 16, 2017 · 5 comments

Comments

@geologic
Copy link

Hi
First time i connect SIM800 it fails sending message, because SIM800 needs time to settle and open TCP connection. The folowing times it connects ok.
I tried add a timeout on the SIM800.CPP TCPConnect() function at:

  if (! expectReply(ok_reply),5000) return false;
  if (! expectReply(F("CONNECT OK")),5000) return false;

but after that it always fails.
Can you help?

Regards

@brianrho
Copy link
Owner

brianrho commented May 16, 2017

You mean that with the original code, the SIM800 fails to connect the very first time but succeeds in subsequent retries?
Did you follow the modem_client example, by preceding TCPconnect() with

modem.setGPRSNetworkSettings(F("your apn"));
modem.enableGPRS(true);

@geologic
Copy link
Author

geologic commented May 17, 2017 via email

@geologic
Copy link
Author

Well, after playing around with your code i notice that you are not checking for success on modem.enableGPRS(), so i did this:

while  ( ! modem.enableGPRS(true)) {
     Serial.println(F("enableGPRS Retry..."));
    delay(1000);
}

@brianrho
Copy link
Owner

The default timeout period was good enough for me and this issue never came up. If it worked for you though, perhaps I'll edit the example.

@brianrho
Copy link
Owner

I think I'll leave out the check since looking through the method's code now, the timeout for each command sent is at least 10s, more than enough in most cases to get the job done and the whole point of encapsulating the commands+reasonable timeouts under one method is to prevent this kind of check from popping up everywhere in application code. Yours is a special case, I think, and I'll leave it up to the user to insert checks as necessary, like you did. It's only an example after all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants