From 8214d67e5f31e1b753dd3ac35b9e20289f345fa9 Mon Sep 17 00:00:00 2001 From: Lucian Copeland Date: Fri, 5 Feb 2021 13:14:49 -0500 Subject: [PATCH 1/2] Fix LWIP connect error report --- ports/esp32s2/common-hal/socketpool/Socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index cee940aafc..b6a4e04f04 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -181,7 +181,7 @@ bool common_hal_socketpool_socket_connect(socketpool_socket_obj_t* self, opts = opts | O_NONBLOCK; lwip_fcntl(self->num, F_SETFL, opts); - if (result) { + if (result >= 0) { self->connected = true; return true; } else { From 6be2466d6fa1cd6e9ea9c0d3e9cb0879e733c626 Mon Sep 17 00:00:00 2001 From: Neradoc Date: Sun, 7 Feb 2021 08:57:19 +0100 Subject: [PATCH 2/2] ESP32S2: Socket.recv_into only took len-1 bytes --- ports/esp32s2/common-hal/socketpool/Socket.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ports/esp32s2/common-hal/socketpool/Socket.c b/ports/esp32s2/common-hal/socketpool/Socket.c index b6a4e04f04..1cdbc90584 100644 --- a/ports/esp32s2/common-hal/socketpool/Socket.c +++ b/ports/esp32s2/common-hal/socketpool/Socket.c @@ -256,7 +256,7 @@ mp_uint_t common_hal_socketpool_socket_recv_into(socketpool_socket_obj_t* self, timed_out = supervisor_ticks_ms64() - start_ticks >= self->timeout_ms; } RUN_BACKGROUND_TASKS; - received = lwip_recv(self->num, (void*) buf, len - 1, 0); + received = lwip_recv(self->num, (void*) buf, len, 0); // In non-blocking mode, fail instead of looping if (received == -1 && self->timeout_ms == 0) {