Skip to content

Commit

Permalink
Fix WiFiUDP::peek return value when buffer is empty (esp8266#1796)
Browse files Browse the repository at this point in the history
  • Loading branch information
igrr committed Mar 23, 2016
1 parent 213914e commit 19e97bf
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion libraries/ESP8266WiFi/src/WiFiUdp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ int WiFiUDP::read(unsigned char* buffer, size_t len)
int WiFiUDP::peek()
{
if (!_ctx)
return 0;
return -1;

return _ctx->peek();
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/ESP8266WiFi/src/include/UdpContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class UdpContext

int read()
{
if (!_rx_buf || _rx_buf->len == _rx_buf_offset)
if (!_rx_buf || _rx_buf_offset == _rx_buf->len)
return -1;

char c = reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
Expand All @@ -215,8 +215,8 @@ class UdpContext

char peek()
{
if (!_rx_buf)
return 0;
if (!_rx_buf || _rx_buf_offset == _rx_buf->len)
return -1;

return reinterpret_cast<char*>(_rx_buf->payload)[_rx_buf_offset];
}
Expand Down

0 comments on commit 19e97bf

Please sign in to comment.