Skip to content

Commit

Permalink
Add support for broadcast messages
Browse files Browse the repository at this point in the history
  • Loading branch information
flash62au committed Mar 10, 2024
1 parent 93fdf71 commit 7043555
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=DCCEXProtocol
version=0.0.9
version=0.0.10
author=Peter Cole, Peter Akers <[email protected]>
maintainer=Peter Cole, Peter Akers <[email protected]>
sentence=DCC-EX Native Protocol implementation
Expand Down
10 changes: 10 additions & 0 deletions src/DCCEXProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,12 @@ void DCCEXProtocol::_processCommand() {
}
break;

case 'm': // Broadcast message
if (DCCEXInbound::isTextParameter(0)) {
_processMessage();
}
break;

case 'I': // Turntable broadcast
if (DCCEXInbound::getParameterCount()==3) {
_processTurntableBroadcast();
Expand Down Expand Up @@ -650,6 +656,10 @@ void DCCEXProtocol::_processServerDescription() { //<iDCCEX version / microproce
// console->println(F("processServerDescription(): end"));
}

void DCCEXProtocol::_processMessage() { //<m "message">
_delegate->receivedMessage(DCCEXInbound::getSafeText(0));
}

char* DCCEXProtocol::_nextServerDescriptionParam(char* description, int startAt, bool lookingAtVersionNumber) {
char _tempString[MAX_SERVER_DESCRIPTION_PARAM_LENGTH];
int i = 0;
Expand Down
6 changes: 6 additions & 0 deletions src/DCCEXProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
/*
Version information:
0.0.10 - Add support for broadcast messages
0.0.9 - if loco is selected by address and that loco is in the roster (with the same DCC Address), updated and send speed commands for both
0.0.8 - No functional changes, add cross-platform and unit testing capabilities (credit to higaski)
0.0.7 - Add isFunctionMomentary(int function);
Expand Down Expand Up @@ -119,6 +120,10 @@ class DCCEXProtocolDelegate {
/// @param patch Patch version of EX-CommandStation (eg. 5.0.7 returns 7)
virtual void receivedServerVersion(int major, int minor, int patch) {}

/// @brief Notify when a broadcast message has been received
/// @param message message that has been broadcast
virtual void receivedMessage(char* message) {}

/// @brief Notify when the roster list is received
virtual void receivedRosterList() {}

Expand Down Expand Up @@ -424,6 +429,7 @@ class DCCEXProtocol {
void _sendCommand();
void _processCommand();
void _processServerDescription();
void _processMessage();
char* _nextServerDescriptionParam(char* description, int startAt, bool lookingAtVersionNumber);

// Consist/loco methods
Expand Down

0 comments on commit 7043555

Please sign in to comment.