From e0d32c9f45f5a8ab6b84172d0cd171aa8c48d173 Mon Sep 17 00:00:00 2001 From: jayjayuk Date: Sat, 12 Dec 2015 23:52:19 +0000 Subject: [PATCH] ESP8266::recv - speed optimisation function was entering while loop and timing out even if there was no data available or data was to be sent (probably most of the time). This optimisation uses an IF statement to check if data is available before entering the while loop --- ESP8266.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ESP8266.cpp b/ESP8266.cpp index 47bcc7c..cab229d 100644 --- a/ESP8266.cpp +++ b/ESP8266.cpp @@ -286,6 +286,7 @@ uint32_t ESP8266::recv(uint8_t mux_id, uint8_t *buffer, uint32_t buffer_size, ui uint32_t ESP8266::recv(uint8_t *coming_mux_id, uint8_t *buffer, uint32_t buffer_size, uint32_t timeout) { + if(!m_puart->available()) return 0; // don't enter while loop if there is no serial data available return recvPkg(buffer, buffer_size, NULL, timeout, coming_mux_id); }