26

All assigned services only state the 16 bit UUID. How can I determine the 128 bit counterpart if I have to specify the service in that format?

From Service Discovery Protocol Overview I know that 128 bit UUIDs are based on a so called "BASE UUID" which is also stated there:

00000000-0000-1000-8000-00805F9B34FB

But how do I create a 128 bit UUID from the 16 bit counterpart? Probably some of the 0 digits have to be replaced, but which and how?

1 Answer 1

52

This can be found in the Bluetooth 4.0 Core spec Vol. 3 - Core System. See the list of adopted specs.

In Part B, covering the Service Discovery Protocol (SDP) under Chapter 2.5.1 "Searching for Services / UUID" will explain how to calculate the UUID.

The full 128-bit value of a 16-bit or 32-bit UUID may be computed by a simple arithmetic operation.

128_bit_value = 16_bit_value * 2^96 + Bluetooth_Base_UUID
128_bit_value = 32_bit_value * 2^96 + Bluetooth_Base_UUID

A 16-bit UUID may be converted to 32-bit UUID format by zero-extending the 16-bit value to 32-bits. An equivalent method is to add the 16-bit UUID value to a zero-valued 32-bit UUID.

Note that, in another section, there's a handy mnemonic:

Or, to put it more simply, the 16-bit Attribute UUID replaces the x’s in the follow- ing:

0000xxxx-0000-1000-8000-00805F9B34FB

In addition, the 32-bit Attribute UUID replaces the x's in the following:

xxxxxxxx-0000-1000-8000-00805F9B34FB

The same equations go for attribute UUIDs. See Part F, covering the Attribute Protocol (ATT) under Chapter 3.2.1 "Protocol Requirements / Basic Concepts". 32 bit attribute UUIDs are first specified in the Bluetooth Core 4.1 spec.

3
  • 2
    Is 0000-1000-8000-00805F9B34FB used in a context where a 16-bit UUID is known to be predefined by the specification? Or is that part of the 128-bit UUID an example of some kind?
    – Cuadue
    Commented Oct 27, 2020 at 20:05
  • @Cuadue, the 00000000-0000-1000-8000-00805F9B34FB is defined as the Bluetooth_Base_UUID - see Bluetooth Core Specification 5.2 specification - Vol. 1, Part E, Section 2.5.1 UUID.
    – Koikos
    Commented Dec 10, 2022 at 14:16
  • For reference: With Bluetooth Core Specification 5.4 the definition moved to Volume 3. Host, Part B, Section 2.5.1 UUID
    – Risto
    Commented Aug 22 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.