Skip to content

Add 2 functions to adjust timeout value in WiFiClient.h and WiFiClient.cpp #9073

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,16 @@ void WiFiClient::abort()
_client->abort(); // Wich in turn calls tcp_abort which calls tcp_abandon().
}

// 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);
}

void WiFiClient::stopAll()
{
for (WiFiClient* it = _s_first; it; it = it->_next) {
Expand Down
6 changes: 6 additions & 0 deletions libraries/ESP8266WiFi/src/WiFiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ class WiFiClient : public Client, public SList<WiFiClient> {
// Immediately stops this client instance.
// Unlike stop(), does not wait to gracefuly shutdown the connection.
void abort();

// 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();

protected:

Expand Down