Skip to content

Commit

Permalink
Introduce constants for the configuration values for flow control (#183)
Browse files Browse the repository at this point in the history
In the configuration, the different options for flow control are encoded
by 0, 1, and 2. Those values are now available as constants in the
binding.

Signed-off-by: Henning Sudbrock <[email protected]>
  • Loading branch information
hsudbrock authored and cdjackson committed Apr 16, 2018
1 parent f9fdbd7 commit dfd90c9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.eclipse.smarthome.core.thing.binding.firmware.FirmwareUpdateHandler;
import org.eclipse.smarthome.core.thing.binding.firmware.ProgressCallback;
import org.eclipse.smarthome.core.thing.binding.firmware.ProgressStep;
import org.openhab.binding.zigbee.ZigBeeBindingConstants;
import org.openhab.binding.zigbee.ember.internal.EmberConfiguration;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.handler.ZigBeeSerialPort;
Expand Down Expand Up @@ -60,18 +61,14 @@ public void initialize() {
EmberConfiguration config = getConfigAs(EmberConfiguration.class);

FlowControl flowControl;
switch (config.zigbee_flowcontrol) {
case 1: // Hardware
flowControl = FlowControl.FLOWCONTROL_OUT_RTSCTS;
break;
case 2: // Software
flowControl = FlowControl.FLOWCONTROL_OUT_XONOFF;
break;
default:
flowControl = FlowControl.FLOWCONTROL_OUT_NONE;
break;
if (ZigBeeBindingConstants.FLOWCONTROL_CONFIG_HARDWARE_CTSRTS.equals(config.zigbee_flowcontrol)) {
flowControl = FlowControl.FLOWCONTROL_OUT_RTSCTS;
} else if (ZigBeeBindingConstants.FLOWCONTROL_CONFIG_SOFTWARE_XONXOFF.equals(config.zigbee_flowcontrol)) {
flowControl = FlowControl.FLOWCONTROL_OUT_XONOFF;
} else {
flowControl = FlowControl.FLOWCONTROL_OUT_NONE;
}

ZigBeePort serialPort = new ZigBeeSerialPort(config.zigbee_port, config.zigbee_baud, flowControl);
final ZigBeeTransportTransmit dongle = new ZigBeeDongleEzsp(serialPort);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.openhab.binding.zigbee.xbee.handler;

import org.eclipse.smarthome.core.thing.Bridge;
import org.openhab.binding.zigbee.ZigBeeBindingConstants;
import org.openhab.binding.zigbee.handler.ZigBeeCoordinatorHandler;
import org.openhab.binding.zigbee.handler.ZigBeeSerialPort;
import org.openhab.binding.zigbee.xbee.internal.XBeeConfiguration;
Expand Down Expand Up @@ -51,16 +52,12 @@ public void initialize() {
XBeeConfiguration config = getConfigAs(XBeeConfiguration.class);

FlowControl flowControl;
switch (config.zigbee_flowcontrol) {
case 1: // Hardware
flowControl = FlowControl.FLOWCONTROL_OUT_RTSCTS;
break;
case 2: // Software
flowControl = FlowControl.FLOWCONTROL_OUT_XONOFF;
break;
default:
flowControl = FlowControl.FLOWCONTROL_OUT_NONE;
break;
if (ZigBeeBindingConstants.FLOWCONTROL_CONFIG_HARDWARE_CTSRTS.equals(config.zigbee_flowcontrol)) {
flowControl = FlowControl.FLOWCONTROL_OUT_RTSCTS;
} else if (ZigBeeBindingConstants.FLOWCONTROL_CONFIG_SOFTWARE_XONXOFF.equals(config.zigbee_flowcontrol)) {
flowControl = FlowControl.FLOWCONTROL_OUT_XONOFF;
} else {
flowControl = FlowControl.FLOWCONTROL_OUT_NONE;
}

ZigBeePort serialPort = new ZigBeeSerialPort(config.zigbee_port, config.zigbee_baud, flowControl);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ public class ZigBeeBindingConstants {
public final static String OFFLINE_NO_ADDRESS = "@text/zigbee.status.offline_noaddress";
public final static String OFFLINE_NODE_NOT_FOUND = "@text/zigbee.status.offline_nodenotfound";
public final static String OFFLINE_DISCOVERY_INCOMPLETE = "@text/zigbee.status.offline_discoveryincomplete";

// List of configuration values for flow control
public final static Integer FLOWCONTROL_CONFIG_NONE = Integer.valueOf(0);
public final static Integer FLOWCONTROL_CONFIG_HARDWARE_CTSRTS = Integer.valueOf(1);
public final static Integer FLOWCONTROL_CONFIG_SOFTWARE_XONXOFF = Integer.valueOf(2);

/**
* Return an ISO 8601 combined date and time string for current date/time
Expand Down

0 comments on commit dfd90c9

Please sign in to comment.