# eric7.MicroPython.BluetoothDialogs.BluetoothAdvertisement

Module implementing a class to parse and store the Bluetooth device advertisement data.

### Global Attributes

ADV_DIRECT_IND
ADV_IND
ADV_NONCONN_IND
ADV_SCAN_IND
ADV_TYPE_COMPLETE_NAME
ADV_TYPE_MANUFACTURER
ADV_TYPE_SHORT_NAME
ADV_TYPE_SVC_DATA
ADV_TYPE_TX_POWER_LEVEL
ADV_TYPE_UUID128_COMPLETE
ADV_TYPE_UUID128_INCOMPLETE
ADV_TYPE_UUID16_COMPLETE
ADV_TYPE_UUID16_INCOMPLETE
ADV_TYPE_UUID32_COMPLETE
ADV_TYPE_UUID32_INCOMPLETE
ManufacturerIDs
SCAN_RSP
ServiceIDs

### Classes

BluetoothAdvertisement | Class to parse and store the Bluetooth device advertisement data.

### Functions

_loadManufacturerIDs | Function to load the manufacturer IDs.
_loadServiceUUIDs | Function to load the service UUIDs.

## BluetoothAdvertisement

Class to parse and store the Bluetooth device advertisement data.

### Derived from

None

### Class Attributes

None

### Class Methods

None

### Methods

BluetoothAdvertisement | Constructor
__decodeField | Private method to get all fields of the specified types.
__splitBytes | Private method to split some data into chunks of given size.
__str__ | Special method to generate a string representation.
address | Public method to get the address string.
completeName | Public method to get the complete advertised name, if available.
manufacturer | Public method to get the manufacturer data.
name | Public method to get the complete or shortened advertised name, if available.
rssi | Public method to get the RSSI value.
services | Public method to get the service IDs.
shortName | Public method to get the shortened advertised name, if available.
txPower | Public method to get the advertised power level in dBm.
update | Public method to update the advertisement data.

### Static Methods

None

#### BluetoothAdvertisement (Constructor)

BluetoothAdvertisement(address)

Constructor

address (str)
  address of the device advertisement

#### BluetoothAdvertisement.__decodeField

__decodeField(*advType)

Private method to get all fields of the specified types.

*advType (int)
  type of fields to be extracted

Yield:
  requested fields

Yield Type:
  bytes

#### BluetoothAdvertisement.__splitBytes

__splitBytes(data, chunkSize)

Private method to split some data into chunks of given size.

data (bytes, bytearray, str)
  data to be chunked
chunkSize (int)
  size for each chunk

Return:
  list of chunks

Return Type:
  list of bytes, bytearray, str

#### BluetoothAdvertisement.__str__

__str__()

Special method to generate a string representation.

Return:
  string representation

Return Type:
  str

#### BluetoothAdvertisement.address

address()

Public method to get the address string.

Return:
  address of the device

Return Type:
  str

#### BluetoothAdvertisement.completeName

completeName()

Public method to get the complete advertised name, if available.

Return:
  advertised name

Return Type:
  str

#### BluetoothAdvertisement.manufacturer

manufacturer(filterId=None, withName=False)

Public method to get the manufacturer data.

filterId (int (optional))
  manufacturer ID to filter on (defaults to None)
withName (bool)
  flag indicating to report the manufacturer name as well (if available) (defaults to False)

Return:
  tuple containing the manufacturer ID, associated data and manufacturer name

Return Type:
  tuple of (int, bytes, str)

#### BluetoothAdvertisement.name

name()

Public method to get the complete or shortened advertised name, if available.

Return:
  advertised name

Return Type:
  str

#### BluetoothAdvertisement.rssi

rssi()

Public method to get the RSSI value.

Return:
  RSSI value in dBm

Return Type:
  int

#### BluetoothAdvertisement.services

services()

Public method to get the service IDs.

Return:
  list of tuples containing the advertised service ID, the associated service name (if available) and a flag indicating a complete ID

Return Type:
  list of tuple of (str, bool)

#### BluetoothAdvertisement.shortName

shortName()

Public method to get the shortened advertised name, if available.

Return:
  advertised name

Return Type:
  str

#### BluetoothAdvertisement.txPower

txPower()

Public method to get the advertised power level in dBm.

Return:
  transmit power of the device (in dBm)

Return Type:
  int

#### BluetoothAdvertisement.update

update(advType, rssi, advData)

Public method to update the advertisement data.

advType (int)
  type of advertisement data
rssi (int)
  RSSI value in dBm
advData (bytes)
  advertisement data

Up

## _loadManufacturerIDs

_loadManufacturerIDs()

Function to load the manufacturer IDs.

Up

## _loadServiceUUIDs

_loadServiceUUIDs()

Function to load the service UUIDs.

Up