From the Bluetooth core specification document "Core_v4.0.pdf"
2.5.1 UUID
The
A UUID is a universally unique identifier, which is guaranteed to being unique across all space and all time. uui Ds can is independently created in a distributed fashion. No Central Registry of assigned UUIDs is required. a UUID is A 128-bit value.
to reduce the burden of storing and TR ansferring 128-bit UUID values, a range of UUID values have been pre-alloc Ated for assignment to often-used, regis-tered purposes. The first UUID in this pre-allocated range is known as The bluetooth Base UUID and have the value 000000 0 0-0000-1000-8000-00805F9B34FB, from the Bluetooth assigned Numbers document. UUID Val-ues in the pre-allocated range has aliases that is represented as 16-bit or 32-bit values. These aliases are often called 16-bit and 32-bit UUIDs, but it is important to note this each actually re Presents a 128-bit UUID value.
The full 128-bit value of a 16-bit or 32-bit UUID is 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+biuetooth_base_uuid A 16-bit uuid May is converted to 32-bit UUID format by zero-extending The 16-bit value to 32-bits. An equivalent method was to add the 16-bit UUID value to a zero-valued 32-bit uuid.
Note that the 16-bit UUIDs is compared directly, as May, 32-bit UUIDs or both 128-bit UUID s. If UUIDs of differing sizes is to be compared, the shorter UUID must is converted to the longer UUID fo Rmat before C Omparison.
In Bluetooth, each service and service attribute is uniquely validated by the globally unique identifier (UUID). As its name implies, each of these identifiers is guaranteed to be unique in time and space.
The UUID class can be represented as short-shaped (16 or 32-bit) and long-shaped (128-bit) uuid.
The UUID value is fixed in a range, and the first value of the range is called the Bluetooth UUID cardinality (BLUETOOTH_BASE_UUID) with a value of 00000000-0000-1000-8000-00805F9B34FB. In this range, the UUID is represented by a 16-bit or 32-bit binary number, often referred to as a 16-bit or 32-bit UUID. Its actual value represents a 128-digit number.
The conversion relationship between the 128-bit UUID value and the 16-bit or 32-bit UUID value is as follows:
128_bit_value=16_bit_value*2^96+bluetooth_base_uuid
128_bit_value=32_bit_value*2^96+biuetooth_base_uuid
A 16-bit UUID can be converted to 32-bit UUID by extending 16 0. If the number of two UUID values is the same, you can directly compare, if the number of bits is different, you need to follow the above relationship, the short UUID is converted to the growth UUID, the same number of digits before comparison.