mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[oppo] Fix issue with polling and setting verbose mode (#8849)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>
This commit is contained in:
parent
eb982a04f8
commit
2d93a26d21
@ -38,6 +38,8 @@ public class OppoBindingConstants {
|
||||
public static final Integer BDP10X_PORT = 48360;
|
||||
public static final Integer BDP20X_PORT = 23;
|
||||
|
||||
public static final String FIRMWARE_PROPERTY = "Firmware Version";
|
||||
|
||||
// List of all Channels
|
||||
public static final String CHANNEL_POWER = "power";
|
||||
public static final String CHANNEL_VOLUME = "volume";
|
||||
|
@ -68,14 +68,10 @@ public enum OppoCommand {
|
||||
|
||||
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<>(
|
||||
Arrays.asList(QUERY_VOLUME, QUERY_HDMI_RESOLUTION, QUERY_PLAYBACK_STATUS, QUERY_DISC_TYPE, QUERY_AUDIO_TYPE,
|
||||
QUERY_SUBTITLE_SHIFT, QUERY_OSD_POSITION, QUERY_REPEAT_MODE, QUERY_ZOOM_MODE, QUERY_INPUT_SOURCE));
|
||||
Arrays.asList(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, QUERY_FIRMWARE_VERSION));
|
||||
|
||||
OppoCommand(String value) {
|
||||
this.value = value;
|
||||
|
@ -88,7 +88,6 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
private List<StateOption> hdmiModeOptions = new ArrayList<>();
|
||||
|
||||
private long lastEventReceived = System.currentTimeMillis();
|
||||
private String versionString = BLANK;
|
||||
private String verboseMode = VERBOSE_2;
|
||||
private String currentChapter = BLANK;
|
||||
private String currentTimeMode = T;
|
||||
@ -97,6 +96,8 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
private boolean isPowerOn = false;
|
||||
private boolean isUDP20X = false;
|
||||
private boolean isBdpIP = false;
|
||||
private boolean isVbModeSet = false;
|
||||
private boolean isInitialQuery = false;
|
||||
private Object sequenceLock = new Object();
|
||||
|
||||
/**
|
||||
@ -243,7 +244,12 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
if (command instanceof OnOffType) {
|
||||
connector.sendCommand(
|
||||
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;
|
||||
case CHANNEL_VOLUME:
|
||||
@ -369,7 +375,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
String key = evt.getKey();
|
||||
String updateData = evt.getValue().trim();
|
||||
if (this.getThing().getStatus() == ThingStatus.OFFLINE) {
|
||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString);
|
||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
||||
}
|
||||
|
||||
synchronized (sequenceLock) {
|
||||
@ -410,7 +416,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
updateChannelState(CHANNEL_TIME_DISPLAY, updateData);
|
||||
break;
|
||||
case QVR:
|
||||
this.versionString = updateData;
|
||||
thing.setProperty(FIRMWARE_PROPERTY, updateData);
|
||||
break;
|
||||
case QPW:
|
||||
updateChannelState(CHANNEL_POWER, updateData);
|
||||
@ -426,6 +432,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
if (ZERO.equals(updateData)) {
|
||||
currentPlayMode = BLANK;
|
||||
isPowerOn = false;
|
||||
isInitialQuery = false;
|
||||
} else {
|
||||
isPowerOn = true;
|
||||
}
|
||||
@ -578,11 +585,11 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
try {
|
||||
long prevUpdateTime = lastEventReceived;
|
||||
|
||||
connector.sendCommand(OppoCommand.SET_VERBOSE_MODE, this.verboseMode);
|
||||
connector.sendCommand(OppoCommand.QUERY_POWER_STATUS);
|
||||
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
||||
|
||||
// if the player is off most of these won't really do much...
|
||||
OppoCommand.INITIAL_COMMANDS.forEach(cmd -> {
|
||||
OppoCommand.QUERY_COMMANDS.forEach(cmd -> {
|
||||
try {
|
||||
connector.sendCommand(cmd);
|
||||
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
||||
@ -606,7 +613,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, error);
|
||||
closeConnection();
|
||||
} else {
|
||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE, this.versionString);
|
||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -639,11 +646,20 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||
|
||||
synchronized (sequenceLock) {
|
||||
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.
|
||||
if (isBdpIP) {
|
||||
if ((isPowerOn && !isInitialQuery) || isBdpIP) {
|
||||
connector.sendCommand(OppoCommand.QUERY_POWER_STATUS);
|
||||
if (isPowerOn) {
|
||||
isInitialQuery = true;
|
||||
OppoCommand.QUERY_COMMANDS.forEach(cmd -> {
|
||||
try {
|
||||
connector.sendCommand(cmd);
|
||||
|
@ -6,9 +6,9 @@
|
||||
|
||||
<!-- Oppo Blu-ray disc player Thing -->
|
||||
<thing-type id="player">
|
||||
<label>Oppo</label>
|
||||
<label>Oppo Blu-ray Disc Player</label>
|
||||
<description>
|
||||
An Oppo Blu-ray Disc Player
|
||||
Controls an Oppo Blu-ray Disc Player
|
||||
</description>
|
||||
|
||||
<channels>
|
||||
@ -40,6 +40,10 @@
|
||||
<channel id="remote_button" typeId="remote_button"/>
|
||||
</channels>
|
||||
|
||||
<properties>
|
||||
<property name="Firmware Version">unknown</property>
|
||||
</properties>
|
||||
|
||||
<config-description>
|
||||
<parameter name="model" type="integer" required="true">
|
||||
<label>Player Model</label>
|
||||
|
Loading…
Reference in New Issue
Block a user