BluetoothSerialConnect(HardwareSerial& serial, bool verbose = true)
Creates a parser and writer around the serial port connected to the BLE module.
Parameters
serial HardwareSerial&
- Use Serial1, Serial2, or another hardware UART when the board provides one.
verbose bool
- When true, received lines are echoed to the Arduino Serial monitor.
void begin(int baudRate = 9600)
Starts the BLE module serial port.
Parameters
baudRate int
- Must match the UART baud configured on the BLE module.
void readSerial()
Reads all available input without blocking and refreshes every control's state.
Note: Call this near the start of every loop. It clears per-cycle event flags before parsing new input; held states (buttons, toggles, slider/joystick values) persist.
void setProtocol(BluetoothSerialConnectProtocol mode) / BluetoothSerialConnectProtocol protocol()
Selects the wire protocol. Defaults to BluetoothSerialConnectModern, matching the current app.
Note: Use BluetoothSerialConnectLegacy only when pairing with an older app version that sends the original B{n} / J{n} / @ / # format.
bool wasButtonPressed(int ch) / wasButtonReleased(int ch) / wasButtonRepeated(int ch)
Reports a button's down, up, and repeat events for the current read cycle.
Returns: true the cycle that event arrived.
bool isButtonPressed(int ch)
Returns whether a button is currently held down.
Returns: true between the down and up events (in modern mode).
bool isJoystickUpdated(int ch)
Returns whether a joystick reported a new position this read cycle.
Returns: true when readSerial() parsed a joystick message for that channel.
BluetoothSerialConnectJoystick getJoystick(int ch)
Returns the latest rotation and magnitude for a joystick channel.
Returns: A BluetoothSerialConnectJoystick value (see below). Invalid channels return a zeroed joystick.
bool isSliderUpdated(int ch) / double getSlider(int ch)
Reports a new slider value and returns the latest value.
Returns: getSlider() returns the value within the slider's configured range.
bool isToggleOn(int ch) / bool wasToggleUpdated(int ch)
Reads a latching toggle's state and whether it changed this cycle.
Returns: isToggleOn() persists; wasToggleUpdated() is true only on the change.
bool isDpadPressed(int ch, BluetoothSerialConnectDpadDirection dir)
Returns whether a D-Pad direction is held or was pressed this cycle.
Parameters
dir BluetoothSerialConnectDpadDirection
- BluetoothSerialConnectDpadUp / Down / Left / Right / UpLeft / UpRight / DownLeft / DownRight / Center.
bool wasDpadPressed(int ch, dir) / wasDpadReleased(int ch, dir) / wasDpadRepeated(int ch, dir)
Reports a D-Pad direction's down, up, and repeat events for the current cycle.
Returns: true the cycle that direction event arrived.
bool hasMessage() / String getMessage()
Reads text the app sent through its console.
Note: getMessage() returns the latest console text and clears the unread flag reported by hasMessage().
void setDisplay(const String& message, int ch)
Updates an LCD-style Text Display component in the app.
Parameters
message String
- Text to show; newlines are escaped on the wire.
ch int
- The display's channel from the board layout.
void setLabel(const String& message, int ch)
Updates a plain text Label component.
Note: Falls back to a display update in legacy mode.
void setIndicator(bool on, int ch)
Turns an Indicator LED component on or off.
void setGauge(double value, int ch, int decimalPlaces = 2)
Sets a Gauge component's value; the bar fills within the gauge's configured range.
Parameters
decimalPlaces int
- Digits sent after the decimal point (default 2).
void sendAlert(const String& message)
Shows a transient alert pop-up in the app.
Parameters
message String
- Keep it short; BLE writes are chunked.
void writeSerial(const String& message)
Writes raw text to the app without adding a verb, channel, or newline.
Note: Send a complete protocol line yourself if you want the app to parse it.
void clearBuffer()
Clears the current cycle's control events.
Note: readSerial() calls this automatically before reading new input.
BluetoothSerialConnectError lastError() / const char* lastErrorMessage() / void clearError()
Reports and clears parser and protocol-configuration problems.
setButtonPrefix(), setJoystickPrefix(), setInputSuffix(), setOutputSuffix(), …
Legacy-mode tuning of the prefixes/suffixes used by the original protocol.
Note: Only relevant after setProtocol(BluetoothSerialConnectLegacy). The modern protocol is fixed and needs none of these.