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

  • Dear AndreasF,

    Thanks for the reply.
    I referred to the following Web page that you taught.
    https://github.com/bjornspockeli/custom_ble_service_example

    In addition, I referred to the following Web page and "nAN - 36 Application Note v1.1".
    https://devzone.nordicsemi.com/f/nordic-q-a/964/a-question-about-function-sd_ble_uuid_vs_add/4595#4595
    https://www.nordicsemi.com/eng/content/download/34055/573345/file/nAN-36.zip

    As a result, I've understood the following.

    1) I can generate a base UUID using Online webpage generater(ex. https://www.uuidgenerator.net/) or nRFgo Studio.
    2) The Online webpage generater generats full 128bits UUID. However nRFgo Studio generats not full 128bits UUID.

    Please refer the following image. This is example view of nRFgo Studio.

    The all 3rd and 4th two bytes is indicated as "XX".
    This means the 3rd and 4th bytes are exchanged another 16bit service UUID.
    This fact can also be read from the tutorial you recommended

    *In my first question, 13th and 14th is the same as 3rd and 4th if reverse the order of UUIDs.

    Based on the above understanding, if we want to change the base UUID of app_uart and app_uart_c to our unique UUID, we can simply change the 128 bit UUID embedded in ble_nus.c and ble_nus_c.h to another private base generated by nRFgo Studio.

    If there is a misunderstanding in the above, I hope you can fix it.

    Best Regards,
    Yasuhiro Senoo

  • hello,i want to change uuid of ibeacon using nus service ,please suggest how to do that ?...thanks.

  • Hi Yasuhiro.

    I've been out of office this week, so sorry for late reply.

    senoo said:

    Note that this Application Note is old and created for the nRF51822, not nRF52832, so there are differences in SDK, SoftDevice, and API.

     

    senoo said:
    1) I can generate a base UUID using Online webpage generater(ex. https://www.uuidgenerator.net/) or nRFgo Studio.

     Yes, I do however recommend that you use the online generator (www.uuidgenerator.net) instead of nRFgo Studio, as it is old and not updated for new devices.

     

    senoo said:
    Based on the above understanding, if we want to change the base UUID of app_uart and app_uart_c to our unique UUID, we can simply change the 128 bit UUID embedded in ble_nus.c and ble_nus_c.h to another private base generated by nRFgo Studio.

     Yes, but as I said above, use for example www.uuidgenerator.net to generate the UUID.

     

     - Andreas

  • Hi.

    Could you please create a new ticket for this question?

    Thanks.

    - Andreas

Reply Children
No Data
Related