diff --git a/.github/ISSUE_TEMPLATE/Issue-report.yml b/.github/ISSUE_TEMPLATE/Issue-report.yml index 3628cba1fca..7e9a8aea4a2 100644 --- a/.github/ISSUE_TEMPLATE/Issue-report.yml +++ b/.github/ISSUE_TEMPLATE/Issue-report.yml @@ -41,6 +41,8 @@ body: options: - latest master (checkout manually) - latest development Release Candidate (RC-X) + - v2.0.13 + - v2.0.12 - v2.0.11 - v2.0.10 - v2.0.9 diff --git a/libraries/WiFi/src/WiFiClient.cpp b/libraries/WiFi/src/WiFiClient.cpp index 85c348327dc..9e2a85f5dea 100644 --- a/libraries/WiFi/src/WiFiClient.cpp +++ b/libraries/WiFi/src/WiFiClient.cpp @@ -153,13 +153,6 @@ class WiFiClientRxBuffer { size_t available(){ return _fill - _pos + r_available(); } - - void flush(){ - if(r_available()){ - fillBuffer(); - } - _pos = _fill; - } }; class WiFiClientSocketHandle { @@ -508,7 +501,26 @@ int WiFiClient::available() // Though flushing means to send all pending data, // seems that in Arduino it also means to clear RX void WiFiClient::flush() { - _rxBuffer->flush(); + int res; + size_t a = available(), toRead = 0; + if(!a){ + return;//nothing to flush + } + uint8_t * buf = (uint8_t *)malloc(WIFI_CLIENT_FLUSH_BUFFER_SIZE); + if(!buf){ + return;//memory error + } + while(a){ + toRead = (a>WIFI_CLIENT_FLUSH_BUFFER_SIZE)?WIFI_CLIENT_FLUSH_BUFFER_SIZE:a; + res = recv(fd(), buf, toRead, MSG_DONTWAIT); + if(res < 0) { + log_e("fail on fd %d, errno: %d, \"%s\"", fd(), errno, strerror(errno)); + stop(); + break; + } + a -= res; + } + free(buf); } uint8_t WiFiClient::connected()