mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-22 23:56:13 +01:00
MQ Init
This commit is contained in:
parent
7442e3452e
commit
4efa260003
|
@ -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;
|
||||
|
|
11
DccMQTT.cpp
11
DccMQTT.cpp
|
@ -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
|
||||
|
|
|
@ -51,14 +51,26 @@ class EthernetInterface {
|
|||
|
||||
public:
|
||||
|
||||
static void setup();
|
||||
static void loop();
|
||||
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:
|
||||
static EthernetInterface * singleton;
|
||||
bool connected;
|
||||
EthernetInterface();
|
||||
void loop2();
|
||||
|
||||
EthernetInterface();
|
||||
EthernetInterface(const EthernetInterface&); // non construction-copyable
|
||||
EthernetInterface& operator=( const EthernetInterface& ); // non copyable
|
||||
static EthernetInterface * singleton;
|
||||
bool connected;
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user