BleDataDecoder
Decodes a BleData into a value of type T without copying.
On iOS, BleData wraps NSData from CoreBluetooth with zero-copy. A BleDataDecoder reads directly from the platform-native buffer via indexed access (BleData.get), avoiding the allocation and memcpy that BleData.toByteArray would incur.
val decoder = BleDataDecoder<HeartRate> { data ->
val flags = data[0].toInt()
val bpm = if (flags and 0x01 == 0) data[1].toInt() and 0xFF
else (data[1].toInt() and 0xFF) or ((data[2].toInt() and 0xFF) shl 8)
HeartRate(bpm)
}Content copied to clipboard
Functions
Link copied to clipboard
Bridge a BleDataDecoder to work with ByteArray input.
Link copied to clipboard
Transform the output of this BleData decoder.