From 041a6534da3c73693b232521096b7bda9fdd0717 Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Sun, 24 Dec 2023 12:03:42 +0100 Subject: [PATCH] more diag and inUse tests --- WifiESP32.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/WifiESP32.cpp b/WifiESP32.cpp index f0a857f..ab5274b 100644 --- a/WifiESP32.cpp +++ b/WifiESP32.cpp @@ -80,16 +80,15 @@ public: }; bool recycle(WiFiClient c) { - if (inUse == true) return false; - - // return false here until we have - // implemented a LRU timer - // if (LRU too recent) return false; + if (wifi == c) { + if (inUse == true) + DIAG(F("WARNING: Duplicate")); + else + DIAG(F("Returning")); + inUse = true; + return true; + } return false; - - wifi = c; - inUse = true; - return true; }; WiFiClient wifi; bool inUse = true; @@ -299,14 +298,14 @@ void WifiESP::loop() { while (client = server->available()) { for (clientId=0; clientId=clients.size()) { NetworkClient nc(client); clients.push_back(nc); - DIAG(F("New client %d, %s"), clientId, client.remoteIP().toString().c_str()); + DIAG(F("New client %d, %s:%d"), clientId, client.remoteIP().toString().c_str(),client.remotePort()); } } }