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