This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to correctly generate UUIDs-128 for user services and chars.?

I know it was asked and I was searching but I didn't find a clear answer about that. I know that I can generate any random 128bit UUID for all my user services & characteristics. But there are at least 5 algorythms how to generate an UUID according to wiki. I tried to download M$ uudigen.exe and run uuidgen on our linux server and both give me random UUIDs (type 4). But BLE base UUID is type 1 that is less random and it allows to mask first 32b to use them for incremental short UUIDs

Also in one of Nordic examples I can see this: #define LBS_UUID_BASE {0x23, 0xD1, 0xBC, 0xEA, 0x5F, 0x78, 0x23, 0x15, 0xDE, 0xEF, 0x12, 0x12, 0x00, 0x00, 0x00, 0x00} #define LBS_UUID_SERVICE 0x1523 #define LBS_UUID_LED_CHAR 0x1525 #define LBS_UUID_BUTTON_CHAR 0x1524

This base UUID was also masked so four last bytes are zero. I'm not sure about byte order, is it right that 1st byte of APP_UUID_BASE is the last byte of UUID in string format as I see from generator? If it was a random UUID then it become non-random after masking (I can generate many UUIDs that will differ only in last 4 bytes and if I zero them I got same UUID - that are no longer UUIDs).

So I guess that version 1 of UUID algorythm should be used (MAC+time), then some part of UUID remains constant and I can safely mask the part occupied by some low bytes of time, am I right? What program do you reccomend for UUID ver 1 generation? I found this Python script that seems doing it well, so can I then mask the beginninig 32bits and use as my UUID_BASE for entire project just incrementing the first 32b part when need a new service or characteristic?

Parents Reply Children
Related