KableBleService

class KableBleService(peripheral: Peripheral, serviceUuid: Uuid) : BleService(source)

BleService implementation backed by a Kable Peripheral for a specific GATT service.

Constructors

Link copied to clipboard
constructor(peripheral: Peripheral, serviceUuid: Uuid)

Functions

Link copied to clipboard

Creates a handle for a characteristic belonging to this service.

Link copied to clipboard
open override fun hasCharacteristic(characteristic: BleCharacteristic): Boolean

Returns true when the characteristic is present on the connected device.

Link copied to clipboard
open override fun observe(characteristic: BleCharacteristic): Flow<ByteArray>

Observes notifications/indications from the characteristic.

open override fun observe(characteristic: BleCharacteristic, onSubscription: suspend () -> Unit): Flow<ByteArray>

Observes notifications/indications from the characteristic with an onSubscription action that fires after notifications are enabled (CCCD written).

Link copied to clipboard
open override fun preferredWriteType(characteristic: BleCharacteristic): BleWriteType

Returns the preferred write type for the characteristic on this platform/device.

Link copied to clipboard
open suspend override fun read(characteristic: BleCharacteristic): ByteArray

Reads the characteristic value once.

Link copied to clipboard
open suspend override fun write(characteristic: BleCharacteristic, data: ByteArray, writeType: BleWriteType)

Writes a value to the characteristic using the requested BLE write type.