subscribe

Attempts to subscribe to the characteristic.

Return

SubscriptionResult.DidSubscribe if subscription was successful, or SubscriptionResult.FailedToSubscribe if subscription failed.

Parameters

onUpdate

called when the ByteArray value of the characteristic changes.


suspend fun <T> subscribe(deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat, onUpdate: (T) -> Unit): RemoteCharacteristic.SubscriptionResult

Attempts to subscribe to the characteristic.

Return

SubscriptionResult.DidSubscribe if subscription was successful, or SubscriptionResult.FailedToSubscribe if subscription failed.

Parameters

deserializationStrategy

the DeserializationStrategy to use to decode the ByteArray value of the characteristic.

bluetoothFormat

the BluetoothFormat to use to decode the ByteArray value of the characteristic.

onUpdate

called when the T value of the characteristic changes.

Type Parameters

T

the type of the value to be decoded from the ByteArray value of the characteristic.


inline suspend fun <T> subscribe(bluetoothFormat: BluetoothFormat = BluetoothFormat, noinline onUpdate: (T) -> Unit): RemoteCharacteristic.SubscriptionResult

Attempts to subscribe to the characteristic.

Return

SubscriptionResult.DidSubscribe if subscription was successful, or SubscriptionResult.FailedToSubscribe if subscription failed.

Parameters

bluetoothFormat

the BluetoothFormat to use to decode the ByteArray value of the characteristic.

onUpdate

called when the T value of the characteristic changes.

Type Parameters

T

the type of the value to be decoded from the ByteArray value of the characteristic.