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

How can I change characteristic(service,Rx,Tx) UUID ?

Hi, Nordic!

I wanna know how change characteristic(service,Rx,Tx) UUIDs .

For example, 

Proximity UUID :  01020304-0506-0708-0910-111213141516

Service UUID :  01020304-0506-0708-0910-AABBCCDDEEFF

Rx Characteristc UUID :  01020305-0506-0708-0910-AABBCCDDEEFF

Tx Characteristc UUID :  01020306-0506-0708-0910-AABBCCDDEEFF

I succeeded in changing the 0305,0306,0307 part. However, I did not change the AABBCCDDEEFF part.

Please ask for help on this issue. 

Thank you.

Below is the code I modified.

static uint32_t rx_char_add(ble_nus_t * p_nus, const ble_nus_init_t * p_nus_init)
{
/**@snippet [Adding proprietary characteristic to S110 SoftDevice] */
ble_gatts_char_md_t char_md;
ble_gatts_attr_md_t cccd_md;
ble_gatts_attr_t attr_char_value;
ble_uuid_t ble_uuid;
ble_gatts_attr_md_t attr_md;

memset(&cccd_md, 0, sizeof(cccd_md));

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&cccd_md.write_perm);

cccd_md.vloc = BLE_GATTS_VLOC_STACK;

memset(&char_md, 0, sizeof(char_md));

char_md.char_props.notify = 1;
char_md.p_char_user_desc = NULL;
char_md.p_char_pf = NULL;
char_md.p_user_desc_md = NULL;
char_md.p_cccd_md = &cccd_md;
char_md.p_sccd_md = NULL;

ble_uuid.type = p_nus->uuid_type;
ble_uuid.uuid = BLE_UUID_NUS_RX_CHARACTERISTIC;

memset(&attr_md, 0, sizeof(attr_md));

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&attr_md.write_perm);

attr_md.vloc = BLE_GATTS_VLOC_STACK;
attr_md.rd_auth = 0;
attr_md.wr_auth = 0;
attr_md.vlen = 1;

memset(&attr_char_value, 0, sizeof(attr_char_value));

attr_char_value.p_uuid = &ble_uuid;
attr_char_value.p_attr_md = &attr_md;
attr_char_value.init_len = sizeof(uint8_t);
attr_char_value.init_offs = 0;
attr_char_value.max_len = BLE_NUS_MAX_RX_CHAR_LEN;
/////////////////////////////////////////////////////////////////////

ble_uuid_t char_uuid;
ble_uuid128_t base_uuid = NUS_BASE_UUID;

BLE_UUID_BLE_ASSIGN(char_uuid, 0xda40);

base_uuid.uuid128[0]=0x17;
base_uuid.uuid128[1]=0x53;
base_uuid.uuid128[2]=0x08;
base_uuid.uuid128[3]=0x19;
base_uuid.uuid128[4]=0xfc;
base_uuid.uuid128[5]=0x1a;
char_uuid.type = p_nus->uuid_type;
//ble_uuid.uuid = BLE_UUID_NUS_SERVICE;
char_uuid.uuid = 0xda40;
uint32_t err_code;
err_code =sd_ble_uuid_vs_add(&base_uuid, &char_uuid.type);
app_uart_put(err_code);

/////////////////////////////////////////////////////////////////////

return sd_ble_gatts_characteristic_add(p_nus->service_handle,
&char_md,
&attr_char_value,
&p_nus->rx_handles);
/**@snippet [Adding proprietary characteristic to S110 SoftDevice] */
}



Parents
  • sd_ble_uuid_vs_add(&base_uuid, &char_uuid.type) return 0x04. 

    Below is ble stack initial function.

    #define CENTRAL_LINK_COUNT              0                   
    #define PERIPHERAL_LINK_COUNT           1                   
    
    static void ble_stack_init(void)
    {
        uint32_t err_code;
    
        nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
        // Initialize SoftDevice.
        SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
        ble_enable_params_t ble_enable_params;
        err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                        PERIPHERAL_LINK_COUNT,
                                                        &ble_enable_params);
        APP_ERROR_CHECK(err_code);
    
        //Check the ram settings against the used number of links
        CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    
        // Enable BLE stack.
    #if (NRF_SD_BLE_API_VERSION == 3)
        ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_MAX_MTU_SIZE;
    #endif
        err_code = softdevice_enable(&ble_enable_params);
        APP_ERROR_CHECK(err_code);
    
        // Subscribe for BLE events.
        err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
        APP_ERROR_CHECK(err_code);
    }

  • Hi,

    0x4 corresponds to NRF_ERROR_NO_MEM (defined in nrf_error.h), which means that the softdevice does not have enough buffer space to store the 128-bit UUID base.  Increasing NRF_SDH_BLE_VS_UUID_COUNT in sdk_config.h should fix this. 

    Best regards,

    Vidar

  • Thank you for your answer!

    Didn't I have to change PHERIPHERAL_LINK_COUNT?

  • PHERIPHERAL_LINK_COUNT defines the number of concurrent peripheral links you can have. So is not related to the error you got. 

Reply Children
No Data
Related