Comprehensive BLE training

BLE UUIDs: 16-bit, 32-bit, 128-bit and Custom Services

Know standard and proprietary UUIDs, use Battery and Device Information services and design regular UUID128 for your product.

Contents
Real photo of ESP32 board with ESP-WROOM-32 module; Example of BLE compatible hardware.
Real photo of ESP32 board with ESP-WROOM-32 module; Example of BLE compatible hardware. Photo: Ubahnverleih; Wikimedia Commons resource; CC0. The content of the photo has not changed; A Wikimedia preview image is used. This is not a documentary photo of the LCENJ experiment.
Step 10 of 20 ways to master BLE

UUID is the identifier of the Service, Characteristic or Descriptor type. The standard short UUID is assigned by the Bluetooth SIG, and for product-specific functionality you should use the generated and documented UUID128.

UUID16, UUID32 and UUID128

UUID16 fits into the Bluetooth Base UUID and is compact for standard types. UUID32 is less common. UUID128 provides a large space for a unique identifier. The textual representation of a UUID is not the same as the over-the-air byte order; Pay attention to Endianness when capturing.

Standard services

Battery Service, Device Information, Heart Rate and Environmental Sensing have defined contracts and allow better compatibility with tools. If your requirement matches the standard, use the same and implement the data type, unit and interval according to the specification.

When to create a dedicated service?

If the product data or operation does not fit into the standard service, generate a random UUID128 for the Service and separate UUIDs for the Characteristics. Generate the UUID with standard tools to reduce the chance of identifier collisions; The UUID is visible and its unguessability is not a security mechanism. Keep the table of UUID, Property, Permission, Value format and protocol version in project documentation.

Copyability of the contract

Changing the length or meaning of Value can break the old program. Put a protocol version characteristic or Version field in Payload. For an incompatible change, define a new UUID or a new Major version and support the previous version for a certain period of time.

UUID scheme for environmental sensor

Create a UUID128 for the Service. Then generate separate UUIDs for Temperature, Humidity, Sample Interval and Protocol Version. In the design table, specify that the temperature is int16 with a scale of 0.01 degrees and the order is Little Endian. This table will be the reference of Firmware and Application.

Short UUID, full UUID and security are three separate issues

Battery Service: 0x180F
Full UUID: 0000180f-0000-1000-8000-00805f9b34fb
Battery Level: 0x2A19, uint8 percentage

16-bit and 32-bit UUIDs are located in the Bluetooth SIG allocation space; For proprietary data, choose a unique 128-bit UUID. A random UUID is a way to reduce the chance of ID collisions and does not play the role of a password. Knowing or guessing the UUID should not allow reading private data or executing commands.

For consistency, the contract table should include UUID, Properties, Permissions, Length, Unit, Byte Order, and Version. Changing the meaning of the data while keeping the UUID constant may cause the old program to misinterpret; Design contract migration and service cache explicitly.

Question and answer article

Ask your technical question

Questions and answers are published after moderation. Authors can see their own pending drafts.

No confirmed questions have been registered for this article yet.