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

Modify the base UUID of the NUS sample

Please tell me how to modify the base UUID of the NUS sample application (app_uart / app_uart_c).

SoC: nRF52832     SDK: nRF5_SDK_14.0.0

<My background>
I am developing BLE software with reference to app_uart/app_uart_c.
In this development, I'd like to modify base UUID of NUS.
Because the NUS service is widely used, there is a risk of interference.

The easiest way to do this is to change the value of NUS_BASE_UUID in the following source code to a different value.

nRF5_SDK_14.0.0_3bcc1f7\components\ble\ble_services\ble_nus\ble_nus.c
#define NUS_BASE_UUID                  {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor specific UUID. */

nRF5_SDK_14.0.0_3bcc1f7\components\ble\ble_services\ble_nus_c\ble_nus_c.h
#define NUS_BASE_UUID                   {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor specific UUID. */

However, the 13th and 14th values of the above UUID are zero, and it looks like a special UUID value that can not be generated by a generic UUID generator.
The result of I generated a UUID on the following Web page, the 13th and 14th were the following values which were not zero.

https://www.uuidgenerator.net/
The Generated sample UUID is e77840e0-e1b5-4c70-a4c4-7ff5c647ec37.


<My question>
Is it the right way to rewrite the base UUID of NUS using the UUID whose 13th and 14th are not zero like the above?
If not, please tell me the correct way to change NUS 's UUID

Parents
  • Hi.

    There is a tutorial which explains how you can create a custom base UUID here.

    Under Step 2, you find the follow explanation:

    Next, we're going to need a 128-bit UUID for our custom service since we're not going to implement our service with one of the 16-bit Bluetooth SIG UUIDs that are reserved for standardized profiles. There are several ways to generate a 128-bit UUID, but we'll use this Online UUID generator. The webpage will generate a random 128-bit UUID, which in my case was

    f364adc9-b000-4042-ba50-05ca45bf8abc

    The UUID is given as the sixteen octets of a UUID are represented as 32 hexadecimal (base 16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12. The 16 octets are given in big-endian, while we use the small-endian representation in our SDK. Thus, we must reverse the byte-ordering when we define our UUID base in the ble_cus.h, as shown below.

    /* This code belongs in ble_cus.h*/
    #define CUSTOM_SERVICE_UUID_BASE         {0xBC, 0x8A, 0xBF, 0x45, 0xCA, 0x05, 0x50, 0xBA, \
                                              0x40, 0x42, 0xB0, 0x00, 0xC9, 0xAD, 0x64, 0xF3}

     

    __________________________________________________________________________________________

    Now, you have generated a sample UUID: e77840e0-e1b5-4c70-a4c4-7ff5c647ec37.

    Doing what the tutorial proposes, gives you the following custom base UUID:

    0x37, 0xEC, 0x47, 0xC6, 0xF5, 0x7F, 0xC4, 0xA4, 0x70, 0x4C, 0xB5, 0xE1, 0xE0, 0x40, 0x78, 0xE7

    Is it the right way to rewrite the base UUID of NUS using the UUID whose 13th and 14th are not zero like the above?

    I'm not sure I completely understood this question, you should do as the tutorial above explained.

    Hope this helps.

    - Andreas

Reply
  • Hi.

    There is a tutorial which explains how you can create a custom base UUID here.

    Under Step 2, you find the follow explanation:

    Next, we're going to need a 128-bit UUID for our custom service since we're not going to implement our service with one of the 16-bit Bluetooth SIG UUIDs that are reserved for standardized profiles. There are several ways to generate a 128-bit UUID, but we'll use this Online UUID generator. The webpage will generate a random 128-bit UUID, which in my case was

    f364adc9-b000-4042-ba50-05ca45bf8abc

    The UUID is given as the sixteen octets of a UUID are represented as 32 hexadecimal (base 16) digits, displayed in five groups separated by hyphens, in the form 8-4-4-4-12. The 16 octets are given in big-endian, while we use the small-endian representation in our SDK. Thus, we must reverse the byte-ordering when we define our UUID base in the ble_cus.h, as shown below.

    /* This code belongs in ble_cus.h*/
    #define CUSTOM_SERVICE_UUID_BASE         {0xBC, 0x8A, 0xBF, 0x45, 0xCA, 0x05, 0x50, 0xBA, \
                                              0x40, 0x42, 0xB0, 0x00, 0xC9, 0xAD, 0x64, 0xF3}

     

    __________________________________________________________________________________________

    Now, you have generated a sample UUID: e77840e0-e1b5-4c70-a4c4-7ff5c647ec37.

    Doing what the tutorial proposes, gives you the following custom base UUID:

    0x37, 0xEC, 0x47, 0xC6, 0xF5, 0x7F, 0xC4, 0xA4, 0x70, 0x4C, 0xB5, 0xE1, 0xE0, 0x40, 0x78, 0xE7

    Is it the right way to rewrite the base UUID of NUS using the UUID whose 13th and 14th are not zero like the above?

    I'm not sure I completely understood this question, you should do as the tutorial above explained.

    Hope this helps.

    - Andreas

Children
Related