4. API - Core Data Types

Value objects representing Bluetooth Core Spec data types.

4.1. UUID16

class bleson.core.types.UUID16(uuid, little_endian=True)

16Bit UUID Type

Parameters:
  • uuid (string, list, tuple, bytes or bytearray) – The 16bit uuid source value
  • little_endian (bool) – Byte order, default True

Example of initialisation with a 16bit integer:

print(UUID16(0xFFFF))

Output:

UUID16(0xffff)

Example of initialisation with a list:

print(UUID16([0x34, 0x12]))

Output:

UUID16(0x1234)

4.2. UUID128

class bleson.core.types.UUID128(uuid, little_endian=True)

128 Bit Type.

Parameters:
  • uuid (string, list, tuple, bytes or bytearray) – The 16bit uuid source value
  • little_endian (bool) – Byte order, default True

Example of initialisation with a list:

print(UUID128([0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x30, 0x15, 0x00, 0x00]))

Output:

UUID128('00001530-1212-efde-1523-785feabcd123')

Example of initialisation with a 16bit integer:

print(UUID128(0x1234))

Output:

UUID128('00001234-0000-1000-8000-00805f9b34fb')

4.3. BDAddress

class bleson.core.types.BDAddress(address=None)

Bluetooth Device Address.

Parameters:address – The device bluetooth address

Example of initialisation with a list:

print(BDAddress([0xab, 0x90, 0x78, 0x56, 0x34, 0x12]))

Output:

BDAddress('12:34:56:78:90:AB')

Example of initialisation with a bytearray:

print(BDAddress(bytearray([0xab, 0x90, 0x78, 0x56, 0x34, 0x12])))

Output:

BDAddress('12:34:56:78:90:AB')

4.4. Device

class bleson.core.types.Device(address: bleson.core.types.BDAddress = None, name=None, rssi=None)

Bluetooth LE Device Info.

Parameters:
  • address (BDAddress) – Bluetooth Device Address
  • name (str) – device name
  • rssi (integer) – device RSSI

Example of initialisation with list:

print(Device(address=BDAddress('12:34:56:78:90:AB'), name='bleson', rssi=-99))

Output:

Device(address=BDAddress('12:34:56:78:90:AB'), name='bleson', rssi=-99)