1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2025-03-13 17:43:08 +01:00

Renamed Enum value UDP to UDPR because of class name clash

This commit is contained in:
Gregor Baues 2020-11-09 17:00:24 +01:00
parent 0eb902f169
commit 6d7d01b1b5
8 changed files with 41 additions and 38 deletions

View File

@ -80,7 +80,7 @@ void setup()
// wifi.setup(WIFI, TCP, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME));
// wifi.setup(WIFI, TCP, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME, 2323)
eth1.setup(ETHERNET, UDP); // ETHERNET, UDP on Port 2560
eth1.setup(ETHERNET, UDPR); // ETHERNET, UDP on Port 2560
// eth1.setup(ETHERNET, TCP); // ETHERNET, UDP on Port 2560
eth2.setup(ETHERNET, TCP, 23); // ETHERNET, TCP on Port 23 for the CLI
// eth1.setup(ETHERNET, TCP, 8888); // ETHERNET, TCP on Port 8888

View File

@ -61,7 +61,7 @@ byte EthernetSetup::setup()
INFO(F("Network Protocol: [%s]"), protocol ? "UDP" : "TCP");
switch (protocol)
{
case UDP:
case UDPR:
{
udp = new EthernetUDP();
byte udpState = udp->begin(port);

View File

@ -25,7 +25,7 @@
typedef enum protocolType {
TCP,
UDP,
UDPR, // UDP clashes with a class name in the network stack
MQTT
} protocolType;

View File

@ -42,7 +42,7 @@ template<class S, class C, class U>
void Transport<S,C,U>::loop() {
switch (protocol)
{
case UDP:
case UDPR:
{
udpHandler(udp);
break;
@ -106,14 +106,14 @@ void Transport<S, C, U>::udpHandler(U* udp)
udp->read(t->buffer, MAX_ETH_BUFFER);
t->buffer[packetSize] = 0; // terminate buffer
t->readStream(&connections[0], false); // there is only one connection for UDP; reading into the buffer has been done
t->readStream(&connections[0], false ); // there is only one connection for UDP; reading into the buffer has been done
memset(t->buffer, 0, MAX_ETH_BUFFER); // reset PacktBuffer
return;
// send the reply
// udp.beginPacket(udp.remoteIP(), udp.remotePort());
// parse(&udp, (byte *)buffer, true); //////////// Put into the TransportProcessor
// parse(&udp, (byte *)buffer, true); //////////// Put into the TransportProcessor Attn the default udp TX buffer on ethernet is 24 on wifi its 256 ??
// udp.endPacket();
}
return;

View File

@ -27,6 +27,36 @@
#include "NetworkInterface.h"
#include "TransportProcessor.h"
typedef enum
{
DCCEX, // if char[0] = < opening bracket the client should be a JMRI / DCC EX client_h
WITHROTTLE, //
HTTP, // If char[0] = G || P || D; if P then char [1] = U || O || A
N_DIAG, // '#' send form a telnet client as FIRST message will then reroute all DIAG messages to that client whilst being able to send jmri type commands
UNKNOWN_PROTOCOL
} appProtocol;
// Needed forward declarations
struct Connection;
class TransportProcessor;
using appProtocolCallback = void (*)(Connection* c, TransportProcessor* t);
struct Connection
{
uint8_t id; // initalized when the pool is setup
Client *client; // idem
char overflow[MAX_OVERFLOW]; // idem
appProtocol p; // dynamically determined upon message reception; first message wins
char delimiter = '\0'; // idem
bool isProtocolDefined = false; // idem
appProtocolCallback appProtocolHandler; // idem
};
template <class S, class C, class U> class Transport: public AbstractTransport
{
@ -34,7 +64,7 @@ private:
C clients[MAX_SOCK_NUM]; // Client objects created by the connectionPool
Connection connections[MAX_SOCK_NUM]; // All the connections build by the connectionPool
bool connected = false;
TransportProcessor* t; // pointer to the object which handles the incomming flow
TransportProcessor* t; // pointer to the object which handles the incomming/outgoing flow
void udpHandler(U* udp); // Reads from a Udp socket - todo add incomming queue for processing when the flow is faster than we can process commands
void tcpSessionHandler(S* server); // tcpSessionHandler -> connections are maintained open until close by the client
@ -42,6 +72,7 @@ private:
void connectionPool(U* udp); // allocates the UDP Sockets at setup time and creates the Connection
public:
uint8_t id;
uint16_t port;
uint8_t protocol; // TCP or UDP

View File

@ -66,8 +66,6 @@ void sendWiThrottleToDCC(Connection *c, TransportProcessor *t, bool blocking)
// STRINGIFY(__FILE__);
DBG(F("WiThrottle [%x:%x] parsing: [%e]"), wt, _buffer, t->command);
wt->parse(&streamer, (byte *)t->command); // get the response; not all commands will produce a reply
if (streamer.count() != -1)
{

View File

@ -24,37 +24,11 @@
#include <WiFiEspAT.h>
#include "RingStream.h"
#include "Transport.h"
#include "NetworkConfig.h"
#include "NetworkInterface.h"
typedef enum
{
DCCEX, // if char[0] = < opening bracket the client should be a JMRI / DCC EX client_h
WITHROTTLE, //
HTTP, // If char[0] = G || P || D; if P then char [1] = U || O || A
N_DIAG, // '#' send form a telnet client as FIRST message will then reroute all DIAG messages to that client whilst being able to send jmri type commands
UNKNOWN_PROTOCOL
} appProtocol;
// Needed forward declarations
struct Connection;
class TransportProcessor;
using appProtocolCallback = void (*)(Connection* c, TransportProcessor* t);
struct Connection
{
uint8_t id; // initalized when the pool is setup
Client *client; // idem
char overflow[MAX_OVERFLOW]; // idem
appProtocol p; // dynamically determined upon message reception; first message wins
char delimiter = '\0'; // idem
bool isProtocolDefined = false; // idem
appProtocolCallback appProtocolHandler; // idem
};
class TransportProcessor
{
private:

View File

@ -44,7 +44,7 @@ bool WifiSetup::setup() {
switch (protocol)
{
case UDP:
case UDPR:
{
INFO(F("\nUDP over Wifi is not yet supported\n"));
connected = false;
@ -97,7 +97,7 @@ bool WifiSetup::setup() {
dnsip = WiFi.dnsServer1();
INFO(F("DNS server IP address: [%d.%d.%d.%d] "), dnsip[0], dnsip[1], dnsip[2], dnsip[3]);
INFO(F("Number of connections: [%d]"), maxConnections);
if( protocol == UDP ) return 0; // no server here as we use UDP
if( protocol == UDPR ) return 0; // no server here as we use UDP
return true;
}
// something went wrong