ClientBleGattCharacteristic

A helper class which provides operations which can happen on a GATT characteristic. Its main responsibility is to provide write/read/notify features in a synchronous manner, because simultaneous calls will be ignored by Android API.

Properties

Link copied to clipboard
Link copied to clipboard

Instance id of the characteristic.

Link copied to clipboard

Permissions of the characteristic.

Link copied to clipboard

Properties of the characteristic.

Link copied to clipboard
val uuid: UUID

UUID of the characteristic.

Functions

Link copied to clipboard

Finds a descriptor by UUID.

Link copied to clipboard
suspend fun getNotifications(bufferSize: Int = 0, bufferOverflow: BufferOverflow = BufferOverflow.DROP_OLDEST): Flow<DataByteArray>

Enables and observes notifications/indications of the characteristic. After subscriber is closed the notifications should be disabled.

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
suspend fun read(): DataByteArray

Reads value from a characteristic and suspends for the result.

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
suspend fun splitWrite(value: DataByteArray, writeType: BleWriteType = BleWriteType.DEFAULT)

Writes bytes to a characteristic and waits for a request to finish. If value is bigger than MTU then it splits the value and send it in consecutive messages.

Link copied to clipboard
@RequiresPermission(value = "android.permission.BLUETOOTH_CONNECT")
suspend fun write(value: DataByteArray, writeType: BleWriteType = BleWriteType.DEFAULT)

Writes bytes to a characteristic and waits for a request to finish.