-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Add 2 functions to adjust timeout value in WiFiClient.h and WiFiClient.cpp #9073
Conversation
Add setTimeout( int ) and int getTimeout
Add setTimeout and getTimeout to allow changes of timeout value.
WiFiClient is Stream, so both Stream::setTimeout and Stream::getTimeout are used and this actually hides both. (and with different signatures, too) Arduino/cores/esp8266/Stream.h Lines 68 to 69 in b3b9276
Aren't these enough? Timeout value is used, just not immediately
|
I started a discussion about this, but there were no responses |
doesn't work? |
Yes it works, I made a mistake. But seems only to work for WiFiClient. |
Looking at ESP32 and Ethernet, setConnectionTimeout modifies the same value of https://github.com/arduino-libraries/Ethernet/blob/39103da0e1bc569023625ee4693272773397dbb6/src/Ethernet.h#L242 ESP32 ::connect() also overwrites the member value, so I/O has to setTimeout() or connect() value would be used afterwards Read / write timeouts are sourced from Our implementation in ClientContext::connect can use |
EthernetClient and WiFiClient in esp32 have own |
Badly worded. ESP32 shares the timeout member within the client class, similar to the way we (ab)use Stream::_timeout In case of ESP8266/Ethernet I just noticed an inconsistency, as it seems to only affect connect() and stop(). No mention of timeouts in libraries/LwIP_, it is never used in any hw operations. |
but Stream's blocking methods have they own separate timeout with a different value
that is why it is set with
and that is OK. read() and write() should not block in Arduino. |
Unfortunately it does not work with a WiFiClientSecure. You can put whatever you want, it will not have any effect on _timeout value when using connect. |
Unfortunately it does not work with a WiFiClientSecure. You can put whatever you want, it will not have any effect on _timeout value when using connect method. |
#8899 has yet to be finished |
Thanks for your support. |
Default value of timeout is 5000 ms but currently it can't be changed in case the user think it is inadequate for its application.
For ESP32 we already have the possibility to specifie the timeout value as an argument of the connect function.
The aim of the request is to provide the possibilty to specifie a value for ESP8266 too.
Usage example:
int oldValue = getTimeout();
setTimeout( newValue );
client.connect( args );
setTimeout( oldValue );
WiFiClient.h:
// Default timeout is set to 5000 ms
// setTimeout gives the possibility to adjust this value.
// getTimeout return the timeout current value.
bool setTimeout( int );
int getTimeout();
WiFiClient.cpp:
// In case you need to increase/decrease timeout current value
bool WiFiClient::setTimeout( int timeout_ms )
{
if ( timeout_ms <= 0 || timeout_ms > 3600000 ) return(false); // More than 0 and less than 1 hour
_timeout = timeout_ms;
if (!_client) return(true);
else _client->setTimeout(_timeout);
return(true);
}
int WiFiClient::getTimeout()
{
return( _timeout );
}