Closed metadaddy closed 9 years ago
Hi,
Thanks a lot for your contribution, but it's better to do it more open for everybody, so we prefer to make the connect function declaration better.
What do you think about:
bool connect(Protocol ptl, const char * host, int port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 * DEFAULT_INTERCHAR_TIMEOUT); bool connect(Protocol ptl, const FlashStringHelper *host, const FlashStringHelper port, int timeout = 2 * DEFAULT_TIMEOUT, int chartimeout = 2 \ DEFAULT_INTERCHAR_TIMEOUT);
And then, change all sim900_read_buffer() calls inside CONNECT functions with "chartimeout" function.
In your sketch you will call like: sim900.connect( XXX, XXX, XXX, 5, 5) or whatever you like.
We prefer that, than putting inside the function this kind of call: "timeout * 1000"
What do you think ?
Best regards
Yes - that makes complete sense - I'll refactor my code as you suggest, test it, and commit the changes if all is good.
@juan3211 Reworked my code as you suggested. Works great for me - in fact, even just using the default value you suggested for chartimeout
(doubling the previous value) works much better.
Thanks. Merged :)
Awesome - thanks!
GPRS::connect()
often failed for me. I found that the SIM900 responds to theAT+CIPSTART
command immediately withOK
, but then takes a couple of seconds to follow up withCONNECT OK
. This delay was more than the default inter-character timeout, sosim900_read_buffer()
would return before it read theCONNECT OK
, andGPRS::connect()
would returnfalse
.Making the inter-character timeout the same as the other timeout parameter fixes this for me.