DCC-EX Simple Throttle
Simple throttle for a DCC-EX CommandStation
Loading...
Searching...
No Matches
/home/runner/work/DCCEXSimpleThrottle/DCCEXSimpleThrottle/CommandStationClient.h
Go to the documentation of this file.
1/*
2 * © 2024 Peter Cole
3 * © 2023 Peter Cole
4 *
5 * This is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * It is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this code. If not, see <https://www.gnu.org/licenses/>.
17 */
18
19#ifndef COMMANDSTATIONCLIENT_H
20#define COMMANDSTATIONCLIENT_H
21
23#include "Defines.h"
24#include <DCCEXProtocol.h>
25
28public:
32 CommandStationClient(Stream *logStream, CommandStationListener *commandStationLister);
33
35 void begin();
36
40 void setConnectionStream(Stream *connectionStream);
41
43 void update();
44
47 bool isConnected();
48
51 DCCEXProtocol *getClient();
52
54 void joinProgTrack();
55
58 void setTrackPower(Event event);
59
60private:
61 Stream *_logStream;
64 DCCEXProtocol *_commandStationClient;
67 uint8_t _rosterRetry;
68 unsigned long _lastRosterRetry;
69 unsigned long _rosterRetryDelay;
70};
71
72#endif // COMMANDSTATIONCLIENT_H
Definition CommandStationClient.h:27
unsigned long _rosterRetryDelay
Definition CommandStationClient.h:69
void joinProgTrack()
Join Prog to Main.
Definition CommandStationClient.cpp:69
DCCEXProtocol * _commandStationClient
Definition CommandStationClient.h:64
void setConnectionStream(Stream *connectionStream)
Set the stream object used to connect to the CommandStation, call after begin() Once set,...
Definition CommandStationClient.cpp:41
DCCEXProtocol * getClient()
Get the actual DCCEXProtocol client to interact with.
Definition CommandStationClient.cpp:67
Stream * _logStream
Definition CommandStationClient.h:61
uint8_t _rosterMaxRetries
Definition CommandStationClient.h:66
Stream * _connectionStream
Definition CommandStationClient.h:63
unsigned long _lastRosterRetry
Definition CommandStationClient.h:68
bool isConnected()
Check if the CommandStation client is connected.
Definition CommandStationClient.cpp:65
CommandStationListener * _commandStationListener
Definition CommandStationClient.h:62
void setTrackPower(Event event)
Set track power according to the provided EventType.
Definition CommandStationClient.cpp:75
void update()
Ensure client is updated regularly.
Definition CommandStationClient.cpp:51
uint8_t _rosterRetry
Definition CommandStationClient.h:67
void begin()
Setup the CommandStation client with log stream and listener ready to connect.
Definition CommandStationClient.cpp:32
bool _isConnected
Definition CommandStationClient.h:65
Class to manage broadcasts and responses from the CommandStation.
Definition CommandStationListener.h:27
Structure for each Event that is published.
Definition EventStructure.h:102