Provide Bluetooth SIG assigned numbers as Kotlin constants#1220
Draft
twyatt wants to merge 6 commits into
Draft
Conversation
Pulls AssignedNumbers.kt (Apache-2.0) from https://github.com/chungchungdev/kotlin-bluetoothsig-assigned-numbers into kable-core, providing Bluetooth SIG assigned numbers for services, characteristics and descriptors as Kotlin constants. Also adds a Bluetooth.BaseUuid plus(UInt) operator so the constants can be combined into full 128-bit UUIDs. Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
Deprecates the string-based Uuid.service/characteristic/descriptor lookup functions in favor of AssignedNumbers constants, and migrates internal usages, the SensorTag sample and README accordingly. Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
Extracts AssignedNumbers.kt from kable-core into a new (optional) bluetooth-sig-assigned-numbers module/artifact. kable-core no longer depends on the constants; deprecation messages now point at the new artifact and the SensorTag sample consumes it explicitly. Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
Moves the constants to the org.bluetooth package with lowercase names so that fully qualified names exactly match the IDs defined in the Bluetooth SIG assigned numbers YAML files, for example: org.bluetooth.service.heart_rate and org.bluetooth.descriptor.gatt.client_characteristic_configuration. Drops the AssignedNumbers wrapper object in favor of top-level service/characteristic/descriptor objects, and removes the redundant value lines from constant documentation. IDs that are not valid Kotlin identifiers (e.g. real-time_ranging_data) are backtick-escaped. Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
All assigned numbers are 16-bit, so they fit in Int without overflow. This works directly with the existing Bluetooth.BaseUuid plus(Int) operator, so the plus(UInt) overload is no longer needed. Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
Regenerates constants from the current Bluetooth SIG assigned numbers repository (2026-07-18), adding 42 new assigned numbers (4 services, 36 characteristics, 2 descriptors) and applying 3 SIG renames: ieee_11073-20601_regulatory_certification_data_list (now a valid identifier as ieee_11073_20601_regulatory_certification_data_list), current_elapsed_time -> elapsed_time, and medical_devices -> udi_for_medical_devices. The descriptors YAML file was also renamed upstream (descriptor_uuids.yaml -> descriptors.yaml). Co-authored-by: Travis Wyatt <travis.i.wyatt@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #898
Provides all Bluetooth SIG assigned numbers for services, characteristics and descriptors as Kotlin constants (with autocompletion and KDoc) in a new
bluetooth-sig-assigned-numbersmodule, and uses the constants instead of the string-based lookups. Based on chungchungdev/kotlin-bluetoothsig-assigned-numbers (Apache-2.0, thanks @chungchungdev!), refreshed against the current Bluetooth SIG assigned numbers repository (2026-07-18, 603 constants).Changes
bluetooth-sig-assigned-numbersmodule (published ascom.juul.kable:bluetooth-sig-assigned-numbers, optional forkable-coreconsumers), structured so that fully qualified constant names exactly match the IDs defined in the Bluetooth SIG assigned numbers YAML files:Package is
org.bluetoothwith lowercase constants in top-levelservice,characteristicanddescriptorobjects (no wrapper object), e.g.org.bluetooth.service.heart_rate,org.bluetooth.characteristic.gap.device_name,org.bluetooth.descriptor.gatt.client_characteristic_configuration.Constants are
Int(all assigned numbers are 16-bit, so none overflow), combining directly with the existingBluetooth.BaseUuid + Intoperator:The three IDs that aren't valid Kotlin identifiers (e.g.
real-time_ranging_data) are backtick-escaped.Constant KDoc holds just the human-readable name (the hex value would be redundant with the constant's value).
Same targets as the other published modules (JVM/JS/WasmJS + Apple targets on macOS hosts); Android consumers use the JVM variant.
WARNINGlevel):Uuid.service(name),Uuid.characteristic(name)andUuid.descriptor(name)now point users at the correspondingorg.bluetoothobject in the new artifact. The constants also cover far more assigned numbers than the Web Bluetooth-sourced maps did, and avoid runtimeNoSuchElementExceptions from typo'd names.characteristicOfdeprecation message example inProfile.kt, the SensorTag sample's battery characteristic (sample now depends on the new artifact), and the README (setup, UUID shorthand section, I/O examples).kable-coreitself has no dependency on the new module, keeping the artifact fully optional.bluetooth-sig-assigned-numbers. (Theapi/androiddump appears to no longer be maintained by binary-compatibility-validator since the migration to AGP's built-in Kotlin, see Kotlin/binary-compatibility-validator#312, so it is untouched.)settings.gradle.kts, Dokka aggregation, and (implicitly) binary compatibility validation.Testing
./gradlew :kable-core:jvmTest— passed./gradlew apiCheck lintKotlin— passed./gradlew :bluetooth-sig-assigned-numbers:assemble :kable-core:compileKotlinJvm :kable-core:compileKotlinJs :kable-core:compileKotlinWasmJs :kable-core:compileAndroidMain— passed./gradlew -PRELEASE_SIGNING_ENABLED=false :bluetooth-sig-assigned-numbers:publishToMavenLocal— passed./gradlew :shared:compileKotlinJvm :shared:compileAndroidMain— passed(Native/Apple targets not compiled; only enabled on macOS hosts.)