From e0aa16ff2cbdd243aa80c831951e14e824b9b9cc Mon Sep 17 00:00:00 2001 From: Harald Barth Date: Thu, 5 Dec 2024 22:03:55 +0100 Subject: [PATCH] adjust max default TCP clients to 9 because of bug in LwIP --- STM32lwipopts.h | 10 +++++++++- config.example.h | 5 ++++- defines.h | 10 ++++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/STM32lwipopts.h b/STM32lwipopts.h index 8347b66..d5e23c5 100644 --- a/STM32lwipopts.h +++ b/STM32lwipopts.h @@ -29,7 +29,15 @@ // we can not include our "defines.h" here // so we need to duplicate that define -#define MAX_NUM_TCP_CLIENTS 20 +#define MAX_NUM_TCP_CLIENTS_HERE 9 + +#ifdef MAX_NUM_TCP_CLIENTS + #if MAX_NUM_TCP_CLIENTS != MAX_NUM_TCP_CLIENTS_HERE + #error MAX_NUM_TCP_CLIENTS and MAX_NUM_TCP_CLIENTS_HERE must be same + #endif +#else + #define MAX_NUM_TCP_CLIENTS MAX_NUM_TCP_CLIENTS_HERE +#endif // increase ARP cache #undef MEMP_NUM_APR_QUEUE diff --git a/config.example.h b/config.example.h index ff4652f..0108721 100644 --- a/config.example.h +++ b/config.example.h @@ -140,7 +140,10 @@ The configuration file for DCC-EX Command Station ///////////////////////////////////////////////////////////////////////////////////// // // MAX_NUM_TCP_CLIENTS: If you on STM32 Ethernet (and only there) want more than -// 10 TCP clients, enable this here **AND** follow the instructions in STM32lwiopts.h +// 9 (*) TCP clients, change this number to for example 20 here **AND** in +// STM32lwiopts.h and follow the instructions in STM32lwiopts.h +// +// (*) It would be 10 if there would not be a bug in LwIP by STM32duino. // //#define MAX_NUM_TCP_CLIENTS 20 diff --git a/defines.h b/defines.h index 0cd891f..561ed64 100644 --- a/defines.h +++ b/defines.h @@ -240,9 +240,15 @@ #endif #if defined(ARDUINO_ARCH_STM32) -// Allow override of MAX_NUM_TCP_CLIENTS but default is 10 +// The LwIP library for the STM32 wired ethernet has by default 10 TCP +// clients defined but because of a bug in the library #11 is not +// rejected but kicks out any old connection. By restricting our limit +// to 9 the #10 will be rejected by our code so that the number can +// never get to 11 which would kick an existing connection. +// If you want to change this value, do that in +// config.h AND in STM32lwipopts.h. #ifndef MAX_NUM_TCP_CLIENTS - #define MAX_NUM_TCP_CLIENTS 10 + #define MAX_NUM_TCP_CLIENTS 9 #endif #else #if defined(ARDUINO_ARCH_ESP32)