BrainAccessClient

class BrainAccessClient(transport: Transport, store: ConfigStore = InMemoryConfigStore(), scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default))

Entry point: owns the scanner (app-scoped, independent of connections, so scan-while- connected is trivial) and the live DeviceSessions. Multiple simultaneous devices are supported — each connection is an independent session with its own scope.

Parameters

transport

the BLE stack (:transport-android in prod, a fake in tests).

store

config persistence (defaults to in-memory).

scope

parent scope for sessions; cancel it to tear everything down.

Constructors

Link copied to clipboard
constructor(transport: Transport, store: ConfigStore = InMemoryConfigStore(), scope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default))

Properties

Link copied to clipboard
val bluetoothState: StateFlow<Boolean>

Phone Bluetooth adapter on/off, observed reactively (see Transport.bluetoothState).

Link copied to clipboard

Functions

Link copied to clipboard

Connect and bring device to DeviceState.Ready. Returns the session, or a failed Result (carrying a BrainAccessError) if connect/handshake fails — in which case any partial connection is torn down.

Link copied to clipboard
suspend fun disconnect(id: DeviceId)

Disconnect and forget a single device.

Link copied to clipboard
suspend fun disconnectAll()

Disconnect every active session.

Link copied to clipboard
fun scan(): Flow<DiscoveredDevice>

Scan for BrainAccess devices; runs independently of any active session.