How can I convert the 16-bit UUID of a Bluetooth service to a 128-bit UUID?

All scheduled service only contain 16-bit UUID. How to detect a 128-bit copy if I need to specify a service in this format?

From Overview of the Service Discovery Protocol I know that 128-bit UUIDs are based on the so-called "BASE UUID", which is also indicated there:

00000000-0000-1000-8000-00805F9B34FB 

But how do I create a 128-bit UUID from a 16-bit copy? Probably some of the 0 digits need to be replaced, but what and how?

+5
source share
1 answer

This can be found in the Bluetooth 4.0 Core Vol specification . 3 - Core System . See list of accepted specifications .

In Part B, covering service discovery protocol (SDP) in Chapter 2.5.1 "Search Services / UUID" will explain how to calculate the UUID.

The full 128-bit value of a 16-bit or 32-bit UUID can be calculated 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 can be converted to a 32-bit UUID format by zero-expanding a 16-bit value to 32 bits. An equivalent method is to add a 16-bit UUID to a 32-bit zero-value UUID.

Note that in another section there is a convenient mnemonics:

Or, more simply, the 16-bit attribute UUID replaces xs in the following order, ING:

 0000xxxx-0000-1000-8000-00805F9B34FB 

In addition, the 32-bit attribute UUID replaces x as follows:

 xxxxxxxx-0000-1000-8000-00805F9B34FB 

The same equations apply to UUID attributes. See Part F covering the Attribute Protocol (ATT) in Section 3.2.1, β€œProtocol Requirements / Concepts . ” The 32-bit UUID attributes are first specified in the Bluetooth Core 4.1 specification.

+17
source

Source: https://habr.com/ru/post/1245737/


All Articles