From 796b4c705c345aed9a15e550c34d653a47fb6f01 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Fri, 29 Aug 2025 19:47:24 +1200 Subject: [PATCH] disconnect existing wifi client when new connection established --- src/helpers/esp32/SerialWifiInterface.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/helpers/esp32/SerialWifiInterface.cpp b/src/helpers/esp32/SerialWifiInterface.cpp index e7dc055e..2df9980a 100644 --- a/src/helpers/esp32/SerialWifiInterface.cpp +++ b/src/helpers/esp32/SerialWifiInterface.cpp @@ -44,7 +44,18 @@ bool SerialWifiInterface::isWriteBusy() const { } size_t SerialWifiInterface::checkRecvFrame(uint8_t dest[]) { - if (!client) client = server.available(); + // check if new client connected + auto newClient = server.available(); + if (newClient) { + + // disconnect existing client + deviceConnected = false; + client.stop(); + + // switch active connection to new client + client = newClient; + + } if (client.connected()) { if (!deviceConnected) {