GattConnection

interface GattConnection

One device's GATT surface. Every fallible op suspends until the stack acknowledges it (the suspend-ack model that replaces the legacy poll-the-event-log state machine). Characteristic identifiers are the UUID strings from GattUuids.

Properties

Link copied to clipboard
abstract val connected: StateFlow<Boolean>

True while the link is up; flips to false on disconnect (drop or local close).

Link copied to clipboard
abstract val id: DeviceId

Functions

Link copied to clipboard
abstract suspend fun disconnect()
Link copied to clipboard
abstract suspend fun discoverServices()
Link copied to clipboard
abstract fun has(characteristic: String): Boolean

Whether characteristic was discovered on this device. Optional services (device info, firmware update) vary by model/firmware; callers gate on this instead of catching reads.

Link copied to clipboard
abstract fun observe(characteristic: String): Flow<ByteArray>

Stream of notification payloads for characteristic.

Link copied to clipboard
abstract suspend fun read(characteristic: String): ByteArray
Link copied to clipboard
open suspend fun requestHighThroughput()

Best-effort link-throughput tuning (connection priority / preferred PHY). High-rate models (MAXI: 32 ch, ~14 kB/s) sit near the default connection parameters' budget — without this the device's own TX queue overflows under RF congestion and it drops (gap-fills) samples. Implementations MUST swallow unsupported-stack failures; default is a no-op.

Link copied to clipboard
abstract suspend fun requestMtu(mtu: Int): Int

Request an MTU; returns the granted MTU.

Link copied to clipboard
abstract suspend fun setNotify(characteristic: String, enable: Boolean)

Enable/disable notifications (writes the CCCD) for characteristic.

Link copied to clipboard
abstract suspend fun write(characteristic: String, value: ByteArray)