writableAlwaysSuccess

open fun writableAlwaysSuccess(properties: Set<CharacteristicProperty.Writable> = setOf(CharacteristicProperty.Write), encrypted: Boolean = false, onWrite: suspend LocalCharacteristic.(ConnectedDevice, ByteArray, Int) -> Unit)

Makes this LocalCharacteristic writable by a com.splendo.kaluga.bluetooth.ConnectedDevice and always responds with GattResponse.WriteSuccess Cannot be called if writable or writableAlwaysSuccess has been called before

Parameters

properties

the CharacteristicProperty.Writable of the characteristic. Must not be empty

encrypted

true if reading from the characteristic should be encrypted. This will result in Permission.WRITE_ENCRYPTION_REQUIRED. Otherwise will add Permission.WRITABLE

onWrite

the function to call when reading from the characteristic. This contains the com.splendo.kaluga.bluetooth.ConnectedDevice, the ByteArray to write and the offset of the data to write


open fun <T> writableAlwaysSuccess(properties: Set<CharacteristicProperty.Writable> = setOf(CharacteristicProperty.Write), encrypted: Boolean = false, deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat, onWrite: suspend LocalCharacteristic.(ConnectedDevice, T) -> Unit)

Makes this LocalCharacteristic writable by a com.splendo.kaluga.bluetooth.ConnectedDevice and always responds with GattResponse.WriteSuccess Cannot be called if writable or writableAlwaysSuccess has been called before

Parameters

properties

the CharacteristicProperty.Writable of the characteristic. Must not be empty

encrypted

true if reading from the characteristic should be encrypted. This will result in Permission.WRITE_ENCRYPTION_REQUIRED. Otherwise will add Permission.WRITABLE

deserializationStrategy

the DeserializationStrategy to use to decode the ByteArray being written to an instance of T

onWrite

the function to call when reading from the characteristic. This contains the com.splendo.kaluga.bluetooth.ConnectedDevice, and the T to write. If the data being written is split over multiple offsets, this will only be called when the data can be fully deserialized

Type Parameters

T

the type of the data being written