A UUID is a Universally Unique Identifier. For BLE devices, the 128 bit UUID represents a specific profile, service or data type. It is guaranteed to be unique across all space and all time according to the Bluetooth 4.2 spec. Each UUID is a 128 bit value. Some examples are:
bfe4eb26-77a9-425e-ac27-c02b152741c2
281c48cb-551e-410c-be37-352b483fc115
9eca9f04-a8d1-4770-ba19-f0295d8a052a
d2926324-345a-4031-a64e-339bc63de080
7e9ba0b7-8075-41da-9baf-b2c616590a31
You will see that the UUID is divided up into sections with a hyphen. the hyphen is not part of the UUID – it is used to make them a little more readable for humans. Hyphens in a UUID are generally ignored by software.
A range of UUIDs is defined by the Bluetooth SIG. These are all formed from the BluetoothBaseUUID of00000000-0000-1000-8000-00805F9B34FB
The second half of the first section (00000000-
) represents a 16 bit number that can be used as a shorthand for a reserved, pre-defined UUID. That allows you to write only the shorthand portion rather than the full UUID value. If your application can use one of these pre-defines UUIDs then it will save some typing at least. If you come across mention of a BLE UUID and it only has four digits, it is a 16-bit UUID and should be interpreted as part of an entire 128-bit UUID. For example, the Battery Service UUID may be written 1815
or 0x1815
but the full UUId is actually
00001815-0000-1000-8000-00805F9B34FB
Next, some predefined 16-bit UUIDs are described. After that, there is some information on creating your own 128-bit UUIDs.
Predefined GATT Service UUIDs
Some of the 16 bit identifiers are used to define well-known services. GATT Services are collections of characteristics and relationships to other services that encapsulate the behaviour of part of a device. A list can be found here https://www.bluetooth.com/specifications/gatt/services/. Some examples include (notice that services appear to all be of the form 0x1---
):
Name | Uniform Type Identifier | Assigned Number |
---|---|---|
Generic Access | org.bluetooth.service.generic_access | 0x1800 |
Alert Notification Service | org.bluetooth.service.alert_notification | 0x1811 |
Automation IO | org.bluetooth.service.automation_io | 0x1815 |
Battery Service | org.bluetooth.service.battery_service | 0x180F |
Binary Sensor | GATT Service UUID | 0x183B |
Current Time Service | org.bluetooth.service.current_time | 0x1805 |
Device Information | org.bluetooth.service.device_information | 0x180A |
Emergency Configuration | GATT Service UUID | 0x183C |
Environmental Sensing | org.bluetooth.service.environmental_sensing | 0x181A |
Generic Attribute | org.bluetooth.service.generic_attribute | 0x1801 |
Human Interface Device | org.bluetooth.service.human_interface_device | 0x1812 |
Immediate Alert | org.bluetooth.service.immediate_alert | 0x1802 |
Indoor Positioning | org.bluetooth.service.indoor_positioning | 0x1821 |
Link Loss | org.bluetooth.service.link_loss | 0x1803 |
Location and Navigation | org.bluetooth.service.location_and_navigation | 0x1819 |
Object Transfer Service | org.bluetooth.service.object_transfer | 0x1825 |
Transport Discovery | org.bluetooth.service.transport_discovery | 0x1824 |
Tx Power | org.bluetooth.service.tx_power | 0x1804 |
User Data | org.bluetooth.service.user_data | 0x181C |
Predefined Characteristic UUIDs
Characteristics are defined attribute types that contain a single logical value. There are a large number of predefined characteristics in the standard. You can find a list at https://www.bluetooth.com/specifications/gatt/characteristics/. (notice that characteristics appear to all be of the form 0x2---
)
Name | Uniform Type Identifier | Assigned Number |
---|---|---|
Alert Category ID | org.bluetooth.characteristic.alert_category_id | 0x2A43 |
Alert Level | org.bluetooth.characteristic.alert_level | 0x2A06 |
Alert Status | org.bluetooth.characteristic.alert_status | 0x2A3F |
Altitude | org.bluetooth.characteristic.altitude | 0x2AB3 |
Analog | org.bluetooth.characteristic.analog | 0x2A58 |
Analog Output | org.bluetooth.characteristic.analog_output | 0x2A59 |
Battery Level | org.bluetooth.characteristic.battery_level | 0x2A19 |
Current Time | org.bluetooth.characteristic.current_time | 0x2A2B |
Digital | org.bluetooth.characteristic.digital | 0x2A56 |
Digital Output | org.bluetooth.characteristic.digital_output | 0x2A57 |
Firmware Revision String | org.bluetooth.characteristic.firmware_revision_string | 0x2A26 |
First Name | org.bluetooth.characteristic.first_name | 0x2A8A |
Device Name | org.bluetooth.characteristic.gap.device_name | 0x2A00 |
Reconnection Address | org.bluetooth.characteristic.gap.reconnection_address | 0x2A03 |
Service Changed | org.bluetooth.characteristic.gatt.service_changed | 0x2A05 |
Hardware Revision String | org.bluetooth.characteristic.hardware_revision_string | 0x2A27 |
Humidity | org.bluetooth.characteristic.humidity | 0x2A6F |
Last Name | org.bluetooth.characteristic.last_name | 0x2A90 |
Latitude | org.bluetooth.characteristic.latitude | 0x2AAE |
Longitude | org.bluetooth.characteristic.Longitude | 0x2AAF |
Manufacturer Name String | org.bluetooth.characteristic.manufacturer_name_string | 0x2A29 |
Measurement Interval | org.bluetooth.characteristic.measurement_interval | 0x2A21 |
Model Number String | org.bluetooth.characteristic.model_number_string | 0x2A24 |
Pressure | org.bluetooth.characteristic.pressure | 0x2A6D |
Rainfall | org.bluetooth.characteristic.rainfall | 0x2A78 |
Serial Number String | org.bluetooth.characteristic.serial_number_string | 0x2A25 |
Service Required | org.bluetooth.characteristic.service_required | 0x2A3B |
Software Revision String | org.bluetooth.characteristic.software_revision_string | 0x2A28 |
String | org.bluetooth.characteristic.string | 0x2A3D |
System ID | org.bluetooth.characteristic.system_id | 0x2A23 |
Temperature | org.bluetooth.characteristic.temperature | 0x2A6E |
Temperature Celsius | org.bluetooth.characteristic.temperature_celsius | 0x2A1F |
Temperature Fahrenheit | org.bluetooth.characteristic.temperature_fahrenheit | 0x2A20 |
Time Broadcast | org.bluetooth.characteristic.time_broadcast | 0x2A15 |
User Defined UUIDs
If you want to create your own custom services, then you will need to create your own UUIDs. So long as the UUID that you create does not end in the BluetoothBaseUUID value, you are free to pick anything you like. The available range of values is so large that there is almost zero chance (about 1 in 10^39) of accidentally duplicating an existing value. there are online generators for this. Version 1 UUIDs are based on the time and your computer’s mac address and version 4 UUIDs are based on a 128 bit random number generator. Try https://www.guidgenerator.com/online-guid-generator.aspx or https://www.uuidgenerator.net/.
If you want to use a number of related services and characteristics, you might want to generate a base UUID and then use the upper four bytes to distinguish them For example, if you generated this UUID 5fb76959-4786-42e7-bd27-45257b2e988f
then you might zero the upper bytes to get a base UUID of 00000000-4786-42e7-bd27-45257b2e988f
So that your own services and characteristics could be represented there. If it suited your purpose, it might be convenient to use the first two bytes to represent services and the second two bytes to represent characteristics. That would make it easier to see what was related to what. There are no rules for this though. Suppose for example, you had a robot that had a service could report its position and a service that could report its IMU readings. You might conceivably come up with a scheme something like this:
UUID | Purpose |
---|---|
27810000-4786-42e7-bd27-45257b2e988f | Robot position service |
27811701-4786-42e7-bd27-45257b2e988f | Robot position X |
27811702-4786-42e7-bd27-45257b2e988f | Robot position Y |
27811703-4786-42e7-bd27-45257b2e988f | Robot position Z |
27400000-4786-42e7-bd27-45257b2e988f | Robot IMU service |
27404301-4786-42e7-bd27-45257b2e988f | Robot Gyro X |
27404301-4786-42e7-bd27-45257b2e988f | Robot Gyro X |
27404301-4786-42e7-bd27-45257b2e988f | Robot Gyro Z |
Mandatory Identifiers
Every Bluetooth device MUST have a 48 bit identifier. This is equivalent to the MAC address used in ethernet networks. Unlike ethernet, there is no guarantee that these are unique or that they positively identify a device for all time. The mandatory Identifier is used to identify a device during communication exchanges. A device that is restarted may use a different identifier.