Skip to content

Commit

Permalink
Added broadcast support
Browse files Browse the repository at this point in the history
  • Loading branch information
tmrobert8 committed Jan 17, 2017
1 parent db1532f commit 7f2a716
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class AtlonaPro3PortocolHandler {
private final static String CMD_RECALLIO_FORMAT = "Recall%d";
private final static String CMD_CLEARIO_FORMAT = "Clear%d";
private final static String CMD_MATRIX_RESET = "Mreset";
private final static String CMD_BROADCAST_ON = "Broadcast on";

// ------------------------------------------------------------------------------------------------
// The following are the various responses specified by the Atlona protocol
Expand All @@ -127,6 +128,7 @@ class AtlonaPro3PortocolHandler {
private final Pattern _saveIoPattern = Pattern.compile("Save(\\d+)");
private final Pattern _recallIoPattern = Pattern.compile("Recall(\\d+)");
private final Pattern _clearIoPattern = Pattern.compile("Clear(\\d+)");
private final Pattern _broadCastPattern = Pattern.compile("Broadcast (\\w+)");
private final static String RSP_MATRIX_RESET = "Mreset";

// ------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -286,8 +288,11 @@ private void postLogin() {
_session.addListener(new NormalResponseCallback());
_callback.statusChanged(ThingStatus.ONLINE, ThingStatusDetail.NONE, null);

// setup the most likely state of these switches (there is no protocol to get them)
// Set broadcast to on to receive notifications when
// routing changes (via the webpage, or presets or IR, etc)
sendCommand(CMD_BROADCAST_ON);

// setup the most likely state of these switches (there is no protocol to get them)
refreshAll();
}

Expand Down Expand Up @@ -935,6 +940,16 @@ private void handleClearIoResponse(Matcher m, String resp) {
// nothing to handle
}

/**
* Handles the broadcast Response. Should have one group specifying the status.
*
* @param m the non-null {@link Matcher} that matched the response
* @param resp the possibly null, possibly empty actual response
*/
private void handleBroadcastResponse(Matcher m, String resp) {
// nothing to handle
}

/**
* Handles the matrix reset response. The matrix will go offline immediately on a reset.
*
Expand Down Expand Up @@ -1056,6 +1071,12 @@ public void responseReceived(String response) {
return;
}

m = _broadCastPattern.matcher(response);
if (m.matches()) {
handleBroadcastResponse(m, response);
return;
}

if (RSP_IRON.equals(response) || RSP_IROFF.equals(response)) {
handleIrLockResponse(response);
return;
Expand Down

0 comments on commit 7f2a716

Please sign in to comment.