toio.cube.api.button module

class toio.cube.api.button.ButtonState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

Value of the state of cube button

RELEASED = 0
PRESSED = 128
class toio.cube.api.button.ButtonInformation(payload: bytearray)[source]

Bases: CubeResponse

Cube button state response

state

State of the cube button

Type:

ButtonState

References

https://toio.github.io/toio-spec/en/docs/ble_button#read-operations

static is_myself(payload: bytearray) bool[source]

If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.

Parameters:

data (GattReadData) – received data from the cube.

__init__(payload: bytearray)[source]
__str__() str[source]

Return str(self).

toio.cube.api.button.ButtonResponseType

Response type of button characteristic

class toio.cube.api.button.Button(interface: CubeInterface)[source]

Bases: CubeCharacteristic

Button characteristic

References

https://toio.github.io/toio-spec/en/docs/ble_button

static is_my_data(payload: bytearray) ButtonInformation | None[source]

If payload is my characteristic response, this function returns CubeResponse object. Otherwise, it returns None.

Parameters:

payload (GattReadData) – received data from the cube.

__init__(interface: CubeInterface)[source]
async read() ButtonInformation | None[source]

Read the state of button

Returns:

ButtonInformation or None (None returns when read fails)

References

https://toio.github.io/toio-spec/en/docs/ble_button#read-operations