diff --git a/CommandDistributor.cpp b/CommandDistributor.cpp index e889f62..924e0af 100644 --- a/CommandDistributor.cpp +++ b/CommandDistributor.cpp @@ -56,8 +56,7 @@ template void CommandDistributor::broadcastReply(clientType t #ifdef CD_HANDLE_RING // wifi or ethernet ring streams with multiple client types RingStream * CommandDistributor::ring=0; - CommandDistributor::clientType CommandDistributor::clients[8]={ - NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE,NONE_TYPE}; +CommandDistributor::clientType CommandDistributor::clients[MAX_NUM_TCP_CLIENTS]={ NONE_TYPE }; // 0 is and must be NONE_TYPE // Parse is called by Withrottle or Ethernet interface to determine which // protocol the client is using and call the appropriate part of dcc++Ex diff --git a/CommandDistributor.h b/CommandDistributor.h index d86b87f..c1bb7f3 100644 --- a/CommandDistributor.h +++ b/CommandDistributor.h @@ -36,13 +36,13 @@ class CommandDistributor { public: - enum clientType: byte {NONE_TYPE,COMMAND_TYPE,WITHROTTLE_TYPE}; + enum clientType: byte {NONE_TYPE=0,COMMAND_TYPE,WITHROTTLE_TYPE}; private: static void broadcastToClients(clientType type); static StringBuffer * broadcastBufferWriter; #ifdef CD_HANDLE_RING static RingStream * ring; - static clientType clients[8]; + static clientType clients[MAX_NUM_TCP_CLIENTS]; #endif public : static void parse(byte clientId,byte* buffer, RingStream * ring); diff --git a/EthernetInterface.h b/EthernetInterface.h index 16156fa..6cea6e8 100644 --- a/EthernetInterface.h +++ b/EthernetInterface.h @@ -45,7 +45,7 @@ #include extern "C" struct netif gnetif; #define STM32_ETHERNET - #define MAX_SOCK_NUM 8 + #define MAX_SOCK_NUM MAX_NUM_TCP_CLIENTS #else #include "Ethernet.h" #endif diff --git a/config.example.h b/config.example.h index d7dab5e..ff4652f 100644 --- a/config.example.h +++ b/config.example.h @@ -137,6 +137,13 @@ The configuration file for DCC-EX Command Station // //#define ENABLE_ETHERNET true +///////////////////////////////////////////////////////////////////////////////////// +// +// 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 +// +//#define MAX_NUM_TCP_CLIENTS 20 + ///////////////////////////////////////////////////////////////////////////////////// // diff --git a/defines.h b/defines.h index 2c3ee55..0cd891f 100644 --- a/defines.h +++ b/defines.h @@ -239,4 +239,19 @@ #endif #endif +#if defined(ARDUINO_ARCH_STM32) +// Allow override of MAX_NUM_TCP_CLIENTS but default is 10 + #ifndef MAX_NUM_TCP_CLIENTS + #define MAX_NUM_TCP_CLIENTS 10 + #endif +#else + #if defined(ARDUINO_ARCH_ESP32) +// Espressif LWIP stack + #define MAX_NUM_TCP_CLIENTS 10 + #else +// Wifi shields etc + #define MAX_NUM_TCP_CLIENTS 8 + #endif #endif + +#endif //DEFINES_H