From 3fe32be5b59dc67a6806ce557b8dfd570c225247 Mon Sep 17 00:00:00 2001 From: pennam Date: Wed, 16 Oct 2024 10:57:37 +0200 Subject: [PATCH] [TEMP] MbedClient: retry write if modem returns NSAPI_ERROR_WOULD_BLOCK This should be handled in modem driver because it was intentionally removed in https://github.com/arduino/ArduinoCore-mbed/pull/906 --- libraries/SocketWrapper/src/MbedClient.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libraries/SocketWrapper/src/MbedClient.cpp b/libraries/SocketWrapper/src/MbedClient.cpp index f50ff18b7..a42401e57 100644 --- a/libraries/SocketWrapper/src/MbedClient.cpp +++ b/libraries/SocketWrapper/src/MbedClient.cpp @@ -210,7 +210,10 @@ size_t arduino::MbedClient::write(const uint8_t *buf, size_t size) { return 0; sock->set_timeout(_timeout); - int ret = sock->send(buf, size); + int ret = NSAPI_ERROR_WOULD_BLOCK; + do { + ret = sock->send(buf, size); + } while ((ret != size && ret == NSAPI_ERROR_WOULD_BLOCK) && connected()); sock->set_blocking(false); return ret >= 0 ? ret : 0; }