Wire format
One component message per line
The app and library exchange small ASCII lines. Most users should call the Arduino API, but the format is useful for debugging, custom tools, and reading the app console.
Data format basics
// Every modern message is one line:
// <verb><channel>:<payload>\n
//
// Examples:
// B0:D\n button 0 down
// S0:127\n slider 0 value
// D0:Ready\n text display 0 says "Ready"
// A:Low battery\n
//
// Text escapes backslash, newline, and carriage return:
// Line 1\nLine 2 becomes Line 1\\nLine 2 on the wire.
| Direction | Message | Format | Example | Handled by | Notes |
|---|---|---|---|---|---|
| App to device | Button down / up / repeat | B{ch}:D | B{ch}:U | B{ch}:R |
B0:D |
wasButtonPressed() / wasButtonReleased() / wasButtonRepeated() | Down on press, up on release, repeat while held when enabled. isButtonPressed() stays true while held. |
| App to device | Joystick update | J{ch}:{rotation},{magnitude} |
J0:90,0.500 |
isJoystickUpdated() / getJoystick() | Rotation is 0-360 degrees, magnitude 0.000-1.000. A zero-magnitude message is sent on recenter. |
| App to device | Slider value | S{ch}:{value} |
S0:42 |
isSliderUpdated() / getSlider() | Value lands within the component's configured min/max range, snapped to its step. |
| App to device | Toggle state | T{ch}:{0|1} |
T0:1 |
isToggleOn() / wasToggleUpdated() | A latching switch. 1 when on, 0 when off. |
| App to device | D-Pad press / release / repeat | P{ch}:{dir},{D|U|R} (legacy P{ch}:{dir} accepted) |
P0:U,D |
wasDpadPressed() | The app sends down on press, up on release, and repeat while held when enabled. The library also accepts direction-only frames, diagonals (UL/UR/DL/DR), and C for custom layouts. |
| App to device | Console text | C:{text} |
C:start |
hasMessage() / getMessage() | Text typed in the app's console. The text is escaped, so it may contain newlines. |
| Device to app | Text display | D{ch}:{text} |
D0:Temp 72F |
setDisplay(message, ch) | Updates the LCD-style display component on that channel. |
| Device to app | Label | L{ch}:{text} |
L0:Ready |
setLabel(message, ch) | Updates a plain text label component. |
| Device to app | Indicator | I{ch}:{0|1} |
I0:1 |
setIndicator(on, ch) | Lights or dims an on/off LED component. |
| Device to app | Gauge value | G{ch}:{value} |
G0:73.5 |
setGauge(value, ch) | Fills the gauge proportionally within its configured range. |
| Device to app | Alert | A:{text} |
A:Low battery |
sendAlert(message) | Shows the text as a transient pop-up. Not addressed to a channel. |
Talking to an older app (legacy mode)
#include <BluetoothSerialConnect.h>
BluetoothSerialConnect serialConnect(Serial1, true);
void setup() {
serialConnect.begin(9600);
// Opt back into the original B{n} / J{n} / @ / # format for sketches
// written against older app versions.
serialConnect.setProtocol(BluetoothSerialConnectLegacy);
}
void loop() {
serialConnect.readSerial();
if (serialConnect.isButtonPressed(0)) {
// ...
}
}