add support for netsim device info variant

This commit is contained in:
Gilles Boccon-Gibod
2024-10-25 04:37:30 -07:00
parent ad7ce79bc4
commit ff8b0c375d

View File

@@ -60,6 +60,7 @@ logger = logging.getLogger(__name__)
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
DEFAULT_NAME = 'bumble0' DEFAULT_NAME = 'bumble0'
DEFAULT_MANUFACTURER = 'Bumble' DEFAULT_MANUFACTURER = 'Bumble'
DEFAULT_VARIANT = ''
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
@@ -313,8 +314,9 @@ async def open_android_netsim_host_transport_with_channel(
): ):
# Wrapper for I/O operations # Wrapper for I/O operations
class HciDevice: class HciDevice:
def __init__(self, name, manufacturer, hci_device): def __init__(self, name, variant, manufacturer, hci_device):
self.name = name self.name = name
self.variant = variant
self.manufacturer = manufacturer self.manufacturer = manufacturer
self.hci_device = hci_device self.hci_device = hci_device
@@ -326,6 +328,7 @@ async def open_android_netsim_host_transport_with_channel(
sdk_version=platform.python_version(), sdk_version=platform.python_version(),
build_id=platform.platform(), build_id=platform.platform(),
arch=platform.machine(), arch=platform.machine(),
variant=self.variant,
) )
chip = Chip(kind=ChipKind.BLUETOOTH, manufacturer=self.manufacturer) chip = Chip(kind=ChipKind.BLUETOOTH, manufacturer=self.manufacturer)
chip_info = ChipInfo(name=self.name, chip=chip, device_info=device_info) chip_info = ChipInfo(name=self.name, chip=chip, device_info=device_info)
@@ -356,12 +359,16 @@ async def open_android_netsim_host_transport_with_channel(
) )
name = DEFAULT_NAME if options is None else options.get('name', DEFAULT_NAME) name = DEFAULT_NAME if options is None else options.get('name', DEFAULT_NAME)
variant = (
DEFAULT_VARIANT if options is None else options.get('variant', DEFAULT_VARIANT)
)
manufacturer = DEFAULT_MANUFACTURER manufacturer = DEFAULT_MANUFACTURER
# Connect as a host # Connect as a host
service = PacketStreamerStub(channel) service = PacketStreamerStub(channel)
hci_device = HciDevice( hci_device = HciDevice(
name=name, name=name,
variant=variant,
manufacturer=manufacturer, manufacturer=manufacturer,
hci_device=service.StreamPackets(), hci_device=service.StreamPackets(),
) )
@@ -411,6 +418,9 @@ async def open_android_netsim_transport(spec: Optional[str]) -> Transport:
The "chip" name, used to identify the "chip" instance. This The "chip" name, used to identify the "chip" instance. This
may be useful when several clients are connected, since each needs to use a may be useful when several clients are connected, since each needs to use a
different name. different name.
variant=<variant>
The device info variant field, which may be used to convey a device or
application type (ex: "virtual-speaker", or "keyboard")
In `controller` mode: In `controller` mode:
The <host>:<port> part is required. <host> may be the address of a local network The <host>:<port> part is required. <host> may be the address of a local network