appleMain.AdvertisementData.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kable-core Show documentation
Show all versions of kable-core Show documentation
Kotlin Asynchronous Bluetooth Low Energy
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)