aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Boutier <charliebout@google.com>2024-03-15 17:29:17 +0000
committerSlvr <30467496+SilverBzH@users.noreply.github.com>2024-03-15 10:53:33 -0700
commit313340f1c6abfa0062813cf3ff7b4c31f798240a (patch)
tree19e520e43d2b30afdca9fe17fb70b4ff66818389
parente8ed69fb09f7b063418ef7465c6b812964612ef6 (diff)
downloadbumble-313340f1c6abfa0062813cf3ff7b4c31f798240a.tar.gz
intel driver: check the vendorId and productId
-rw-r--r--bumble/drivers/intel.py40
1 files changed, 36 insertions, 4 deletions
diff --git a/bumble/drivers/intel.py b/bumble/drivers/intel.py
index c65d528..e613c1e 100644
--- a/bumble/drivers/intel.py
+++ b/bumble/drivers/intel.py
@@ -30,6 +30,17 @@ from bumble.hci import (
logger = logging.getLogger(__name__)
# -----------------------------------------------------------------------------
+# Constant
+# -----------------------------------------------------------------------------
+
+INTEL_USB_PRODUCTS = {
+ # Intel AX210
+ (0x8087, 0x0032),
+ # Intel BE200
+ (0x8087, 0x0036),
+}
+
+# -----------------------------------------------------------------------------
# HCI Commands
# -----------------------------------------------------------------------------
HCI_INTEL_DDC_CONFIG_WRITE_COMMAND = hci_vendor_command_op_code(0xFC8B) # type: ignore
@@ -52,13 +63,34 @@ class Driver(common.Driver):
def __init__(self, host):
self.host = host
+ @staticmethod
+ def check(host):
+ driver = host.hci_metadata.get("driver")
+ if driver == "intel":
+ return True
+
+ vendor_id = host.hci_metadata.get("vendor_id")
+ product_id = host.hci_metadata.get("product_id")
+
+ if vendor_id is None or product_id is None:
+ logger.debug("USB metadata not sufficient")
+ return False
+
+ if (vendor_id, product_id) not in INTEL_USB_PRODUCTS:
+ logger.debug(
+ f"USB device ({vendor_id:04X}, {product_id:04X}) " "not in known list"
+ )
+ return False
+
+ return True
+
@classmethod
- async def for_host(cls, host): # type: ignore
+ async def for_host(cls, host, force=False): # type: ignore
# Only instantiate this driver if explicitly selected
- if host.hci_metadata.get("driver") == "intel":
- return cls(host)
+ if not force and not cls.check(host):
+ return None
- return None
+ return cls(host)
async def init_controller(self):
self.host.ready = True