bluez_peripheral.advert module

class bluez_peripheral.advert.Advertisement(local_name=None, service_uuids=None, *, appearance=None, timeout=None, discoverable=None, packet_type=AdvertisingPacketType.PERIPHERAL, manufacturer_data=None, solicit_uuids=None, service_data=None, includes=<AdvertisingIncludes.NONE: 0>, duration=2, min_advertising_interval_ms=None, max_advertising_interval_ms=None)[source]

Bases: UniquePathMixin

An advertisement for a particular service or collection of services that can be registered and broadcast to nearby devices. Represents an org.bluez.LEAdvertisement1 instance.

Parameters:
  • localName – The device name to advertise.

  • serviceUUIDs – A list of service UUIDs advertise.

  • appearance (int | bytes | None) – The appearance value to advertise. See the Bluetooth SIG Assigned Numbers (Search for “Appearance Values”)

  • timeout (int | None) – The time from registration until this advert is removed (defaults to None meaning never timeout).

  • discoverable (bool | None) – Whether or not the device this advert should be generally discoverable.

  • packetType – The type of advertising packet requested.

  • manufacturerData – Any manufacturer specific data to include in the advert.

  • solicitUUIDs – Array of service UUIDs to attempt to solicit (not widely used).

  • serviceData – Any service data elements to include.

  • includes (AdvertisingIncludes) – Fields that can be optionally included in the advertising packet. Only the bluez_peripheral.flags.AdvertisingIncludes.TX_POWER flag seems to work correctly with bluez.

  • duration (int | None) – Duration of the advert when multiple adverts are ongoing.

  • min_advertising_interval_ms (int | None) – Optional minimum advertising interval in milliseconds; must be set together with max.

  • max_advertising_interval_ms (int | None) – Optional maximum advertising interval in milliseconds; must be set together with min. See MinInterval / MaxInterval in the bluez LEAdvertisement documentation.

  • local_name (str | None)

  • service_uuids (Collection[str | bytes | UUID | UUID16 | int] | None)

  • packet_type (AdvertisingPacketType)

  • manufacturer_data (Dict[int, bytes] | None)

  • solicit_uuids (Collection[str | bytes | UUID | UUID16 | int] | None)

  • service_data (Dict[str | bytes | UUID | UUID16 | int, bytes] | None)

property export_path: str | None

Returns the message bus path that the advert is exported on or None.

async register(bus, *, path=None, adapter=None)[source]

Register this advert with bluez to start advertising.

Parameters:
  • bus (MessageBus) – The message bus used to communicate with bluez.

  • adapter (Adapter | None) – The adapter to use.

  • path (str | None) – The dbus path to use for registration.

Return type:

None

async unregister()[source]

Unregister this advertisement from bluez to stop advertising.

Return type:

None