1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-23 08:06:13 +01:00
This commit is contained in:
Gregor Baues 2021-04-27 15:03:15 +02:00
parent 7442e3452e
commit 4efa260003
4 changed files with 27 additions and 12 deletions

View File

@ -56,6 +56,7 @@ const int16_t HASH_KEYWORD_LCN = 15137;
const int16_t HASH_KEYWORD_RESET = 26133;
const int16_t HASH_KEYWORD_SPEED28 = -17064;
const int16_t HASH_KEYWORD_SPEED128 = 25816;
const int16_t HASH_KEYWORD_MQTT = 11111;
int16_t DCCEXParser::stashP[MAX_COMMAND_PARAMS];
bool DCCEXParser::stashBusy;

View File

@ -33,6 +33,8 @@
#include <DccMQTT.h>
DccMQTT DccMQTT::singleton;
void DccMQTT::setup()
{
@ -43,11 +45,12 @@ void DccMQTT::setup()
// PubSubClient mqttClient(ethClient);
// PubSubClient *DccMQTT::mqClient = &mqttClient;
server = IPAddress(MQTT_BROKER_ADDRESS);
// char _csidMsg[64]{'\0'}; //!< string buffer for the serialized message to return
// mqttClient.setServer(server, MQTT_BROKER_PORT); // Initalize MQ broker
// get a eth client session
ethClient = EthernetInterface::get()->getServer()->available();
// initalize MQ Broker
mqttClient = PubSubClient(ethClient);
mqttClient.setServer(IPAddress(MQTT_BROKER_ADDRESS), MQTT_BROKER_PORT);
// DBG(F("MQTT Client : Server ok ..."));
// mqttClient.setCallback(mqttCallback); // Initalize callback function for incomming messages

View File

@ -62,7 +62,6 @@ public:
void loop();
~DccMQTT() = default;
DccMQTT()
};

View File

@ -54,11 +54,23 @@ class EthernetInterface {
static void setup();
static void loop();
bool isConnected() { return connected; };
static EthernetInterface *get() { return singleton; };
EthernetClient *getClient(int socket) { return &clients[socket]; };
EthernetServer *getServer() { return server; };
~EthernetInterface() = default;
private:
EthernetInterface();
EthernetInterface(const EthernetInterface&); // non construction-copyable
EthernetInterface& operator=( const EthernetInterface& ); // non copyable
static EthernetInterface * singleton;
bool connected;
EthernetInterface();
void loop2();
EthernetServer * server;
EthernetClient clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
uint8_t buffer[MAX_ETH_BUFFER+1]; // buffer used by TCP for the recv