Skip to content
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

Revert 8541 wifi client fix #267

Merged
Merged
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
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/Issue-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 20 additions & 8 deletions libraries/WiFi/src/WiFiClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,6 @@ class WiFiClientRxBuffer {
size_t available(){
return _fill - _pos + r_available();
}

void flush(){
if(r_available()){
fillBuffer();
}
_pos = _fill;
}
};

class WiFiClientSocketHandle {
Expand Down Expand Up @@ -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()
Expand Down