Uint8Codec

Single-byte unsigned integer codec (0..255). Common for level/enum characteristics like Battery Level (0x2A19).

Strict size: decode throws IllegalArgumentException if input is not exactly 1 byte. encode throws if value is out of range.

Functions

Link copied to clipboard

Bridge a BleDecoder to work with BleData input.

Link copied to clipboard

Bridge a BleEncoder to produce BleData via BleData factory.

Link copied to clipboard
fun <A, B> BleCodec<A>.bimap(encode: (B) -> A, decode: (A) -> B): BleCodec<B>

Transform both directions of this codec.

Link copied to clipboard
fun <A, B> BleEncoder<B>.contramap(transform: (A) -> B): BleEncoder<A>

Transform the input of this encoder.

Link copied to clipboard
open override fun decode(data: ByteArray): Int
Link copied to clipboard
open override fun encode(value: Int): ByteArray
Link copied to clipboard
fun <A, B> BleDecoder<A>.map(transform: (A) -> B): BleDecoder<B>

Transform the output of this decoder.