RemoteCharacteristic

A GATT characteristic of a service on a remote connected peripheral device.

The API allows to access the value of the characteristic.

Depending on the properties of the characteristic, it may be possible to read, write, subscribe for value changes, etc.

Properties

Link copied to clipboard
Link copied to clipboard
abstract val instanceId: Int
Link copied to clipboard
abstract val isNotifying: Boolean

Returns whether the characteristic is notifying or indicating.

Link copied to clipboard
open override val owner: Peripheral<*, *>?
Link copied to clipboard
Link copied to clipboard
abstract override val service: AnyRemoteService
Link copied to clipboard
abstract val uuid: Uuid

Functions

Link copied to clipboard
open fun isReadable(): Boolean
Link copied to clipboard
Link copied to clipboard
open fun isWritable(): Boolean
Link copied to clipboard
abstract suspend fun read(): ByteArray

Reads the value of the characteristic.

Link copied to clipboard
abstract suspend fun setNotifying(enabled: Boolean)

Enables notifications or indications, depending on the characteristic's properties.

Link copied to clipboard
abstract fun subscribe(onSubscription: suspend RemoteCharacteristic.() -> Unit = {}): Flow<ByteArray>

Subscribes for notifications or indications of the characteristic.

Link copied to clipboard
abstract suspend fun waitForValueChange(rawDataFilter: (ByteArray) -> Boolean = { true }, merge: suspend (accumulator: ByteArray, received: ByteArray, index: Int) -> MergeResult = { _, rec, _ -> MergeResult.Completed(rec) }, filter: (ByteArray) -> Boolean = { true }, trigger: suspend RemoteCharacteristic.() -> Unit = {}): ByteArray

Waits for the value of the characteristic to change.

Link copied to clipboard
abstract suspend fun write(data: ByteArray, writeType: WriteType = properties.defaultWriteType ?: WriteType.WITH_RESPONSE)

Writes the value of the characteristic.