From 7f2a7165421c7775ae13777b43076d41eb12b190 Mon Sep 17 00:00:00 2001 From: Tim Roberts Date: Tue, 17 Jan 2017 09:20:08 -0500 Subject: [PATCH] Added broadcast support --- .../pro3/AtlonaPro3PortocolHandler.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/addons/binding/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java b/addons/binding/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java index d677a256d3173..6d59787d33315 100644 --- a/addons/binding/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java +++ b/addons/binding/org.openhab.binding.atlona/src/main/java/org/openhab/binding/atlona/internal/pro3/AtlonaPro3PortocolHandler.java @@ -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 @@ -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"; // ------------------------------------------------------------------------------------------------ @@ -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(); } @@ -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. * @@ -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;