Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support discovery of USB dongles #178

Closed
hsudbrock opened this issue Apr 10, 2018 · 6 comments
Closed

Support discovery of USB dongles #178

hsudbrock opened this issue Apr 10, 2018 · 6 comments

Comments

@hsudbrock
Copy link
Contributor

Context
With eclipse-archived/smarthome#5315, Eclipse SmartHome supports the discovery of USB dongles which provide a serial port. To participate in this discovery, bindings can provide an instance of org.eclipse.smarthome.config.discovery.usbserial.UsbSerialDiscoveryParticipant. This UsbSerialDiscoveryParticipant will be called for newly discovered USB dongles with serial port, getting information about the USB dongle, the serial port, and the USB interface attached to the serial port. The UsbSerialDiscoveryParticipant can then provide DiscoveryResults for supported USB dongles.

Issue
The ZigBee binding should participate in this discovery, and provide DiscoveryResults for ZigBee USB dongles.

@hsudbrock
Copy link
Contributor Author

I would like to provide a first PR for this issue, enabling the discovery of the USB dongles that are available to me:

  • bitronVideo ZigBee dongle (Ember chip, "BV 2010/10"); USB vendor ID 10c4, USB product ID 8b34
  • Qivicon ZigBee dongle (Telegesis chip); USB vendor ID 10c4, USB product ID 8293
  • Qivicon ZigBee dongle (Telegesis chip); USB vendor ID 10c4, USB product ID 89fb

@cdjackson
Copy link
Contributor

cdjackson commented Apr 10, 2018 via email

hsudbrock added a commit to hsudbrock/org.openhab.binding.zigbee that referenced this issue Apr 10, 2018
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: openhab#178
Signed-off-by: Henning Sudbrock <[email protected]>
hsudbrock added a commit to hsudbrock/org.openhab.binding.zigbee that referenced this issue Apr 11, 2018
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: openhab#178
Signed-off-by: Henning Sudbrock <[email protected]>
hsudbrock added a commit to hsudbrock/org.openhab.binding.zigbee that referenced this issue Apr 11, 2018
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: openhab#178
Signed-off-by: Henning Sudbrock <[email protected]>
hsudbrock added a commit to hsudbrock/org.openhab.binding.zigbee that referenced this issue Apr 12, 2018
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: openhab#178
Signed-off-by: Henning Sudbrock <[email protected]>
hsudbrock added a commit to hsudbrock/org.openhab.binding.zigbee that referenced this issue Apr 12, 2018
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: openhab#178
Signed-off-by: Henning Sudbrock <[email protected]>
hsudbrock added a commit to hsudbrock/org.openhab.binding.zigbee that referenced this issue Apr 17, 2018
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: openhab#178
Signed-off-by: Henning Sudbrock <[email protected]>
hsudbrock added a commit to hsudbrock/org.openhab.binding.zigbee that referenced this issue Apr 20, 2018
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: openhab#178
Signed-off-by: Henning Sudbrock <[email protected]>
tomhoefer pushed a commit that referenced this issue Apr 21, 2018
…ber dongle) (#179)

* [178] Support Discovery of USB dongles (for some Telegesis and one Ember
dongle)

Adds discovery participants for the USB-serial discovery of Eclipse
SmartHome, able to discover three Telegesis dongles (from the Qivicon
brand) and one Ember dongle (from Bitron Video brand).

Bug: #178
Signed-off-by: Henning Sudbrock <[email protected]>

* Address review comments by @cdjackson and @tomhoefer.

* Rename constant for USB product ID for one Qivicon/Telgesis USB
dongle.
* Add flow control configuration for Ember discovery result (to XONOFF)

* Use constant for specifying flow control in ember USB discovery
participant

Signed-off-by: Henning Sudbrock <[email protected]>
@puzzle-star
Copy link
Contributor

Hi @hsudbrock,

I have seen that the discovery of the USB devices, and naming the different dongles via udev, do not seem to interface very well (at least for me).

The discovery participant is returning the /dev/ttyUSBx (for instance) and using the discovered device name as representationProperty. But this name might change between reboots, so normally, when using different dongles, we symlink to it (i.e. /dev/telegesis-1 -> /dev/ttyUSB0) via udev rules.

With the USB discovery, if for some reason the devname changes between reboots, the dongle becomes unusable. On the other side, if after discovering it I manually change the serial port of the device to the persistent name symlink, it will keep on appearing as new device in the inbox (yes, I can hide it, but it is annoying and maybe misleading for current users).

Changing the representationProperty to the serial number (or maybe vip_pid_serial) might prevent it from appearing again in the inbox (not sure), but would still require to manually change the serial port to the symlink.

Would it make sense to change (this is ESH, not OH):

Path devicePath = Paths.get(devDirectory).resolve(serialPortName);`

To some thing like (this is pseudocode, just to check if this would make sense to you):

Path devicePath = resolveDevicePath(devDirectory, serialPortName);
...
Path resolveDevicePath(String devDirectory, String serialPortName) {
    Path devicePath = Paths.get(devDirectory).resolve(serialPortName);
    File devDir = new File(devDirectory);
    for (File dev : devDir.listFiles()) {
       Path devPath = dev.toPath();
       if (Files.isSymbolicLink(devPath) && Files.isSameFile(devPath, devicePath)) return devPath;
    }
    return devicePath;
}

I know it is not the most efficient, as it traverses the the full dev directory looking for symlinks to the discovered path, but allows to honour the different dongle naming persistence.

Pedro

@cdjackson
Copy link
Contributor

@puzzle-star maybe it's better to create a new issue since this is closed a long time now, and it will get lost.

@puzzle-star
Copy link
Contributor

Done :)

@cdjackson
Copy link
Contributor

cdjackson commented Nov 24, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants