forked from auracaster/bumble_mirror
intel driver: check the vendorId and productId
This commit is contained in:
@@ -29,6 +29,17 @@ from bumble.hci import (
|
|||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
# Constant
|
||||||
|
# -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
INTEL_USB_PRODUCTS = {
|
||||||
|
# Intel AX210
|
||||||
|
(0x8087, 0x0032),
|
||||||
|
# Intel BE200
|
||||||
|
(0x8087, 0x0036),
|
||||||
|
}
|
||||||
|
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# HCI Commands
|
# HCI Commands
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
@@ -52,13 +63,34 @@ class Driver(common.Driver):
|
|||||||
def __init__(self, host):
|
def __init__(self, host):
|
||||||
self.host = host
|
self.host = host
|
||||||
|
|
||||||
@classmethod
|
@staticmethod
|
||||||
async def for_host(cls, host): # type: ignore
|
def check(host):
|
||||||
# Only instantiate this driver if explicitly selected
|
driver = host.hci_metadata.get("driver")
|
||||||
if host.hci_metadata.get("driver") == "intel":
|
if driver == "intel":
|
||||||
return cls(host)
|
return True
|
||||||
|
|
||||||
return None
|
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, force=False): # type: ignore
|
||||||
|
# Only instantiate this driver if explicitly selected
|
||||||
|
if not force and not cls.check(host):
|
||||||
|
return None
|
||||||
|
|
||||||
|
return cls(host)
|
||||||
|
|
||||||
async def init_controller(self):
|
async def init_controller(self):
|
||||||
self.host.ready = True
|
self.host.ready = True
|
||||||
|
|||||||
Reference in New Issue
Block a user