bluez_peripheral.advert module

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

Bases: BaseServiceInterface

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) – The appearance value to advertise. See the Bluetooth SIG Assigned Numbers (Search for “Appearance Values”)

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

  • discoverable (bool) – 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) – Duration of the advert when multiple adverts are ongoing.

  • release_callback (Callable[[], None] | Callable[[], Awaitable[None]] | None) – A function to call when the advert release function is called. The default release callback will unexport the advert.

  • local_name (str)

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

  • 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)

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