From a0c975dfbce684695c1011e2462df303651fbb87 Mon Sep 17 00:00:00 2001 From: dyarkovoy Date: Wed, 10 Apr 2019 03:41:29 +0300 Subject: [PATCH] Reset retry counter upon successful write (#2638) Currently WiFiClient::write is unable to send messages over 25Kb, because of the hard-coded retry limit of 10, that is getting decremented on every successful send. Since we cannot send more than 2*MTU bytes in one go, and have only 10 retries, write() is limited to approximately 25Kb. Technically it is not a bug, as it correctly returns the number of sent bytes and the caller can set up futher retries. But not all libs are aware of this behavior, for example, WebServer is not. I suggest improving current behavior by resetting retry counter every time we had a successful write, so the limit of 10 retries will apply to Failed writes only, and will not apply to Successful writes. This will allow to write() blobs of arbitrary sizes. --- libraries/WiFi/src/WiFiClient.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index 359e90b8..77aa9ae5 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -358,6 +358,7 @@ size_t WiFiClient::write(const uint8_t *buf, size_t size) } else { buf += res; bytesRemaining -= res; + retry = WIFI_CLIENT_MAX_WRITE_RETRY; } } else if(res < 0) {