From 9a3c9a30b315169e42fa09c106ac382bcbf38c35 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Thu, 10 Jan 2019 12:18:26 +0200 Subject: [PATCH 1/2] [ESP8266] Drop signalling SIGIO artificially if UDP send fails With TCP it's desirable that SIGIO wakes up the application to check if there is buffer space space available on the mode. With UDP the behavior is not acceptable as we don't know if the other endpoint is there as connection establishment is missing. Hence buffers might stay full forever. --- components/wifi/esp8266-driver/ESP8266Interface.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/wifi/esp8266-driver/ESP8266Interface.cpp b/components/wifi/esp8266-driver/ESP8266Interface.cpp index 72c9a7fd07..e49f8ffabd 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.cpp +++ b/components/wifi/esp8266-driver/ESP8266Interface.cpp @@ -505,9 +505,11 @@ int ESP8266Interface::socket_send(void *handle, const void *data, unsigned size) } while ((sendStartTime - rtos::Kernel::get_ms_count() < 50) && (status != NSAPI_ERROR_OK)); - if (status == NSAPI_ERROR_WOULD_BLOCK) { + if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_TCP) { debug("Enqueuing the event call"); _global_event_queue->call_in(100, callback(this, &ESP8266Interface::event)); + } else if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_UDP) { + status = NSAPI_ERROR_DEVICE_ERROR; } return status != NSAPI_ERROR_OK ? status : size; From e9ceff24504afba3342ebca38c762213c4af4027 Mon Sep 17 00:00:00 2001 From: Veijo Pesonen Date: Thu, 10 Jan 2019 12:32:53 +0200 Subject: [PATCH 2/2] [ESP8266] fixes a debug print --- components/wifi/esp8266-driver/ESP8266Interface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/wifi/esp8266-driver/ESP8266Interface.cpp b/components/wifi/esp8266-driver/ESP8266Interface.cpp index e49f8ffabd..e64e617de6 100644 --- a/components/wifi/esp8266-driver/ESP8266Interface.cpp +++ b/components/wifi/esp8266-driver/ESP8266Interface.cpp @@ -506,7 +506,7 @@ int ESP8266Interface::socket_send(void *handle, const void *data, unsigned size) && (status != NSAPI_ERROR_OK)); if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_TCP) { - debug("Enqueuing the event call"); + tr_debug("ESP8266Interface::socket_send(): enqueuing the event call"); _global_event_queue->call_in(100, callback(this, &ESP8266Interface::event)); } else if (status == NSAPI_ERROR_WOULD_BLOCK && socket->proto == NSAPI_UDP) { status = NSAPI_ERROR_DEVICE_ERROR;