mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
add function peekBytes to WiFiClient/WiFiClientSecure to allow to peek multiple bytes if possible
This commit is contained in:
@ -239,6 +239,27 @@ int WiFiClient::peek()
|
||||
return _client->peek();
|
||||
}
|
||||
|
||||
size_t WiFiClient::peekBytes(uint8_t *buffer, size_t length) {
|
||||
size_t count = 0;
|
||||
|
||||
if(!_client) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
_startMillis = millis();
|
||||
while((available() < (int) length) && ((millis() - _startMillis) < _timeout)) {
|
||||
yield();
|
||||
}
|
||||
|
||||
if(available() < (int) length) {
|
||||
count = available();
|
||||
} else {
|
||||
count = length;
|
||||
}
|
||||
|
||||
return _client->peekBytes((char *)buffer, count);
|
||||
}
|
||||
|
||||
void WiFiClient::flush()
|
||||
{
|
||||
if (_client)
|
||||
|
Reference in New Issue
Block a user