toio.device_interface package

Submodules

Module contents

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(char_uuid: UUID) bytearray[source]
abstract async write(char_uuid: UUID, data: bytes | bytearray | memoryview, response: bool = False) None[source]
abstract async register_notification_handler(char_uuid: UUID, notification_handler: Callable[[BleakGATTCharacteristic, bytearray], None | Awaitable[None]]) bool[source]
abstract async unregister_notification_handler(char_uuid: UUID) bool[source]
abstract is_connect() bool[source]

Implemented in v1.1.0 or later

get current connection state

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(*args, **kwargs) List[CubeInfo][source]