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

usb_probe.py: Add interactive mode for finding a specific device #505

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AlanRosenthal
Copy link
Collaborator

❯ python apps/usb_probe.py --interactive
Unplug your device and press the enter key!
Plug in your device and press the enter key!

ID 2FE3:000B
  Bumble Transport Names: usb:0 or usb:2FE3:000B
  Bus/Device:             001/031
  Class:                  Wireless Controller
  Subclass/Protocol:      1/1 [Bluetooth]

````
❯ python apps/usb_probe.py --interactive
Unplug your device and press the enter key!
Plug in your device and press the enter key!

ID 2FE3:000B
  Bumble Transport Names: usb:0 or usb:2FE3:000B
  Bus/Device:             001/031
  Class:                  Wireless Controller
  Subclass/Protocol:      1/1 [Bluetooth]
````
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.

'--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

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

Successfully merging this pull request may close these issues.

2 participants