how to choose an UUID?
发布于 8 个月前 作者 rolandash 263 次浏览 来自 分享

there are three types of UUID usages, 16-bit, 32-bit and 128-bit.

16-bit is generally used for standard services/characteristic/descriptors that have been defined by BLE SIG.,

BLE SIG does not make it ‘illegal’ to use a 16-bit UUID for custom attributes, but it does recommend that for custom services, you should use 128-bit UUID which does not match the base 128-bit UUID of BLE SIG.


  1. Custom Services, characteristics or descriptors (let us call them SCD) should never be 16-bit or 32-bit UUID.

  2. Custom SCD can only be 128-bit UUID. Though there is no strict rule written about this in BLE spec, but that is what is STRONGLY preferred.

  3. Ensure your 128-bit UUID is not the base BLE UUID (00000000-0000-1000-8000-00805F9B34FB)

  4. The 16-bit or 32-bit UUID are converted to 128-bit UUID by changing the first 4 bytes of the base UUID.

For example, 0x2018 is represented as 00002018-0000-1000-8000-00805F9B34FB. So changing only the first 4 bytes of the base UUID does not mean that you are not clashing with the existing 16 or 32-bit UUID.

Ensure that you have some change in the rest of the bytes of base UUID.

Unfortunately, BLE spec does not tell how to create 128-bit UUIDs for custom SCD. Also, there is no registration that can be done for a custom 128-bit UUID, so you can never know if the one you choose is unique or not.

I suggest something like this:

Take the base UUID and mask out all the bytes except the first 4 bytes:


Change the last 4 bytes (0x34FB in base UUID) to your company’s ID.

Define all your custom SCD by changing values in XXXXYYYY. You can make such changes in the middle bytes too.