RemoteCharacteristic

Constructors

Link copied to clipboard
constructor(wrapper: RemoteCharacteristicWrapper, service: RemoteService, emitNewAction: (DeviceConnectionManager.Event.AddAction) -> Unit, logger: Logger)

Constructor

Types

Link copied to clipboard

A subscription to a com.splendo.kaluga.bluetooth.RemoteCharacteristic. Can be created using RemoteCharacteristic.subscribe if Characteristic.properties contains CharacteristicProperty.Notifiable. Call unsubscribe to remove the subscription. This will automatically stop notification if this is the last remaining subscription to the characteristic.

Link copied to clipboard
sealed class SubscriptionResult

Result from calling RemoteCharacteristic.subscribe

Properties

Link copied to clipboard
open override val descriptors: List<RemoteDescriptor>

The list of RemoteDescriptor available for this characteristic

Link copied to clipboard
val isNotifying: StateFlow<Boolean>

If true this characteristic has been set to automatically provide updates to its value

Link copied to clipboard
Link copied to clipboard
open override val service: RemoteService
Link copied to clipboard
open override val uuid: UUID
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard

Enables notification or indication for this RemoteCharacteristic.

Link copied to clipboard

Checks if the characteristic has a given CharacteristicProperty

Link copied to clipboard

Requests a read of the value of the attribute from the device and suspends until the value is received.

inline suspend fun <T> read(bluetoothFormat: BluetoothFormat = BluetoothFormat): T
suspend fun <T> read(deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat): T

Requests a read of the a value of T of the attribute from the device and suspends until the value is received.

Link copied to clipboard
inline suspend fun <T> readOrNull(bluetoothFormat: BluetoothFormat = BluetoothFormat): T?
suspend fun <T> readOrNull(deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat): T?

Requests a read of the a value of T of the attribute from the device and suspends until the value is received.

Link copied to clipboard
Link copied to clipboard

Starts to enable notification or indication for this RemoteCharacteristic.

Link copied to clipboard
Link copied to clipboard

Creates and emits a WriteAction to write a given ByteArray

inline fun <T> startWrite(bluetoothFormat: BluetoothFormat = BluetoothFormat, newValue: T): DeviceAction.Write.Characteristic
fun <T> startWrite(serializationStrategy: SerializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat, newValue: T): DeviceAction.Write.Characteristic

Creates and emits a WriteAction to write a given T

Link copied to clipboard
inline suspend fun <T> subscribe(bluetoothFormat: BluetoothFormat = BluetoothFormat, noinline onUpdate: (T) -> Unit): RemoteCharacteristic.SubscriptionResult
suspend fun <T> subscribe(deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat, onUpdate: (T) -> Unit): RemoteCharacteristic.SubscriptionResult

Attempts to subscribe to the characteristic.

Link copied to clipboard

Gets a (Flow of) the ByteArray value from a RemoteCharacteristic This method will automatically subscribe/unsubscribe to the RemoteCharacteristic when the Flow is collected

inline fun <T> RemoteCharacteristic.value(bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T>
fun <T> RemoteCharacteristic.value(deserializationStrategy: DeserializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat): Flow<T>

Gets a (Flow of) T value from a RemoteCharacteristic This method will automatically subscribe/unsubscribe to the RemoteCharacteristic when the Flow is collected

Link copied to clipboard

Attempts to write a ByteArray to the attribute on the device and suspends until the write completes.

inline suspend fun <T> write(bluetoothFormat: BluetoothFormat = BluetoothFormat, newValue: T): GattResponse.WriteResponse
suspend fun <T> write(serializationStrategy: SerializationStrategy<T>, bluetoothFormat: BluetoothFormat = BluetoothFormat, newValue: T): GattResponse.WriteResponse

Attempts to write a value of T to the attribute on the device and suspends until the write completes.