1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 12:51:24 +01:00

Variable number of TCP clients

This commit is contained in:
Harald Barth 2024-11-04 17:28:51 +01:00
parent 657fb7009c
commit 701f4e852f
5 changed files with 26 additions and 5 deletions

View File

@ -56,8 +56,7 @@ template<typename... Targs> 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

View File

@ -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);

View File

@ -45,7 +45,7 @@
#include <lwip/netif.h>
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

View File

@ -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
/////////////////////////////////////////////////////////////////////////////////////
//

View File

@ -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