From 201f6b3246930f0bf54e33bfe3a582a9329c56af Mon Sep 17 00:00:00 2001 From: Brian O'Connell Date: Wed, 3 Nov 2021 23:44:14 -0400 Subject: [PATCH] fix(nuvo): fixes protocol errors when connecting via an MPS4 Signed-off-by: Brian O'Connell --- bundles/org.openhab.binding.nuvo/README.md | 6 +- .../nuvo/internal/NuvoBindingConstants.java | 3 + .../internal/communication/NuvoConnector.java | 6 + .../nuvo/internal/handler/NuvoHandler.java | 170 ++++++++++++------ 4 files changed, 128 insertions(+), 57 deletions(-) diff --git a/bundles/org.openhab.binding.nuvo/README.md b/bundles/org.openhab.binding.nuvo/README.md index 7939f2da9529d..512b4dafba780 100644 --- a/bundles/org.openhab.binding.nuvo/README.md +++ b/bundles/org.openhab.binding.nuvo/README.md @@ -47,8 +47,8 @@ The thing has the following configuration parameters: Some notes: -* The direct connection to the MPS4 server has not been exhaustively tested, please report any issues found. -* The only issue with the MPS4 connection seen thus far is that the setting SxDISPINFO as seen in the advanced rules below does not work. +* If the port is set to 5006 the binding will adjust its protocol to connect to a NuVo via an MPS4 IP connection. +* MPS4 connections do not support SxDISPINFO commands including those outlined in the advanced rules section below. * If a zone has a maximum volume limit configured by the Nuvo configurator, the volume slider will automatically drop back to that level if set above the configured limit. * Source display_line1 thru 4 can only be updated on non NuvoNet sources. * The track_position channel does not update continuously for NuvoNet sources. It only changes when the track changes or playback is paused/unpaused. @@ -104,7 +104,7 @@ nuvo:amplifier:myamp "Nuvo WHA" [ serialPort="COM5", numZones=6, clockSync=false // serial over IP connection nuvo:amplifier:myamp "Nuvo WHA" [ host="192.168.0.10", port=4444, numZones=6, clockSync=false] -// MPS4 server IP connection (experimental) +// MPS4 server IP connection nuvo:amplifier:myamp "Nuvo WHA" [ host="192.168.0.10", port=5006, numZones=6, clockSync=false] ``` diff --git a/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/NuvoBindingConstants.java b/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/NuvoBindingConstants.java index 5a365ae803ac7..3c04af93c000d 100644 --- a/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/NuvoBindingConstants.java +++ b/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/NuvoBindingConstants.java @@ -83,4 +83,7 @@ public class NuvoBindingConstants { public static final String NAME_QUOTE = "NAME\""; public static final String MUTE = "MUTE"; public static final String VOL = "VOL"; + + // MPS4 + public static final String TYPE_PING = "PING"; } diff --git a/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/communication/NuvoConnector.java b/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/communication/NuvoConnector.java index 35fe19ca55501..fd07ece33b853 100644 --- a/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/communication/NuvoConnector.java +++ b/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/communication/NuvoConnector.java @@ -45,6 +45,7 @@ public abstract class NuvoConnector { private static final String ALL_OFF = "#ALLOFF"; private static final String MUTE = "#MUTE"; private static final String PAGE = "#PAGE"; + private static final String PING = "#PING"; private static final byte[] WAKE_STR = "\r".getBytes(StandardCharsets.US_ASCII); @@ -304,6 +305,11 @@ public void handleIncomingMessage(byte[] incomingMessage) { return; } + if (message.contains(PING)) { + dispatchKeyValue(TYPE_PING, BLANK, BLANK); + return; + } + if (message.contains(VER_STR)) { // example: #VER"NV-E6G FWv2.66 HWv0" // split on " and return the version number diff --git a/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/handler/NuvoHandler.java b/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/handler/NuvoHandler.java index 6494814be4006..2a0100deddce8 100644 --- a/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/handler/NuvoHandler.java +++ b/bundles/org.openhab.binding.nuvo/src/main/java/org/openhab/binding/nuvo/internal/handler/NuvoHandler.java @@ -87,6 +87,7 @@ public class NuvoHandler extends BaseThingHandler implements NuvoMessageEventLis private static final long CLOCK_SYNC_INTERVAL_SEC = 3600; private static final long INITIAL_POLLING_DELAY_SEC = 30; private static final long INITIAL_CLOCK_SYNC_DELAY_SEC = 10; + private static final long PING_TIMEOUT_SEC = 60; // spec says wait 50ms, min is 100 private static final long SLEEP_BETWEEN_CMD_MS = 100; private static final Unit