[oppo] Fix issue with polling and setting verbose mode (#8640)

Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
pull/8850/head
mlobstein 2020-10-23 11:36:36 -05:00 committed by GitHub
parent e8280b2ef9
commit 24343948cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 18 deletions

View File

@ -68,14 +68,10 @@ public enum OppoCommand {
private final String value; private final String value;
public static final Set<OppoCommand> INITIAL_COMMANDS = new HashSet<>(
Arrays.asList(QUERY_POWER_STATUS, QUERY_FIRMWARE_VERSION, QUERY_VOLUME, QUERY_HDMI_RESOLUTION,
QUERY_HDR_SETTING, QUERY_PLAYBACK_STATUS, QUERY_DISC_TYPE, QUERY_AUDIO_TYPE, QUERY_SUBTITLE_SHIFT,
QUERY_OSD_POSITION, QUERY_REPEAT_MODE, QUERY_ZOOM_MODE, QUERY_INPUT_SOURCE));
public static final Set<OppoCommand> QUERY_COMMANDS = new HashSet<>( public static final Set<OppoCommand> QUERY_COMMANDS = new HashSet<>(
Arrays.asList(QUERY_VOLUME, QUERY_HDMI_RESOLUTION, QUERY_PLAYBACK_STATUS, QUERY_DISC_TYPE, QUERY_AUDIO_TYPE, Arrays.asList(QUERY_VOLUME, QUERY_HDMI_RESOLUTION, QUERY_HDR_SETTING, QUERY_PLAYBACK_STATUS,
QUERY_SUBTITLE_SHIFT, QUERY_OSD_POSITION, QUERY_REPEAT_MODE, QUERY_ZOOM_MODE, QUERY_INPUT_SOURCE)); QUERY_DISC_TYPE, QUERY_AUDIO_TYPE, QUERY_SUBTITLE_SHIFT, QUERY_OSD_POSITION, QUERY_REPEAT_MODE,
QUERY_ZOOM_MODE, QUERY_INPUT_SOURCE, QUERY_FIRMWARE_VERSION));
OppoCommand(String value) { OppoCommand(String value) {
this.value = value; this.value = value;

View File

@ -13,6 +13,7 @@
package org.openhab.binding.oppo.internal.handler; package org.openhab.binding.oppo.internal.handler;
import static org.openhab.binding.oppo.internal.OppoBindingConstants.*; import static org.openhab.binding.oppo.internal.OppoBindingConstants.*;
import static org.openhab.core.thing.Thing.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
@ -88,7 +89,6 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
private List<StateOption> hdmiModeOptions = new ArrayList<>(); private List<StateOption> hdmiModeOptions = new ArrayList<>();
private long lastEventReceived = System.currentTimeMillis(); private long lastEventReceived = System.currentTimeMillis();
private String versionString = BLANK;
private String verboseMode = VERBOSE_2; private String verboseMode = VERBOSE_2;
private String currentChapter = BLANK; private String currentChapter = BLANK;
private String currentTimeMode = T; private String currentTimeMode = T;
@ -97,6 +97,8 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
private boolean isPowerOn = false; private boolean isPowerOn = false;
private boolean isUDP20X = false; private boolean isUDP20X = false;
private boolean isBdpIP = false; private boolean isBdpIP = false;
private boolean isVbModeSet = false;
private boolean isInitialQuery = false;
private Object sequenceLock = new Object(); private Object sequenceLock = new Object();
/** /**
@ -243,7 +245,12 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
if (command instanceof OnOffType) { if (command instanceof OnOffType) {
connector.sendCommand( connector.sendCommand(
command == OnOffType.ON ? OppoCommand.POWER_ON : OppoCommand.POWER_OFF); command == OnOffType.ON ? OppoCommand.POWER_ON : OppoCommand.POWER_OFF);
isPowerOn = (command == OnOffType.ON ? true : false);
// set the power flag to false only, will be set true by QPW or UPW messages
if (command == OnOffType.OFF) {
isPowerOn = false;
isInitialQuery = false;
}
} }
break; break;
case CHANNEL_VOLUME: case CHANNEL_VOLUME:
@ -369,7 +376,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
String key = evt.getKey(); String key = evt.getKey();
String updateData = evt.getValue().trim(); String updateData = evt.getValue().trim();
if (this.getThing().getStatus() == ThingStatus.OFFLINE) { if (this.getThing().getStatus() == ThingStatus.OFFLINE) {
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString); updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
} }
synchronized (sequenceLock) { synchronized (sequenceLock) {
@ -410,7 +417,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
updateChannelState(CHANNEL_TIME_DISPLAY, updateData); updateChannelState(CHANNEL_TIME_DISPLAY, updateData);
break; break;
case QVR: case QVR:
this.versionString = updateData; thing.setProperty(PROPERTY_FIRMWARE_VERSION, updateData);
break; break;
case QPW: case QPW:
updateChannelState(CHANNEL_POWER, updateData); updateChannelState(CHANNEL_POWER, updateData);
@ -426,6 +433,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
if (ZERO.equals(updateData)) { if (ZERO.equals(updateData)) {
currentPlayMode = BLANK; currentPlayMode = BLANK;
isPowerOn = false; isPowerOn = false;
isInitialQuery = false;
} else { } else {
isPowerOn = true; isPowerOn = true;
} }
@ -578,11 +586,11 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
try { try {
long prevUpdateTime = lastEventReceived; long prevUpdateTime = lastEventReceived;
connector.sendCommand(OppoCommand.SET_VERBOSE_MODE, this.verboseMode); connector.sendCommand(OppoCommand.QUERY_POWER_STATUS);
Thread.sleep(SLEEP_BETWEEN_CMD_MS); Thread.sleep(SLEEP_BETWEEN_CMD_MS);
// if the player is off most of these won't really do much... // if the player is off most of these won't really do much...
OppoCommand.INITIAL_COMMANDS.forEach(cmd -> { OppoCommand.QUERY_COMMANDS.forEach(cmd -> {
try { try {
connector.sendCommand(cmd); connector.sendCommand(cmd);
Thread.sleep(SLEEP_BETWEEN_CMD_MS); Thread.sleep(SLEEP_BETWEEN_CMD_MS);
@ -606,7 +614,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error); updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error);
closeConnection(); closeConnection();
} else { } else {
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString); updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
} }
} }
} }
@ -639,11 +647,20 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
synchronized (sequenceLock) { synchronized (sequenceLock) {
try { try {
// if using direct IP connection on the 83/9x/10x, no unsolicited updates are sent // the verbose mode must be set while the player is on
if (isPowerOn && !isVbModeSet && !isBdpIP) {
connector.sendCommand(OppoCommand.SET_VERBOSE_MODE, this.verboseMode);
isVbModeSet = true;
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
}
// If using direct serial connection, the query is done once after the player is turned on
// - OR - if using direct IP connection on the 83/9x/10x, no unsolicited updates are sent
// so we must query everything to know what changed. // so we must query everything to know what changed.
if (isBdpIP) { if ((isPowerOn && !isInitialQuery) || isBdpIP) {
connector.sendCommand(OppoCommand.QUERY_POWER_STATUS); connector.sendCommand(OppoCommand.QUERY_POWER_STATUS);
if (isPowerOn) { if (isPowerOn) {
isInitialQuery = true;
OppoCommand.QUERY_COMMANDS.forEach(cmd -> { OppoCommand.QUERY_COMMANDS.forEach(cmd -> {
try { try {
connector.sendCommand(cmd); connector.sendCommand(cmd);

View File

@ -6,9 +6,9 @@
<!-- Oppo Blu-ray disc player Thing --> <!-- Oppo Blu-ray disc player Thing -->
<thing-type id="player"> <thing-type id="player">
<label>Oppo</label> <label>Oppo Blu-ray Disc Player</label>
<description> <description>
An Oppo Blu-ray Disc Player Controls an Oppo Blu-ray Disc Player
</description> </description>
<channels> <channels>