From a992035e1099bd344e080704ab649c57b0e26887 Mon Sep 17 00:00:00 2001 From: pmantoine Date: Mon, 22 Jul 2024 10:22:25 +0800 Subject: [PATCH] Bugfix STM32 MAX_SOCK_NUM set to 8 for now --- EthernetInterface.cpp | 16 ++++++++++------ EthernetInterface.h | 5 ++--- version.h | 3 ++- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/EthernetInterface.cpp b/EthernetInterface.cpp index 8e34db8..2fd36f2 100644 --- a/EthernetInterface.cpp +++ b/EthernetInterface.cpp @@ -211,6 +211,8 @@ bool EthernetInterface::checkLink() { } mdns.begin(Ethernet.localIP(), WIFI_HOSTNAME); // hostname mdns.addServiceRecord(WIFI_HOSTNAME "._withrottle", IP_PORT, MDNSServiceTCP); + // Not sure if we need to run it once, but just in case! + mdns.run(); // only create a outboundRing it none exists, this may happen if the cable // gets disconnected and connected again if(!outboundRing) @@ -244,10 +246,14 @@ bool EthernetInterface::checkLink() { } void EthernetInterface::loop2() { - if (!outboundRing) { // no idea to call loop2() if we can't handle outgoing data in it - if (Diag::ETHERNET) DIAG(F("No outboundRing")); - return; - } + if (!outboundRing) { // no idea to call loop2() if we can't handle outgoing data in it + if (Diag::ETHERNET) DIAG(F("No outboundRing")); + return; + } + + // Always do this because we don't want traffic to intefere with being found! + mdns.run(); + // get client from the server #if defined (STM32_ETHERNET) // STM32Ethernet doesn't use accept(), just available() @@ -323,8 +329,6 @@ void EthernetInterface::loop2() { } } - mdns.run(); - WiThrottle::loop(outboundRing); // handle at most 1 outbound transmission diff --git a/EthernetInterface.h b/EthernetInterface.h index 2be42f1..e69aa34 100644 --- a/EthernetInterface.h +++ b/EthernetInterface.h @@ -43,7 +43,7 @@ #include extern "C" struct netif gnetif; #define STM32_ETHERNET - #define MAX_SOCK_NUM 10 + #define MAX_SOCK_NUM 8 #else #include "Ethernet.h" // #define MAX_SOCK_NUM 4 @@ -57,7 +57,6 @@ #define MAX_ETH_BUFFER 512 #define OUTBOUND_RING_SIZE 2048 - class EthernetInterface { public: @@ -76,7 +75,7 @@ class EthernetInterface { struct { EthernetClient client; bool inUse; - } clients[MAX_CLIENT]; + } clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield uint8_t buffer[MAX_ETH_BUFFER+1]; // buffer used by TCP for the recv diff --git a/version.h b/version.h index 56b9640..80e7945 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,8 @@ #include "StringFormatter.h" -#define VERSION "5.3.13" +#define VERSION "5.3.14" +// 5.3.14 - Bugfix: MAX_SOCK_NUM on STM32 for now set to 8 which seems reliable - no doubt some setting in lwip needs tweaking for more // 5.3.13 - Bugfix: refactored the Ethernet client handling code to use an inUse boolean for each client - now works! // 5.2.60 - Bugfix: Opcode AFTEROVERLOAD does not have an argument that is a pin and needs to be initialized // - Remove inrush throttle after half good time so that we go to mode overload if problem persists