mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-03-14 18:13:09 +01:00
Renamed Enum value UDP to UDPR because of class name clash
This commit is contained in:
parent
0eb902f169
commit
6d7d01b1b5
@ -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));
|
||||||
// wifi.setup(WIFI, TCP, F(WIFI_SSID), F(WIFI_PASSWORD), F(WIFI_HOSTNAME, 2323)
|
// 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
|
// eth1.setup(ETHERNET, TCP); // ETHERNET, UDP on Port 2560
|
||||||
eth2.setup(ETHERNET, TCP, 23); // ETHERNET, TCP on Port 23 for the CLI
|
eth2.setup(ETHERNET, TCP, 23); // ETHERNET, TCP on Port 23 for the CLI
|
||||||
// eth1.setup(ETHERNET, TCP, 8888); // ETHERNET, TCP on Port 8888
|
// eth1.setup(ETHERNET, TCP, 8888); // ETHERNET, TCP on Port 8888
|
||||||
|
@ -61,7 +61,7 @@ byte EthernetSetup::setup()
|
|||||||
INFO(F("Network Protocol: [%s]"), protocol ? "UDP" : "TCP");
|
INFO(F("Network Protocol: [%s]"), protocol ? "UDP" : "TCP");
|
||||||
switch (protocol)
|
switch (protocol)
|
||||||
{
|
{
|
||||||
case UDP:
|
case UDPR:
|
||||||
{
|
{
|
||||||
udp = new EthernetUDP();
|
udp = new EthernetUDP();
|
||||||
byte udpState = udp->begin(port);
|
byte udpState = udp->begin(port);
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
typedef enum protocolType {
|
typedef enum protocolType {
|
||||||
TCP,
|
TCP,
|
||||||
UDP,
|
UDPR, // UDP clashes with a class name in the network stack
|
||||||
MQTT
|
MQTT
|
||||||
} protocolType;
|
} protocolType;
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ template<class S, class C, class U>
|
|||||||
void Transport<S,C,U>::loop() {
|
void Transport<S,C,U>::loop() {
|
||||||
switch (protocol)
|
switch (protocol)
|
||||||
{
|
{
|
||||||
case UDP:
|
case UDPR:
|
||||||
{
|
{
|
||||||
udpHandler(udp);
|
udpHandler(udp);
|
||||||
break;
|
break;
|
||||||
@ -113,7 +113,7 @@ void Transport<S, C, U>::udpHandler(U* udp)
|
|||||||
|
|
||||||
// send the reply
|
// send the reply
|
||||||
// udp.beginPacket(udp.remoteIP(), udp.remotePort());
|
// 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();
|
// udp.endPacket();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
33
Transport.h
33
Transport.h
@ -27,6 +27,36 @@
|
|||||||
#include "NetworkInterface.h"
|
#include "NetworkInterface.h"
|
||||||
#include "TransportProcessor.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
|
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
|
C clients[MAX_SOCK_NUM]; // Client objects created by the connectionPool
|
||||||
Connection connections[MAX_SOCK_NUM]; // All the connections build by the connectionPool
|
Connection connections[MAX_SOCK_NUM]; // All the connections build by the connectionPool
|
||||||
bool connected = false;
|
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 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
|
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
|
void connectionPool(U* udp); // allocates the UDP Sockets at setup time and creates the Connection
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
uint8_t id;
|
uint8_t id;
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
uint8_t protocol; // TCP or UDP
|
uint8_t protocol; // TCP or UDP
|
||||||
|
@ -66,8 +66,6 @@ void sendWiThrottleToDCC(Connection *c, TransportProcessor *t, bool blocking)
|
|||||||
|
|
||||||
// STRINGIFY(__FILE__);
|
// STRINGIFY(__FILE__);
|
||||||
DBG(F("WiThrottle [%x:%x] parsing: [%e]"), wt, _buffer, t->command);
|
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
|
wt->parse(&streamer, (byte *)t->command); // get the response; not all commands will produce a reply
|
||||||
if (streamer.count() != -1)
|
if (streamer.count() != -1)
|
||||||
{
|
{
|
||||||
|
@ -24,37 +24,11 @@
|
|||||||
#include <WiFiEspAT.h>
|
#include <WiFiEspAT.h>
|
||||||
|
|
||||||
#include "RingStream.h"
|
#include "RingStream.h"
|
||||||
|
#include "Transport.h"
|
||||||
#include "NetworkConfig.h"
|
#include "NetworkConfig.h"
|
||||||
#include "NetworkInterface.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
|
class TransportProcessor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -44,7 +44,7 @@ bool WifiSetup::setup() {
|
|||||||
|
|
||||||
switch (protocol)
|
switch (protocol)
|
||||||
{
|
{
|
||||||
case UDP:
|
case UDPR:
|
||||||
{
|
{
|
||||||
INFO(F("\nUDP over Wifi is not yet supported\n"));
|
INFO(F("\nUDP over Wifi is not yet supported\n"));
|
||||||
connected = false;
|
connected = false;
|
||||||
@ -97,7 +97,7 @@ bool WifiSetup::setup() {
|
|||||||
dnsip = WiFi.dnsServer1();
|
dnsip = WiFi.dnsServer1();
|
||||||
INFO(F("DNS server IP address: [%d.%d.%d.%d] "), dnsip[0], dnsip[1], dnsip[2], dnsip[3]);
|
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);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
// something went wrong
|
// something went wrong
|
||||||
|
Loading…
Reference in New Issue
Block a user