From 93330064ffea5462e1b938e2f337bd1abd85bc1c Mon Sep 17 00:00:00 2001 From: KAWASHIMA Yoshiyuki Date: Sat, 7 Dec 2024 05:09:23 +0900 Subject: [PATCH] Use `Uuid` from Kotlin standard library (#758) --- gradle/libs.versions.toml | 1 - kable-core/api/android/kable-core.api | 72 +++++++++---------- kable-core/api/jvm/kable-core.api | 72 +++++++++---------- kable-core/build.gradle.kts | 7 +- .../BluetoothDeviceAndroidPeripheral.kt | 3 +- .../BluetoothLeScannerAndroidScanner.kt | 3 +- kable-core/src/androidMain/kotlin/Profile.kt | 19 ++--- .../kotlin/ScanResultAndroidAdvertisement.kt | 8 ++- .../ClientCharacteristicConfigUuid.kt | 4 +- .../src/androidMain/kotlin/logs/LogMessage.kt | 11 +-- .../src/appleMain/kotlin/AdvertisementData.kt | 2 +- .../CBPeripheralCoreBluetoothAdvertisement.kt | 2 +- .../src/appleMain/kotlin/CentralManager.kt | 2 +- .../CentralManagerCoreBluetoothScanner.kt | 2 +- kable-core/src/appleMain/kotlin/Identifier.kt | 5 +- .../appleMain/kotlin/PlatformAdvertisement.kt | 2 +- kable-core/src/appleMain/kotlin/Profile.kt | 2 +- .../src/appleMain/kotlin/ScannerBuilder.kt | 2 +- kable-core/src/appleMain/kotlin/Uuid.kt | 9 ++- .../src/commonMain/kotlin/Advertisement.kt | 2 +- kable-core/src/commonMain/kotlin/Bluetooth.kt | 4 +- .../src/commonMain/kotlin/Descriptor.kt | 2 +- kable-core/src/commonMain/kotlin/Filter.kt | 2 +- .../src/commonMain/kotlin/FilterPredicate.kt | 2 +- .../kotlin/FilterPredicateBuilder.kt | 2 +- .../src/commonMain/kotlin/Peripheral.kt | 1 - kable-core/src/commonMain/kotlin/Profile.kt | 13 ++-- .../src/commonMain/kotlin/logs/LogMessage.kt | 2 +- .../src/commonMain/kotlin/logs/Logging.kt | 2 +- .../commonTest/kotlin/FilterPredicateTests.kt | 6 +- .../src/commonTest/kotlin/FiltersTests.kt | 6 +- .../src/commonTest/kotlin/LogMessageTests.kt | 8 +-- .../src/commonTest/kotlin/ObservationTest.kt | 6 +- ...vertisingEventWebBluetoothAdvertisement.kt | 2 +- .../jsMain/kotlin/BluetoothLEScanOptions.kt | 2 +- .../src/jsMain/kotlin/Options.deprecated.kt | 2 +- kable-core/src/jsMain/kotlin/Options.kt | 2 +- .../src/jsMain/kotlin/OptionsBuilder.kt | 2 +- .../jsMain/kotlin/PlatformAdvertisement.kt | 2 +- kable-core/src/jsMain/kotlin/Profile.kt | 2 +- kable-core/src/jsMain/kotlin/Uuid.kt | 5 +- .../jvmMain/kotlin/com/juul/kable/Profile.kt | 2 +- 42 files changed, 156 insertions(+), 151 deletions(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 55e2a27f6..bbf4c437d 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,6 @@ kotlinx-coroutines-test = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-t kotlinx-io = { module = "org.jetbrains.kotlinx:kotlinx-io-core", version = "0.5.4" } tuulbox-collections = { module = "com.juul.tuulbox:collections", version.ref = "tuulbox" } tuulbox-coroutines = { module = "com.juul.tuulbox:coroutines", version.ref = "tuulbox" } -uuid = { module = "com.benasher44:uuid", version = "0.8.4" } wrappers-bom = { module = "org.jetbrains.kotlin-wrappers:kotlin-wrappers-bom", version = "1.0.0-pre.835" } wrappers-web = { module = "org.jetbrains.kotlin-wrappers:kotlin-web" } diff --git a/kable-core/api/android/kable-core.api b/kable-core/api/android/kable-core.api index a71277c56..30fd8754d 100644 --- a/kable-core/api/android/kable-core.api +++ b/kable-core/api/android/kable-core.api @@ -8,7 +8,7 @@ public abstract interface class com/juul/kable/Advertisement { public abstract fun getUuids ()Ljava/util/List; public abstract fun isConnectable ()Ljava/lang/Boolean; public abstract fun manufacturerData (I)[B - public abstract fun serviceData (Ljava/util/UUID;)[B + public abstract fun serviceData (Lkotlin/uuid/Uuid;)[B } public abstract interface class com/juul/kable/AndroidPeripheral : com/juul/kable/Peripheral { @@ -81,8 +81,8 @@ public final class com/juul/kable/Bluetooth$Availability$Unavailable : com/juul/ public final class com/juul/kable/Bluetooth$BaseUuid { public static final field INSTANCE Lcom/juul/kable/Bluetooth$BaseUuid; - public final fun plus (I)Ljava/util/UUID; - public final fun plus (J)Ljava/util/UUID; + public final fun plus (I)Lkotlin/uuid/Uuid; + public final fun plus (J)Lkotlin/uuid/Uuid; public fun toString ()Ljava/lang/String; } @@ -91,8 +91,8 @@ public final class com/juul/kable/BroadcastReceiverFlowKt { } public abstract interface class com/juul/kable/Characteristic { - public abstract fun getCharacteristicUuid ()Ljava/util/UUID; - public abstract fun getServiceUuid ()Ljava/util/UUID; + public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/Characteristic$Properties { @@ -109,20 +109,20 @@ public final class com/juul/kable/Characteristic$Properties { } public abstract interface class com/juul/kable/Descriptor { - public abstract fun getCharacteristicUuid ()Ljava/util/UUID; - public abstract fun getDescriptorUuid ()Ljava/util/UUID; - public abstract fun getServiceUuid ()Ljava/util/UUID; + public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public abstract fun getDescriptorUuid ()Lkotlin/uuid/Uuid; + public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/DiscoveredCharacteristic : com/juul/kable/Characteristic { public final fun copy (Landroid/bluetooth/BluetoothGattCharacteristic;)Lcom/juul/kable/DiscoveredCharacteristic; public static synthetic fun copy$default (Lcom/juul/kable/DiscoveredCharacteristic;Landroid/bluetooth/BluetoothGattCharacteristic;ILjava/lang/Object;)Lcom/juul/kable/DiscoveredCharacteristic; public fun equals (Ljava/lang/Object;)Z - public fun getCharacteristicUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; public final fun getDescriptors ()Ljava/util/List; public final fun getInstanceId ()I public final fun getProperties-bty6q6U ()I - public fun getServiceUuid ()Ljava/util/UUID; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -131,9 +131,9 @@ public final class com/juul/kable/DiscoveredDescriptor : com/juul/kable/Descript public final fun copy (Landroid/bluetooth/BluetoothGattDescriptor;)Lcom/juul/kable/DiscoveredDescriptor; public static synthetic fun copy$default (Lcom/juul/kable/DiscoveredDescriptor;Landroid/bluetooth/BluetoothGattDescriptor;ILjava/lang/Object;)Lcom/juul/kable/DiscoveredDescriptor; public fun equals (Ljava/lang/Object;)Z - public fun getCharacteristicUuid ()Ljava/util/UUID; - public fun getDescriptorUuid ()Ljava/util/UUID; - public fun getServiceUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public fun getDescriptorUuid ()Lkotlin/uuid/Uuid; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -144,7 +144,7 @@ public final class com/juul/kable/DiscoveredService : com/juul/kable/Service { public fun equals (Ljava/lang/Object;)Z public final fun getCharacteristics ()Ljava/util/List; public final fun getInstanceId ()I - public fun getServiceUuid ()Ljava/util/UUID; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -203,12 +203,12 @@ public final class com/juul/kable/Filter$Name$Prefix : com/juul/kable/Filter$Nam } public final class com/juul/kable/Filter$Service : com/juul/kable/Filter { - public fun (Ljava/util/UUID;)V - public final fun component1 ()Ljava/util/UUID; - public final fun copy (Ljava/util/UUID;)Lcom/juul/kable/Filter$Service; - public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service; + public fun (Lkotlin/uuid/Uuid;)V + public final fun component1 ()Lkotlin/uuid/Uuid; + public final fun copy (Lkotlin/uuid/Uuid;)Lcom/juul/kable/Filter$Service; + public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service; public fun equals (Ljava/lang/Object;)Z - public final fun getUuid ()Ljava/util/UUID; + public final fun getUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -261,28 +261,28 @@ public final class com/juul/kable/KableInitializer : androidx/startup/Initialize } public final class com/juul/kable/LazyCharacteristic : com/juul/kable/Characteristic { - public final fun component1 ()Ljava/util/UUID; - public final fun component2 ()Ljava/util/UUID; - public final fun copy (Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyCharacteristic; - public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic; + public final fun component1 ()Lkotlin/uuid/Uuid; + public final fun component2 ()Lkotlin/uuid/Uuid; + public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyCharacteristic; + public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic; public fun equals (Ljava/lang/Object;)Z - public fun getCharacteristicUuid ()Ljava/util/UUID; - public fun getServiceUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } public final class com/juul/kable/LazyDescriptor : com/juul/kable/Descriptor { - public fun (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)V - public final fun component1 ()Ljava/util/UUID; - public final fun component2 ()Ljava/util/UUID; - public final fun component3 ()Ljava/util/UUID; - public final fun copy (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyDescriptor; - public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor; + public fun (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)V + public final fun component1 ()Lkotlin/uuid/Uuid; + public final fun component2 ()Lkotlin/uuid/Uuid; + public final fun component3 ()Lkotlin/uuid/Uuid; + public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyDescriptor; + public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor; public fun equals (Ljava/lang/Object;)Z - public fun getCharacteristicUuid ()Ljava/util/UUID; - public fun getDescriptorUuid ()Ljava/util/UUID; - public fun getServiceUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public fun getDescriptorUuid ()Lkotlin/uuid/Uuid; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -452,7 +452,7 @@ public final class com/juul/kable/ScannerKt { } public abstract interface class com/juul/kable/Service { - public abstract fun getServiceUuid ()Ljava/util/UUID; + public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/ServicesDiscoveredPeripheral { @@ -639,7 +639,7 @@ public final class com/juul/kable/logs/Logging { } public abstract interface class com/juul/kable/logs/Logging$DataProcessor { - public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Ljava/lang/String; + public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Ljava/lang/String; } public final class com/juul/kable/logs/Logging$DataProcessor$Operation : java/lang/Enum { diff --git a/kable-core/api/jvm/kable-core.api b/kable-core/api/jvm/kable-core.api index 193cfe5bd..85f52dd9d 100644 --- a/kable-core/api/jvm/kable-core.api +++ b/kable-core/api/jvm/kable-core.api @@ -8,7 +8,7 @@ public abstract interface class com/juul/kable/Advertisement { public abstract fun getUuids ()Ljava/util/List; public abstract fun isConnectable ()Ljava/lang/Boolean; public abstract fun manufacturerData (I)[B - public abstract fun serviceData (Ljava/util/UUID;)[B + public abstract fun serviceData (Lkotlin/uuid/Uuid;)[B } public final class com/juul/kable/Bluetooth { @@ -40,14 +40,14 @@ public final class com/juul/kable/Bluetooth$Availability$Unavailable : com/juul/ public final class com/juul/kable/Bluetooth$BaseUuid { public static final field INSTANCE Lcom/juul/kable/Bluetooth$BaseUuid; - public final fun plus (I)Ljava/util/UUID; - public final fun plus (J)Ljava/util/UUID; + public final fun plus (I)Lkotlin/uuid/Uuid; + public final fun plus (J)Lkotlin/uuid/Uuid; public fun toString ()Ljava/lang/String; } public abstract interface class com/juul/kable/Characteristic { - public abstract fun getCharacteristicUuid ()Ljava/util/UUID; - public abstract fun getServiceUuid ()Ljava/util/UUID; + public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/Characteristic$Properties { @@ -64,30 +64,30 @@ public final class com/juul/kable/Characteristic$Properties { } public abstract interface class com/juul/kable/Descriptor { - public abstract fun getCharacteristicUuid ()Ljava/util/UUID; - public abstract fun getDescriptorUuid ()Ljava/util/UUID; - public abstract fun getServiceUuid ()Ljava/util/UUID; + public abstract fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public abstract fun getDescriptorUuid ()Lkotlin/uuid/Uuid; + public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/DiscoveredCharacteristic : com/juul/kable/Characteristic { public fun ()V - public fun getCharacteristicUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; public final fun getDescriptors ()Ljava/util/List; public final fun getProperties-bty6q6U ()I - public fun getServiceUuid ()Ljava/util/UUID; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/DiscoveredDescriptor : com/juul/kable/Descriptor { public fun ()V - public fun getCharacteristicUuid ()Ljava/util/UUID; - public fun getDescriptorUuid ()Ljava/util/UUID; - public fun getServiceUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public fun getDescriptorUuid ()Lkotlin/uuid/Uuid; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/DiscoveredService : com/juul/kable/Service { public fun ()V public final fun getCharacteristics ()Ljava/util/List; - public fun getServiceUuid ()Ljava/util/UUID; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; } public abstract interface annotation class com/juul/kable/ExperimentalApi : java/lang/annotation/Annotation { @@ -144,12 +144,12 @@ public final class com/juul/kable/Filter$Name$Prefix : com/juul/kable/Filter$Nam } public final class com/juul/kable/Filter$Service : com/juul/kable/Filter { - public fun (Ljava/util/UUID;)V - public final fun component1 ()Ljava/util/UUID; - public final fun copy (Ljava/util/UUID;)Lcom/juul/kable/Filter$Service; - public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service; + public fun (Lkotlin/uuid/Uuid;)V + public final fun component1 ()Lkotlin/uuid/Uuid; + public final fun copy (Lkotlin/uuid/Uuid;)Lcom/juul/kable/Filter$Service; + public static synthetic fun copy$default (Lcom/juul/kable/Filter$Service;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/Filter$Service; public fun equals (Ljava/lang/Object;)Z - public final fun getUuid ()Ljava/util/UUID; + public final fun getUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -183,28 +183,28 @@ public final class com/juul/kable/InternalError : java/lang/Error { } public final class com/juul/kable/LazyCharacteristic : com/juul/kable/Characteristic { - public final fun component1 ()Ljava/util/UUID; - public final fun component2 ()Ljava/util/UUID; - public final fun copy (Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyCharacteristic; - public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic; + public final fun component1 ()Lkotlin/uuid/Uuid; + public final fun component2 ()Lkotlin/uuid/Uuid; + public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyCharacteristic; + public static synthetic fun copy$default (Lcom/juul/kable/LazyCharacteristic;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyCharacteristic; public fun equals (Ljava/lang/Object;)Z - public fun getCharacteristicUuid ()Ljava/util/UUID; - public fun getServiceUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } public final class com/juul/kable/LazyDescriptor : com/juul/kable/Descriptor { - public fun (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)V - public final fun component1 ()Ljava/util/UUID; - public final fun component2 ()Ljava/util/UUID; - public final fun component3 ()Ljava/util/UUID; - public final fun copy (Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Lcom/juul/kable/LazyDescriptor; - public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor; + public fun (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)V + public final fun component1 ()Lkotlin/uuid/Uuid; + public final fun component2 ()Lkotlin/uuid/Uuid; + public final fun component3 ()Lkotlin/uuid/Uuid; + public final fun copy (Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Lcom/juul/kable/LazyDescriptor; + public static synthetic fun copy$default (Lcom/juul/kable/LazyDescriptor;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;ILjava/lang/Object;)Lcom/juul/kable/LazyDescriptor; public fun equals (Ljava/lang/Object;)Z - public fun getCharacteristicUuid ()Ljava/util/UUID; - public fun getDescriptorUuid ()Ljava/util/UUID; - public fun getServiceUuid ()Ljava/util/UUID; + public fun getCharacteristicUuid ()Lkotlin/uuid/Uuid; + public fun getDescriptorUuid ()Lkotlin/uuid/Uuid; + public fun getServiceUuid ()Lkotlin/uuid/Uuid; public fun hashCode ()I public fun toString ()Ljava/lang/String; } @@ -307,7 +307,7 @@ public final class com/juul/kable/ScannerKt { } public abstract interface class com/juul/kable/Service { - public abstract fun getServiceUuid ()Ljava/util/UUID; + public abstract fun getServiceUuid ()Lkotlin/uuid/Uuid; } public final class com/juul/kable/ServicesDiscoveredPeripheral { @@ -470,7 +470,7 @@ public final class com/juul/kable/logs/Logging { } public abstract interface class com/juul/kable/logs/Logging$DataProcessor { - public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Ljava/util/UUID;Ljava/util/UUID;Ljava/util/UUID;)Ljava/lang/String; + public abstract fun process ([BLcom/juul/kable/logs/Logging$DataProcessor$Operation;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;Lkotlin/uuid/Uuid;)Ljava/lang/String; } public final class com/juul/kable/logs/Logging$DataProcessor$Operation : java/lang/Enum { diff --git a/kable-core/build.gradle.kts b/kable-core/build.gradle.kts index a560a245e..a83828979 100644 --- a/kable-core/build.gradle.kts +++ b/kable-core/build.gradle.kts @@ -23,10 +23,15 @@ kotlin { jvm() sourceSets { + all { + languageSettings { + optIn("kotlin.uuid.ExperimentalUuidApi") + } + } + commonMain.dependencies { api(libs.kotlinx.coroutines.core) api(libs.kotlinx.io) - api(libs.uuid) implementation(libs.datetime) implementation(libs.tuulbox.collections) } diff --git a/kable-core/src/androidMain/kotlin/BluetoothDeviceAndroidPeripheral.kt b/kable-core/src/androidMain/kotlin/BluetoothDeviceAndroidPeripheral.kt index a0fcf8eec..6f4255721 100644 --- a/kable-core/src/androidMain/kotlin/BluetoothDeviceAndroidPeripheral.kt +++ b/kable-core/src/androidMain/kotlin/BluetoothDeviceAndroidPeripheral.kt @@ -42,6 +42,7 @@ import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlin.coroutines.cancellation.CancellationException import kotlin.time.Duration +import kotlin.uuid.toKotlinUuid // Number of service discovery attempts to make if no services are discovered. // https://github.com/JuulLabs/kable/issues/295 @@ -369,7 +370,7 @@ private val Priority.intValue: Int } private val PlatformCharacteristic.configDescriptor: PlatformDescriptor? - get() = descriptors.firstOrNull { clientCharacteristicConfigUuid == it.uuid } + get() = descriptors.firstOrNull { clientCharacteristicConfigUuid == it.uuid.toKotlinUuid() } private val PlatformCharacteristic.supportsNotify: Boolean get() = properties and PROPERTY_NOTIFY != 0 diff --git a/kable-core/src/androidMain/kotlin/BluetoothLeScannerAndroidScanner.kt b/kable-core/src/androidMain/kotlin/BluetoothLeScannerAndroidScanner.kt index 84ad570cc..56107613b 100644 --- a/kable-core/src/androidMain/kotlin/BluetoothLeScannerAndroidScanner.kt +++ b/kable-core/src/androidMain/kotlin/BluetoothLeScannerAndroidScanner.kt @@ -23,6 +23,7 @@ import kotlinx.coroutines.channels.trySendBlocking import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.filter +import kotlin.uuid.toJavaUuid internal class BluetoothLeScannerAndroidScanner( private val filters: List, @@ -142,7 +143,7 @@ private fun FilterPredicate.toNativeScanFilter(): ScanFilter = is Name.Exact -> setDeviceName(filter.exact) is Address -> setDeviceAddress(filter.address) is ManufacturerData -> setManufacturerData(filter.id, filter.data, filter.dataMask) - is Service -> setServiceUuid(ParcelUuid(filter.uuid)) + is Service -> setServiceUuid(ParcelUuid(filter.uuid.toJavaUuid())) else -> throw AssertionError("Unsupported filter element") } } diff --git a/kable-core/src/androidMain/kotlin/Profile.kt b/kable-core/src/androidMain/kotlin/Profile.kt index 975ccb747..c1509f071 100644 --- a/kable-core/src/androidMain/kotlin/Profile.kt +++ b/kable-core/src/androidMain/kotlin/Profile.kt @@ -5,8 +5,9 @@ package com.juul.kable import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattDescriptor import android.bluetooth.BluetoothGattService -import com.benasher44.uuid.Uuid import com.juul.kable.Characteristic.Properties +import kotlin.uuid.Uuid +import kotlin.uuid.toKotlinUuid @Suppress("ACTUAL_WITHOUT_EXPECT") // https://youtrack.jetbrains.com/issue/KT-37316 internal actual typealias PlatformService = BluetoothGattService @@ -24,7 +25,7 @@ public actual data class DiscoveredService internal constructor( public actual val characteristics: List = service.characteristics.map(::DiscoveredCharacteristic) - actual override val serviceUuid: Uuid get() = service.uuid + actual override val serviceUuid: Uuid get() = service.uuid.toKotlinUuid() val instanceId: Int get() = service.instanceId } @@ -35,8 +36,8 @@ public actual data class DiscoveredCharacteristic internal constructor( public actual val descriptors: List = characteristic.descriptors.map(::DiscoveredDescriptor) - actual override val serviceUuid: Uuid get() = characteristic.service.uuid - actual override val characteristicUuid: Uuid get() = characteristic.uuid + actual override val serviceUuid: Uuid get() = characteristic.service.uuid.toKotlinUuid() + actual override val characteristicUuid: Uuid get() = characteristic.uuid.toKotlinUuid() val instanceId: Int get() = characteristic.instanceId public actual val properties: Properties get() = Properties(characteristic.properties) } @@ -45,12 +46,12 @@ public actual data class DiscoveredDescriptor internal constructor( internal actual val descriptor: PlatformDescriptor, ) : Descriptor { - actual override val serviceUuid: Uuid get() = descriptor.characteristic.service.uuid - actual override val characteristicUuid: Uuid get() = descriptor.characteristic.uuid - actual override val descriptorUuid: Uuid get() = descriptor.uuid + actual override val serviceUuid: Uuid get() = descriptor.characteristic.service.uuid.toKotlinUuid() + actual override val characteristicUuid: Uuid get() = descriptor.characteristic.uuid.toKotlinUuid() + actual override val descriptorUuid: Uuid get() = descriptor.uuid.toKotlinUuid() } internal fun PlatformCharacteristic.toLazyCharacteristic() = LazyCharacteristic( - serviceUuid = service.uuid, - characteristicUuid = uuid, + serviceUuid = service.uuid.toKotlinUuid(), + characteristicUuid = uuid.toKotlinUuid(), ) diff --git a/kable-core/src/androidMain/kotlin/ScanResultAndroidAdvertisement.kt b/kable-core/src/androidMain/kotlin/ScanResultAndroidAdvertisement.kt index fc4163550..2d914426b 100644 --- a/kable-core/src/androidMain/kotlin/ScanResultAndroidAdvertisement.kt +++ b/kable-core/src/androidMain/kotlin/ScanResultAndroidAdvertisement.kt @@ -9,9 +9,11 @@ import android.bluetooth.le.ScanResult import android.os.Build.VERSION import android.os.Build.VERSION_CODES import android.os.ParcelUuid -import com.benasher44.uuid.Uuid import com.juul.kable.PlatformAdvertisement.BondState import kotlinx.parcelize.Parcelize +import kotlin.uuid.Uuid +import kotlin.uuid.toJavaUuid +import kotlin.uuid.toKotlinUuid @Parcelize internal class ScanResultAndroidAdvertisement( @@ -65,10 +67,10 @@ internal class ScanResultAndroidAdvertisement( get() = scanResult.scanRecord?.txPowerLevel override val uuids: List - get() = scanResult.scanRecord?.serviceUuids?.map { it.uuid } ?: emptyList() + get() = scanResult.scanRecord?.serviceUuids?.map { it.uuid.toKotlinUuid() } ?: emptyList() override fun serviceData(uuid: Uuid): ByteArray? = - scanResult.scanRecord?.serviceData?.get(ParcelUuid(uuid)) + scanResult.scanRecord?.serviceData?.get(ParcelUuid(uuid.toJavaUuid())) override fun manufacturerData(companyIdentifierCode: Int): ByteArray? = scanResult.scanRecord?.getManufacturerSpecificData(companyIdentifierCode) diff --git a/kable-core/src/androidMain/kotlin/bluetooth/ClientCharacteristicConfigUuid.kt b/kable-core/src/androidMain/kotlin/bluetooth/ClientCharacteristicConfigUuid.kt index 89a3e2b29..ba3e47117 100644 --- a/kable-core/src/androidMain/kotlin/bluetooth/ClientCharacteristicConfigUuid.kt +++ b/kable-core/src/androidMain/kotlin/bluetooth/ClientCharacteristicConfigUuid.kt @@ -1,6 +1,6 @@ package com.juul.kable.bluetooth -import com.benasher44.uuid.uuidFrom import com.juul.kable.external.CLIENT_CHARACTERISTIC_CONFIG_UUID +import kotlin.uuid.Uuid -internal val clientCharacteristicConfigUuid = uuidFrom(CLIENT_CHARACTERISTIC_CONFIG_UUID) +internal val clientCharacteristicConfigUuid = Uuid.parse(CLIENT_CHARACTERISTIC_CONFIG_UUID) diff --git a/kable-core/src/androidMain/kotlin/logs/LogMessage.kt b/kable-core/src/androidMain/kotlin/logs/LogMessage.kt index a412244ce..9fd6c101c 100644 --- a/kable-core/src/androidMain/kotlin/logs/LogMessage.kt +++ b/kable-core/src/androidMain/kotlin/logs/LogMessage.kt @@ -5,6 +5,7 @@ package com.juul.kable.logs import android.bluetooth.BluetoothGattCharacteristic import android.bluetooth.BluetoothGattDescriptor import com.juul.kable.gatt.GattStatus +import kotlin.uuid.toKotlinUuid internal actual val LOG_INDENT: String? = null @@ -14,15 +15,15 @@ internal fun LogMessage.detail(status: GattStatus) { internal fun LogMessage.detail(characteristic: BluetoothGattCharacteristic) { detail( - characteristic.service.uuid, - characteristic.uuid, + characteristic.service.uuid.toKotlinUuid(), + characteristic.uuid.toKotlinUuid(), ) } internal fun LogMessage.detail(descriptor: BluetoothGattDescriptor) { detail( - descriptor.characteristic.service.uuid, - descriptor.characteristic.uuid, - descriptor.uuid, + descriptor.characteristic.service.uuid.toKotlinUuid(), + descriptor.characteristic.uuid.toKotlinUuid(), + descriptor.uuid.toKotlinUuid(), ) } diff --git a/kable-core/src/appleMain/kotlin/AdvertisementData.kt b/kable-core/src/appleMain/kotlin/AdvertisementData.kt index d8afc7f79..296b7c4d9 100644 --- a/kable-core/src/appleMain/kotlin/AdvertisementData.kt +++ b/kable-core/src/appleMain/kotlin/AdvertisementData.kt @@ -1,11 +1,11 @@ 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 +import kotlin.uuid.Uuid internal value class AdvertisementData(private val source: Map) { diff --git a/kable-core/src/appleMain/kotlin/CBPeripheralCoreBluetoothAdvertisement.kt b/kable-core/src/appleMain/kotlin/CBPeripheralCoreBluetoothAdvertisement.kt index aca9d4457..ea00c7206 100644 --- a/kable-core/src/appleMain/kotlin/CBPeripheralCoreBluetoothAdvertisement.kt +++ b/kable-core/src/appleMain/kotlin/CBPeripheralCoreBluetoothAdvertisement.kt @@ -1,6 +1,5 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import platform.CoreBluetooth.CBAdvertisementDataIsConnectable import platform.CoreBluetooth.CBAdvertisementDataLocalNameKey import platform.CoreBluetooth.CBAdvertisementDataManufacturerDataKey @@ -12,6 +11,7 @@ import platform.CoreBluetooth.CBUUID import platform.Foundation.NSData import platform.Foundation.NSNumber import kotlin.experimental.ExperimentalNativeApi +import kotlin.uuid.Uuid internal class CBPeripheralCoreBluetoothAdvertisement( override val rssi: Int, diff --git a/kable-core/src/appleMain/kotlin/CentralManager.kt b/kable-core/src/appleMain/kotlin/CentralManager.kt index c52f52376..67603aa76 100644 --- a/kable-core/src/appleMain/kotlin/CentralManager.kt +++ b/kable-core/src/appleMain/kotlin/CentralManager.kt @@ -1,6 +1,5 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.logs.Logging import kotlinx.atomicfu.atomic import kotlinx.coroutines.flow.MutableStateFlow @@ -12,6 +11,7 @@ import platform.CoreBluetooth.CBPeripheral import platform.Foundation.NSData import kotlin.coroutines.CoroutineContext import kotlin.time.Duration +import kotlin.uuid.Uuid private const val DISPATCH_QUEUE_LABEL = "central" diff --git a/kable-core/src/appleMain/kotlin/CentralManagerCoreBluetoothScanner.kt b/kable-core/src/appleMain/kotlin/CentralManagerCoreBluetoothScanner.kt index 14809a0fa..9a720a34c 100644 --- a/kable-core/src/appleMain/kotlin/CentralManagerCoreBluetoothScanner.kt +++ b/kable-core/src/appleMain/kotlin/CentralManagerCoreBluetoothScanner.kt @@ -1,6 +1,5 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.CentralManagerDelegate.Response.DidDiscoverPeripheral import com.juul.kable.Filter.Service import com.juul.kable.UnmetRequirementReason.BluetoothDisabled @@ -18,6 +17,7 @@ import platform.CoreBluetooth.CBManagerStatePoweredOff import platform.CoreBluetooth.CBManagerStatePoweredOn import platform.CoreBluetooth.CBManagerStateUnauthorized import platform.CoreBluetooth.CBManagerStateUnsupported +import kotlin.uuid.Uuid internal class CentralManagerCoreBluetoothScanner( central: CentralManager, diff --git a/kable-core/src/appleMain/kotlin/Identifier.kt b/kable-core/src/appleMain/kotlin/Identifier.kt index ed5bab470..ec19f35af 100644 --- a/kable-core/src/appleMain/kotlin/Identifier.kt +++ b/kable-core/src/appleMain/kotlin/Identifier.kt @@ -1,8 +1,7 @@ package com.juul.kable -import com.benasher44.uuid.Uuid -import com.benasher44.uuid.uuidFrom +import kotlin.uuid.Uuid public actual typealias Identifier = Uuid -public actual fun String.toIdentifier(): Identifier = uuidFrom(this) +public actual fun String.toIdentifier(): Identifier = Uuid.parse(this) diff --git a/kable-core/src/appleMain/kotlin/PlatformAdvertisement.kt b/kable-core/src/appleMain/kotlin/PlatformAdvertisement.kt index 9780948be..a43c9a7fc 100644 --- a/kable-core/src/appleMain/kotlin/PlatformAdvertisement.kt +++ b/kable-core/src/appleMain/kotlin/PlatformAdvertisement.kt @@ -1,7 +1,7 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import platform.Foundation.NSData +import kotlin.uuid.Uuid public actual interface PlatformAdvertisement : Advertisement { public fun serviceDataAsNSData(uuid: Uuid): NSData? diff --git a/kable-core/src/appleMain/kotlin/Profile.kt b/kable-core/src/appleMain/kotlin/Profile.kt index af6d16b8d..1aa75c012 100644 --- a/kable-core/src/appleMain/kotlin/Profile.kt +++ b/kable-core/src/appleMain/kotlin/Profile.kt @@ -1,10 +1,10 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.Characteristic.Properties import platform.CoreBluetooth.CBCharacteristic import platform.CoreBluetooth.CBDescriptor import platform.CoreBluetooth.CBService +import kotlin.uuid.Uuid @Suppress("ACTUAL_WITHOUT_EXPECT") // https://youtrack.jetbrains.com/issue/KT-37316 internal actual typealias PlatformService = CBService diff --git a/kable-core/src/appleMain/kotlin/ScannerBuilder.kt b/kable-core/src/appleMain/kotlin/ScannerBuilder.kt index 71000b747..93acff9b9 100644 --- a/kable-core/src/appleMain/kotlin/ScannerBuilder.kt +++ b/kable-core/src/appleMain/kotlin/ScannerBuilder.kt @@ -1,10 +1,10 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.logs.Logging import com.juul.kable.logs.LoggingBuilder import platform.CoreBluetooth.CBCentralManagerScanOptionAllowDuplicatesKey import platform.CoreBluetooth.CBCentralManagerScanOptionSolicitedServiceUUIDsKey +import kotlin.uuid.Uuid public actual class ScannerBuilder { diff --git a/kable-core/src/appleMain/kotlin/Uuid.kt b/kable-core/src/appleMain/kotlin/Uuid.kt index ea0505111..3d0dab8f0 100644 --- a/kable-core/src/appleMain/kotlin/Uuid.kt +++ b/kable-core/src/appleMain/kotlin/Uuid.kt @@ -1,15 +1,14 @@ package com.juul.kable -import com.benasher44.uuid.Uuid -import com.benasher44.uuid.uuidFrom import platform.CoreBluetooth.CBUUID import platform.Foundation.NSUUID +import kotlin.uuid.Uuid internal fun Uuid.toNSUUID(): NSUUID = NSUUID(toString()) internal fun Uuid.toCBUUID(): CBUUID = CBUUID.UUIDWithString(toString()) internal fun CBUUID.toUuid(): Uuid = when (UUIDString.length) { - 4 -> uuidFrom("0000$UUIDString-0000-1000-8000-00805F9B34FB") - else -> uuidFrom(UUIDString) + 4 -> Uuid.parse("0000$UUIDString-0000-1000-8000-00805F9B34FB") + else -> Uuid.parse(UUIDString) } -internal fun NSUUID.toUuid(): Uuid = uuidFrom(UUIDString) +internal fun NSUUID.toUuid(): Uuid = Uuid.parse(UUIDString) diff --git a/kable-core/src/commonMain/kotlin/Advertisement.kt b/kable-core/src/commonMain/kotlin/Advertisement.kt index 8374b6d0b..e40e54bbd 100644 --- a/kable-core/src/commonMain/kotlin/Advertisement.kt +++ b/kable-core/src/commonMain/kotlin/Advertisement.kt @@ -1,6 +1,6 @@ package com.juul.kable -import com.benasher44.uuid.Uuid +import kotlin.uuid.Uuid public interface Advertisement { diff --git a/kable-core/src/commonMain/kotlin/Bluetooth.kt b/kable-core/src/commonMain/kotlin/Bluetooth.kt index 701b8f174..d51c7c230 100644 --- a/kable-core/src/commonMain/kotlin/Bluetooth.kt +++ b/kable-core/src/commonMain/kotlin/Bluetooth.kt @@ -2,9 +2,9 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import kotlinx.coroutines.flow.Flow import kotlin.jvm.JvmName +import kotlin.uuid.Uuid import com.juul.kable.bluetooth.isSupported as isBluetoothSupported @Deprecated( @@ -30,7 +30,7 @@ public object Bluetooth { /** @param shortUuid 32-bits (or less) short UUID (if larger than 32-bits, will be truncated to 32-bits). */ public operator fun plus(shortUuid: Long): Uuid = - Uuid(mostSignificantBits + (shortUuid and 0xFFFF_FFFF shl 32), leastSignificantBits) + Uuid.fromLongs(mostSignificantBits + (shortUuid and 0xFFFF_FFFF shl 32), leastSignificantBits) override fun toString(): String = "00000000-0000-1000-8000-00805F9B34FB" } diff --git a/kable-core/src/commonMain/kotlin/Descriptor.kt b/kable-core/src/commonMain/kotlin/Descriptor.kt index 1bc0a05c2..c66817f7a 100644 --- a/kable-core/src/commonMain/kotlin/Descriptor.kt +++ b/kable-core/src/commonMain/kotlin/Descriptor.kt @@ -1,6 +1,6 @@ package com.juul.kable -import com.benasher44.uuid.Uuid +import kotlin.uuid.Uuid internal fun List.first( descriptorUuid: Uuid, diff --git a/kable-core/src/commonMain/kotlin/Filter.kt b/kable-core/src/commonMain/kotlin/Filter.kt index 34909be45..71a2c20e6 100644 --- a/kable-core/src/commonMain/kotlin/Filter.kt +++ b/kable-core/src/commonMain/kotlin/Filter.kt @@ -1,9 +1,9 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.Filter.Name.Exact import com.juul.kable.Filter.Name.Prefix import kotlin.experimental.and +import kotlin.uuid.Uuid /** * All [Filter]s are supported on all platforms, except for [Filter.Address], which is only supported on Android. diff --git a/kable-core/src/commonMain/kotlin/FilterPredicate.kt b/kable-core/src/commonMain/kotlin/FilterPredicate.kt index 9df23b74a..ec54de0f8 100644 --- a/kable-core/src/commonMain/kotlin/FilterPredicate.kt +++ b/kable-core/src/commonMain/kotlin/FilterPredicate.kt @@ -1,10 +1,10 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.Filter.Address import com.juul.kable.Filter.Name import com.juul.kable.Filter.Service import kotlin.jvm.JvmInline +import kotlin.uuid.Uuid @JvmInline internal value class FilterPredicate( diff --git a/kable-core/src/commonMain/kotlin/FilterPredicateBuilder.kt b/kable-core/src/commonMain/kotlin/FilterPredicateBuilder.kt index 90c8b8bd0..d9834fca0 100644 --- a/kable-core/src/commonMain/kotlin/FilterPredicateBuilder.kt +++ b/kable-core/src/commonMain/kotlin/FilterPredicateBuilder.kt @@ -1,6 +1,6 @@ package com.juul.kable -import com.benasher44.uuid.Uuid +import kotlin.uuid.Uuid public class FilterPredicateBuilder internal constructor() { public var name: Filter.Name? = null diff --git a/kable-core/src/commonMain/kotlin/Peripheral.kt b/kable-core/src/commonMain/kotlin/Peripheral.kt index 42184438e..1ce86048c 100644 --- a/kable-core/src/commonMain/kotlin/Peripheral.kt +++ b/kable-core/src/commonMain/kotlin/Peripheral.kt @@ -3,7 +3,6 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.State.Disconnecting import com.juul.kable.WriteType.WithoutResponse import kotlinx.coroutines.CoroutineScope diff --git a/kable-core/src/commonMain/kotlin/Profile.kt b/kable-core/src/commonMain/kotlin/Profile.kt index 9fbc67810..2a891fe5f 100644 --- a/kable-core/src/commonMain/kotlin/Profile.kt +++ b/kable-core/src/commonMain/kotlin/Profile.kt @@ -2,12 +2,11 @@ package com.juul.kable -import com.benasher44.uuid.Uuid -import com.benasher44.uuid.uuidFrom import com.juul.kable.Characteristic.Properties import com.juul.kable.WriteType.WithResponse import com.juul.kable.WriteType.WithoutResponse import kotlin.jvm.JvmInline +import kotlin.uuid.Uuid public interface Service { public val serviceUuid: Uuid @@ -122,8 +121,8 @@ public fun characteristicOf( service: String, characteristic: String, ): Characteristic = LazyCharacteristic( - serviceUuid = uuidFrom(service), - characteristicUuid = uuidFrom(characteristic), + serviceUuid = Uuid.parse(service), + characteristicUuid = Uuid.parse(characteristic), ) public fun descriptorOf( @@ -131,9 +130,9 @@ public fun descriptorOf( characteristic: String, descriptor: String, ): Descriptor = LazyDescriptor( - serviceUuid = uuidFrom(service), - characteristicUuid = uuidFrom(characteristic), - descriptorUuid = uuidFrom(descriptor), + serviceUuid = Uuid.parse(service), + characteristicUuid = Uuid.parse(characteristic), + descriptorUuid = Uuid.parse(descriptor), ) internal fun List.obtain( diff --git a/kable-core/src/commonMain/kotlin/logs/LogMessage.kt b/kable-core/src/commonMain/kotlin/logs/LogMessage.kt index fbf7888e4..8d98c7b17 100644 --- a/kable-core/src/commonMain/kotlin/logs/LogMessage.kt +++ b/kable-core/src/commonMain/kotlin/logs/LogMessage.kt @@ -1,12 +1,12 @@ package com.juul.kable.logs -import com.benasher44.uuid.Uuid import com.juul.kable.Characteristic import com.juul.kable.Descriptor import com.juul.kable.WriteType import com.juul.kable.logs.Logging.DataProcessor.Operation import com.juul.kable.logs.Logging.Format.Compact import com.juul.kable.logs.Logging.Format.Multiline +import kotlin.uuid.Uuid internal expect val LOG_INDENT: String? diff --git a/kable-core/src/commonMain/kotlin/logs/Logging.kt b/kable-core/src/commonMain/kotlin/logs/Logging.kt index ae2a9ac67..2020f8e1d 100644 --- a/kable-core/src/commonMain/kotlin/logs/Logging.kt +++ b/kable-core/src/commonMain/kotlin/logs/Logging.kt @@ -1,7 +1,7 @@ package com.juul.kable.logs -import com.benasher44.uuid.Uuid import com.juul.kable.ObsoleteKableApi +import kotlin.uuid.Uuid public typealias LoggingBuilder = Logging.() -> Unit diff --git a/kable-core/src/commonTest/kotlin/FilterPredicateTests.kt b/kable-core/src/commonTest/kotlin/FilterPredicateTests.kt index df45c3285..c922c4e44 100644 --- a/kable-core/src/commonTest/kotlin/FilterPredicateTests.kt +++ b/kable-core/src/commonTest/kotlin/FilterPredicateTests.kt @@ -1,17 +1,17 @@ package com.juul.kable -import com.benasher44.uuid.uuidFrom import com.juul.kable.Filter.Name.Exact import com.juul.kable.Filter.Name.Prefix import kotlin.test.Test import kotlin.test.assertFalse import kotlin.test.assertTrue +import kotlin.uuid.Uuid import com.juul.kable.Filter.ManufacturerData as ManufacturerDataFilter class FilterPredicateTests { - private val TEST_UUID_1 = uuidFrom("deadbeef-0000-0000-0000-000000000000") - private val TEST_UUID_2 = uuidFrom("0badcafe-0000-0000-0000-000000000000") + private val TEST_UUID_1 = Uuid.parse("deadbeef-0000-0000-0000-000000000000") + private val TEST_UUID_2 = Uuid.parse("0badcafe-0000-0000-0000-000000000000") @Test fun matches_nameFilterVsExactMatch_isTrue() { diff --git a/kable-core/src/commonTest/kotlin/FiltersTests.kt b/kable-core/src/commonTest/kotlin/FiltersTests.kt index 364ea61a9..4466fa9d8 100644 --- a/kable-core/src/commonTest/kotlin/FiltersTests.kt +++ b/kable-core/src/commonTest/kotlin/FiltersTests.kt @@ -1,16 +1,16 @@ package com.juul.kable -import com.benasher44.uuid.uuidFrom import com.juul.kable.Filter.Name.Exact import com.juul.kable.Filter.Name.Prefix import kotlin.test.Test import kotlin.test.assertFalse import kotlin.test.assertTrue +import kotlin.uuid.Uuid class FiltersTests { - private val TEST_UUID_1 = uuidFrom("deadbeef-0000-0000-0000-000000000000") - private val TEST_UUID_2 = uuidFrom("0badcafe-0000-0000-0000-000000000000") + private val TEST_UUID_1 = Uuid.parse("deadbeef-0000-0000-0000-000000000000") + private val TEST_UUID_2 = Uuid.parse("0badcafe-0000-0000-0000-000000000000") @Test fun matches_emptySetVsNothing_isTrue() { diff --git a/kable-core/src/commonTest/kotlin/LogMessageTests.kt b/kable-core/src/commonTest/kotlin/LogMessageTests.kt index fd3633fe7..6549f3295 100644 --- a/kable-core/src/commonTest/kotlin/LogMessageTests.kt +++ b/kable-core/src/commonTest/kotlin/LogMessageTests.kt @@ -1,6 +1,5 @@ package com.juul.kable -import com.benasher44.uuid.uuidFrom import com.juul.kable.logs.LogMessage import com.juul.kable.logs.Logging import com.juul.kable.logs.Logging.DataProcessor.Operation.Read @@ -9,10 +8,11 @@ import com.juul.kable.logs.Logging.Format.Multiline import com.juul.kable.logs.Logging.Level.Data import kotlin.test.Test import kotlin.test.assertEquals +import kotlin.uuid.Uuid -private val TEST_UUID_1 = uuidFrom("ad0be000-0000-4000-a000-000000000000") -private val TEST_UUID_2 = uuidFrom("c0c0a000-0000-4000-a000-000000000000") -private val TEST_UUID_3 = uuidFrom("decade00-0000-4000-a000-000000000000") +private val TEST_UUID_1 = Uuid.parse("ad0be000-0000-4000-a000-000000000000") +private val TEST_UUID_2 = Uuid.parse("c0c0a000-0000-4000-a000-000000000000") +private val TEST_UUID_3 = Uuid.parse("decade00-0000-4000-a000-000000000000") class LogMessageTests { diff --git a/kable-core/src/commonTest/kotlin/ObservationTest.kt b/kable-core/src/commonTest/kotlin/ObservationTest.kt index dfa98e2d2..52d4518e4 100644 --- a/kable-core/src/commonTest/kotlin/ObservationTest.kt +++ b/kable-core/src/commonTest/kotlin/ObservationTest.kt @@ -1,6 +1,5 @@ package com.juul.kable -import com.benasher44.uuid.uuid4 import com.juul.kable.State.Connected import com.juul.kable.State.Connecting import com.juul.kable.State.Disconnected @@ -19,10 +18,11 @@ import kotlin.test.Test import kotlin.test.assertEquals import kotlin.test.assertFailsWith import kotlin.test.assertFalse +import kotlin.uuid.Uuid private fun generateCharacteristic() = characteristicOf( - service = uuid4().toString(), - characteristic = uuid4().toString(), + service = Uuid.random().toString(), + characteristic = Uuid.random().toString(), ) @OptIn(ExperimentalCoroutinesApi::class) diff --git a/kable-core/src/jsMain/kotlin/BluetoothAdvertisingEventWebBluetoothAdvertisement.kt b/kable-core/src/jsMain/kotlin/BluetoothAdvertisingEventWebBluetoothAdvertisement.kt index c55bf3474..b48ebae7b 100644 --- a/kable-core/src/jsMain/kotlin/BluetoothAdvertisingEventWebBluetoothAdvertisement.kt +++ b/kable-core/src/jsMain/kotlin/BluetoothAdvertisingEventWebBluetoothAdvertisement.kt @@ -1,10 +1,10 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.external.BluetoothAdvertisingEvent import com.juul.kable.external.BluetoothDevice import com.juul.kable.external.iterable import org.khronos.webgl.DataView +import kotlin.uuid.Uuid internal class BluetoothAdvertisingEventWebBluetoothAdvertisement( private val advertisement: BluetoothAdvertisingEvent, diff --git a/kable-core/src/jsMain/kotlin/BluetoothLEScanOptions.kt b/kable-core/src/jsMain/kotlin/BluetoothLEScanOptions.kt index 935d35178..20630a933 100644 --- a/kable-core/src/jsMain/kotlin/BluetoothLEScanOptions.kt +++ b/kable-core/src/jsMain/kotlin/BluetoothLEScanOptions.kt @@ -1,10 +1,10 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.external.BluetoothLEScanFilterInit import com.juul.kable.external.BluetoothLEScanOptions import com.juul.kable.external.BluetoothManufacturerDataFilterInit import js.objects.jso +import kotlin.uuid.Uuid /** Convert list of public API type to Web Bluetooth (JavaScript) type. */ internal fun List.toBluetoothLEScanOptions(): BluetoothLEScanOptions = jso { diff --git a/kable-core/src/jsMain/kotlin/Options.deprecated.kt b/kable-core/src/jsMain/kotlin/Options.deprecated.kt index e8c493dd3..cee17efa1 100644 --- a/kable-core/src/jsMain/kotlin/Options.deprecated.kt +++ b/kable-core/src/jsMain/kotlin/Options.deprecated.kt @@ -1,6 +1,6 @@ package com.juul.kable -import com.benasher44.uuid.Uuid +import kotlin.uuid.Uuid @Deprecated( message = "Use Options builder instead. See https://github.com/JuulLabs/kable/issues/723 for details.", diff --git a/kable-core/src/jsMain/kotlin/Options.kt b/kable-core/src/jsMain/kotlin/Options.kt index 3a0cd454a..a8cbb3129 100644 --- a/kable-core/src/jsMain/kotlin/Options.kt +++ b/kable-core/src/jsMain/kotlin/Options.kt @@ -1,8 +1,8 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.external.RequestDeviceOptions import js.objects.jso +import kotlin.uuid.Uuid /** https://developer.mozilla.org/en-US/docs/Web/API/Bluetooth/requestDevice */ public fun Options(builder: OptionsBuilder.() -> Unit): Options = diff --git a/kable-core/src/jsMain/kotlin/OptionsBuilder.kt b/kable-core/src/jsMain/kotlin/OptionsBuilder.kt index 507f35ef1..4e0c7839c 100644 --- a/kable-core/src/jsMain/kotlin/OptionsBuilder.kt +++ b/kable-core/src/jsMain/kotlin/OptionsBuilder.kt @@ -1,6 +1,6 @@ package com.juul.kable -import com.benasher44.uuid.Uuid +import kotlin.uuid.Uuid public class OptionsBuilder internal constructor() { diff --git a/kable-core/src/jsMain/kotlin/PlatformAdvertisement.kt b/kable-core/src/jsMain/kotlin/PlatformAdvertisement.kt index 42e7c37e5..1fb3ee7c4 100644 --- a/kable-core/src/jsMain/kotlin/PlatformAdvertisement.kt +++ b/kable-core/src/jsMain/kotlin/PlatformAdvertisement.kt @@ -1,7 +1,7 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import org.khronos.webgl.DataView +import kotlin.uuid.Uuid public actual interface PlatformAdvertisement : Advertisement { public fun serviceDataAsDataView(uuid: Uuid): DataView? diff --git a/kable-core/src/jsMain/kotlin/Profile.kt b/kable-core/src/jsMain/kotlin/Profile.kt index c855fbd55..e260a840e 100644 --- a/kable-core/src/jsMain/kotlin/Profile.kt +++ b/kable-core/src/jsMain/kotlin/Profile.kt @@ -1,6 +1,5 @@ package com.juul.kable -import com.benasher44.uuid.Uuid import com.juul.kable.Characteristic.Properties import com.juul.kable.external.BluetoothCharacteristicProperties import com.juul.kable.external.BluetoothRemoteGATTCharacteristic @@ -9,6 +8,7 @@ import com.juul.kable.external.BluetoothRemoteGATTService import com.juul.kable.logs.Logger import com.juul.kable.logs.detail import kotlinx.coroutines.await +import kotlin.uuid.Uuid @Suppress("ACTUAL_WITHOUT_EXPECT") // https://youtrack.jetbrains.com/issue/KT-37316 internal actual typealias PlatformService = BluetoothRemoteGATTService diff --git a/kable-core/src/jsMain/kotlin/Uuid.kt b/kable-core/src/jsMain/kotlin/Uuid.kt index e9aa74568..e42d5a703 100644 --- a/kable-core/src/jsMain/kotlin/Uuid.kt +++ b/kable-core/src/jsMain/kotlin/Uuid.kt @@ -1,9 +1,8 @@ package com.juul.kable -import com.benasher44.uuid.Uuid -import com.benasher44.uuid.uuidFrom import com.juul.kable.external.BluetoothServiceUUID import com.juul.kable.external.BluetoothUUID +import kotlin.uuid.Uuid // Number of characters in a 16-bit UUID alias in string hex representation private const val UUID_ALIAS_STRING_LENGTH = 4 @@ -19,7 +18,7 @@ private const val UUID_ALIAS_STRING_LENGTH = 4 internal typealias UUID = String internal fun UUID.toUuid(): Uuid = - uuidFrom( + Uuid.parse( when (length) { UUID_ALIAS_STRING_LENGTH -> BluetoothUUID.canonicalUUID(toInt(16)) else -> this diff --git a/kable-core/src/jvmMain/kotlin/com/juul/kable/Profile.kt b/kable-core/src/jvmMain/kotlin/com/juul/kable/Profile.kt index 42cdb02fb..c25d4fe7e 100644 --- a/kable-core/src/jvmMain/kotlin/com/juul/kable/Profile.kt +++ b/kable-core/src/jvmMain/kotlin/com/juul/kable/Profile.kt @@ -1,6 +1,6 @@ package com.juul.kable -import com.benasher44.uuid.Uuid +import kotlin.uuid.Uuid internal actual class PlatformService internal actual class PlatformCharacteristic