From e6797d1095a9ee7ee3344277187e6f56e9ce53ab Mon Sep 17 00:00:00 2001 From: travis-farmer Date: Sat, 4 Nov 2023 07:36:23 -0400 Subject: [PATCH] Giga wifi works for 3 clients MAX --- Wifi_NINA.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Wifi_NINA.cpp b/Wifi_NINA.cpp index 5f8048d..ea970f3 100644 --- a/Wifi_NINA.cpp +++ b/Wifi_NINA.cpp @@ -49,7 +49,7 @@ #else #warning "WiFiNINA has no SPI port or pin allocations for this archiecture yet!" #endif -#define MAX_CLIENTS 4 +#define MAX_CLIENTS 10 /*class NetworkClient { public: NetworkClient(WiFiClient c) { @@ -80,7 +80,6 @@ static WiFiServer *server = NULL; static RingStream *outboundRing = new RingStream(10240); static bool APmode = false; static IPAddress ip; - // #ifdef WIFI_TASK_ON_CORE0 // void wifiLoop(void *){ // for(;;){ @@ -370,14 +369,14 @@ const char *wlerror[] = { } }*/ -WiFiClient clients[MAX_CLIENTS]; // nulled in setup +WiFiClient * clients[MAX_CLIENTS]; // nulled in setup void WifiNINA::checkForNewClient() { auto newClient=server->available(); if (!newClient) return; for (byte clientId=0; clientIdconnected()) { + clients[clientId]->stop(); DIAG(F("Remove client %d"), clientId); CommandDistributor::forget(clientId); //delete c; //TJF: this causes a crash when client drops.. commenting out for now. - //clients[clientId]=NULL; // TJF: what to do... what to do... + clients[clientId]=nullptr; // TJF: what to do... what to do... } } } @@ -401,11 +401,11 @@ void WifiNINA::checkForClientInput() { for (byte clientId=0; clientIdavailable(); if (len) { // read data from client byte cmd[len+1]; - for(int i=0; iread(); cmd[len]=0; CommandDistributor::parse(clientId,cmd,outboundRing); } @@ -431,7 +431,7 @@ void WifiNINA::checkForClientOutput() { DIAG(F("send message")); //TJF: only for diag //TJF: the old code had to add a 0x00 byte to the end to terminate the //TJF: c string, before sending it. i take it this is not needed? - for (int i=0;iread()); + for (int i=0;iwrite(outboundRing->read()); } void WifiNINA::loop() {