[oppo] Fix setting verbose mode at startup issue (#10306)
Signed-off-by: Michael Lobstein <michael.lobstein@gmail.com>pull/10319/head
parent
c6423120c9
commit
493f8c4ebe
|
@ -44,7 +44,7 @@ The thing has the following configuration parameters:
|
||||||
| Address | host | Host name or IP address of the Oppo player or serial over IP device. | host name or ip |
|
| Address | host | Host name or IP address of the Oppo player or serial over IP device. | host name or ip |
|
||||||
| Port | port | Communication port for using serial over IP. Leave blank if using direct IP connection to the player. | ip port number |
|
| Port | port | Communication port for using serial over IP. Leave blank if using direct IP connection to the player. | ip port number |
|
||||||
| Serial Port | serialPort | Serial port to use for directly connecting to the Oppo player | a comm port name |
|
| Serial Port | serialPort | Serial port to use for directly connecting to the Oppo player | a comm port name |
|
||||||
| Verbose Mode | verboseMode | (Optional) If true, the player will send time updates every second. If set false, the binding polls the player every 15 seconds. | Boolean; default false |
|
| Verbose Mode | verboseMode | (Optional) If true, the player will send time updates every second. If set false, the binding polls the player every 10 seconds. | Boolean; default false |
|
||||||
|
|
||||||
Some notes:
|
Some notes:
|
||||||
|
|
||||||
|
@ -54,9 +54,10 @@ Some notes:
|
||||||
* The UDP-20x series should be fully functional over direct IP connection but this was not able to be tested by the developer.
|
* The UDP-20x series should be fully functional over direct IP connection but this was not able to be tested by the developer.
|
||||||
* As previously noted, when using verbose mode, the player will send time code messages once per second while playback is ongoing.
|
* As previously noted, when using verbose mode, the player will send time code messages once per second while playback is ongoing.
|
||||||
* Be aware that this could cause performance impacts to your openHAB system.
|
* Be aware that this could cause performance impacts to your openHAB system.
|
||||||
* In non-verbose (the default), the binding will poll the player every 15 seconds to update play time, track and chapter information instead.
|
* In non-verbose (the default), the binding will poll the player every 10 seconds to update play time, track and chapter information instead.
|
||||||
* In order for the direct IP connection to work while the player is turned off, the Standby Mode setting must be set to "Quick Start" in the Device Setup menu.
|
* In order for the direct IP connection to work while the player is turned off, the Standby Mode setting must be set to "Quick Start" in the Device Setup menu.
|
||||||
* Likewise if the player is turned off, it may not be discoverable by the Binding's discovery scan.
|
* Likewise if the player is turned off, it may not be discoverable by the Binding's discovery scan.
|
||||||
|
* If the player is switched off when the binding first starts up or if power to the player is ever interrupted, up to 30 seconds may elapse before the binding begins to update when the player is switched on.
|
||||||
* If you experience any issues using the binding, first ensure that the player's firmware is up to date with the latest available version (especially on the older models).
|
* If you experience any issues using the binding, first ensure that the player's firmware is up to date with the latest available version (especially on the older models).
|
||||||
* For the older models, some of the features in the control API were added after the players were shipped.
|
* For the older models, some of the features in the control API were added after the players were shipped.
|
||||||
* Available HDMI modes for BDP-83 & BDP-9x: AUTO, SRC, 1080P, 1080I, 720P, SDP, SDI
|
* Available HDMI modes for BDP-83 & BDP-9x: AUTO, SRC, 1080P, 1080I, 720P, SDP, SDI
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
*/
|
*/
|
||||||
package org.openhab.binding.oppo.internal.communication;
|
package org.openhab.binding.oppo.internal.communication;
|
||||||
|
|
||||||
|
import static org.openhab.binding.oppo.internal.OppoBindingConstants.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
@ -38,6 +40,8 @@ public abstract class OppoConnector {
|
||||||
private static final Pattern QRY_PATTERN = Pattern.compile("^@(Q[A-Z0-9]{2}|VUP|VDN) OK (.*)$");
|
private static final Pattern QRY_PATTERN = Pattern.compile("^@(Q[A-Z0-9]{2}|VUP|VDN) OK (.*)$");
|
||||||
private static final Pattern STUS_PATTERN = Pattern.compile("^@(U[A-Z0-9]{2}) (.*)$");
|
private static final Pattern STUS_PATTERN = Pattern.compile("^@(U[A-Z0-9]{2}) (.*)$");
|
||||||
|
|
||||||
|
private static final String OK_ON = "@OK ON";
|
||||||
|
private static final String OK_OFF = "@OK OFF";
|
||||||
private static final String NOP_OK = "@NOP OK";
|
private static final String NOP_OK = "@NOP OK";
|
||||||
private static final String NOP = "NOP";
|
private static final String NOP = "NOP";
|
||||||
private static final String OK = "OK";
|
private static final String OK = "OK";
|
||||||
|
@ -249,6 +253,17 @@ public abstract class OppoConnector {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Before verbose mode 2 & 3 get set, these are the responses to QPW
|
||||||
|
if (OK_ON.equals(message)) {
|
||||||
|
dispatchKeyValue(QPW, ON);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (OK_OFF.equals(message)) {
|
||||||
|
dispatchKeyValue(QPW, OFF);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Player sent an OK response to a query: @QDT OK DVD-VIDEO or a volume update @VUP OK 100
|
// Player sent an OK response to a query: @QDT OK DVD-VIDEO or a volume update @VUP OK 100
|
||||||
Matcher matcher = QRY_PATTERN.matcher(message);
|
Matcher matcher = QRY_PATTERN.matcher(message);
|
||||||
if (matcher.find()) {
|
if (matcher.find()) {
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class OppoDiscoveryService extends AbstractDiscoveryService {
|
||||||
multiSocket.receive(receivePacket);
|
multiSocket.receive(receivePacket);
|
||||||
|
|
||||||
String message = new String(receivePacket.getData(), StandardCharsets.US_ASCII).trim();
|
String message = new String(receivePacket.getData(), StandardCharsets.US_ASCII).trim();
|
||||||
if (message != null && message.length() > 0) {
|
if (message.length() > 0) {
|
||||||
messageReceive(message);
|
messageReceive(message);
|
||||||
}
|
}
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
|
@ -158,7 +158,7 @@ public class OppoDiscoveryService extends AbstractDiscoveryService {
|
||||||
|
|
||||||
multiSocket.close();
|
multiSocket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
if (!e.getMessage().contains("No IP addresses bound to interface")) {
|
if (e.getMessage() != null && !e.getMessage().contains("No IP addresses bound to interface")) {
|
||||||
logger.debug("OppoDiscoveryService IOException: {}", e.getMessage(), e);
|
logger.debug("OppoDiscoveryService IOException: {}", e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,8 +69,8 @@ import org.slf4j.LoggerFactory;
|
||||||
@NonNullByDefault
|
@NonNullByDefault
|
||||||
public class OppoHandler extends BaseThingHandler implements OppoMessageEventListener {
|
public class OppoHandler extends BaseThingHandler implements OppoMessageEventListener {
|
||||||
private static final long RECON_POLLING_INTERVAL_SEC = 60;
|
private static final long RECON_POLLING_INTERVAL_SEC = 60;
|
||||||
private static final long POLLING_INTERVAL_SEC = 15;
|
private static final long POLLING_INTERVAL_SEC = 10;
|
||||||
private static final long INITIAL_POLLING_DELAY_SEC = 10;
|
private static final long INITIAL_POLLING_DELAY_SEC = 5;
|
||||||
private static final long SLEEP_BETWEEN_CMD_MS = 100;
|
private static final long SLEEP_BETWEEN_CMD_MS = 100;
|
||||||
|
|
||||||
private static final Pattern TIME_CODE_PATTERN = Pattern
|
private static final Pattern TIME_CODE_PATTERN = Pattern
|
||||||
|
@ -221,7 +221,7 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||||
*
|
*
|
||||||
* @param channelUID the channel sending the command
|
* @param channelUID the channel sending the command
|
||||||
* @param command the command received
|
* @param command the command received
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void handleCommand(ChannelUID channelUID, Command command) {
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
|
@ -615,6 +615,8 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||||
closeConnection();
|
closeConnection();
|
||||||
} else {
|
} else {
|
||||||
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
updateStatus(ThingStatus.ONLINE, ThingStatusDetail.NONE);
|
||||||
|
isInitialQuery = false;
|
||||||
|
isVbModeSet = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -647,19 +649,21 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||||
|
|
||||||
synchronized (sequenceLock) {
|
synchronized (sequenceLock) {
|
||||||
try {
|
try {
|
||||||
// the verbose mode must be set while the player is on
|
// Verbose mode 2 & 3 only do once until power comes on OR always for BDP direct IP
|
||||||
if (isPowerOn && !isVbModeSet && !isBdpIP) {
|
if ((!isPowerOn && !isInitialQuery) || isBdpIP) {
|
||||||
connector.sendCommand(OppoCommand.SET_VERBOSE_MODE, this.verboseMode);
|
connector.sendCommand(OppoCommand.QUERY_POWER_STATUS);
|
||||||
isVbModeSet = true;
|
|
||||||
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If using direct serial connection, the query is done once after the player is turned on
|
if (isPowerOn) {
|
||||||
// - OR - 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
|
||||||
// so we must query everything to know what changed.
|
if (!isVbModeSet && !isBdpIP) {
|
||||||
if ((isPowerOn && !isInitialQuery) || isBdpIP) {
|
connector.sendCommand(OppoCommand.SET_VERBOSE_MODE, this.verboseMode);
|
||||||
connector.sendCommand(OppoCommand.QUERY_POWER_STATUS);
|
isVbModeSet = true;
|
||||||
if (isPowerOn) {
|
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Verbose mode 2 & 3 only do once OR always for BDP direct IP
|
||||||
|
if (!isInitialQuery || isBdpIP) {
|
||||||
isInitialQuery = true;
|
isInitialQuery = true;
|
||||||
OppoCommand.QUERY_COMMANDS.forEach(cmd -> {
|
OppoCommand.QUERY_COMMANDS.forEach(cmd -> {
|
||||||
try {
|
try {
|
||||||
|
@ -670,34 +674,34 @@ public class OppoHandler extends BaseThingHandler implements OppoMessageEventLis
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// for Verbose mode 2 get the current play back time if we are playing, otherwise just do NO_OP
|
// for Verbose mode 2 get the current play back time if we are playing, otherwise just do
|
||||||
if ((VERBOSE_2.equals(this.verboseMode) && PLAY.equals(currentPlayMode))
|
// NO_OP
|
||||||
|| (isBdpIP && isPowerOn)) {
|
if ((VERBOSE_2.equals(this.verboseMode) && PLAY.equals(currentPlayMode)) || isBdpIP) {
|
||||||
switch (currentTimeMode) {
|
switch (currentTimeMode) {
|
||||||
case T:
|
case T:
|
||||||
connector.sendCommand(OppoCommand.QUERY_TITLE_ELAPSED);
|
connector.sendCommand(OppoCommand.QUERY_TITLE_ELAPSED);
|
||||||
break;
|
break;
|
||||||
case X:
|
case X:
|
||||||
connector.sendCommand(OppoCommand.QUERY_TITLE_REMAIN);
|
connector.sendCommand(OppoCommand.QUERY_TITLE_REMAIN);
|
||||||
break;
|
break;
|
||||||
case C:
|
case C:
|
||||||
connector.sendCommand(OppoCommand.QUERY_CHAPTER_ELAPSED);
|
connector.sendCommand(OppoCommand.QUERY_CHAPTER_ELAPSED);
|
||||||
break;
|
break;
|
||||||
case K:
|
case K:
|
||||||
connector.sendCommand(OppoCommand.QUERY_CHAPTER_REMAIN);
|
connector.sendCommand(OppoCommand.QUERY_CHAPTER_REMAIN);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
||||||
|
|
||||||
|
// make queries to refresh total number of titles/tracks & chapters
|
||||||
|
connector.sendCommand(OppoCommand.QUERY_TITLE_TRACK);
|
||||||
|
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
||||||
|
connector.sendCommand(OppoCommand.QUERY_CHAPTER);
|
||||||
|
} else if (!isBdpIP) {
|
||||||
|
// verbose mode 3
|
||||||
|
connector.sendCommand(OppoCommand.NO_OP);
|
||||||
}
|
}
|
||||||
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
|
||||||
|
|
||||||
// make queries to refresh total number of titles/tracks & chapters
|
|
||||||
connector.sendCommand(OppoCommand.QUERY_TITLE_TRACK);
|
|
||||||
Thread.sleep(SLEEP_BETWEEN_CMD_MS);
|
|
||||||
connector.sendCommand(OppoCommand.QUERY_CHAPTER);
|
|
||||||
} else if (!isBdpIP) {
|
|
||||||
// verbose mode 3
|
|
||||||
connector.sendCommand(OppoCommand.NO_OP);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OppoException | InterruptedException e) {
|
} catch (OppoException | InterruptedException e) {
|
||||||
|
|
Loading…
Reference in New Issue