How do I add 2nd base UUID for Service and Characteristic?

Hello, i try to get a service with base_uuid1 and to this service a characteristic with the base_uuid2. I am trying to implement BLE MIDI, the BLE_MIDI Specs:

  1. BLE Service and Characteristics Definitions The following service and characteristic are defined:
  • MIDI Service (UUID: 03B80E5A-EDE8-4B33-A751-6CE34EC4C700)
  • MIDI Data I/O Characteristic (UUID: 7772E5DB-3868-4112-A1A9-F2669D106BF3)

I did the tutorials and created my service ID like the MIDI SERVICE UUID from the specs. The Characteristic tutorial just let me add a custom 16bit UUID but i need to change the complete base_uuid. But when i am changing the base_uuid in the our_service.c the nrf52 DK is not advertising anymore and all four leds light up.

This is from the our_service.h

// FROM_SERVICE_TUTORIAL: Defining 16-bit service and 128-bit base UUIDs
#define BLE_UUID_OUR_BASE_UUID              {{0x00, 0xC7, 0xC4, 0x4E, 0xE3, 0x6C, 0x51, 0xA7, 0x33, 0x4B, 0xE8, 0xED, 0x5A, 0x0E, 0xB8, 0x03}} // 128-bit base UUID
#define BLE_UUID_OUR_SERVICE_UUID                0x0E5A // Just a random, but recognizable value

// ALREADY_DONE_FOR_YOU: Defining 16-bit characteristic UUID
#define BLE_UUID_OUR_BASE_CHAR_UUID              {{0xF3, 0x6B, 0x10, 0x9D, 0x66, 0xF2, 0xA9, 0xA1, 0x12, 0x41, 0x68, 0x38, 0xDB, 0xE5, 0x72, 0x77}} // 128-bit base UUID

from the our_service.h

static uint32_t our_char_add(ble_os_t * p_our_service)
    uint32_t   err_code = 0; // Variable to hold return codes from library and softdevice functions
    // OUR_JOB: Step 2.A, Add a custom characteristic UUID
    ble_uuid_t          char_uuid;
    ble_uuid128_t       base_uuid = BLE_UUID_OUR_BASE_CHAR_UUID;
    char_uuid.uuid      = BLE_UUID_OUR_CHARACTERISTC_UUID;

	sd_ble_uuid_vs_add(&base_uuid, &char_uuid.type);


err_code = sd_ble_gatts_characteristic_add(p_our_service->service_handle,


And i Didint do anything to the our_service_init().

I hope someone can help my i am a little confused and new working with the nrf. Thank you. I probably forgot the most things so please ask.

  • You need to call sd_ble_uuid_vs_add as many times as your custom UUID base number. Store ID of each base (it's index in virtual table of 128-bit UUID bases inside Soft Device) and use it to construct as many 128-bit UUIDs as you want.

  • I called sd_ble_uuid_vs_add twice, one time in the our_service_init with the base_uuid for the service and the second time in the our_char_add() with the base_uuid for the characteristics.

  • Sorry I saw it only once in your code snippet. So the purpose of the question is what? You expect someone debugging your code? On Nordic stack (Soft Device) all UUIDs are in fact 128-bit and interpreted as 16-bit short UUID + 128-bit UUID base index. By default only BT SIG 128-bit UUID is having valid index inside Soft Device (after enabling it) so any further base you need to provision. When you call sd_ble_uuid_vs_add function you supply pointer to "type" which is then filled by SoftDevice by new valid "index" (unless function returns error status which you should definitely check). Then simply use this new index when creating new complete UUIDs and all works.

  • i just dont get it why the second time i am using sd_ble_uuid_vd_add the program crashes. it works fine when i use the same base_uuid for the service and the characteristic. but when i change one its not working

  • All good found my problem.

    To use two or more vendor specific UUIDs you will need to define how many such UUIDs you need. In the typical SDK example (and in the tutorial code) you do this in the function ble_stack_init() found in main.c. Add the line

    ble_enable_params.common_enable_params.vs_uuid_count = 2;

    and you should be able to use two vs UUIDs.