From c8c68381d6a39dc65c76fc88a65cf1526ec257a1 Mon Sep 17 00:00:00 2001 From: Russ Butler Date: Thu, 29 Nov 2018 16:19:04 -0600 Subject: [PATCH] Fix ESP8266 recv_udp timeout with flow control UDP packets are always received as OOB data. Without checking for new OOB data with a call to "_process_oob" then recv_udp never blocks. If a UDP packet is not available then NSAPI_ERROR_WOULD_BLOCK is returned. This causes mbed-os's DNS handling to always fail when flow control is enabled. This patch fixes recv_udp by always calling "_process_oob" regardless of if flow control is enabled. This ensures that recv_udp follows the timeout parameter and waits for new data to arrive. --- components/wifi/esp8266-driver/ESP8266/ESP8266.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp b/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp index bcddc4a2d1..61ae9839bc 100644 --- a/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp +++ b/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp @@ -782,10 +782,9 @@ int32_t ESP8266::recv_udp(int id, void *data, uint32_t amount, uint32_t timeout) _smutex.lock(); set_timeout(timeout); - // No flow control, drain the USART receive register ASAP to avoid data overrun - if (_serial_rts == NC) { - _process_oob(timeout, true); - } + // Process OOB data since this is + // how UDP packets are received + _process_oob(timeout, true); set_timeout();