1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 11:28:14 +00:00

Ignoring non-webusb devices

This commit is contained in:
Karel Bilek 2018-02-02 18:53:26 +01:00 committed by Pavol Rusnak
parent ac09c8d7de
commit 29ad78d57b

View File

@ -103,6 +103,8 @@ class WebUsbTransport(Transport):
for dev in context.getDeviceIterator(skip_on_error=True):
if not (is_trezor1(dev) or is_trezor2(dev) or is_trezor2_bl(dev)):
continue
if not is_vendor_class(dev):
continue
devices.append(WebUsbTransport(dev))
return devices
@ -175,6 +177,10 @@ def is_trezor2(dev):
def is_trezor2_bl(dev):
return (dev.getVendorID(), dev.getProductID()) == DEV_TREZOR2_BL
def is_vendor_class(dev):
configurationId = 0
altSettingId = 0
return dev[configurationId][INTERFACE][altSettingId].getClass() == usb1.libusb1.LIBUSB_CLASS_VENDOR_SPEC
def dev_to_str(dev):
return ':'.join(str(x) for x in ['%03i' % (dev.getBusNumber(), )] + dev.getPortNumberList())