Please tell me how to set 128bit UUID to "ble_uuid_t" in [Function for adding the Custom Value characteristic].

OS in development environment :Windows10
HARD :(Taiyo Yuden)EBSHSN Series Evaluation Board : Central / Peripherals
CPU :(Nordic) nRF52832 / ARMR Cortex-M4F 32 bit processor 28-pin Land Grid Array / 15GPIOs / SWD
builder :SEGGER Embedded Studio for ARM Release 3.34a Build 2018022300.35192 Windows x64
Copyright 2014-2018 SEGGER Microcontroller GmbH & Co. KG
Copyright 1997-2018 Rowley Associates Ltd.
GCC/BINUTILS: Built using the GNU ARM Embedded Toolchain version 6-2017-q2-update source distribution
Clang/LLVM: Built using the version 5.0.0 source distribution
Soft Ver:nRF5_SDK_15.3.0_59ac345

I thought about it with reference to [Common type and macro definition> Definition], but I think that it will affect related programs if the [p_cus-> uuid_type] part of the 16-bit setting is not performed even with the 128-bit setting.

(For 16bit)
    ble_uuid_t ble_uuid;
    ble_uuid.type = p_cus->uuid_type;
(For 128bit)
    ble_uuid_t ble_uuid;
    ble_uuid.type = BLE_UUID_TYPE_VENDOR_BEGIN;

Please tell me the setting method for 128bit.
Thanking you in advance.

Parents Reply Children
  • Mr. Hung Bui
    I checked [ble_nus.c].
    128bit UUID is set in [NUS_BASE_UUID], but 16bit UUID is set in the communication item UUID. Is there a way to set 128bit UUID for each communication item?
    128bit UUID is set for each item in the communication application on the tablet side.
    ------------------------------------------
    #define BLE_UUID_NUS_TX_CHARACTERISTIC 0x0003 /**< The UUID of the TX Characteristic. */
    #define BLE_UUID_NUS_RX_CHARACTERISTIC 0x0002 /**< The UUID of the RX Characteristic. */
    #define NUS_BASE_UUID {{0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E}} /**< Used vendor specific UUID. */
    -----------------------------------------
    Thanking you in advance.

  • Hi Toshikazu, 

    The way it works in our softdevice is that you add a 128 bits (16 bytes) base UUID into the softdevice and you declare a 16 bits  UUID of the service/characteristic on top of that.

    This 16 bits UUID will be place in byte 12th and 13th in the UUID base and this will create a full 128 bit UUID for the service/characteristic. 

    For example if the base is: 
    0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x00, 0x00, 0x40, 0x6E

    And the TX characteristic has 16 bit UUID 0x0003 . 

    The full UUID of the characteristic will be: 
    0x9E, 0xCA, 0xDC, 0x24, 0x0E, 0xE5, 0xA9, 0xE0, 0x93, 0xF3, 0xA3, 0xB5, 0x03, 0x00, 0x40, 0x6E


    Do you have a requirement that each of your characteristic should have different base UUIDs ? 

    If it's the case you may need to define multiple of them using sd_ble_uuid_vs_add() and then use the correspondent uuid_type for each of the characteristic declaration. 

  • Mr. Hung Bui
    It seems that I was not able to ask the question correctly, so I will ask again

    Please tell me how to set the following conditions and how to communicate.
    [conditions]
    1) Communicate using your own UUID, not the UUID issued by the Bluetooth SIG.
    2) A unique 128-bit UUID is set for each item.
    3) I want to communicate using 19 unique UUIDs (128 bits)
    (Because the existing application is used, it is necessary to create it according to the application)
    Thank you.

  • Hi Toshikazu, 

    I'm sorry that my suggestion was not clear enough. Let me try again. 

    It's possible to add multiple unique 128 bits UUID. You just need to add each of the UUID base using sd_ble_uuid_vs_add() function and  then use the correspondent uuid_type for each of the characteristic/service declaration. 

     For example this code will add 2 services with different UUIDs: 

    ble_uuid128_t nus_base_uuid1 = NUS_BASE_UUID1;
    
    ble_uuid128_t nus_base_uuid2 = NUS_BASE_UUID2;
    
    /**@snippet [Adding proprietary Service to the SoftDevice] */
    // Add a custom base UUID.
    err_code = sd_ble_uuid_vs_add(&nus_base_uuid1, &p_nus1->uuid_type);
    VERIFY_SUCCESS(err_code);
    
    err_code = sd_ble_uuid_vs_add(&nus_base_uuid2, &p_nus2->uuid_type);
    VERIFY_SUCCESS(err_code);
    
    ble_uuid1.type = p_nus1->uuid_type;
    ble_uuid1.uuid = BLE_UUID_NUS_SERVICE1;
    
    ble_uuid2.type = p_nus2->uuid_type;
    ble_uuid2.uuid = BLE_UUID_NUS_SERVICE2;
    
    // Add the service.
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
    &ble_uuid1,
    &p_nus1->service_handle);
    
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
    &ble_uuid2,
    &p_nus2->service_handle);

    In this case, when you call sd_ble_uuid_vs_add() the p_nus1->uuid_type will have value 2 (BLE_UUID_TYPE_VENDOR_BEGIN) and then the second call p_nus2->uuid_type  will have value 3. 
    It's the index of the UUID base in the softdevice. After each call this index will be increased by one. 
    So you will need to add 19 UUID using 19 sd_ble_uuid_vs_add() calls. 

    Please notice the way the base UUID and the 16 bit UUID form the complete 128 bit UUID as I explained earlier. 

    It's quite a large attribute table with 19 different UUIDs. You may need to increase: 
    - NRF_SDH_BLE_VS_UUID_COUNT

    - NRF_SDH_BLE_GATTS_ATTR_TAB_SIZE

    in sdk_config.h

    So that the softdevice can handle this large number of service/characteristics. However please try to test first with a few of them. 

  • Mr. Hung Bui
    I don't know how to set [p_nus1] [p_nus1].
    In the case of [ble_nus.c]
     -Create "m_nus" by "BLE_NUS_DEF (m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT);" in "main.c" of "ble_app_uart".
     -Pass "m_nus" to [ble_nus.c] and change it to [p_nus] for use.
    I don't know the processing content of "BLE_NUS_DEF (m_nus, NRF_SDH_BLE_TOTAL_LINK_COUNT);", so please tell me how to set it.
    Thank you.

Related