toio.device_interface package

device_interface

Abstraction layer to communicate toio Core Cubes.

The abstract base classes defined are as follows:

  • ScannerInterface

  • CubeInterface

class toio.device_interface.CubeInterface[source]

Bases: object

Interface to communicate to a toio Core Cube.

abstract async connect() bool[source]
abstract async disconnect() bool[source]
abstract async read(uuid: UUID) bytearray[source]
abstract async write(uuid: UUID, data: bytes | bytearray | memoryview, response: bool = False) None[source]
abstract async register_notification_handler(uuid: UUID, handler: Callable[[BleakGATTCharacteristic, bytearray], None | Awaitable[None]]) bool[source]
abstract async unregister_notification_handler(uuid: UUID) bool[source]
class toio.device_interface.CubeInfo(name, device, interface, advertisement)[source]

Bases: NamedTuple

name: str | None

Alias for field number 0

device: BLEDevice

Alias for field number 1

interface: CubeInterface

Alias for field number 2

advertisement: AdvertisementData

Alias for field number 3

class toio.device_interface.ScannerInterface[source]

Bases: object

Interface to scan toio Core Cubes. This interface is used from toio.scanner.* module.

abstract async scan(num: int | None = None, cube_id: set[str] | None = None, address: set[str] | None = None, sort: Literal['rssi', 'local_name'] | None = None, timeout: float = 5.0) list[toio.device_interface.CubeInfo][source]

Submodules