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

commonMain.dk.cachet.carp.common.application.devices.BLESerialNumberDeviceRegistration.kt Maven / Gradle / Ivy

Go to download

Helper classes and base types relied upon by all subsystems. This library does not contain any domain logic.

The newest version!
package dk.cachet.carp.common.application.devices

import dk.cachet.carp.common.infrastructure.serialization.NotSerializable
import kotlinx.serialization.*
import kotlin.js.JsExport


/**
 * A [DeviceRegistration] for Bluetooth Low Energy (BLE) devices which uses the serial number in the
 * Device Information Service GATT spec (https://www.bluetooth.com/specifications/gatt/services/)
 * to uniquely identify the device.
 */
@Serializable
@JsExport
data class BLESerialNumberDeviceRegistration(
    val serialNumber: String,
    @Required
    override val deviceDisplayName: String? = null
) : DeviceRegistration()
{
    init
    {
        require( serialNumber.isNotBlank() )
    }

    @Required
    override val deviceId: String = serialNumber
}


@Suppress( "SERIALIZER_TYPE_INCOMPATIBLE" )
@Serializable( with = NotSerializable::class )
@JsExport
class BLESerialNumberDeviceRegistrationBuilder : DeviceRegistrationBuilder()
{
    /**
     * The serial number, as broadcast by the Device Information GATT service.
     *
     * This should not be blank.
     */
    var serialNumber: String = ""

    override fun build(): BLESerialNumberDeviceRegistration =
        BLESerialNumberDeviceRegistration( serialNumber, deviceDisplayName )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy