advertising

Advertising is the first phase of BLE where devices can broadcast

to_hex(seq)

Pretty prints a byte sequence as hex values.

to_bytes_literal(seq)

Prints a byte sequence as a Python bytes literal that only uses hex encoding.

decode_data(data, *, key_encoding='B')

Helper which decodes length encoded structures into a dictionary with the given key encoding.

compute_length(data_dict, *, key_encoding='B')

Computes the length of the encoded data dictionary.

encode_data(data_dict, *, key_encoding='B')

Helper which encodes dictionaries into length encoded structures with the given key encoding.

class AdvertisingDataField

Top level class for any descriptor classes that live in Advertisement or its subclasses.

class AdvertisingFlag(bit_position)

A single bit flag within an AdvertisingFlags object.

class AdvertisingFlags(advertisement, advertising_data_type)

Standard advertising flags

limited_discovery

Discoverable only for a limited time period.

general_discovery

Will advertise until discovered.

le_only

BR/EDR not supported.

class String(*, advertising_data_type)

UTF-8 encoded string in an Advertisement.

Not null terminated once encoded because length is always transmitted.

class Struct(struct_format, *, advertising_data_type)

struct encoded data in an Advertisement.

class LazyObjectField(cls, attribute_name, *, advertising_data_type, **kwargs)

Non-data descriptor useful for lazily binding a complex object to an advertisement object.

property advertising_data_type

Return the data type value used to indicate this field.

class Advertisement(*, entry=None)

Core Advertisement type.

The class attribute match_prefixes, if not None, is a tuple of bytestring prefixes to match against the multiple data structures in the advertisement.

match_prefixes = ()

For Advertisement, matches will always return True. Subclasses may override this value.

short_name

Short local device name (shortened to fit).

complete_name

Complete local device name.

tx_power

Transmit power level

appearance

Appearance.

property rssi

Signal strength of the scanned advertisement. Only available on Advertisements returned from BLERadio.start_scan(). (read-only)

classmethod get_prefix_bytes()

Return a merged version of match_prefixes as a single bytes object, with length headers.

classmethod matches(entry)

Returns True if the given _bleio.ScanEntry advertisement fields matches all of the given prefixes in the match_prefixes tuple attribute. Subclasses may override this to match any instead of all.

classmethod matches_prefixes(entry, *, all_)

Returns True if the given _bleio.ScanEntry advertisement fields match any or all of the given prefixes in the match_prefixes tuple attribute. If all_ is True, all the prefixes must match. If all_ is False, returns True if at least one of the prefixes match.

standard

This module provides BLE standard defined advertisements. The Advertisements are single purpose even though multiple purposes may actually be present in a single packet.

class BoundServiceList(advertisement, *, standard_services, vendor_services)

Sequence-like object of Service UUID objects. It stores both standard and vendor UUIDs.

append(service)

Append a service to the list.

extend(services)

Appends all services in the iterable to the list.

class ServiceList(*, standard_services, vendor_services)

Descriptor for a list of Service UUIDs that lazily binds a corresponding BoundServiceList.

class ProvideServicesAdvertisement(*services, entry=None)

Advertise what services that the device makes available upon connection.

services

List of services the device can provide.

classmethod matches(entry)

Only one kind of service list need be present in a ProvideServicesAdvertisement, so override the default behavior and match any prefix, not all.

class SolicitServicesAdvertisement(*services, entry=None)

Advertise what services the device would like to use over a connection.

solicited_services

List of services the device would like to use.

class ManufacturerData(obj, *, advertising_data_type=255, company_id, key_encoding='B')

Encapsulates manufacturer specific keyed data bytes. The manufacturer is identified by the company_id and the data is structured like an advertisement with a configurable key format. The order of the serialized data is determined by the order that the ManufacturerDataField attributes are set in - this can be useful for match_prefixes in an Advertisement sub-class.

class ManufacturerDataField(key, value_format, field_names=None)

A single piece of data within the manufacturer specific data. The format can be repeated.

class ServiceData(service)

Encapsulates service data. It is read as a memoryview which can be manipulated or set as a bytearray to change the size.

adafruit

This module provides Adafruit defined advertisements.

Adafruit manufacturing data is key encoded like advertisement data and the Apple manufacturing data. However, the keys are 16-bits to enable many different uses. Keys above 0xf000 can be used by Adafruit customers for their own data.

class AdafruitColor(*, entry=None)

Broadcast a single RGB color.

color

Color to broadcast as RGB integer.