Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions apps/usb_probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,34 @@ def is_bluetooth_hci(device):
# -----------------------------------------------------------------------------
@click.command()
@click.option('--verbose', is_flag=True, default=False, help='Print more details')
def main(verbose):
@click.option(
'--interactive',
is_flag=True,
default=False,
help='Detech a device by unplugging / replugging it in',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Detech -> Detect

)
def main(verbose, interactive):
logging.basicConfig(level=os.environ.get('BUMBLE_LOGLEVEL', 'WARNING').upper())

load_libusb()
with usb1.USBContext() as context:
bluetooth_device_count = 0
devices = {}

for device in context.getDeviceIterator(skip_on_error=True):
if interactive:
input("Unplug your device and press the enter key!")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to also support USB hotplug events to re-scan automatically when a device is removed/added, so you don't have to type anything on the keyboard.

devices_without = set(context.getDeviceIterator(skip_on_error=True))
input("Plug in your device and press the enter key!")
devices_with = set(context.getDeviceIterator(skip_on_error=True))
device_iterator = devices_with - devices_without
print()
if not device_iterator:
print("No differences detected, try again!")
return
else:
device_iterator = context.getDeviceIterator(skip_on_error=True)

for device in device_iterator:
device_class = device.getDeviceClass()
device_subclass = device.getDeviceSubClass()
device_protocol = device.getDeviceProtocol()
Expand Down