Skip to content

Commit

Permalink
intel driver: check the vendorId and productId
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverBzH committed Mar 15, 2024
1 parent 8a20043 commit 6305eaa
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions bumble/drivers/intel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@
# -----------------------------------------------------------------------------
logger = logging.getLogger(__name__)

# -----------------------------------------------------------------------------
# Constant
# -----------------------------------------------------------------------------

INTEL_USB_PRODUCTS = {
# Intel AX210
(0x8087, 0x0032),
# Intel BE200
(0x8087, 0x0036),
}

# -----------------------------------------------------------------------------
# HCI Commands
# -----------------------------------------------------------------------------
Expand All @@ -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:
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
Expand Down

0 comments on commit 6305eaa

Please sign in to comment.