How can I convert a Bluetooth 16 bit service UUID into a 128 bit UUID?

前端 未结 1 842
天涯浪人
天涯浪人 2021-02-02 12:54

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 Pro

相关标签:
1条回答
  • 2021-02-02 13:41

    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.

    0 讨论(0)
提交回复
热议问题