diff --git a/org.openhab.binding.zigbee.ember/.classpath b/org.openhab.binding.zigbee.ember/.classpath
index ed1202591..dcf1fa621 100644
--- a/org.openhab.binding.zigbee.ember/.classpath
+++ b/org.openhab.binding.zigbee.ember/.classpath
@@ -1,12 +1,13 @@
-
+
+
-
+
diff --git a/org.openhab.binding.zigbee.ember/META-INF/MANIFEST.MF b/org.openhab.binding.zigbee.ember/META-INF/MANIFEST.MF
index f33111dc5..21db3071e 100644
--- a/org.openhab.binding.zigbee.ember/META-INF/MANIFEST.MF
+++ b/org.openhab.binding.zigbee.ember/META-INF/MANIFEST.MF
@@ -18,6 +18,7 @@ Import-Package: com.zsmartsystems.zigbee,
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.config.discovery,
+ org.eclipse.smarthome.config.discovery.usbserial,
org.eclipse.smarthome.core.i18n,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.thing,
@@ -26,6 +27,7 @@ Import-Package: com.zsmartsystems.zigbee,
org.eclipse.smarthome.core.thing.binding.firmware,
org.eclipse.smarthome.core.thing.type,
org.eclipse.smarthome.core.types,
+ org.junit;version="4.0.0";resolution:=optional,
org.openhab.binding.zigbee,
org.openhab.binding.zigbee.discovery,
org.openhab.binding.zigbee.handler,
diff --git a/org.openhab.binding.zigbee.ember/src/main/java/org/openhab/binding/zigbee/ember/internal/discovery/ZigBeeEmberUsbSerialDiscoveryParticipant.java b/org.openhab.binding.zigbee.ember/src/main/java/org/openhab/binding/zigbee/ember/internal/discovery/ZigBeeEmberUsbSerialDiscoveryParticipant.java
new file mode 100644
index 000000000..1e0df89d8
--- /dev/null
+++ b/org.openhab.binding.zigbee.ember/src/main/java/org/openhab/binding/zigbee/ember/internal/discovery/ZigBeeEmberUsbSerialDiscoveryParticipant.java
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2014-2018 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.openhab.binding.zigbee.ember.internal.discovery;
+
+import static java.util.Arrays.asList;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_BAUD;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_FLOWCONTROL;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_PORT;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.FLOWCONTROL_CONFIG_SOFTWARE_XONXOFF;
+import static org.openhab.binding.zigbee.ember.EmberBindingConstants.THING_TYPE_EMBER;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.smarthome.config.discovery.DiscoveryResult;
+import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder;
+import org.eclipse.smarthome.config.discovery.usbserial.UsbSerialDeviceInformation;
+import org.eclipse.smarthome.config.discovery.usbserial.UsbSerialDiscoveryParticipant;
+import org.eclipse.smarthome.core.thing.ThingTypeUID;
+import org.eclipse.smarthome.core.thing.ThingUID;
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * Discovery for ZigBee USB dongles, integrated in Eclipse SmartHome's USB-serial discovery by implementing
+ * a component of type {@link UsbSerialDiscoveryParticipant}.
+ *
+ * Currently, this {@link UsbSerialDiscoveryParticipant} supports the ZigBee dongle 'BV AV2010/10' from Bitron Video.
+ *
+ * @author Henning Sudbrock - initial contribution
+ */
+@Component(service = UsbSerialDiscoveryParticipant.class)
+public class ZigBeeEmberUsbSerialDiscoveryParticipant implements UsbSerialDiscoveryParticipant {
+
+ private static final Set SUPPORTED_THING_TYPES = new HashSet<>(asList(THING_TYPE_EMBER));
+
+ public static final int SILICON_LABS_USB_VENDOR_ID = 0x10c4;
+ public static final int BITRON_VIDEO_2010_10_PRODUCT_ID = 0x8b34;
+ private static final int BITRON_VIDEO_2010_10_BAUD_RATE = 57600;
+ private static final String BITRON_VIDEO_2010_10_DEFAULT_LABEL = "Bitron Video AV2010/10 Ember ZigBee Dongle";
+
+ @Override
+ public Set getSupportedThingTypeUIDs() {
+ return SUPPORTED_THING_TYPES;
+ }
+
+ @Override
+ public @Nullable DiscoveryResult createResult(UsbSerialDeviceInformation deviceInformation) {
+ if (isBitronVideoDongle(deviceInformation)) {
+ return DiscoveryResultBuilder.create(createBitronVideoDongleThingType(deviceInformation))
+ .withLabel(createBitronVideoDongleLabel(deviceInformation))
+ .withRepresentationProperty(CONFIGURATION_PORT)
+ .withProperty(CONFIGURATION_PORT, deviceInformation.getSerialPort())
+ .withProperty(CONFIGURATION_BAUD, BITRON_VIDEO_2010_10_BAUD_RATE)
+ .withProperty(CONFIGURATION_FLOWCONTROL, FLOWCONTROL_CONFIG_SOFTWARE_XONXOFF)
+ .build();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public @Nullable ThingUID getThingUID(UsbSerialDeviceInformation deviceInformation) {
+ if (isBitronVideoDongle(deviceInformation)) {
+ return createBitronVideoDongleThingType(deviceInformation);
+ } else {
+ return null;
+ }
+ }
+
+ private boolean isBitronVideoDongle(UsbSerialDeviceInformation deviceInformation) {
+ return deviceInformation.getVendorId() == SILICON_LABS_USB_VENDOR_ID
+ && deviceInformation.getProductId() == BITRON_VIDEO_2010_10_PRODUCT_ID;
+ }
+
+ private ThingUID createBitronVideoDongleThingType(UsbSerialDeviceInformation deviceInformation) {
+ return new ThingUID(THING_TYPE_EMBER, deviceInformation.getSerialNumber());
+ }
+
+ private @Nullable String createBitronVideoDongleLabel(UsbSerialDeviceInformation deviceInformation) {
+ if (deviceInformation.getProduct() != null && !deviceInformation.getProduct().isEmpty()) {
+ return deviceInformation.getProduct() + " (ZigBee USB dongle)";
+ } else {
+ return BITRON_VIDEO_2010_10_DEFAULT_LABEL;
+ }
+ }
+}
diff --git a/org.openhab.binding.zigbee.ember/src/test/java/org/openhab/binding/zigbee/ember/internal/discovery/ZigBeeEmberUsbSerialDiscoveryParticipantTest.java b/org.openhab.binding.zigbee.ember/src/test/java/org/openhab/binding/zigbee/ember/internal/discovery/ZigBeeEmberUsbSerialDiscoveryParticipantTest.java
new file mode 100644
index 000000000..af24ac391
--- /dev/null
+++ b/org.openhab.binding.zigbee.ember/src/test/java/org/openhab/binding/zigbee/ember/internal/discovery/ZigBeeEmberUsbSerialDiscoveryParticipantTest.java
@@ -0,0 +1,89 @@
+/**
+ * Copyright (c) 2014-2018 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.openhab.binding.zigbee.ember.internal.discovery;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_BAUD;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_PORT;
+import static org.openhab.binding.zigbee.ember.EmberBindingConstants.THING_TYPE_EMBER;
+import static org.openhab.binding.zigbee.ember.internal.discovery.ZigBeeEmberUsbSerialDiscoveryParticipant.BITRON_VIDEO_2010_10_PRODUCT_ID;
+import static org.openhab.binding.zigbee.ember.internal.discovery.ZigBeeEmberUsbSerialDiscoveryParticipant.SILICON_LABS_USB_VENDOR_ID;
+
+import org.eclipse.smarthome.config.discovery.DiscoveryResult;
+import org.eclipse.smarthome.config.discovery.usbserial.UsbSerialDeviceInformation;
+import org.eclipse.smarthome.core.thing.ThingUID;
+import org.junit.Before;
+import org.junit.Test;
+import org.openhab.binding.zigbee.ember.EmberBindingConstants;
+import org.openhab.binding.zigbee.ember.internal.discovery.ZigBeeEmberUsbSerialDiscoveryParticipant;
+
+/**
+ * Unit tests for the {@link ZigBeeEmberUsbSerialDiscoveryParticipant}.
+ */
+public class ZigBeeEmberUsbSerialDiscoveryParticipantTest {
+
+ private ZigBeeEmberUsbSerialDiscoveryParticipant discoveryParticipant;
+
+ @Before
+ public void setup() {
+ discoveryParticipant = new ZigBeeEmberUsbSerialDiscoveryParticipant();
+ }
+
+ /**
+ * If only USB vendor ID or only USB product ID or none of them matches, then no device is discovered.
+ */
+ @Test
+ public void testNonEmberDongleNotDiscovered() {
+ assertNull(discoveryParticipant.getThingUID(forUsbDongle(SILICON_LABS_USB_VENDOR_ID, 0x1234)));
+ assertNull(discoveryParticipant.getThingUID(forUsbDongle(0xabcd, BITRON_VIDEO_2010_10_PRODUCT_ID)));
+ assertNull(discoveryParticipant.getThingUID(forUsbDongle(0xabcd, 0x1234)));
+
+ assertNull(discoveryParticipant.createResult(forUsbDongle(SILICON_LABS_USB_VENDOR_ID, 0x1234)));
+ assertNull(discoveryParticipant.createResult(forUsbDongle(0xabcd, BITRON_VIDEO_2010_10_PRODUCT_ID)));
+ assertNull(discoveryParticipant.createResult(forUsbDongle(0xabcd, 0x1234)));
+ }
+
+ /**
+ * For matching USB vendor and product ID, a suitable thingUID is returned.
+ */
+ @Test
+ public void testEmberDongleDiscoveredThingUID() {
+ ThingUID thingUID = discoveryParticipant.getThingUID(
+ forUsbDongle(SILICON_LABS_USB_VENDOR_ID, BITRON_VIDEO_2010_10_PRODUCT_ID, "serial", "/dev/ttyUSB0"));
+
+ assertNotNull(thingUID);
+ assertEquals(thingUID, new ThingUID(THING_TYPE_EMBER, "serial"));
+ }
+
+ /**
+ * For matching USB vendor and product ID, a suitable discovery result is returned.
+ */
+ @Test
+ public void testEmberDongleDiscoveredDiscoveryResult() {
+ DiscoveryResult discoveryResult = discoveryParticipant.createResult(
+ forUsbDongle(SILICON_LABS_USB_VENDOR_ID, BITRON_VIDEO_2010_10_PRODUCT_ID, "serial", "/dev/ttyUSB0"));
+
+ assertNotNull(discoveryResult);
+ assertEquals(discoveryResult.getThingUID(), new ThingUID(THING_TYPE_EMBER, "serial"));
+ assertNotNull(discoveryResult.getLabel());
+ assertEquals(discoveryResult.getRepresentationProperty(), CONFIGURATION_PORT);
+ assertEquals(discoveryResult.getProperties().get(CONFIGURATION_PORT), "/dev/ttyUSB0");
+ assertNotNull(discoveryResult.getProperties().get(CONFIGURATION_BAUD));
+ }
+
+ private UsbSerialDeviceInformation forUsbDongle(int vendorId, int productId, String serial, String device) {
+ return new UsbSerialDeviceInformation(vendorId, productId, serial, null, null, 0, null, device);
+ }
+
+ private UsbSerialDeviceInformation forUsbDongle(int vendorId, int productId) {
+ return new UsbSerialDeviceInformation(vendorId, productId, null, null, null, 0, null, "/dev/ttyUSB0");
+ }
+
+}
diff --git a/org.openhab.binding.zigbee.telegesis/.classpath b/org.openhab.binding.zigbee.telegesis/.classpath
index ed1202591..dcf1fa621 100644
--- a/org.openhab.binding.zigbee.telegesis/.classpath
+++ b/org.openhab.binding.zigbee.telegesis/.classpath
@@ -1,12 +1,13 @@
-
+
+
-
+
diff --git a/org.openhab.binding.zigbee.telegesis/META-INF/MANIFEST.MF b/org.openhab.binding.zigbee.telegesis/META-INF/MANIFEST.MF
index 9872d1e35..84f688f67 100644
--- a/org.openhab.binding.zigbee.telegesis/META-INF/MANIFEST.MF
+++ b/org.openhab.binding.zigbee.telegesis/META-INF/MANIFEST.MF
@@ -19,6 +19,7 @@ Import-Package: com.zsmartsystems.zigbee,
org.eclipse.jdt.annotation;resolution:=optional,
org.eclipse.smarthome.config.core,
org.eclipse.smarthome.config.discovery,
+ org.eclipse.smarthome.config.discovery.usbserial,
org.eclipse.smarthome.core.i18n,
org.eclipse.smarthome.core.library.types,
org.eclipse.smarthome.core.thing,
@@ -27,6 +28,7 @@ Import-Package: com.zsmartsystems.zigbee,
org.eclipse.smarthome.core.thing.binding.firmware,
org.eclipse.smarthome.core.thing.type,
org.eclipse.smarthome.core.types,
+ org.junit;version="4.0.0";resolution:=optional,
org.openhab.binding.zigbee,
org.openhab.binding.zigbee.discovery,
org.openhab.binding.zigbee.handler,
diff --git a/org.openhab.binding.zigbee.telegesis/src/main/java/org/openhab/binding/zigbee/telegesis/internal/discovery/ZigBeeTelegesisUsbSerialDiscoveryParticipant.java b/org.openhab.binding.zigbee.telegesis/src/main/java/org/openhab/binding/zigbee/telegesis/internal/discovery/ZigBeeTelegesisUsbSerialDiscoveryParticipant.java
new file mode 100644
index 000000000..417503c7a
--- /dev/null
+++ b/org.openhab.binding.zigbee.telegesis/src/main/java/org/openhab/binding/zigbee/telegesis/internal/discovery/ZigBeeTelegesisUsbSerialDiscoveryParticipant.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2014-2018 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.openhab.binding.zigbee.telegesis.internal.discovery;
+
+import static java.util.Arrays.asList;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_BAUD;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_PORT;
+import static org.openhab.binding.zigbee.telegesis.TelegesisBindingConstants.THING_TYPE_TELEGESIS;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.smarthome.config.discovery.DiscoveryResult;
+import org.eclipse.smarthome.config.discovery.DiscoveryResultBuilder;
+import org.eclipse.smarthome.config.discovery.usbserial.UsbSerialDeviceInformation;
+import org.eclipse.smarthome.config.discovery.usbserial.UsbSerialDiscoveryParticipant;
+import org.eclipse.smarthome.core.thing.ThingTypeUID;
+import org.eclipse.smarthome.core.thing.ThingUID;
+import org.osgi.service.component.annotations.Component;
+
+/**
+ * Discovery for ZigBee USB dongles, integrated in Eclipse SmartHome's USB-serial discovery by implementing
+ * a component of type {@link UsbSerialDiscoveryParticipant}.
+ *
+ * Currently, this {@link UsbSerialDiscoveryParticipant} supports three USB dongles built around
+ * a SiLabs EM357 ZigBee chip and a CP210x USB to UART bridge.
+ *
+ * @author Henning Sudbrock - initial contribution
+ */
+@Component(service = UsbSerialDiscoveryParticipant.class)
+public class ZigBeeTelegesisUsbSerialDiscoveryParticipant implements UsbSerialDiscoveryParticipant {
+
+ private static final Set SUPPORTED_THING_TYPES = new HashSet<>(asList(THING_TYPE_TELEGESIS));
+
+ public static final int SILICON_LABS_USB_VENDOR_ID = 0x10c4;
+
+ /**
+ * For the {@link ZigBeeTelegesisUsbSerialDiscoveryParticipant#SILICON_LABS_USB_VENDOR_ID}, this USB product ID
+ * is used for the Telegesis ZigBee dongle model ETRX3USB+8M, as well as for one version of the QIVICON ZigBee stick
+ * (which is also produced by Telegesis).
+ */
+ public static final int QIVICON_DONGLE_V1_AND_TELEGESIS_USB_PRODUCT_ID = 0x8293;
+
+ /**
+ * For the {@link ZigBeeTelegesisUsbSerialDiscoveryParticipant#SILICON_LABS_USB_VENDOR_ID}, this USB product ID
+ * is used for one version of the QIVICON ZigBee stick.
+ */
+ public static final int QIVICON_DONGLE_V2_USB_PRODUCT_ID = 0x89fb;
+
+ private static final int QIVICON_DONGLE_BAUD_RATE = 19200;
+
+ private static final String QIVICON_DONGLE_DEFAULT_LABEL = "Telegesis ZigBee Dongle";
+
+ @Override
+ public Set getSupportedThingTypeUIDs() {
+ return SUPPORTED_THING_TYPES;
+ }
+
+ @Override
+ public @Nullable DiscoveryResult createResult(UsbSerialDeviceInformation deviceInformation) {
+ if (isQiviconTelegesisDongle(deviceInformation)) {
+ return DiscoveryResultBuilder.create(createQiviconTelegesisDongleThingType(deviceInformation))
+ .withLabel(createQiviconTelegesisDongleLabel(deviceInformation))
+ .withRepresentationProperty(CONFIGURATION_PORT)
+ .withProperty(CONFIGURATION_PORT, deviceInformation.getSerialPort())
+ .withProperty(CONFIGURATION_BAUD, QIVICON_DONGLE_BAUD_RATE).build();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+ public @Nullable ThingUID getThingUID(UsbSerialDeviceInformation deviceInformation) {
+ if (isQiviconTelegesisDongle(deviceInformation)) {
+ return createQiviconTelegesisDongleThingType(deviceInformation);
+ } else {
+ return null;
+ }
+ }
+
+ private boolean isQiviconTelegesisDongle(UsbSerialDeviceInformation deviceInformation) {
+ return deviceInformation.getVendorId() == SILICON_LABS_USB_VENDOR_ID
+ && (deviceInformation.getProductId() == QIVICON_DONGLE_V1_AND_TELEGESIS_USB_PRODUCT_ID
+ || deviceInformation.getProductId() == QIVICON_DONGLE_V2_USB_PRODUCT_ID);
+ }
+
+ private ThingUID createQiviconTelegesisDongleThingType(UsbSerialDeviceInformation deviceInformation) {
+ return new ThingUID(THING_TYPE_TELEGESIS, deviceInformation.getSerialNumber());
+ }
+
+ private @Nullable String createQiviconTelegesisDongleLabel(UsbSerialDeviceInformation deviceInformation) {
+ if (deviceInformation.getProduct() != null && !deviceInformation.getProduct().isEmpty()) {
+ return deviceInformation.getProduct() + " (ZigBee USB dongle)";
+ } else {
+ return QIVICON_DONGLE_DEFAULT_LABEL;
+ }
+ }
+}
diff --git a/org.openhab.binding.zigbee.telegesis/src/test/java/org/openhab/binding/zigbee/telegesis/internal/discovery/ZigBeeTelegesisUsbSerialDiscoveryParticipantTest.java b/org.openhab.binding.zigbee.telegesis/src/test/java/org/openhab/binding/zigbee/telegesis/internal/discovery/ZigBeeTelegesisUsbSerialDiscoveryParticipantTest.java
new file mode 100644
index 000000000..734724376
--- /dev/null
+++ b/org.openhab.binding.zigbee.telegesis/src/test/java/org/openhab/binding/zigbee/telegesis/internal/discovery/ZigBeeTelegesisUsbSerialDiscoveryParticipantTest.java
@@ -0,0 +1,119 @@
+/**
+ * Copyright (c) 2014-2018 by the respective copyright holders.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.openhab.binding.zigbee.telegesis.internal.discovery;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_BAUD;
+import static org.openhab.binding.zigbee.ZigBeeBindingConstants.CONFIGURATION_PORT;
+import static org.openhab.binding.zigbee.telegesis.TelegesisBindingConstants.THING_TYPE_TELEGESIS;
+import static org.openhab.binding.zigbee.telegesis.internal.discovery.ZigBeeTelegesisUsbSerialDiscoveryParticipant.QIVICON_DONGLE_V1_AND_TELEGESIS_USB_PRODUCT_ID;
+import static org.openhab.binding.zigbee.telegesis.internal.discovery.ZigBeeTelegesisUsbSerialDiscoveryParticipant.QIVICON_DONGLE_V2_USB_PRODUCT_ID;
+import static org.openhab.binding.zigbee.telegesis.internal.discovery.ZigBeeTelegesisUsbSerialDiscoveryParticipant.SILICON_LABS_USB_VENDOR_ID;
+
+import org.eclipse.smarthome.config.discovery.DiscoveryResult;
+import org.eclipse.smarthome.config.discovery.usbserial.UsbSerialDeviceInformation;
+import org.eclipse.smarthome.core.thing.ThingUID;
+import org.junit.Before;
+import org.junit.Test;
+import org.openhab.binding.zigbee.telegesis.internal.discovery.ZigBeeTelegesisUsbSerialDiscoveryParticipant;
+
+/**
+ * Unit tests for the {@link ZigBeeTelegesisUsbSerialDiscoveryParticipant}.
+ */
+public class ZigBeeTelegesisUsbSerialDiscoveryParticipantTest {
+
+ private ZigBeeTelegesisUsbSerialDiscoveryParticipant discoveryParticipant;
+
+ @Before
+ public void setup() {
+ discoveryParticipant = new ZigBeeTelegesisUsbSerialDiscoveryParticipant();
+ }
+
+ /**
+ * If only USB vendor ID or only USB product ID or none of them matches, then no device is discovered.
+ */
+ @Test
+ public void testNonTelegesisDongleNotDiscovered() {
+ assertNull(discoveryParticipant.getThingUID(forUsbDongle(SILICON_LABS_USB_VENDOR_ID, 0x1234)));
+ assertNull(discoveryParticipant.getThingUID(forUsbDongle(0xabcd, QIVICON_DONGLE_V1_AND_TELEGESIS_USB_PRODUCT_ID)));
+ assertNull(discoveryParticipant.getThingUID(forUsbDongle(0xabcd, QIVICON_DONGLE_V2_USB_PRODUCT_ID)));
+ assertNull(discoveryParticipant.getThingUID(forUsbDongle(0xabcd, 0x1234)));
+
+ assertNull(discoveryParticipant.createResult(forUsbDongle(SILICON_LABS_USB_VENDOR_ID, 0x1234)));
+ assertNull(discoveryParticipant.createResult(forUsbDongle(0xabcd, QIVICON_DONGLE_V1_AND_TELEGESIS_USB_PRODUCT_ID)));
+ assertNull(discoveryParticipant.createResult(forUsbDongle(0xabcd, QIVICON_DONGLE_V2_USB_PRODUCT_ID)));
+ assertNull(discoveryParticipant.createResult(forUsbDongle(0xabcd, 0x1234)));
+ }
+
+ /**
+ * For matching USB vendor and product ID, a suitable thingUID is returned.
+ */
+ @Test
+ public void testTelegesisDongleV1DiscoveredThingUID() {
+ ThingUID thingUID = discoveryParticipant.getThingUID(
+ forUsbDongle(SILICON_LABS_USB_VENDOR_ID, QIVICON_DONGLE_V1_AND_TELEGESIS_USB_PRODUCT_ID, "serial", "/dev/ttyUSB0"));
+
+ assertNotNull(thingUID);
+ assertEquals(thingUID, new ThingUID(THING_TYPE_TELEGESIS, "serial"));
+ }
+
+ /**
+ * For matching USB vendor and product ID, a suitable discovery result is returned.
+ */
+ @Test
+ public void testTelegesisDongleV1DiscoveredDiscoveryResult() {
+ DiscoveryResult discoveryResult = discoveryParticipant.createResult(
+ forUsbDongle(SILICON_LABS_USB_VENDOR_ID, QIVICON_DONGLE_V1_AND_TELEGESIS_USB_PRODUCT_ID, "serial", "/dev/ttyUSB0"));
+
+ assertNotNull(discoveryResult);
+ assertEquals(discoveryResult.getThingUID(), new ThingUID(THING_TYPE_TELEGESIS, "serial"));
+ assertNotNull(discoveryResult.getLabel());
+ assertEquals(discoveryResult.getRepresentationProperty(), CONFIGURATION_PORT);
+ assertEquals(discoveryResult.getProperties().get(CONFIGURATION_PORT), "/dev/ttyUSB0");
+ assertNotNull(discoveryResult.getProperties().get(CONFIGURATION_BAUD));
+ }
+
+ /**
+ * For matching USB vendor and product ID, a suitable thingUID is returned.
+ */
+ @Test
+ public void testTelegesisDongleV2DiscoveredThingUID() {
+ ThingUID thingUID = discoveryParticipant.getThingUID(
+ forUsbDongle(SILICON_LABS_USB_VENDOR_ID, QIVICON_DONGLE_V2_USB_PRODUCT_ID, "serial", "/dev/ttyUSB0"));
+
+ assertNotNull(thingUID);
+ assertEquals(thingUID, new ThingUID(THING_TYPE_TELEGESIS, "serial"));
+ }
+
+ /**
+ * For matching USB vendor and product ID, a suitable discovery result is returned.
+ */
+ @Test
+ public void testTelegesisDongleV2DiscoveredDiscoveryResult() {
+ DiscoveryResult discoveryResult = discoveryParticipant.createResult(
+ forUsbDongle(SILICON_LABS_USB_VENDOR_ID, QIVICON_DONGLE_V2_USB_PRODUCT_ID, "serial", "/dev/ttyUSB0"));
+
+ assertNotNull(discoveryResult);
+ assertEquals(discoveryResult.getThingUID(), new ThingUID(THING_TYPE_TELEGESIS, "serial"));
+ assertNotNull(discoveryResult.getLabel());
+ assertEquals(discoveryResult.getRepresentationProperty(), CONFIGURATION_PORT);
+ assertEquals(discoveryResult.getProperties().get(CONFIGURATION_PORT), "/dev/ttyUSB0");
+ assertNotNull(discoveryResult.getProperties().get(CONFIGURATION_BAUD));
+ }
+
+ private UsbSerialDeviceInformation forUsbDongle(int vendorId, int productId, String serial, String device) {
+ return new UsbSerialDeviceInformation(vendorId, productId, serial, null, null, 0, null, device);
+ }
+
+ private UsbSerialDeviceInformation forUsbDongle(int vendorId, int productId) {
+ return new UsbSerialDeviceInformation(vendorId, productId, null, null, null, 0, null, "/dev/ttyUSB0");
+ }
+
+}