This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do you add more than 1 custom UUID?

Hi Nordic DevTeam,

So I already followed this tutorial on how to add custom service UUID.

https://github.com/NordicPlayground/nRF5x-custom-ble-service-tutorial

I have 3 services that I want to add DFU, NUS and Custom, and probably more Custom UUID later.

I kept getting error 12 (NRF_ERROR_DATA_SIZE) on the ble_advertising_init() even though I already updated the #define NRF_SDH_BLE_VS_UUID_COUNT 3 (I assume it's 3 because DFU, NUS and Custom?)

Here's my code :

static ble_uuid_t m_adv_uuids[]          =                                          /**< Universally unique service identifier. */
{
    {BLE_UUID_NUS_SERVICE, NUS_SERVICE_UUID_TYPE},
    {CUSTOM_SERVICE_UUID, BLE_UUID_TYPE_VENDOR_BEGIN}
};

...
...
...

/**@brief Function for initializing services that will be used by the application.
 */
static void services_init(void)
{
    uint32_t           err_code;
    ble_nus_init_t     nus_init;
    nrf_ble_qwr_init_t qwr_init = {0};
    ble_cus_init_t     cus_init;

    // Initialize Queued Write Module.
    qwr_init.error_handler = nrf_qwr_error_handler;

    err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
    APP_ERROR_CHECK(err_code);

    // Initialize NUS.
    memset(&nus_init, 0, sizeof(nus_init));

    nus_init.data_handler = nus_data_handler;

    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);

    // Initialise CUS Service init structure to zero.
    memset(&cus_init, 0, sizeof(cus_init));

    err_code = ble_cus_init(&m_cus, &cus_init);
    APP_ERROR_CHECK(err_code);

    // BEGIN Block Added for DFU
    // ONLY ADD THIS BLOCK TO THE EXISTING FUNCTION
    // Initialize the DFU service
    ble_dfu_buttonless_init_t dfus_init =
    {
      .evt_handler = ble_dfu_buttonless_evt_handler
    };

    err_code = ble_dfu_buttonless_init(&dfus_init);
    APP_ERROR_CHECK(err_code);
    // END Block Added for DFU


}

....
....
....

/**@brief Function for initializing the Advertising functionality.
 */
static void advertising_init(void)
{
    uint32_t               err_code;
    ble_advertising_init_t init;

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

    init.advdata.name_type          = BLE_ADVDATA_FULL_NAME;
    init.advdata.include_appearance = true;
    init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;// BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
    init.srdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    init.srdata.uuids_complete.p_uuids  = m_adv_uuids;

    advertising_config_get(&init.config);

    init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&m_advertising, &init);
    NRF_LOG_INFO("%d", err_code);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
}

What's wrong with my initialisation bit?

Parents Reply
  • Hello,

    coyodha said:
    I already adjusted the RAM when the debug terminal asks too, but I still get this message

    I see. What is the size of your advertising data? What is the total byte size you are trying to put into the scan response?
    From the included code snippet I am only able to see that you intend to advertise with the full name, and that you are placing the uuid's in the scan reponse - but I am unable to see the size of the name or uuids.
    Try removing one or two of the UUID's from the scan response for instance, does this negate the error? If so, it very likely stems from the advertising data being too big.
    If this is the case, you can evaluate if you need to advertise all uuid's, or if there is anything else you can cut down on to get within the size limit of the advertising data.

    ERROR 12 [NRF_ERROR_DATA_SIZE] at C:\...\ble_app_libUARTE_dfu\main.c:1984

    Just to make sure, could you confirm which function is being called on line 1984 of your main.c program?
    There is no way for me to check this myself, unfortunately.

    Looking forward to resolving this issue together!

    Best regards,
    Karl

Children
  • Hi Karl,

    You are right, the problem is the size of the advertising data.

    When I just have the NUS service, the program doesn't execute that error.

    Now, I am trying to make sense of what to put in. What's the difference between advertising data and scan response?

    /**@brief Function for initializing the Advertising functionality.
     */
    static void advertising_init(void)
    {
        uint32_t               err_code;
        ble_advertising_init_t init;
    
        memset(&init, 0, sizeof(init));
    
    
        init.advdata.name_type          = BLE_ADVDATA_SHORT_NAME;
        init.advdata.short_name_len     = 3; // Advertise only first 3 letters of name
        init.advdata.include_appearance = true;
        init.advdata.flags              = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;// BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE;
        
        init.advdata.uuids_complete.uuid_cnt = 1;
        init.advdata.uuids_complete.p_uuids  = &m_adv_uuids[0];
    
        init.srdata.uuids_more_available.uuid_cnt = 1;
        init.srdata.uuids_more_available.p_uuids = &m_adv_uuids[1];
    
        init.config.ble_adv_fast_enabled = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
    
        advertising_config_get(&init.config);
    
        init.evt_handler = on_adv_evt;
    
        err_code = ble_advertising_init(&m_advertising, &init);
        APP_ERROR_CHECK(err_code);
    
        ble_advertising_conn_cfg_tag_set(&m_advertising, APP_BLE_CONN_CFG_TAG);
    }

    The code above works in my case, but I am actually not sure what I am doing. I can see all the UUID Service in nRF Connect. 

    How's the structure for advertising data and scan response?

Related