LeAdvertiser#

class pytest_bluezenv.LeAdvertiser(service_uuids=(), adv_type='peripheral', index=0, adapter_path='/org/bluez/hci0', discoverable=True, timeout=None)[source]#

Host plugin registering a minimal connectable org.bluez.LEAdvertisement1 object on a Bluetooth adapter.

In LE-only mode bluetoothd does not advertise the host by itself. Load this plugin to make the host discoverable and connectable by a peer. Registration completes before the test starts. On teardown the advertisement is unregistered and removed from the bus.

Parameters:
  • service_uuids (sequence) – service UUIDs to advertise.

  • adv_type (str) – advertisement type, "peripheral" or "broadcast".

  • index (int) – index appended to the advertisement object path to keep advertisements of several instances distinct.

  • adapter_path (str) – D-Bus object path of the adapter to advertise on.

  • discoverable (bool) – whether to set the Discoverable advertisement property.

  • timeout (float) – seconds to wait for the advertisement to be registered, or None to use the default timeout.

Example

LE_CONF = "[General]\nControllerMode = le\n"

@host_config(
    [Bluetoothd(conf=LE_CONF)],
    [Bluetoothd(conf=LE_CONF), LeAdvertiser(service_uuids=["180d"])],
)
def test_le_connect(hosts):
    client, server = hosts
PATH_BASE#

base D-Bus object path of the advertisements. The instance index is appended to it.

Type:

str

__init__(service_uuids=(), adv_type='peripheral', index=0, adapter_path='/org/bluez/hci0', discoverable=True, timeout=None)[source]#

Configure a plugin on the upper tester at collection time.

Methods

presetup(config)

Configure a plugin on the upper tester before VM hosts start.

setup(impl)

Register the advertisement with bluetoothd and wait for it to be accepted (VM side).

teardown()

Unregister the advertisement and remove it from the bus (VM side).