All Downloads are FREE. Search and download functionalities are using the official Maven repository.

iosMain.dev.bluefalcon.BluetoothCharacteristic.kt Maven / Gradle / Ivy

package dev.bluefalcon

import kotlinx.cinterop.addressOf
import kotlinx.cinterop.usePinned
import platform.CoreBluetooth.CBCharacteristic
import platform.CoreBluetooth.CBDescriptor
import platform.posix.memcpy

actual class BluetoothCharacteristic(val characteristic: CBCharacteristic) {
    actual val name: String?
        get() = characteristic.UUID.description()
    actual val value: ByteArray?
        @ExperimentalUnsignedTypes
        get() = characteristic.value?.let { data ->
            ByteArray(data.length.toInt()).apply {
                usePinned {
                    memcpy(it.addressOf(0), data.bytes, data.length)
                }
            }
        }
    actual val descriptors: List
        get() = characteristic.descriptors as List
}

actual typealias  BluetoothCharacteristicDescriptor = CBDescriptor




© 2015 - 2025 Weber Informatics LLC | Privacy Policy