Skip to content

Commit

Permalink
Review comment: baudRate as parameter
Browse files Browse the repository at this point in the history
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
  • Loading branch information
lolodomo committed Mar 15, 2024
1 parent dd5abf5 commit a74bd4a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,7 @@ public enum RotelModel {
NUMERIC_KEY_CMDS, ZONE234_NUMERIC_KEY_CMDS, MENU3_CTRL_CMDS, OTHER_CMDS_SET1, OTHER_CMDS_SET2,
OTHER_CMDS_SET4, OTHER_CMDS_SET8),
(byte) 0xCC, 42, 5, true, RotelFlagsMapping.MAPPING5),
RX1052_19200("RX-1052 (baud rate 19200)", 19200, 22, 3, true, 90, true, 10, false, RECORD_FONCTION_SELECT, -1,
concatenate(TUNER_CMDS_SET2, ZONE234_TUNER_CMDS_SET1, NUMERIC_KEY_CMDS, ZONE234_NUMERIC_KEY_CMDS,
OTHER_CMDS_SET2, OTHER_CMDS_SET9),
(byte) 0x61, 11, 5, false, RotelFlagsMapping.MAPPING6),
RX1052_38400("RX-1052 (baud rate 38400)", 38400, 22, 3, true, 90, true, 10, false, RECORD_FONCTION_SELECT, -1,
RX1052("RX-1052", 38400, 22, 3, true, 90, true, 10, false, RECORD_FONCTION_SELECT, -1,
concatenate(TUNER_CMDS_SET2, ZONE234_TUNER_CMDS_SET1, NUMERIC_KEY_CMDS, ZONE234_NUMERIC_KEY_CMDS,
OTHER_CMDS_SET2, OTHER_CMDS_SET9),
(byte) 0x61, 11, 5, false, RotelFlagsMapping.MAPPING6),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.openhab.binding.rotel.internal.configuration;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* The {@link RotelThingConfiguration} class contains fields mapping thing configuration parameters.
Expand All @@ -22,8 +23,8 @@
@NonNullByDefault
public class RotelThingConfiguration {

public @NonNullByDefault({}) Boolean newerUnit;
public @NonNullByDefault({}) String serialPort;
public @Nullable Integer baudRate;
public @NonNullByDefault({}) String host;
public @NonNullByDefault({}) Integer port;
public @NonNullByDefault({}) String inputLabelCd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public void initialize() {
model = RotelModel.RSX1562;
break;
case THING_TYPE_ID_RX1052:
model = config.newerUnit ? RotelModel.RX1052_38400 : RotelModel.RX1052_19200;
model = RotelModel.RX1052;
break;
case THING_TYPE_ID_A11:
model = RotelModel.A11;
Expand Down Expand Up @@ -440,8 +440,9 @@ public void initialize() {
if (USE_SIMULATED_DEVICE) {
connector = new RotelSimuConnector(model, protocolHandler, sourcesLabels, readerThreadName);
} else if (config.serialPort != null) {
connector = new RotelSerialConnector(serialPortManager, config.serialPort, model.getBaudRate(),
protocolHandler, readerThreadName);
connector = new RotelSerialConnector(serialPortManager, config.serialPort,
config.baudRate != null ? config.baudRate : model.getBaudRate(), protocolHandler,
readerThreadName);
} else {
connector = new RotelIpConnector(config.host, config.port, protocolHandler, readerThreadName);
}
Expand Down Expand Up @@ -2603,9 +2604,9 @@ private RotelCommand getVolumeUpCommand(int numZone) {
case 0:
// Spec for RX-1052 defines an unusual code for main zone volume up.
// An error in the spec is suspected. The general volume up code is preferred.
return (model.hasOtherThanPrimaryCommands() && model != RotelModel.RX1052_19200
&& model != RotelModel.RX1052_38400) ? RotelCommand.MAIN_ZONE_VOLUME_UP
: RotelCommand.VOLUME_UP;
return (model.hasOtherThanPrimaryCommands() && model != RotelModel.RX1052)
? RotelCommand.MAIN_ZONE_VOLUME_UP
: RotelCommand.VOLUME_UP;
case 1:
return RotelCommand.ZONE1_VOLUME_UP;
case 2:
Expand All @@ -2631,9 +2632,9 @@ private RotelCommand getVolumeDownCommand(int numZone) {
case 0:
// Spec for RX-1052 defines an unusual code for main zone volume down.
// An error in the spec is suspected. The general volume down code is preferred.
return (model.hasOtherThanPrimaryCommands() && model != RotelModel.RX1052_19200
&& model != RotelModel.RX1052_38400) ? RotelCommand.MAIN_ZONE_VOLUME_DOWN
: RotelCommand.VOLUME_DOWN;
return (model.hasOtherThanPrimaryCommands() && model != RotelModel.RX1052)
? RotelCommand.MAIN_ZONE_VOLUME_DOWN
: RotelCommand.VOLUME_DOWN;
case 1:
return RotelCommand.ZONE1_VOLUME_DOWN;
case 2:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -321,17 +321,22 @@
</config-description>

<config-description uri="thing-type:rotel:serial6">
<parameter name="newerUnit" type="boolean" required="false">
<label>@text/config.newerUnit.label</label>
<description>@text/config.newerUnit.description</description>
<default>true</default>
</parameter>
<parameter name="serialPort" type="text" required="false">
<context>serial-port</context>
<limitToOptions>false</limitToOptions>
<label>@text/config.serialPort.label</label>
<description>@text/config.serialPort.description</description>
</parameter>
<parameter name="baudRate" type="integer" required="false">
<label>@text/config.baudRate.label</label>
<description>@text/config.baudRate.description</description>
<limitToOptions>true</limitToOptions>
<options>
<option value="19200">19200</option>
<option value="38400">38400</option>
</options>
<default>38400</default>
</parameter>
<parameter name="host" type="text" required="false">
<context>network-address</context>
<label>@text/config.hostOverIp.label</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ channel-type.rotel.volumeUpDown.description = Increase or decrease the volume

# thing type configuration

config.baudRate.label = Baud Rate
config.baudRate.description = Choose 38400 as baud rate if your black unit has at least serial number 090-6441001 or your silver unit has at least serial number 990-6441001.
config.host.label = Address
config.host.description = Host name or IP address of the Rotel device (IP connection) or the machine connected to the Rotel device (serial over IP)
config.hostOverIp.label = Address
Expand All @@ -172,8 +174,6 @@ config.inputLabelVideo5.label = Input Label Video 5
config.inputLabelVideo5.description = Label setup for the source Video 5
config.inputLabelVideo6.label = Input Label Video 6
config.inputLabelVideo6.description = Label setup for the source Video 6
config.newerUnit.label = Newer Unit
config.newerUnit.description = Newer units use a highest baud rate for the serial communication. Enable this parameter if your unit has a serial number after 090-6441001 (Black unit) or 990-6441001 (Silver unit).
config.port.label = Port
config.port.description = Communication port (IP or serial over IP). For IP connection to the Rotel device, keep the default port 9590
config.portOverIp.label = Port
Expand Down

0 comments on commit a74bd4a

Please sign in to comment.