toio.cube.api.configuration module¶
- class toio.cube.api.configuration.RequestProtocolVersion[source]¶
Bases:
CubeCommand
Protocol version request command
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#requesting-the-ble-protocol-version
- class toio.cube.api.configuration.SetHorizontalDetectionThreshold(threshold: int)[source]¶
Bases:
CubeCommand
Horizontal detection threshold setting command
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#horizontal-detection-threshold-settings
- class toio.cube.api.configuration.SetCollisionDetectionThreshold(threshold: int)[source]¶
Bases:
CubeCommand
Collision detection threshold setting command
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#collision-detection-threshold-settings
- class toio.cube.api.configuration.SetDoubleTapDetectionTimeInterval(threshold: int)[source]¶
Bases:
CubeCommand
Double-tap detection time interval setting command
References
- class toio.cube.api.configuration.NotificationCondition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Notification conditions of ID notification
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#notification-conditions
- Always = 0¶
- ChangeDetection = 1¶
- Periodic = 255¶
- class toio.cube.api.configuration.SetIdNotification(interval_ms: int, condition: NotificationCondition)[source]¶
Bases:
CubeCommand
ID notification setting command
References
- __init__(interval_ms: int, condition: NotificationCondition) None [source]¶
- class toio.cube.api.configuration.SetIdMissedNotification(sensitivity_ms: int)[source]¶
Bases:
CubeCommand
ID missed notification setting command
References
- class toio.cube.api.configuration.MagneticSensorFunction(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
- Disable = 0¶
- MagnetState = 1¶
- MagneticForce = 2¶
- class toio.cube.api.configuration.MagneticSensorCondition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
- Always = 0¶
- ChangeDetection = 1¶
- class toio.cube.api.configuration.SetMagneticSensor(function_type: MagneticSensorFunction, interval_ms: int, condition: MagneticSensorCondition)[source]¶
Bases:
CubeCommand
Magnet sensor setting command
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#magnetic-sensor-settings-
- __init__(function_type: MagneticSensorFunction, interval_ms: int, condition: MagneticSensorCondition) None [source]¶
- class toio.cube.api.configuration.MotorSpeedInformationAcquisitionState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
- Disable = 0¶
- Enable = 1¶
- class toio.cube.api.configuration.SetMotorSpeedInformationAcquisition(state: MotorSpeedInformationAcquisitionState)[source]¶
Bases:
CubeCommand
Motor speed information acquisition setting command
References
- __init__(state: MotorSpeedInformationAcquisitionState) None [source]¶
- class toio.cube.api.configuration.PostureAngleDetectionType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
- Euler = 1¶
- Quaternions = 2¶
- HighPrecisionEuler = 3¶
- class toio.cube.api.configuration.PostureAngleDetectionCondition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Notification condition of posture angle detection
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#notification-conditions-1
- Always = 0¶
- ChangeDetection = 1¶
- class toio.cube.api.configuration.SetPostureAngleDetection(detection_type: PostureAngleDetectionType, interval_ms: int, condition: PostureAngleDetectionCondition)[source]¶
Bases:
CubeCommand
Posture angle detection setting command
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#posture-angle-detection-settings-
- __init__(detection_type: PostureAngleDetectionType, interval_ms: int, condition: PostureAngleDetectionCondition)[source]¶
- class toio.cube.api.configuration.ConnectionInterval(interval: int)[source]¶
Bases:
object
Representation of BLE connection interval
- value¶
connection interval value
- Type:
int
- BLE_MIN_INTERVAL = 6¶
Minimum connection interval defined by BLE specifications
- BLE_MAX_INTERVAL = 3200¶
Maximum connection interval defined by BLE specifications
- BLE_INTERVAL_UNIT = 1.25¶
Millisecond per unit
- BLE_INTERVAL_NONE = 65535¶
This means ‘connection interval is not specified’
- static from_ms(interval_ms: float) int [source]¶
Convert millisecond to connection interval value.
- Parameters:
interval_ms (float) – interval (millisecond)
- Returns:
connection interval value
- Return type:
int
- static to_ms(interval_value: int) float [source]¶
Convert connection interval value to millisecond.
- Parameters:
interval_value (int) – interval_value
- Returns:
connection interval time (millisecond)
- Return type:
float
- property value_ms¶
Return the connection interval time of ConnectionInterval instance.
- Returns:
connection interval time (millisecond)
- Return type:
float
- class toio.cube.api.configuration.RequestConnectionInterval(min_interval: int, max_interval: int)[source]¶
Bases:
CubeCommand
Request to change bluetooth Connection interval
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#request-to-change-connection-interval-
- class toio.cube.api.configuration.GetRequestedConnectionIntervalValue[source]¶
Bases:
CubeCommand
Get requested connection interval value
References
- class toio.cube.api.configuration.GetCurrentConnectionIntervalValue[source]¶
Bases:
CubeCommand
Get current connection interval value
References
- class toio.cube.api.configuration.ProtocolVersion(payload: bytearray)[source]¶
Bases:
CubeResponse
Protocol version response
- version¶
version (UTF-8)
- Type:
str
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#obtaining-the-ble-protocol-version
- class toio.cube.api.configuration.ResponseIdNotificationSettings(payload: bytearray)[source]¶
Bases:
CubeResponse
ID notification setting response
- result¶
Result of the command
- Type:
bool
References
- class toio.cube.api.configuration.ResponseIdMissedNotificationSettings(payload: bytearray)[source]¶
Bases:
CubeResponse
ID missed notification setting response
- result¶
Result of the command
- Type:
bool
References
- class toio.cube.api.configuration.ResponseMagneticSensorSettings(payload: bytearray)[source]¶
Bases:
CubeResponse
Magnetic sensor setting response
- result¶
Result of the command
- Type:
bool
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#responses-to-magnetic-sensor-settings
- class toio.cube.api.configuration.ResponseMotorSpeedInformationAcquisitionSettings(payload: bytearray)[source]¶
Bases:
CubeResponse
Motor speed information setting response
- result¶
Result of the command
- Type:
bool
References
- class toio.cube.api.configuration.ResponsePostureAngleDetectionSettings(payload: bytearray)[source]¶
Bases:
CubeResponse
Posture angle detection setting response
- result¶
Result of the command
- Type:
bool
References
- class toio.cube.api.configuration.ResponseConnectionIntervalRequest(payload: bytearray)[source]¶
Bases:
CubeResponse
Protocol version response
- result¶
Result of the command
- Type:
bool
References
- class toio.cube.api.configuration.ResponseGettingRequestedConnectionInterval(payload: bytearray)[source]¶
Bases:
CubeResponse
Response of getting requested connection interval value
- min_interval¶
minimum connection interval
- Type:
- max_interval¶
maximum connection interval
- Type:
References
- class toio.cube.api.configuration.ResponseGettingCurrentConnectionInterval(payload: bytearray)[source]¶
Bases:
CubeResponse
Response of getting current connection interval value
- min_interval¶
minimum connection interval
- Type:
- max_interval¶
maximum connection interval
- Type:
References
- toio.cube.api.configuration.ConfigurationResponseType¶
Response types of configuration characteristic
alias of
Union
[ProtocolVersion
,ResponseIdNotificationSettings
,ResponseIdMissedNotificationSettings
,ResponseMagneticSensorSettings
,ResponseMotorSpeedInformationAcquisitionSettings
,ResponsePostureAngleDetectionSettings
,ResponseConnectionIntervalRequest
,ResponseGettingRequestedConnectionInterval
,ResponseGettingCurrentConnectionInterval
]
- class toio.cube.api.configuration.Configuration(interface: CubeInterface, device: Any)[source]¶
Bases:
CubeCharacteristic
Configuration characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_configuration
- static is_my_data(payload: bytearray) ProtocolVersion | ResponseIdNotificationSettings | ResponseIdMissedNotificationSettings | ResponseMagneticSensorSettings | ResponseMotorSpeedInformationAcquisitionSettings | ResponsePostureAngleDetectionSettings | ResponseConnectionIntervalRequest | ResponseGettingRequestedConnectionInterval | ResponseGettingCurrentConnectionInterval | 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, device: Any) None [source]¶
- async request_protocol_version() None [source]¶
Send protocol version request command
This function DO NOT return response payload. Receive the result by notification.
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#requesting-the-ble-protocol-version
- async set_horizontal_detection_threshold(threshold: int) None [source]¶
Send horizontal detection threshold setting command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
threshold (int) – Threshold
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#horizontal-detection-threshold-settings
- async set_collision_detection_threshold(threshold: int) None [source]¶
Send collision detection threshold setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
threshold (int) – Threshold
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#collision-detection-threshold-settings
- async set_double_tap_detection_threshold(threshold: int) None [source]¶
Send double-tap detection threshold setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
threshold (int) – Threshold
References
- async set_id_notification(interval_ms: int, condition: NotificationCondition) None [source]¶
Send id information notification setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
interval_ms (int) – Notification interval [ms]
condition (NotificationCondition) – Condition
References
- async set_id_missed_notification(sensitivity_ms: int) None [source]¶
Send ID missed notification setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
sensitivity_ms (int) – Sensitivity [ms]
References
- async set_magnetic_sensor(function_type: MagneticSensorFunction, interval_ms: int, condition: MagneticSensorCondition) None [source]¶
Send magnetic sensor setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
function_type (MagneticSensorFunction) – Function type
interval_ms (int) – Notification interval [ms]
condition (MagneticSensorCondition) – Condition
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#magnetic-sensor-settings-
- async set_motor_speed_information_acquisition(state: MotorSpeedInformationAcquisitionState) None [source]¶
Send motor speed information acquisition setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
state (MotorSpeedInformationAcquisitionState) – state
References
- async set_posture_angle_detection(detection_type: PostureAngleDetectionType, interval_ms: int, condition: PostureAngleDetectionCondition) None [source]¶
Send posture angle setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
detection_type (PostureAngleDetectionType) – Detection type
interval_ms (int) – Notification interval [ms]
condition (PostureAngleDetectionCondition) – Condition
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#posture-angle-detection-settings-
- async request_to_change_connection_interval(min_interval: int, max_interval: int) None [source]¶
Request the connected central device to change the connection interval.
Note
If central device can not accept the requested connection interval value, one of the following occurs: - Bluetooth connection is disconnected. - Another connection interval value is set that can be accepted by the central device.
max_interval must be greater than or equal to min_interval. (except the value is 0xFFFF)
- Parameters:
min_interval (int) – min_interval, from 6 to 3200, or 0xFFFF (0xFFFF means “to be determined by central”)
max_interval (int) – max_interval, from 6 to 3200, or 0xFFFF (0xFFFF means “to be determined by central”)
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#request-to-change-connection-interval-
- async get_requested_connection_interval() None [source]¶
Get requested connection interval value.
References