Skip to content

Commit

Permalink
Simplify "client characteristic config" UUID definition
Browse files Browse the repository at this point in the history
  • Loading branch information
twyatt committed Jan 19, 2025
1 parent 7257014 commit 00756a7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.toJavaUuid
import kotlin.uuid.toKotlinUuid

// Number of service discovery attempts to make if no services are discovered.
Expand Down Expand Up @@ -370,7 +371,7 @@ private val Priority.intValue: Int
}

private val PlatformCharacteristic.configDescriptor: PlatformDescriptor?
get() = descriptors.firstOrNull { clientCharacteristicConfigUuid == it.uuid.toKotlinUuid() }
get() = descriptors.firstOrNull { clientCharacteristicConfigUuid == it.uuid }

private val PlatformCharacteristic.supportsNotify: Boolean
get() = properties and PROPERTY_NOTIFY != 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.juul.kable.bluetooth

import com.juul.kable.external.CLIENT_CHARACTERISTIC_CONFIG_UUID
import kotlin.uuid.Uuid
import com.juul.kable.Bluetooth
import kotlin.uuid.toJavaUuid

internal val clientCharacteristicConfigUuid = Uuid.parse(CLIENT_CHARACTERISTIC_CONFIG_UUID)
internal val clientCharacteristicConfigUuid = (Bluetooth.BaseUuid + 0x2902).toJavaUuid()
3 changes: 0 additions & 3 deletions kable-core/src/androidMain/kotlin/external/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,3 @@ internal const val GATT_NOT_ENCRYPTED = 0x8e
internal const val GATT_CCC_CFG_ERR = 0xFD
internal const val GATT_PRC_IN_PROGRESS = 0xFE
internal const val GATT_OUT_OF_RANGE = 0xFF

// https://android.googlesource.com/platform/development/+/7167a054a8027f75025c865322fa84791a9b3bd1/samples/BluetoothLeGatt/src/com/example/bluetooth/le/SampleGattAttributes.java#27
internal const val CLIENT_CHARACTERISTIC_CONFIG_UUID = "00002902-0000-1000-8000-00805f9b34fb"

0 comments on commit 00756a7

Please sign in to comment.