mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Fix WiFiUDP::peek return value when buffer is empty (#1796)
This commit is contained in:
parent
213914e1ce
commit
19e97bfe15
@ -236,7 +236,7 @@ int WiFiUDP::read(unsigned char* buffer, size_t len)
|
|||||||
int WiFiUDP::peek()
|
int WiFiUDP::peek()
|
||||||
{
|
{
|
||||||
if (!_ctx)
|
if (!_ctx)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
return _ctx->peek();
|
return _ctx->peek();
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ public:
|
|||||||
|
|
||||||
int read()
|
int read()
|
||||||
{
|
{
|
||||||
if (!_rx_buf || _rx_buf->len == _rx_buf_offset)
|
if (!_rx_buf || _rx_buf_offset == _rx_buf->len)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
char c = reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
|
char c = reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
|
||||||
@ -215,8 +215,8 @@ public:
|
|||||||
|
|
||||||
char peek()
|
char peek()
|
||||||
{
|
{
|
||||||
if (!_rx_buf)
|
if (!_rx_buf || _rx_buf_offset == _rx_buf->len)
|
||||||
return 0;
|
return -1;
|
||||||
|
|
||||||
return reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
|
return reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user