From f9d724c09e5190c1bbfb6b39b6ff4aa8a649a421 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Wed, 10 Aug 2022 15:24:08 -0700 Subject: [PATCH] Fix retries after successful connection. We may have set retries to 0 to enforce a timeout but the connect succeeded. When it succeeds, we want to allow retries later in case we lose signal briefly. (The callback will do this too but the connect function will override it after.) Also, remove extra code from websocket that is leftover from debugging. --- ports/espressif/common-hal/wifi/Radio.c | 3 +++ supervisor/shared/web_workflow/websocket.c | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/espressif/common-hal/wifi/Radio.c b/ports/espressif/common-hal/wifi/Radio.c index 545af1d6cb..8616501ba2 100644 --- a/ports/espressif/common-hal/wifi/Radio.c +++ b/ports/espressif/common-hal/wifi/Radio.c @@ -336,6 +336,9 @@ wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t return WIFI_RADIO_ERROR_NO_AP_FOUND; } return self->last_disconnect_reason; + } else { + // We're connected, allow us to retry if we get disconnected. + self->retries_left = self->starting_retries; } return WIFI_RADIO_ERROR_NONE; } diff --git a/supervisor/shared/web_workflow/websocket.c b/supervisor/shared/web_workflow/websocket.c index bb5f5b43d0..79f1a63d7e 100644 --- a/supervisor/shared/web_workflow/websocket.c +++ b/supervisor/shared/web_workflow/websocket.c @@ -248,9 +248,6 @@ static void _websocket_send(_websocket *ws, const char *text, size_t len) { _send_raw(&ws->socket, extended_len, 4); } _send_raw(&ws->socket, (const uint8_t *)text, len); - char copy[len]; - memcpy(copy, text, len); - copy[len] = '\0'; } void websocket_write(const char *text, size_t len) {