10. Internal API

10.1. Abstract Interfaces

class bleson.interfaces.provider.Provider
abstract get_adapter(adapter_id=None)

Return an Adapter instance, default to first one available

class bleson.interfaces.adapter.Adapter

Adapter interface

abstract off()

Power off the adapter hardware.

abstract on()

Power on the adapter hardware.

abstract open()

Initialise the adapter.

abstract start_advertising(advertisement, scan_response=None)

Start BLE advertising.

abstract start_scanning()

Start BLE scanning.

abstract stop_advertising()

Stop BLE advertising.

abstract stop_scanning()

Stop BLE scanning.

class bleson.interfaces.role.Role
abstract start()

Start the role.

abstract stop()

Stop the role.

class bleson.core.types.ValueObject
__bytes__()

Return bytes in little endian byte order.

__len__()

10.2. Platform Implementations

10.2.1. Linux

Bleson uses the Linux kernel’s HCI Sockets interface, is not dependent on the userland BlueZ service or binaries, it’s pure Python sockets.

class bleson.providers.linux.linux_provider.LinuxProvider
get_adapter(adapter_id=0)

Return an Adapter instance, default to first one available

class bleson.providers.linux.linux_adapter.BluetoothHCIAdapter(device_id=0)
off()

Power off the adapter hardware.

on()

Power on the adapter hardware.

open()

Initialise the adapter.

start_advertising(advertisement, scan_response=None)

Start BLE advertising.

start_scanning()

Start BLE scanning.

stop_advertising()

Stop BLE advertising.

stop_scanning()

Stop BLE scanning.

10.2.2. macOS

The CoreBluetooth dispatch queue is run in a background thread, requires the use of features added in PyObjC 4.1 for macOS < 10.12.

class bleson.providers.macos.macos_provider.MacOSProvider
get_adapter(adapter_id=0)

Return an Adapter instance, default to first one available

class bleson.providers.macos.macos_adapter.CoreBluetoothAdapter(*args, **kwargs)
off()

Power off the adapter hardware.

on()

Power on the adapter hardware.

open()

Initialise the adapter.

start_advertising(advertisement, scan_response=None)

Start BLE advertising.

start_scanning()

Start BLE scanning.

stop_advertising()

Stop BLE advertising.

stop_scanning()

Stop BLE scanning.

10.2.3. Windows

On Windows there is an additional module used called ‘blesonwin’, it provides a Python native module to access the WinRT BLE API’s. It’s not recommended to use this module directly in user scripts.

class bleson.providers.win32.win32_provider.Win32Provider
get_adapter(adapter_id=0)

Return an Adapter instance, default to first one available

class bleson.providers.win32.win32_adapter.BluetoothAdapter(device_id=0)
off()

Power off the adapter hardware.

on()

Power on the adapter hardware.

open()

Initialise the adapter.

start_advertising(advertisement, scan_response=None)

Start BLE advertising.

start_scanning()

Start BLE scanning.

stop_advertising()

Stop BLE advertising.

stop_scanning()

Stop BLE scanning.