From 6aa9e0bdf7b37a1c05177994d030ef3089f18084 Mon Sep 17 00:00:00 2001 From: Stryxion Date: Thu, 8 Jan 2026 14:54:58 +0100 Subject: [PATCH 1/4] feat: Add filtering options for usb probe --- apps/usb_probe.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/apps/usb_probe.py b/apps/usb_probe.py index 404efbac..6c23af56 100644 --- a/apps/usb_probe.py +++ b/apps/usb_probe.py @@ -166,7 +166,10 @@ def is_bluetooth_hci(device): # ----------------------------------------------------------------------------- @click.command() @click.option('--verbose', is_flag=True, default=False, help='Print more details') -def main(verbose): +@click.option('--manufacturer', default="", help='filter by manufacturer') +@click.option('--product', default="", help='filter by product') +@click.option('-hci-only', default=False, is_flag=True, help='filter by hci device') +def main(verbose:bool, manufacturer:str, product:str, hci_only:bool): bumble.logging.setup_basic_logging('WARNING') load_libusb() @@ -234,6 +237,17 @@ def main(verbose): f'{basic_transport_name}/{device_serial_number}' ) + # Filter + if product != "": + if device_product != product: + continue + if manufacturer != "": + if device_manufacturer != manufacturer: + continue + + if not is_bluetooth_hci(device) and hci_only: + continue + # Print the results print( color( From 05fd4fbfc67e91e3b3233f3f369d68be1f80cc18 Mon Sep 17 00:00:00 2001 From: Stryxion Date: Fri, 9 Jan 2026 08:46:31 +0100 Subject: [PATCH 2/4] fix: review --- apps/usb_probe.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/apps/usb_probe.py b/apps/usb_probe.py index 6c23af56..38144ff1 100644 --- a/apps/usb_probe.py +++ b/apps/usb_probe.py @@ -166,10 +166,10 @@ def is_bluetooth_hci(device): # ----------------------------------------------------------------------------- @click.command() @click.option('--verbose', is_flag=True, default=False, help='Print more details') -@click.option('--manufacturer', default="", help='filter by manufacturer') -@click.option('--product', default="", help='filter by product') -@click.option('-hci-only', default=False, is_flag=True, help='filter by hci device') -def main(verbose:bool, manufacturer:str, product:str, hci_only:bool): +@click.option('--hci-only', is_flag=True, default=False, help='only show HCI device') +@click.option('--manufacturer', help='filter by manufacturer') +@click.option('--product', help='filter by product') +def main(verbose: bool, manufacturer: str, product: str, hci_only: bool): bumble.logging.setup_basic_logging('WARNING') load_libusb() @@ -238,13 +238,10 @@ def main(verbose:bool, manufacturer:str, product:str, hci_only:bool): ) # Filter - if product != "": - if device_product != product: - continue - if manufacturer != "": - if device_manufacturer != manufacturer: - continue - + if product and device_product != product: + continue + if manufacturer and device_manufacturer != manufacturer: + continue if not is_bluetooth_hci(device) and hci_only: continue From 9e270d4d62c235c228a654a1e81d8cfec9dbace3 Mon Sep 17 00:00:00 2001 From: Stryxion Date: Mon, 12 Jan 2026 09:36:35 +0100 Subject: [PATCH 3/4] fix: mypy --- apps/usb_probe.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/usb_probe.py b/apps/usb_probe.py index 38144ff1..32d0255f 100644 --- a/apps/usb_probe.py +++ b/apps/usb_probe.py @@ -26,6 +26,8 @@ # ----------------------------------------------------------------------------- # Imports # ----------------------------------------------------------------------------- +from typing import Any + import click import usb1 @@ -175,7 +177,7 @@ def main(verbose: bool, manufacturer: str, product: str, hci_only: bool): load_libusb() with usb1.USBContext() as context: bluetooth_device_count = 0 - devices = {} + devices: dict[tuple[Any, Any], list[str|None]] = {} for device in context.getDeviceIterator(skip_on_error=True): device_class = device.getDeviceClass() From 671f306a27a4648eeb5ac90b39d0974ab15d8892 Mon Sep 17 00:00:00 2001 From: Stryxion Date: Tue, 13 Jan 2026 09:42:40 +0100 Subject: [PATCH 4/4] fix: black --- apps/usb_probe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/usb_probe.py b/apps/usb_probe.py index 32d0255f..51ab91cc 100644 --- a/apps/usb_probe.py +++ b/apps/usb_probe.py @@ -177,7 +177,7 @@ def main(verbose: bool, manufacturer: str, product: str, hci_only: bool): load_libusb() with usb1.USBContext() as context: bluetooth_device_count = 0 - devices: dict[tuple[Any, Any], list[str|None]] = {} + devices: dict[tuple[Any, Any], list[str | None]] = {} for device in context.getDeviceIterator(skip_on_error=True): device_class = device.getDeviceClass()