BluetoothController

class BluetoothController(blueFalcon: BlueFalcon)

A wrapper around the BlueFalcon Bluetooth library to manage Bluetooth operations for BrainAccess devices.

Parameters

blueFalcon

The BlueFalcon instance handling BLE communication.

Constructors

Link copied to clipboard
constructor(blueFalcon: BlueFalcon)

Properties

Link copied to clipboard
var onConnectionChanged: (BluetoothPeripheral, Boolean) -> Unit?

Callback invoked when a device connection state changes. The Boolean parameter is true if connected, false otherwise.

Link copied to clipboard
var onDeviceDiscovered: (BluetoothPeripheral) -> Unit?

Callback invoked when a new Bluetooth peripheral is discovered.

Functions

Link copied to clipboard
fun changeMtu(peripheral: BluetoothPeripheral, mtu: Int)

Changes the MTU size for the specified device.

Link copied to clipboard
fun connect(peripheral: BluetoothPeripheral)

Connects to a specified Bluetooth peripheral.

Link copied to clipboard
fun disconnect(peripheral: BluetoothPeripheral)

Disconnects from a specified Bluetooth peripheral.

Link copied to clipboard
fun notifyCharacteristic(peripheral: BluetoothPeripheral, characteristic: BluetoothCharacteristic, enable: Boolean)

Enables or disables notifications for a characteristic.

Link copied to clipboard
fun readCharacteristic(peripheral: BluetoothPeripheral, characteristic: BluetoothCharacteristic)

Reads a Bluetooth characteristic from a device.

Link copied to clipboard
fun readDescriptor(peripheral: BluetoothPeripheral, characteristic: BluetoothCharacteristic, descriptor: BluetoothCharacteristicDescriptor)

Reads a descriptor associated with a Bluetooth characteristic.

Link copied to clipboard
fun removeDelegate(delegate: BlueFalconDelegate)

Removes a previously added delegate.

Link copied to clipboard
fun setDelegate(delegate: BlueFalconDelegate)

Adds a delegate to receive Bluetooth events.

Link copied to clipboard
fun startScan()

Starts scanning for nearby Bluetooth devices.

Link copied to clipboard
fun stopScan()

Stops scanning for Bluetooth devices.

Link copied to clipboard
fun writeCharacteristic(peripheral: BluetoothPeripheral, characteristic: BluetoothCharacteristic, data: ByteArray)

Writes data to a Bluetooth characteristic.

Link copied to clipboard
fun writeDescriptor(peripheral: BluetoothPeripheral, descriptor: BluetoothCharacteristicDescriptor, data: ByteArray)

Writes data to a Bluetooth characteristic descriptor.