Skip to main content

Module protocol

Module protocol 

Source
Expand description

The controller’s Bluetooth LE wire format.

The controller exposes one custom GATT service with two characteristics: one to write two-byte Commands to, and one that notifies with 60-byte data packets once Command::Sensor has been sent.

BytesContent
0–15Motion sample 1: u32 time (µs), accel xyz, gyro xyz (i16 each)
16–31Motion sample 2, same layout
32–47Motion sample 3, same layout
48–53Magnetometer, i16 each, stored in y, x, z order
54–56Touchpad position: two 10-bit values packed into 20 bits
57Temperature
58Buttons, one bit each; bit 6 is set while nothing is pressed
59Unknown

All multi-byte values are little-endian.

Structs§

Buttons
The set of buttons held down.
ImuSample
One gyroscope and accelerometer reading. Each packet carries three.
Packet
One decoded data packet.
Touch
Where a finger is on the touchpad. Both axes run from 0 to TOUCH_MAX; x grows to the right and y grows toward the handle.

Enums§

Command
A command written to the controller.
ParseError
Why a packet could not be decoded.

Constants§

ACCEL_SCALE
Accelerometer scale: m/s² per count.
GYRO_SCALE
Gyroscope scale: rad/s per count.
MAG_SCALE
Magnetometer scale: µT per count.
NAME_PREFIX
The advertised name starts with this, followed by a four-character id in brackets.
NOTIFY_UUID
Characteristic that notifies with data packets.
PACKET_LEN
Length of a full data packet.
SAMPLE_INTERVAL_US
Typical spacing of motion samples, in microseconds (about 206 samples per second).
SERVICE_UUID
The controller’s custom GATT service.
TOUCH_MAX
Largest touchpad coordinate on either axis.
WRITE_UUID
Characteristic that accepts Commands.