From 53ed3f5c3d4450b6498e8039b7e2e0274440bd05 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 f147e65e22..e38928355a 100644 --- a/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp +++ b/components/wifi/esp8266-driver/ESP8266/ESP8266.cpp @@ -755,10 +755,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();