blatann.gap.advertise_data module

class blatann.gap.advertise_data.AdvertisingFlags

Bases: object

LIMITED_DISCOVERY_MODE = 1
GENERAL_DISCOVERY_MODE = 2
BR_EDR_NOT_SUPPORTED = 4
BR_EDR_CONTROLLER = 8
BR_EDR_HOST = 16
class blatann.gap.advertise_data.AdvertisingData(flags=None, local_name=None, local_name_complete=True, service_uuid16s=None, service_uuid128s=None, has_more_uuid16_services=False, has_more_uuid128_services=False, service_data=None, manufacturer_data=None, **other_entries)

Bases: object

Class which represents data that can be advertised

MAX_ENCODED_LENGTH = 31
class Types(value)

Bases: Enum

An enumeration.

flags = 1
service_16bit_uuid_more_available = 2
service_16bit_uuid_complete = 3
service_32bit_uuid_more_available = 4
service_32bit_uuid_complete = 5
service_128bit_uuid_more_available = 6
service_128bit_uuid_complete = 7
short_local_name = 8
complete_local_name = 9
tx_power_level = 10
class_of_device = 13
simple_pairing_hash_c = 14
simple_pairing_randimizer_r = 15
security_manager_tk_value = 16
security_manager_oob_flags = 17
slave_connection_interval_range = 18
solicited_sevice_uuids_16bit = 20
solicited_sevice_uuids_128bit = 21
service_data = 22
public_target_address = 23
random_target_address = 24
appearance = 25
advertising_interval = 26
le_bluetooth_device_address = 27
le_role = 28
simple_pairng_hash_c256 = 29
simple_pairng_randomizer_r256 = 30
service_data_32bit_uuid = 32
service_data_128bit_uuid = 33
uri = 36
information_3d_data = 61
manufacturer_specific_data = 255
property flags: Optional[int]

The advertising flags in the payload, if set

Getter

Gets the advertising flags in the payload, or None if not set

Setter

Sets the advertising flags in the payload

Delete

Removes the advertising flags from the payload

property service_data: Optional[Union[bytes, List[int]]]

The service data in the payload, if set

Getter

Gets the service data in the payload, or None if not set

Setter

Sets the service data for the payload

Delete

Removes the service data from the payload

property manufacturer_data: Optional[Union[bytes, List[int]]]

The manufacturer data in the payload, if set

Getter

Gets the manufacturer data in the payload, or None if not set

Setter

Sets the manufacturer data for the payload

Delete

Removes the manufacturer data from the payload

property service_uuids: List[Uuid]

Gets all of the 16-bit and 128-bit service UUIDs specified in the advertising data

check_encoded_length()

Checks if the encoded length of this advertising data payload meets the maximum allowed length specified by the Bluetooth specification

Return type

Tuple[int, bool]

Returns

a tuple of the encoded length and a bool result of whether or not it meets requirements

to_ble_adv_data()

Converts the advertising data to a BLEAdvData object that can be used by the nRF Driver

Returns

the BLEAdvData object which represents this advertising data

Return type

nrf_types.BLEAdvData

to_bytes()

Converts the advertising data to the encoded bytes that will be advertised over the air. Advertising payloads are encoded in a length-type-value format

Return type

bytes

Returns

The encoded payload

classmethod from_ble_adv_records(advertise_records)

Converts a dictionary of AdvertisingData.Type: value keypairs into an object of this class

Parameters

advertise_records (dict) – a dictionary mapping the advertise data types to their corresponding values

Returns

the AdvertisingData from the records given

Return type

AdvertisingData

class blatann.gap.advertise_data.ScanReport(adv_report, resolved_address)

Bases: object

Represents a payload and associated metadata that’s received during scanning

property device_name: str

Read Only

The name of the device, pulled from the advertising data (if advertised) or uses the Peer’s MAC Address if not set

property is_bonded_device: bool

If the scan report is from a BLE device that the local device has a matching bond database entry

property resolved_address: Optional[PeerAddress]

If the scan report is from a bonded device, this is the resolved public/static/random BLE address. This may be the same as peer_addr if the device is not advertising as a private resolvable address

update(adv_report)

Used internally to merge a new advertising payload that was received into the current scan report

class blatann.gap.advertise_data.ScanReportCollection

Bases: object

Collection of all the advertising data and scan reports found in a scanning session

property advertising_peers_found: Iterable[ScanReport]

Gets the list of scans which have been combined and condensed into a list where each entry is a unique peer. The scan reports in this list represent aggregated data of each advertising packet received by the advertising device, such that later advertising packets will update/overwrite packet attributes received from earlier packets, if the data has been modified.

Returns

The list of scan reports, with each being a unique peer

property all_scan_reports: Iterable[ScanReport]

Gets the list of all of the individual advertising packets received.

Returns

The list of all scan reports

get_report_for_peer(peer_addr)

Gets the combined/aggregated scan report for a given Peer’s address. If the peer’s scan report isn’t found, returns None

Parameters

peer_addr – The peer’s address to search for

Return type

Optional[ScanReport]

Returns

The associated scan report, if found

clear()

Clears out all of the scan reports cached

update(adv_report, resolved_peer_addr=None)

Used internally to update the collection with a new advertising report received

Return type

ScanReport

Returns

The Scan Report created from the advertising report