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

appleMain.AdvertisementData.kt Maven / Gradle / Ivy

There is a newer version: 0.35.0-rc
Show newest version
package com.juul.kable

import com.benasher44.uuid.Uuid
import platform.CoreBluetooth.CBAdvertisementDataLocalNameKey
import platform.CoreBluetooth.CBAdvertisementDataManufacturerDataKey
import platform.CoreBluetooth.CBAdvertisementDataServiceUUIDsKey
import platform.CoreBluetooth.CBUUID
import platform.Foundation.NSData

internal value class AdvertisementData(private val source: Map) {

    val serviceUuids: List?
        get() = (source[CBAdvertisementDataServiceUUIDsKey] as? List)?.map(CBUUID::toUuid)

    val localName: String?
        get() = source[CBAdvertisementDataLocalNameKey] as? String

    val manufacturerData: ManufacturerData?
        get() = (source[CBAdvertisementDataManufacturerDataKey] as? NSData)?.toManufacturerData()
}

internal fun Map.asAdvertisementData() = AdvertisementData(this)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy