mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-18 10:32:02 +00:00
transport_hid: more strict interface detection
This commit is contained in:
parent
2a3f613242
commit
b60ab51f9b
@ -53,11 +53,18 @@ class HidTransport(Transport):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def enumerate(debug=False):
|
def enumerate(debug=False):
|
||||||
return [
|
devices = []
|
||||||
HidTransport(dev) for dev in hid.enumerate(0, 0)
|
for dev in hid.enumerate(0, 0):
|
||||||
if ((is_trezor1(dev) or is_trezor2(dev) or is_trezor2_bl(dev)) and
|
if not (is_trezor1(dev) or is_trezor2(dev) or is_trezor2_bl(dev)):
|
||||||
(is_debug(dev) == debug))
|
continue
|
||||||
]
|
if debug:
|
||||||
|
if not is_debuglink(dev):
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if not is_wirelink(dev):
|
||||||
|
continue
|
||||||
|
devices.append(HidTransport(dev))
|
||||||
|
return devices
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def find_by_path(path=None):
|
def find_by_path(path=None):
|
||||||
@ -148,5 +155,9 @@ def is_trezor2_bl(dev):
|
|||||||
return (dev['vendor_id'], dev['product_id']) == DEV_TREZOR2_BL
|
return (dev['vendor_id'], dev['product_id']) == DEV_TREZOR2_BL
|
||||||
|
|
||||||
|
|
||||||
def is_debug(dev):
|
def is_wirelink(dev):
|
||||||
return (dev['usage_page'] == 0xFF01 or dev['interface_number'] == 1)
|
return (dev['usage_page'] == 0xFF00 or dev['interface_number'] == 0)
|
||||||
|
|
||||||
|
|
||||||
|
def is_debuglink(dev):
|
||||||
|
return (dev['usage_page'] == 0xFF01 or dev['interface_number'] == 1)
|
Loading…
Reference in New Issue
Block a user