Skip to content

Commit b5d091f

Browse files
committed
wificlient can override setTimeout
1 parent cc1951a commit b5d091f

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

libraries/ESP8266WiFi/src/WiFiClient.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size)
216216
{
217217
return 0;
218218
}
219-
_client->setTimeout(_timeout);
220219
return _client->write((const char*)buf, size);
221220
}
222221

@@ -229,7 +228,6 @@ size_t WiFiClient::write(Stream& stream)
229228
return 0;
230229
}
231230
// core up to 2.7.4 was equivalent to this
232-
_client->setTimeout(_timeout);
233231
return stream.sendAll(this);
234232
}
235233

@@ -239,7 +237,6 @@ size_t WiFiClient::write_P(PGM_P buf, size_t size)
239237
{
240238
return 0;
241239
}
242-
_client->setTimeout(_timeout);
243240
StreamConstPtr nopeek(buf, size);
244241
return nopeek.sendAll(this);
245242
}
@@ -267,13 +264,11 @@ int WiFiClient::read()
267264

268265
int WiFiClient::read(uint8_t* buf, size_t size)
269266
{
270-
_client->setTimeout(_timeout);
271267
return (int)_client->read((char*)buf, size);
272268
}
273269

274270
int WiFiClient::read(char* buf, size_t size)
275271
{
276-
_client->setTimeout(_timeout);
277272
return (int)_client->read(buf, size);
278273
}
279274

@@ -282,7 +277,6 @@ int WiFiClient::peek()
282277
if (!available())
283278
return -1;
284279

285-
_client->setTimeout(_timeout);
286280
return _client->peek();
287281
}
288282

@@ -304,7 +298,6 @@ size_t WiFiClient::peekBytes(uint8_t *buffer, size_t length) {
304298
count = length;
305299
}
306300

307-
_client->setTimeout(_timeout);
308301
return _client->peekBytes((char *)buffer, count);
309302
}
310303

@@ -459,7 +452,6 @@ const char* WiFiClient::peekBuffer ()
459452
// return number of byte accessible by peekBuffer()
460453
size_t WiFiClient::peekAvailable ()
461454
{
462-
_client->setTimeout(_timeout);
463455
return _client? _client->peekAvailable(): 0;
464456
}
465457

@@ -469,3 +461,10 @@ void WiFiClient::peekConsume (size_t consume)
469461
if (_client)
470462
_client->peekConsume(consume);
471463
}
464+
465+
void WiFiClient::setTimeout(uint16_t timeout) {
466+
_timeout = timeout;
467+
if (_client) {
468+
_client->setTimeout(timeout);
469+
}
470+
}

libraries/ESP8266WiFi/src/WiFiClient.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class WiFiClient : public Client, public SList<WiFiClient> {
9696
virtual IPAddress localIP();
9797
virtual uint16_t localPort();
9898

99+
void setTimeout(uint16_t);
100+
99101
static void setLocalPortStart(uint16_t port) { _localPort = port; }
100102

101103
int availableForWrite() override;

0 commit comments

Comments
 (0)