diff --git a/DCCEXProtocol_8h_source.html b/DCCEXProtocol_8h_source.html index c9b5625..570e939 100644 --- a/DCCEXProtocol_8h_source.html +++ b/DCCEXProtocol_8h_source.html @@ -106,415 +106,425 @@
34 /*
35 Version information:
36 
-
37 0.0.16 - add public sendCommand method
-
38 0.0.15 - any acquired loco is now retained in the roster
-
39 0.0.14 - add getNumberSupportedLocos() used for the fake heartbeat
-
40 0.0.13 - Fix bug to allow compilation on AVR platforms, change ssize_t to int
-
41  - Add serial connectivity example
-
42  - Add support for SCREEN updates to delegate
-
43  - Enhance buffer management to clear command buffer if full
-
44 0.0.12 - Improved memory management
-
45 0.0.11 - support for individual track power receivedIndividualTrackPower(TrackPower state, int track)
-
46  - improved logic for overall track power
-
47 0.0.10 - Add support for broadcast messages
-
48 0.0.9 - if loco is selected by address and that loco is in the roster (with the same DCC Address), updated and send
-
49  speed commands for both
-
50 0.0.8 - No functional changes, add cross-platform and unit testing capabilities (credit to
-
51  higaski)
-
52 0.0.7 - Add isFunctionMomentary(int function);
-
53 0.0.6 - Add getFunctionName(int function);
-
54 0.0.5 - Increase MAX_FUNCTIONS to 32.
-
55  - Also add check to make sure the incoming does not exceed MAX_FUNCTIONS
-
56 0.0.4 - No functional changes, update author/maintainer and URL library properties
-
57 0.0.3 - Add getByAddress method to ConsistLoco
-
58  - Fix bug when removing locos from a consist
-
59  - Tidy setTrackType() method
-
60 0.0.2 - Add TrackManager configuration method and broadcast processing
-
61  - Add TrackManager, SSID, and mDNS examples
-
62 0.0.1 - Initial library release via the Arduino Library Manager
-
63 */
-
64 
-
65 #ifndef DCCEXPROTOCOL_H
-
66 #define DCCEXPROTOCOL_H
+
37 0.0.17 - Fix typo in turntable example
+
38  - Fix bug where the turntable isMoving() method always returned true
+
39  - Add enableHeartbeat(heartbeatDelay) to send a heartbeat every x ms if a command is not sent
+
40 0.0.16 - add public sendCommand method
+
41 0.0.15 - any acquired loco is now retained in the roster
+
42 0.0.14 - add getNumberSupportedLocos() used for the fake heartbeat
+
43 0.0.13 - Fix bug to allow compilation on AVR platforms, change ssize_t to int
+
44  - Add serial connectivity example
+
45  - Add support for SCREEN updates to delegate
+
46  - Enhance buffer management to clear command buffer if full
+
47 0.0.12 - Improved memory management
+
48 0.0.11 - support for individual track power receivedIndividualTrackPower(TrackPower state, int track)
+
49  - improved logic for overall track power
+
50 0.0.10 - Add support for broadcast messages
+
51 0.0.9 - if loco is selected by address and that loco is in the roster (with the same DCC Address), updated and send
+
52  speed commands for both
+
53 0.0.8 - No functional changes, add cross-platform and unit testing capabilities (credit to
+
54  higaski)
+
55 0.0.7 - Add isFunctionMomentary(int function);
+
56 0.0.6 - Add getFunctionName(int function);
+
57 0.0.5 - Increase MAX_FUNCTIONS to 32.
+
58  - Also add check to make sure the incoming does not exceed MAX_FUNCTIONS
+
59 0.0.4 - No functional changes, update author/maintainer and URL library properties
+
60 0.0.3 - Add getByAddress method to ConsistLoco
+
61  - Fix bug when removing locos from a consist
+
62  - Tidy setTrackType() method
+
63 0.0.2 - Add TrackManager configuration method and broadcast processing
+
64  - Add TrackManager, SSID, and mDNS examples
+
65 0.0.1 - Initial library release via the Arduino Library Manager
+
66 */
67 
-
68 #include "DCCEXInbound.h"
-
69 #include "DCCEXLoco.h"
-
70 #include "DCCEXRoutes.h"
-
71 #include "DCCEXTurnouts.h"
-
72 #include "DCCEXTurntables.h"
-
73 #include <Arduino.h>
-
74 
-
75 const int MAX_OUTBOUND_COMMAND_LENGTH = 100; // Max number of bytes for outbound commands
-
76 const int MAX_SERVER_DESCRIPTION_PARAM_LENGTH = 100; // Max number of bytes for <s> server details response
-
77 const int MAX_COMMAND_PARAMS = 50; // Max number of params to parse via DCCEXInbound parser
-
78 
-
79 // Valid track power state values
-
80 enum TrackPower {
-
81  PowerOff = 0,
-
82  PowerOn = 1,
-
83  PowerUnknown = 2,
-
84 };
-
85 
-
86 // Valid TrackManager types
-
87 enum TrackManagerMode {
-
88  MAIN, // Normal DCC track mode
-
89  PROG, // Programming DCC track mode
-
90  DC, // DC mode
-
91  DCX, // Reverse polarity DC mode
-
92  NONE, // Track is unused
-
93 };
-
94 
-
96 class NullStream : public Stream {
-
97 public:
-
99  NullStream() {}
-
100 
-
103  int available() { return 0; }
-
104 
-
106  void flush() {}
+
68 #ifndef DCCEXPROTOCOL_H
+
69 #define DCCEXPROTOCOL_H
+
70 
+
71 #include "DCCEXInbound.h"
+
72 #include "DCCEXLoco.h"
+
73 #include "DCCEXRoutes.h"
+
74 #include "DCCEXTurnouts.h"
+
75 #include "DCCEXTurntables.h"
+
76 #include <Arduino.h>
+
77 
+
78 const int MAX_OUTBOUND_COMMAND_LENGTH = 100; // Max number of bytes for outbound commands
+
79 const int MAX_SERVER_DESCRIPTION_PARAM_LENGTH = 100; // Max number of bytes for <s> server details response
+
80 const int MAX_COMMAND_PARAMS = 50; // Max number of params to parse via DCCEXInbound parser
+
81 
+
82 // Valid track power state values
+
83 enum TrackPower {
+
84  PowerOff = 0,
+
85  PowerOn = 1,
+
86  PowerUnknown = 2,
+
87 };
+
88 
+
89 // Valid TrackManager types
+
90 enum TrackManagerMode {
+
91  MAIN, // Normal DCC track mode
+
92  PROG, // Programming DCC track mode
+
93  DC, // DC mode
+
94  DCX, // Reverse polarity DC mode
+
95  NONE, // Track is unused
+
96 };
+
97 
+
99 class NullStream : public Stream {
+
100 public:
+
102  NullStream() {}
+
103 
+
106  int available() { return 0; }
107 
-
110  int peek() { return -1; }
-
111 
-
114  int read() { return -1; }
-
115 
-
119  size_t write(uint8_t c) { return 1; }
-
120 
-
125  size_t write(const uint8_t *buffer, size_t size) { return size; }
-
126 };
-
127 
-
129 class DCCEXProtocolDelegate {
-
130 public:
-
135  virtual void receivedServerVersion(int major, int minor, int patch) {}
-
136 
-
139  virtual void receivedMessage(char *message) {}
-
140 
-
142  virtual void receivedRosterList() {}
+
109  void flush() {}
+
110 
+
113  int peek() { return -1; }
+
114 
+
117  int read() { return -1; }
+
118 
+
122  size_t write(uint8_t c) { return 1; }
+
123 
+
128  size_t write(const uint8_t *buffer, size_t size) { return size; }
+
129 };
+
130 
+
132 class DCCEXProtocolDelegate {
+
133 public:
+
138  virtual void receivedServerVersion(int major, int minor, int patch) {}
+
139 
+
142  virtual void receivedMessage(char *message) {}
143 
-
145  virtual void receivedTurnoutList() {}
+
145  virtual void receivedRosterList() {}
146 
-
148  virtual void receivedRouteList() {}
+
148  virtual void receivedTurnoutList() {}
149 
-
151  virtual void receivedTurntableList() {}
+
151  virtual void receivedRouteList() {}
152 
-
155  virtual void receivedLocoUpdate(Loco *loco) {}
-
156 
-
159  virtual void receivedTrackPower(TrackPower state) {}
-
160 
-
164  virtual void receivedIndividualTrackPower(TrackPower state, int track) {}
-
165 
-
170  virtual void receivedTrackType(char track, TrackManagerMode type, int address) {}
-
171 
-
175  virtual void receivedTurnoutAction(int turnoutId, bool thrown) {}
-
176 
-
181  virtual void receivedTurntableAction(int turntableId, int position, bool moving) {}
-
182 
-
185  virtual void receivedReadLoco(int address) {}
-
186 
-
191  virtual void receivedScreenUpdate(int screen, int row, char *message) {}
-
192 };
-
193 
-
195 class DCCEXProtocol {
-
196 public:
-
197  // Protocol and server methods
-
198 
-
201  DCCEXProtocol(int maxCmdBuffer = 500);
-
202 
-
204  ~DCCEXProtocol();
+
154  virtual void receivedTurntableList() {}
+
155 
+
158  virtual void receivedLocoUpdate(Loco *loco) {}
+
159 
+
162  virtual void receivedTrackPower(TrackPower state) {}
+
163 
+
167  virtual void receivedIndividualTrackPower(TrackPower state, int track) {}
+
168 
+
173  virtual void receivedTrackType(char track, TrackManagerMode type, int address) {}
+
174 
+
178  virtual void receivedTurnoutAction(int turnoutId, bool thrown) {}
+
179 
+
184  virtual void receivedTurntableAction(int turntableId, int position, bool moving) {}
+
185 
+
188  virtual void receivedReadLoco(int address) {}
+
189 
+
194  virtual void receivedScreenUpdate(int screen, int row, char *message) {}
+
195 };
+
196 
+
198 class DCCEXProtocol {
+
199 public:
+
200  // Protocol and server methods
+
201 
+
204  DCCEXProtocol(int maxCmdBuffer = 500);
205 
-
208  void setDelegate(DCCEXProtocolDelegate *delegate);
-
209 
-
212  void setLogStream(Stream *console);
-
213 
-
216  void connect(Stream *stream);
-
217 
-
219  void disconnect();
+
207  ~DCCEXProtocol();
+
208 
+
211  void setDelegate(DCCEXProtocolDelegate *delegate);
+
212 
+
215  void setLogStream(Stream *console);
+
216 
+
219  void enableHeartbeat(unsigned long heartbeatDelay = 60000);
220 
-
222  void check();
-
223 
-
226  void sendCommand(char *cmd);
+
223  void connect(Stream *stream);
+
224 
+
226  void disconnect();
227 
-
233  void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired);
+
229  void check();
+
230 
+
233  void sendCommand(char *cmd);
234 
-
237  bool receivedLists();
-
238 
-
240  void requestServerVersion();
+
240  void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired);
241 
-
244  bool receivedVersion();
+
244  bool receivedLists();
245 
-
248  int getMajorVersion();
-
249 
-
252  int getMinorVersion();
-
253 
-
256  int getPatchVersion();
-
257 
-
260  unsigned long getLastServerResponseTime(); // seconds since Arduino start
-
261 
-
262  // Consist/Loco methods
-
263 
-
268  void setThrottle(Loco *loco, int speed, Direction direction);
-
269 
-
274  void setThrottle(Consist *consist, int speed, Direction direction);
-
275 
-
279  void functionOn(Loco *loco, int function);
-
280 
-
284  void functionOff(Loco *loco, int function);
-
285 
-
290  bool isFunctionOn(Loco *loco, int function);
-
291 
-
295  void functionOn(Consist *consist, int function);
-
296 
-
300  void functionOff(Consist *consist, int function);
-
301 
-
306  bool isFunctionOn(Consist *consist, int function);
-
307 
-
310  void requestLocoUpdate(int address);
-
311 
-
313  void readLoco();
+
247  void requestServerVersion();
+
248 
+
251  bool receivedVersion();
+
252 
+
255  int getMajorVersion();
+
256 
+
259  int getMinorVersion();
+
260 
+
263  int getPatchVersion();
+
264 
+
267  unsigned long getLastServerResponseTime(); // seconds since Arduino start
+
268 
+
269  // Consist/Loco methods
+
270 
+
275  void setThrottle(Loco *loco, int speed, Direction direction);
+
276 
+
281  void setThrottle(Consist *consist, int speed, Direction direction);
+
282 
+
286  void functionOn(Loco *loco, int function);
+
287 
+
291  void functionOff(Loco *loco, int function);
+
292 
+
297  bool isFunctionOn(Loco *loco, int function);
+
298 
+
302  void functionOn(Consist *consist, int function);
+
303 
+
307  void functionOff(Consist *consist, int function);
+
308 
+
313  bool isFunctionOn(Consist *consist, int function);
314 
-
316  void emergencyStop();
-
317 
-
318  // Roster methods
-
319 
-
322  int getRosterCount();
-
323 
-
326  bool receivedRoster();
-
327 
-
331  Loco *findLocoInRoster(int address);
-
332 
-
333  // Turnout methods
+
317  void requestLocoUpdate(int address);
+
318 
+
320  void readLoco();
+
321 
+
323  void emergencyStop();
+
324 
+
325  // Roster methods
+
326 
+
329  int getRosterCount();
+
330 
+
333  bool receivedRoster();
334 
-
337  int getTurnoutCount();
-
338 
-
341  bool receivedTurnoutList();
-
342 
-
346  Turnout *getTurnoutById(int turnoutId);
-
347 
-
350  void closeTurnout(int turnoutId);
-
351 
-
354  void throwTurnout(int turnoutId);
-
355 
-
358  void toggleTurnout(int turnoutId);
-
359 
-
360  // Route methods
-
361 
-
364  int getRouteCount();
-
365 
-
368  bool receivedRouteList();
-
369 
-
372  void startRoute(int routeId);
-
373 
-
375  void pauseRoutes();
+
338  Loco *findLocoInRoster(int address);
+
339 
+
340  // Turnout methods
+
341 
+
344  int getTurnoutCount();
+
345 
+
348  bool receivedTurnoutList();
+
349 
+
353  Turnout *getTurnoutById(int turnoutId);
+
354 
+
357  void closeTurnout(int turnoutId);
+
358 
+
361  void throwTurnout(int turnoutId);
+
362 
+
365  void toggleTurnout(int turnoutId);
+
366 
+
367  // Route methods
+
368 
+
371  int getRouteCount();
+
372 
+
375  bool receivedRouteList();
376 
-
378  void resumeRoutes();
-
379 
-
380  // Turntable methods
-
381 
-
384  int getTurntableCount();
-
385 
-
388  bool receivedTurntableList();
-
389 
-
393  Turntable *getTurntableById(int turntableId);
-
394 
-
399  void rotateTurntable(int turntableId, int position, int activity = 0);
-
400 
-
401  // Track management methods
-
402 
-
404  void powerOn();
-
405 
-
407  void powerOff();
-
408 
-
411  void powerTrackOn(char track);
+
379  void startRoute(int routeId);
+
380 
+
382  void pauseRoutes();
+
383 
+
385  void resumeRoutes();
+
386 
+
387  // Turntable methods
+
388 
+
391  int getTurntableCount();
+
392 
+
395  bool receivedTurntableList();
+
396 
+
400  Turntable *getTurntableById(int turntableId);
+
401 
+
406  void rotateTurntable(int turntableId, int position, int activity = 0);
+
407 
+
408  // Track management methods
+
409 
+
411  void powerOn();
412 
-
415  void powerTrackOff(char track);
-
416 
-
421  void setTrackType(char track, TrackManagerMode type, int address);
-
422 
-
423  // DCC accessory methods
-
424 
-
428  void activateAccessory(int accessoryAddress, int accessorySubAddr);
+
414  void powerOff();
+
415 
+
418  void powerTrackOn(char track);
+
419 
+
422  void powerTrackOff(char track);
+
423 
+
428  void setTrackType(char track, TrackManagerMode type, int address);
429 
-
433  void deactivateAccessory(int accessoryAddress, int accessorySubAddr);
-
434 
-
437  void activateLinearAccessory(int linearAddress);
-
438 
-
441  void deactivateLinearAccessory(int linearAddress);
-
442 
-
444  void getNumberSupportedLocos();
+
430  // DCC accessory methods
+
431 
+
435  void activateAccessory(int accessoryAddress, int accessorySubAddr);
+
436 
+
440  void deactivateAccessory(int accessoryAddress, int accessorySubAddr);
+
441 
+
444  void activateLinearAccessory(int linearAddress);
445 
-
446  // Attributes
-
447 
-
449  Loco *roster = nullptr;
-
450 
-
452  Turnout *turnouts = nullptr;
-
453 
-
455  Route *routes = nullptr;
-
456 
-
458  Turntable *turntables = nullptr;
-
459 
-
460 private:
-
461  // Methods
-
462  // Protocol and server methods
-
463  void _init();
-
464  void _sendCommand();
-
465  void _processCommand();
-
466  void _processServerDescription();
-
467  void _processMessage();
-
468  void _processScreenUpdate();
-
469 
-
470  // Consist/loco methods
-
471  void _processLocoBroadcast();
-
472  int _getValidFunctionMap(int functionMap);
-
473  int _getSpeedFromSpeedByte(int speedByte);
-
474  Direction _getDirectionFromSpeedByte(int speedByte);
-
475  void _setLoco(int address, int speed, Direction direction);
-
476  void _processReadResponse();
+
448  void deactivateLinearAccessory(int linearAddress);
+
449 
+
451  void getNumberSupportedLocos();
+
452 
+
453  // Attributes
+
454 
+
456  Loco *roster = nullptr;
+
457 
+
459  Turnout *turnouts = nullptr;
+
460 
+
462  Route *routes = nullptr;
+
463 
+
465  Turntable *turntables = nullptr;
+
466 
+
467 private:
+
468  // Methods
+
469  // Protocol and server methods
+
470  void _init();
+
471  void _sendCommand();
+
472  void _processCommand();
+
473  void _processServerDescription();
+
474  void _processMessage();
+
475  void _processScreenUpdate();
+
476  void _sendHeartbeat();
477 
-
478  // Roster methods
-
479  void _getRoster();
-
480  bool _requestedRoster();
-
481  void _processRosterList();
-
482  void _requestRosterEntry(int address);
-
483  void _processRosterEntry();
-
484 
-
485  // Turnout methods
-
486  void _getTurnouts();
-
487  bool _requestedTurnouts();
-
488  void _processTurnoutList();
-
489  void _requestTurnoutEntry(int id);
-
490  void _processTurnoutEntry();
-
491  void _processTurnoutBroadcast();
+
478  // Consist/loco methods
+
479  void _processLocoBroadcast();
+
480  int _getValidFunctionMap(int functionMap);
+
481  int _getSpeedFromSpeedByte(int speedByte);
+
482  Direction _getDirectionFromSpeedByte(int speedByte);
+
483  void _setLoco(int address, int speed, Direction direction);
+
484  void _processReadResponse();
+
485 
+
486  // Roster methods
+
487  void _getRoster();
+
488  bool _requestedRoster();
+
489  void _processRosterList();
+
490  void _requestRosterEntry(int address);
+
491  void _processRosterEntry();
492 
-
493  // Route methods
-
494  void _getRoutes();
-
495  bool _requestedRoutes();
-
496  void _processRouteList();
-
497  void _requestRouteEntry(int id);
-
498  void _processRouteEntry();
-
499 
-
500  // Turntable methods
-
501  void _getTurntables();
-
502  bool _requestedTurntables();
-
503  void _processTurntableList();
-
504  void _requestTurntableEntry(int id);
-
505  void _processTurntableEntry();
-
506  void _requestTurntableIndexEntry(int id);
-
507  void _processTurntableIndexEntry();
-
508  void _processTurntableBroadcast();
-
509 
-
510  // Track management methods
-
511  void _processTrackPower();
-
512  void _processTrackType();
-
513 
-
514  // Attributes
-
515  int _rosterCount = 0; // Count of roster items received
-
516  int _turnoutCount = 0; // Count of turnout objects received
-
517  int _routeCount = 0; // Count of route objects received
-
518  int _turntableCount = 0; // Count of turntable objects received
-
519  int _version[3] = {}; // EX-CommandStation version x.y.z
-
520  Stream *_stream; // Stream object where commands are sent/received
-
521  Stream *_console; // Stream object for console output
-
522  NullStream _nullStream; // Send streams to null if no object provided
-
523  int _bufflen; // Used to ensure command buffer size not exceeded
-
524  int _maxCmdBuffer; // Max size for the command buffer
-
525  char *_cmdBuffer; // Char array for inbound command buffer
-
526  char _outboundCommand[MAX_OUTBOUND_COMMAND_LENGTH]; // Char array for outbound commands
-
527  DCCEXProtocolDelegate *_delegate = nullptr; // Pointer to the delegate for notifications
-
528  unsigned long _lastServerResponseTime; // Records the timestamp of the last server response
-
529  char _inputBuffer[512]; // Char array for input buffer
-
530  int _nextChar; // where the next character to be read goes in the buffer
-
531  bool _receivedVersion = false; // Flag that server version has been received
-
532  bool _receivedLists = false; // Flag if all requested lists have been received
-
533  bool _rosterRequested = false; // Flag that roster has been requested
-
534  bool _receivedRoster = false; // Flag that roster has been received
-
535  bool _turnoutListRequested = false; // Flag that turnout list requested
-
536  bool _receivedTurnoutList = false; // Flag that turnout list received
-
537  bool _routeListRequested = false; // Flag that route list requested
-
538  bool _receivedRouteList = false; // Flag that route list received
-
539  bool _turntableListRequested = false; // Flag that turntable list requested
-
540  bool _receivedTurntableList = false; // Flag that turntable list received
-
541 };
-
542 
-
543 #endif // DCCEXPROTOCOL_H
+
493  // Turnout methods
+
494  void _getTurnouts();
+
495  bool _requestedTurnouts();
+
496  void _processTurnoutList();
+
497  void _requestTurnoutEntry(int id);
+
498  void _processTurnoutEntry();
+
499  void _processTurnoutBroadcast();
+
500 
+
501  // Route methods
+
502  void _getRoutes();
+
503  bool _requestedRoutes();
+
504  void _processRouteList();
+
505  void _requestRouteEntry(int id);
+
506  void _processRouteEntry();
+
507 
+
508  // Turntable methods
+
509  void _getTurntables();
+
510  bool _requestedTurntables();
+
511  void _processTurntableList();
+
512  void _requestTurntableEntry(int id);
+
513  void _processTurntableEntry();
+
514  void _requestTurntableIndexEntry(int id);
+
515  void _processTurntableIndexEntry();
+
516  void _processTurntableBroadcast();
+
517 
+
518  // Track management methods
+
519  void _processTrackPower();
+
520  void _processTrackType();
+
521 
+
522  // Attributes
+
523  int _rosterCount = 0; // Count of roster items received
+
524  int _turnoutCount = 0; // Count of turnout objects received
+
525  int _routeCount = 0; // Count of route objects received
+
526  int _turntableCount = 0; // Count of turntable objects received
+
527  int _version[3] = {}; // EX-CommandStation version x.y.z
+
528  Stream *_stream; // Stream object where commands are sent/received
+
529  Stream *_console; // Stream object for console output
+
530  NullStream _nullStream; // Send streams to null if no object provided
+
531  int _bufflen; // Used to ensure command buffer size not exceeded
+
532  int _maxCmdBuffer; // Max size for the command buffer
+
533  char *_cmdBuffer; // Char array for inbound command buffer
+
534  char _outboundCommand[MAX_OUTBOUND_COMMAND_LENGTH]; // Char array for outbound commands
+
535  DCCEXProtocolDelegate *_delegate = nullptr; // Pointer to the delegate for notifications
+
536  unsigned long _lastServerResponseTime; // Records the timestamp of the last server response
+
537  char _inputBuffer[512]; // Char array for input buffer
+
538  int _nextChar; // where the next character to be read goes in the buffer
+
539  bool _receivedVersion = false; // Flag that server version has been received
+
540  bool _receivedLists = false; // Flag if all requested lists have been received
+
541  bool _rosterRequested = false; // Flag that roster has been requested
+
542  bool _receivedRoster = false; // Flag that roster has been received
+
543  bool _turnoutListRequested = false; // Flag that turnout list requested
+
544  bool _receivedTurnoutList = false; // Flag that turnout list received
+
545  bool _routeListRequested = false; // Flag that route list requested
+
546  bool _receivedRouteList = false; // Flag that route list received
+
547  bool _turntableListRequested = false; // Flag that turntable list requested
+
548  bool _receivedTurntableList = false; // Flag that turntable list received
+
549  bool _enableHeartbeat; // Flag if heartbeat is enabled
+
550  unsigned long _heartbeatDelay; // Delay between heartbeats if enabled
+
551  unsigned long _lastHeartbeat; // Time in ms of the last heartbeat, also set by sending a command
+
552 };
+
553 
+
554 #endif // DCCEXPROTOCOL_H
Consist
Class to create a software consist of one or more ConsistLoco objects.
Definition: DCCEXLoco.h:185
-
DCCEXProtocolDelegate
Delegate responses and broadcast events to the client software to enable custom event handlers.
Definition: DCCEXProtocol.h:129
-
DCCEXProtocolDelegate::receivedServerVersion
virtual void receivedServerVersion(int major, int minor, int patch)
Notify when the server version has been received.
Definition: DCCEXProtocol.h:135
-
DCCEXProtocolDelegate::receivedRosterList
virtual void receivedRosterList()
Notify when the roster list is received.
Definition: DCCEXProtocol.h:142
-
DCCEXProtocolDelegate::receivedTurnoutAction
virtual void receivedTurnoutAction(int turnoutId, bool thrown)
Notify when a turnout state change is received.
Definition: DCCEXProtocol.h:175
-
DCCEXProtocolDelegate::receivedMessage
virtual void receivedMessage(char *message)
Notify when a broadcast message has been received.
Definition: DCCEXProtocol.h:139
-
DCCEXProtocolDelegate::receivedTrackType
virtual void receivedTrackType(char track, TrackManagerMode type, int address)
Notify when a track type change is received.
Definition: DCCEXProtocol.h:170
-
DCCEXProtocolDelegate::receivedScreenUpdate
virtual void receivedScreenUpdate(int screen, int row, char *message)
Notify when a screen update is received.
Definition: DCCEXProtocol.h:191
-
DCCEXProtocolDelegate::receivedIndividualTrackPower
virtual void receivedIndividualTrackPower(TrackPower state, int track)
Notify when an individual track power state change is received.
Definition: DCCEXProtocol.h:164
-
DCCEXProtocolDelegate::receivedLocoUpdate
virtual void receivedLocoUpdate(Loco *loco)
Notify when an update to a Loco object is received.
Definition: DCCEXProtocol.h:155
-
DCCEXProtocolDelegate::receivedTurntableList
virtual void receivedTurntableList()
Notify when the turntable list is received.
Definition: DCCEXProtocol.h:151
-
DCCEXProtocolDelegate::receivedRouteList
virtual void receivedRouteList()
Notify when the route list is received.
Definition: DCCEXProtocol.h:148
-
DCCEXProtocolDelegate::receivedReadLoco
virtual void receivedReadLoco(int address)
Notify when a loco address is read from the programming track.
Definition: DCCEXProtocol.h:185
-
DCCEXProtocolDelegate::receivedTurnoutList
virtual void receivedTurnoutList()
Notify when the turnout list is received.
Definition: DCCEXProtocol.h:145
-
DCCEXProtocolDelegate::receivedTurntableAction
virtual void receivedTurntableAction(int turntableId, int position, bool moving)
Notify when a turntable index change is received.
Definition: DCCEXProtocol.h:181
-
DCCEXProtocolDelegate::receivedTrackPower
virtual void receivedTrackPower(TrackPower state)
Notify when the global track power state change is received.
Definition: DCCEXProtocol.h:159
-
DCCEXProtocol
Main class for the DCCEXProtocol library.
Definition: DCCEXProtocol.h:195
-
DCCEXProtocol::setThrottle
void setThrottle(Loco *loco, int speed, Direction direction)
Set the provided loco to the specified speed and direction.
Definition: DCCEXProtocol.cpp:183
-
DCCEXProtocol::getMinorVersion
int getMinorVersion()
Retrieve the minor version of EX-Commandstation.
Definition: DCCEXProtocol.cpp:175
-
DCCEXProtocol::receivedTurntableList
bool receivedTurntableList()
Check if turntable list has been received.
Definition: DCCEXProtocol.cpp:386
-
DCCEXProtocol::functionOff
void functionOff(Loco *loco, int function)
Turn the specified function off for the provided loco.
Definition: DCCEXProtocol.cpp:218
-
DCCEXProtocol::disconnect
void disconnect()
Disconnect from DCC-EX.
Definition: DCCEXProtocol.cpp:84
-
DCCEXProtocol::throwTurnout
void throwTurnout(int turnoutId)
Throw the specified turnout/point.
Definition: DCCEXProtocol.cpp:331
-
DCCEXProtocol::powerOff
void powerOff()
Global track power off command.
Definition: DCCEXProtocol.cpp:425
-
DCCEXProtocol::getPatchVersion
int getPatchVersion()
Retreive the patch version of EX-CommandStation.
Definition: DCCEXProtocol.cpp:177
-
DCCEXProtocol::toggleTurnout
void toggleTurnout(int turnoutId)
Toggle the specified turnout/point (if closed, will throw, and vice versa)
Definition: DCCEXProtocol.cpp:338
-
DCCEXProtocol::receivedVersion
bool receivedVersion()
Check if server version has been received.
Definition: DCCEXProtocol.cpp:171
-
DCCEXProtocol::connect
void connect(Stream *stream)
Connect the stream object to interact with DCC-EX.
Definition: DCCEXProtocol.cpp:79
-
DCCEXProtocol::startRoute
void startRoute(int routeId)
Start a route/automation.
Definition: DCCEXProtocol.cpp:355
-
DCCEXProtocol::getLastServerResponseTime
unsigned long getLastServerResponseTime()
Retrieve the last time the server responded.
Definition: DCCEXProtocol.cpp:179
-
DCCEXProtocol::routes
Route * routes
Linked list of Route objects to form the list of routes and automations.
Definition: DCCEXProtocol.h:455
-
DCCEXProtocol::receivedRouteList
bool receivedRouteList()
Check if route list has been received.
Definition: DCCEXProtocol.cpp:353
-
DCCEXProtocol::receivedTurnoutList
bool receivedTurnoutList()
Check if turnout list has been received.
Definition: DCCEXProtocol.cpp:312
-
DCCEXProtocol::getTurntableCount
int getTurntableCount()
Get the number of turntable entries.
Definition: DCCEXProtocol.cpp:384
-
DCCEXProtocol::rotateTurntable
void rotateTurntable(int turntableId, int position, int activity=0)
Rotate a turntable object.
Definition: DCCEXProtocol.cpp:397
-
DCCEXProtocol::receivedRoster
bool receivedRoster()
Check if roster has been received.
Definition: DCCEXProtocol.cpp:294
-
DCCEXProtocol::~DCCEXProtocol
~DCCEXProtocol()
Destructor for the DCCEXProtocol object.
Definition: DCCEXProtocol.cpp:65
-
DCCEXProtocol::roster
Loco * roster
Linked list of Loco objects to form the roster.
Definition: DCCEXProtocol.h:449
-
DCCEXProtocol::powerTrackOff
void powerTrackOff(char track)
Turn power off for the specified track.
Definition: DCCEXProtocol.cpp:439
-
DCCEXProtocol::deactivateAccessory
void deactivateAccessory(int accessoryAddress, int accessorySubAddr)
Deactivate DCC accessory at the specified address and subaddress.
Definition: DCCEXProtocol.cpp:482
-
DCCEXProtocol::getNumberSupportedLocos
void getNumberSupportedLocos()
Request the number of supported cabs(locos)
Definition: DCCEXProtocol.cpp:509
-
DCCEXProtocol::turntables
Turntable * turntables
Linked list of Turntable objects to form the list of turntables.
Definition: DCCEXProtocol.h:458
-
DCCEXProtocol::functionOn
void functionOn(Loco *loco, int function)
Turn the specified function on for the provided loco.
Definition: DCCEXProtocol.cpp:206
-
DCCEXProtocol::getRouteCount
int getRouteCount()
Get the number of route entries.
Definition: DCCEXProtocol.cpp:351
-
DCCEXProtocol::setTrackType
void setTrackType(char track, TrackManagerMode type, int address)
set track type for the specified track
Definition: DCCEXProtocol.cpp:446
-
DCCEXProtocol::getRosterCount
int getRosterCount()
Get the number of roster entries.
Definition: DCCEXProtocol.cpp:292
-
DCCEXProtocol::readLoco
void readLoco()
Initiate reading a loco address from the programming track, response will be a delegate notification.
Definition: DCCEXProtocol.cpp:274
-
DCCEXProtocol::activateAccessory
void activateAccessory(int accessoryAddress, int accessorySubAddr)
Activate DCC accessory at the specified address and subaddress.
Definition: DCCEXProtocol.cpp:473
-
DCCEXProtocol::receivedLists
bool receivedLists()
Check if all lists have been received (roster, routes, turnouts, turntables)
Definition: DCCEXProtocol.cpp:160
-
DCCEXProtocol::getMajorVersion
int getMajorVersion()
Retrieve the major version of EX-CommandStation.
Definition: DCCEXProtocol.cpp:173
-
DCCEXProtocol::sendCommand
void sendCommand(char *cmd)
allows sending of an arbitray command
Definition: DCCEXProtocol.cpp:120
-
DCCEXProtocol::getLists
void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired)
Request DCC-EX object lists (Roster, Turnouts, Routes, Turntables)
Definition: DCCEXProtocol.cpp:126
-
DCCEXProtocol::activateLinearAccessory
void activateLinearAccessory(int linearAddress)
Activate DCC accessory at the specified linear address.
Definition: DCCEXProtocol.cpp:491
-
DCCEXProtocol::closeTurnout
void closeTurnout(int turnoutId)
Close the specified turnout/point.
Definition: DCCEXProtocol.cpp:324
-
DCCEXProtocol::powerTrackOn
void powerTrackOn(char track)
Turn power on for the specified track.
Definition: DCCEXProtocol.cpp:432
-
DCCEXProtocol::isFunctionOn
bool isFunctionOn(Loco *loco, int function)
Test if the specified function for the provided loco is on.
Definition: DCCEXProtocol.cpp:230
-
DCCEXProtocol::getTurntableById
Turntable * getTurntableById(int turntableId)
Retrieve a turntable object by its ID.
Definition: DCCEXProtocol.cpp:388
-
DCCEXProtocol::powerOn
void powerOn()
Global track power on command.
Definition: DCCEXProtocol.cpp:418
-
DCCEXProtocol::getTurnoutById
Turnout * getTurnoutById(int turnoutId)
Retrieve a turnout/point object by its ID.
Definition: DCCEXProtocol.cpp:315
-
DCCEXProtocol::turnouts
Turnout * turnouts
Linked list of Turnout objects to form the turnout list.
Definition: DCCEXProtocol.h:452
-
DCCEXProtocol::pauseRoutes
void pauseRoutes()
Pause all routes/automations.
Definition: DCCEXProtocol.cpp:364
-
DCCEXProtocol::getTurnoutCount
int getTurnoutCount()
Get the number of turnouts.
Definition: DCCEXProtocol.cpp:310
-
DCCEXProtocol::setLogStream
void setLogStream(Stream *console)
Set the stream object for console output.
Definition: DCCEXProtocol.cpp:77
+
DCCEXProtocolDelegate
Delegate responses and broadcast events to the client software to enable custom event handlers.
Definition: DCCEXProtocol.h:132
+
DCCEXProtocolDelegate::receivedServerVersion
virtual void receivedServerVersion(int major, int minor, int patch)
Notify when the server version has been received.
Definition: DCCEXProtocol.h:138
+
DCCEXProtocolDelegate::receivedRosterList
virtual void receivedRosterList()
Notify when the roster list is received.
Definition: DCCEXProtocol.h:145
+
DCCEXProtocolDelegate::receivedTurnoutAction
virtual void receivedTurnoutAction(int turnoutId, bool thrown)
Notify when a turnout state change is received.
Definition: DCCEXProtocol.h:178
+
DCCEXProtocolDelegate::receivedMessage
virtual void receivedMessage(char *message)
Notify when a broadcast message has been received.
Definition: DCCEXProtocol.h:142
+
DCCEXProtocolDelegate::receivedTrackType
virtual void receivedTrackType(char track, TrackManagerMode type, int address)
Notify when a track type change is received.
Definition: DCCEXProtocol.h:173
+
DCCEXProtocolDelegate::receivedScreenUpdate
virtual void receivedScreenUpdate(int screen, int row, char *message)
Notify when a screen update is received.
Definition: DCCEXProtocol.h:194
+
DCCEXProtocolDelegate::receivedIndividualTrackPower
virtual void receivedIndividualTrackPower(TrackPower state, int track)
Notify when an individual track power state change is received.
Definition: DCCEXProtocol.h:167
+
DCCEXProtocolDelegate::receivedLocoUpdate
virtual void receivedLocoUpdate(Loco *loco)
Notify when an update to a Loco object is received.
Definition: DCCEXProtocol.h:158
+
DCCEXProtocolDelegate::receivedTurntableList
virtual void receivedTurntableList()
Notify when the turntable list is received.
Definition: DCCEXProtocol.h:154
+
DCCEXProtocolDelegate::receivedRouteList
virtual void receivedRouteList()
Notify when the route list is received.
Definition: DCCEXProtocol.h:151
+
DCCEXProtocolDelegate::receivedReadLoco
virtual void receivedReadLoco(int address)
Notify when a loco address is read from the programming track.
Definition: DCCEXProtocol.h:188
+
DCCEXProtocolDelegate::receivedTurnoutList
virtual void receivedTurnoutList()
Notify when the turnout list is received.
Definition: DCCEXProtocol.h:148
+
DCCEXProtocolDelegate::receivedTurntableAction
virtual void receivedTurntableAction(int turntableId, int position, bool moving)
Notify when a turntable index change is received.
Definition: DCCEXProtocol.h:184
+
DCCEXProtocolDelegate::receivedTrackPower
virtual void receivedTrackPower(TrackPower state)
Notify when the global track power state change is received.
Definition: DCCEXProtocol.h:162
+
DCCEXProtocol
Main class for the DCCEXProtocol library.
Definition: DCCEXProtocol.h:198
+
DCCEXProtocol::setThrottle
void setThrottle(Loco *loco, int speed, Direction direction)
Set the provided loco to the specified speed and direction.
Definition: DCCEXProtocol.cpp:196
+
DCCEXProtocol::getMinorVersion
int getMinorVersion()
Retrieve the minor version of EX-Commandstation.
Definition: DCCEXProtocol.cpp:188
+
DCCEXProtocol::receivedTurntableList
bool receivedTurntableList()
Check if turntable list has been received.
Definition: DCCEXProtocol.cpp:399
+
DCCEXProtocol::functionOff
void functionOff(Loco *loco, int function)
Turn the specified function off for the provided loco.
Definition: DCCEXProtocol.cpp:231
+
DCCEXProtocol::disconnect
void disconnect()
Disconnect from DCC-EX.
Definition: DCCEXProtocol.cpp:94
+
DCCEXProtocol::throwTurnout
void throwTurnout(int turnoutId)
Throw the specified turnout/point.
Definition: DCCEXProtocol.cpp:344
+
DCCEXProtocol::powerOff
void powerOff()
Global track power off command.
Definition: DCCEXProtocol.cpp:438
+
DCCEXProtocol::getPatchVersion
int getPatchVersion()
Retreive the patch version of EX-CommandStation.
Definition: DCCEXProtocol.cpp:190
+
DCCEXProtocol::toggleTurnout
void toggleTurnout(int turnoutId)
Toggle the specified turnout/point (if closed, will throw, and vice versa)
Definition: DCCEXProtocol.cpp:351
+
DCCEXProtocol::receivedVersion
bool receivedVersion()
Check if server version has been received.
Definition: DCCEXProtocol.cpp:184
+
DCCEXProtocol::connect
void connect(Stream *stream)
Connect the stream object to interact with DCC-EX.
Definition: DCCEXProtocol.cpp:89
+
DCCEXProtocol::startRoute
void startRoute(int routeId)
Start a route/automation.
Definition: DCCEXProtocol.cpp:368
+
DCCEXProtocol::getLastServerResponseTime
unsigned long getLastServerResponseTime()
Retrieve the last time the server responded.
Definition: DCCEXProtocol.cpp:192
+
DCCEXProtocol::routes
Route * routes
Linked list of Route objects to form the list of routes and automations.
Definition: DCCEXProtocol.h:462
+
DCCEXProtocol::receivedRouteList
bool receivedRouteList()
Check if route list has been received.
Definition: DCCEXProtocol.cpp:366
+
DCCEXProtocol::receivedTurnoutList
bool receivedTurnoutList()
Check if turnout list has been received.
Definition: DCCEXProtocol.cpp:325
+
DCCEXProtocol::getTurntableCount
int getTurntableCount()
Get the number of turntable entries.
Definition: DCCEXProtocol.cpp:397
+
DCCEXProtocol::rotateTurntable
void rotateTurntable(int turntableId, int position, int activity=0)
Rotate a turntable object.
Definition: DCCEXProtocol.cpp:410
+
DCCEXProtocol::receivedRoster
bool receivedRoster()
Check if roster has been received.
Definition: DCCEXProtocol.cpp:307
+
DCCEXProtocol::~DCCEXProtocol
~DCCEXProtocol()
Destructor for the DCCEXProtocol object.
Definition: DCCEXProtocol.cpp:70
+
DCCEXProtocol::roster
Loco * roster
Linked list of Loco objects to form the roster.
Definition: DCCEXProtocol.h:456
+
DCCEXProtocol::powerTrackOff
void powerTrackOff(char track)
Turn power off for the specified track.
Definition: DCCEXProtocol.cpp:452
+
DCCEXProtocol::deactivateAccessory
void deactivateAccessory(int accessoryAddress, int accessorySubAddr)
Deactivate DCC accessory at the specified address and subaddress.
Definition: DCCEXProtocol.cpp:495
+
DCCEXProtocol::getNumberSupportedLocos
void getNumberSupportedLocos()
Request the number of supported cabs(locos)
Definition: DCCEXProtocol.cpp:522
+
DCCEXProtocol::turntables
Turntable * turntables
Linked list of Turntable objects to form the list of turntables.
Definition: DCCEXProtocol.h:465
+
DCCEXProtocol::functionOn
void functionOn(Loco *loco, int function)
Turn the specified function on for the provided loco.
Definition: DCCEXProtocol.cpp:219
+
DCCEXProtocol::getRouteCount
int getRouteCount()
Get the number of route entries.
Definition: DCCEXProtocol.cpp:364
+
DCCEXProtocol::setTrackType
void setTrackType(char track, TrackManagerMode type, int address)
set track type for the specified track
Definition: DCCEXProtocol.cpp:459
+
DCCEXProtocol::getRosterCount
int getRosterCount()
Get the number of roster entries.
Definition: DCCEXProtocol.cpp:305
+
DCCEXProtocol::readLoco
void readLoco()
Initiate reading a loco address from the programming track, response will be a delegate notification.
Definition: DCCEXProtocol.cpp:287
+
DCCEXProtocol::enableHeartbeat
void enableHeartbeat(unsigned long heartbeatDelay=60000)
Enable heartbeat if required - can help WiFi connections that drop out.
Definition: DCCEXProtocol.cpp:84
+
DCCEXProtocol::activateAccessory
void activateAccessory(int accessoryAddress, int accessorySubAddr)
Activate DCC accessory at the specified address and subaddress.
Definition: DCCEXProtocol.cpp:486
+
DCCEXProtocol::receivedLists
bool receivedLists()
Check if all lists have been received (roster, routes, turnouts, turntables)
Definition: DCCEXProtocol.cpp:173
+
DCCEXProtocol::getMajorVersion
int getMajorVersion()
Retrieve the major version of EX-CommandStation.
Definition: DCCEXProtocol.cpp:186
+
DCCEXProtocol::sendCommand
void sendCommand(char *cmd)
allows sending of an arbitray command
Definition: DCCEXProtocol.cpp:133
+
DCCEXProtocol::getLists
void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired)
Request DCC-EX object lists (Roster, Turnouts, Routes, Turntables)
Definition: DCCEXProtocol.cpp:139
+
DCCEXProtocol::activateLinearAccessory
void activateLinearAccessory(int linearAddress)
Activate DCC accessory at the specified linear address.
Definition: DCCEXProtocol.cpp:504
+
DCCEXProtocol::closeTurnout
void closeTurnout(int turnoutId)
Close the specified turnout/point.
Definition: DCCEXProtocol.cpp:337
+
DCCEXProtocol::powerTrackOn
void powerTrackOn(char track)
Turn power on for the specified track.
Definition: DCCEXProtocol.cpp:445
+
DCCEXProtocol::isFunctionOn
bool isFunctionOn(Loco *loco, int function)
Test if the specified function for the provided loco is on.
Definition: DCCEXProtocol.cpp:243
+
DCCEXProtocol::getTurntableById
Turntable * getTurntableById(int turntableId)
Retrieve a turntable object by its ID.
Definition: DCCEXProtocol.cpp:401
+
DCCEXProtocol::powerOn
void powerOn()
Global track power on command.
Definition: DCCEXProtocol.cpp:431
+
DCCEXProtocol::getTurnoutById
Turnout * getTurnoutById(int turnoutId)
Retrieve a turnout/point object by its ID.
Definition: DCCEXProtocol.cpp:328
+
DCCEXProtocol::turnouts
Turnout * turnouts
Linked list of Turnout objects to form the turnout list.
Definition: DCCEXProtocol.h:459
+
DCCEXProtocol::pauseRoutes
void pauseRoutes()
Pause all routes/automations.
Definition: DCCEXProtocol.cpp:377
+
DCCEXProtocol::getTurnoutCount
int getTurnoutCount()
Get the number of turnouts.
Definition: DCCEXProtocol.cpp:323
+
DCCEXProtocol::setLogStream
void setLogStream(Stream *console)
Set the stream object for console output.
Definition: DCCEXProtocol.cpp:82
DCCEXProtocol::DCCEXProtocol
DCCEXProtocol(int maxCmdBuffer=500)
Constructor for the DCCEXProtocol object.
Definition: DCCEXProtocol.cpp:50
-
DCCEXProtocol::resumeRoutes
void resumeRoutes()
Resume all routes/automations.
Definition: DCCEXProtocol.cpp:373
-
DCCEXProtocol::findLocoInRoster
Loco * findLocoInRoster(int address)
Search for the specified DCC address in the roster.
Definition: DCCEXProtocol.cpp:299
-
DCCEXProtocol::requestLocoUpdate
void requestLocoUpdate(int address)
Explicitly request an update for the specified loco.
Definition: DCCEXProtocol.cpp:265
-
DCCEXProtocol::deactivateLinearAccessory
void deactivateLinearAccessory(int linearAddress)
Deactivate DCC accessory at the specified linear address.
Definition: DCCEXProtocol.cpp:500
-
DCCEXProtocol::setDelegate
void setDelegate(DCCEXProtocolDelegate *delegate)
Set the delegate object for callbacks.
Definition: DCCEXProtocol.cpp:74
-
DCCEXProtocol::requestServerVersion
void requestServerVersion()
Request server version information.
Definition: DCCEXProtocol.cpp:162
-
DCCEXProtocol::check
void check()
Check for incoming DCC-EX broadcasts/responses and parse them.
Definition: DCCEXProtocol.cpp:90
-
DCCEXProtocol::emergencyStop
void emergencyStop()
Initiate an emergency stop.
Definition: DCCEXProtocol.cpp:281
+
DCCEXProtocol::resumeRoutes
void resumeRoutes()
Resume all routes/automations.
Definition: DCCEXProtocol.cpp:386
+
DCCEXProtocol::findLocoInRoster
Loco * findLocoInRoster(int address)
Search for the specified DCC address in the roster.
Definition: DCCEXProtocol.cpp:312
+
DCCEXProtocol::requestLocoUpdate
void requestLocoUpdate(int address)
Explicitly request an update for the specified loco.
Definition: DCCEXProtocol.cpp:278
+
DCCEXProtocol::deactivateLinearAccessory
void deactivateLinearAccessory(int linearAddress)
Deactivate DCC accessory at the specified linear address.
Definition: DCCEXProtocol.cpp:513
+
DCCEXProtocol::setDelegate
void setDelegate(DCCEXProtocolDelegate *delegate)
Set the delegate object for callbacks.
Definition: DCCEXProtocol.cpp:79
+
DCCEXProtocol::requestServerVersion
void requestServerVersion()
Request server version information.
Definition: DCCEXProtocol.cpp:175
+
DCCEXProtocol::check
void check()
Check for incoming DCC-EX broadcasts/responses and parse them.
Definition: DCCEXProtocol.cpp:100
+
DCCEXProtocol::emergencyStop
void emergencyStop()
Initiate an emergency stop.
Definition: DCCEXProtocol.cpp:294
Loco
Class for a Loco object representing a DCC addressed locomotive.
Definition: DCCEXLoco.h:54
-
NullStream
Nullstream class for initial DCCEXProtocol instantiation to direct streams to nothing.
Definition: DCCEXProtocol.h:96
-
NullStream::write
size_t write(uint8_t c)
Dummy write method for single int.
Definition: DCCEXProtocol.h:119
-
NullStream::peek
int peek()
Dummy peek method.
Definition: DCCEXProtocol.h:110
-
NullStream::available
int available()
Dummy availability check.
Definition: DCCEXProtocol.h:103
-
NullStream::flush
void flush()
Dummy flush method.
Definition: DCCEXProtocol.h:106
-
NullStream::NullStream
NullStream()
Constructor for the NullStream object.
Definition: DCCEXProtocol.h:99
-
NullStream::read
int read()
Dummy read method.
Definition: DCCEXProtocol.h:114
-
NullStream::write
size_t write(const uint8_t *buffer, size_t size)
Dummy write method for buffered input.
Definition: DCCEXProtocol.h:125
+
NullStream
Nullstream class for initial DCCEXProtocol instantiation to direct streams to nothing.
Definition: DCCEXProtocol.h:99
+
NullStream::write
size_t write(uint8_t c)
Dummy write method for single int.
Definition: DCCEXProtocol.h:122
+
NullStream::peek
int peek()
Dummy peek method.
Definition: DCCEXProtocol.h:113
+
NullStream::available
int available()
Dummy availability check.
Definition: DCCEXProtocol.h:106
+
NullStream::flush
void flush()
Dummy flush method.
Definition: DCCEXProtocol.h:109
+
NullStream::NullStream
NullStream()
Constructor for the NullStream object.
Definition: DCCEXProtocol.h:102
+
NullStream::read
int read()
Dummy read method.
Definition: DCCEXProtocol.h:117
+
NullStream::write
size_t write(const uint8_t *buffer, size_t size)
Dummy write method for buffered input.
Definition: DCCEXProtocol.h:128
Route
Class to contain and maintain the various Route attributes and methods.
Definition: DCCEXRoutes.h:40
Turnout
Class to contain and maintain the various Turnout/Point attributes and methods.
Definition: DCCEXTurnouts.h:35
Turntable
Class to contain and maintain the various Turntable attributes and methods.
Definition: DCCEXTurntables.h:82
diff --git a/DCCEXTurntables_8h_source.html b/DCCEXTurntables_8h_source.html index 0af6edd..d6e7b65 100644 --- a/DCCEXTurntables_8h_source.html +++ b/DCCEXTurntables_8h_source.html @@ -192,16 +192,16 @@
179 
180 #endif
TurntableIndex
Class to contain and maintain the various Turntable Index attributes and methods associated with a Tu...
Definition: DCCEXTurntables.h:41
-
TurntableIndex::TurntableIndex
TurntableIndex(int ttId, int id, int angle, char *name)
Constructor.
Definition: DCCEXTurntables.cpp:37
-
TurntableIndex::getName
char * getName()
Get index name.
Definition: DCCEXTurntables.cpp:51
-
TurntableIndex::getTTId
int getTTId()
Get the turntable ID.
Definition: DCCEXTurntables.cpp:45
-
TurntableIndex::getNextIndex
TurntableIndex * getNextIndex()
Get next TurntableIndex object.
Definition: DCCEXTurntables.cpp:53
-
TurntableIndex::getAngle
int getAngle()
Get angle of the index from home.
Definition: DCCEXTurntables.cpp:49
-
TurntableIndex::getId
int getId()
Get index ID (0 is always home)
Definition: DCCEXTurntables.cpp:47
+
TurntableIndex::TurntableIndex
TurntableIndex(int ttId, int id, int angle, char *name)
Constructor.
Definition: DCCEXTurntables.cpp:36
+
TurntableIndex::getName
char * getName()
Get index name.
Definition: DCCEXTurntables.cpp:50
+
TurntableIndex::getTTId
int getTTId()
Get the turntable ID.
Definition: DCCEXTurntables.cpp:44
+
TurntableIndex::getNextIndex
TurntableIndex * getNextIndex()
Get next TurntableIndex object.
Definition: DCCEXTurntables.cpp:52
+
TurntableIndex::getAngle
int getAngle()
Get angle of the index from home.
Definition: DCCEXTurntables.cpp:48
+
TurntableIndex::getId
int getId()
Get index ID (0 is always home)
Definition: DCCEXTurntables.cpp:46
Turntable
Class to contain and maintain the various Turntable attributes and methods.
Definition: DCCEXTurntables.h:82
Turntable::getNumberOfIndexes
int getNumberOfIndexes()
Get the number of indexes defined for the turntable.
Definition: DCCEXTurntables.cpp:92
Turntable::getIndexCount
int getIndexCount()
Get the count of indexes added to the index list (counted from the <JP id> command response)
Definition: DCCEXTurntables.cpp:104
-
Turntable::Turntable
Turntable(int id)
Constructor.
Definition: DCCEXTurntables.cpp:59
+
Turntable::Turntable
Turntable(int id)
Constructor.
Definition: DCCEXTurntables.cpp:58
Turntable::getFirst
static Turntable * getFirst()
Get the first turntable object.
Definition: DCCEXTurntables.cpp:106
Turntable::setNumberOfIndexes
void setNumberOfIndexes(int numberOfIndexes)
Set the number of indexes the turntable has defined (from the <JT id> command response)
Definition: DCCEXTurntables.cpp:90
Turntable::getCount
int getCount()
Get the number of turntables.
Definition: DCCEXTurntables.cpp:102
diff --git a/_sources/usage.rst.txt b/_sources/usage.rst.txt index 942d0f4..3d24a79 100644 --- a/_sources/usage.rst.txt +++ b/_sources/usage.rst.txt @@ -19,6 +19,8 @@ Once the `DCCEXProtocol` object is instantiated, a connection must be made to th It is also recommended to enable logging to an Arduino Stream using the `setLogStream(&stream)` method. +For WiFi clients, long periods of no interactive commands being sent may cause the WiFi client to be disconnected, so it is recommended to enable heartbeats for these, which defaults to sending a heartbeat every 60 seconds. If commands are sent regularly, no heartbeats are sent. + An example using an ESP32 with WiFi to connect to EX-CommandStation, with logging to the serial console: .. code-block:: cpp @@ -34,6 +36,7 @@ An example using an ESP32 with WiFi to connect to EX-CommandStation, with loggin while(1) delay(1000); } dccexProtocol.setLogStream(&Serial); + dccexProtocol.enableHeartbeat(); dccexProtocol.connect(&client); } @@ -100,7 +103,7 @@ All objects are contained within linked lists and can be access via for loops: // route methods are available here } - for (Turntable* turntable=dccexProtocol.roster->getFirst(); turntable; turntable=turntable->getNext()) { + for (Turntable* turntable=dccexProtocol.turntables->getFirst(); turntable; turntable=turntable->getNext()) { // turntable methods are available here for (TurntableIndex* ttIndex=turntable->getFirstIndex(); ttIndex; ttIndex=ttIndex->getNextIndex()) { // turntable index methods are available here diff --git a/bugs-requests.html b/bugs-requests.html index 387c942..41a552c 100644 --- a/bugs-requests.html +++ b/bugs-requests.html @@ -142,6 +142,7 @@
  • DCCEXProtocol::~DCCEXProtocol()
  • DCCEXProtocol::setDelegate()
  • DCCEXProtocol::setLogStream()
  • +
  • DCCEXProtocol::enableHeartbeat()
  • DCCEXProtocol::connect()
  • DCCEXProtocol::disconnect()
  • DCCEXProtocol::check()
  • @@ -203,6 +204,7 @@
  • DCCEXProtocol::_processServerDescription()
  • DCCEXProtocol::_processMessage()
  • DCCEXProtocol::_processScreenUpdate()
  • +
  • DCCEXProtocol::_sendHeartbeat()
  • DCCEXProtocol::_processLocoBroadcast()
  • DCCEXProtocol::_getValidFunctionMap()
  • DCCEXProtocol::_getSpeedFromSpeedByte()
  • @@ -261,6 +263,9 @@
  • DCCEXProtocol::_receivedRouteList
  • DCCEXProtocol::_turntableListRequested
  • DCCEXProtocol::_receivedTurntableList
  • +
  • DCCEXProtocol::_enableHeartbeat
  • +
  • DCCEXProtocol::_heartbeatDelay
  • +
  • DCCEXProtocol::_lastHeartbeat
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate
  • DCCEXProtocolDelegate