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 Children
  • Hi Karl,

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

    <debug> nrf_sdh_ble: RAM starts at 0x20002D68
    <info> app: 12
    <error> app: ERROR 12 [NRF_ERROR_DATA_SIZE] at C:\...\ble_app_libUARTE_dfu\main.c:1984
    PC at: 0x0002F369
    <error> app: End of error report

    I followed all these threads but I still don't quite get it : 

    https://devzone.nordicsemi.com/f/nordic-q-a/59712/error-code-12-in-advertising-tutorial

    https://devzone.nordicsemi.com/f/nordic-q-a/39697/custom-service-proximity-example-merge---error-12-nrf_error_data_size-in-ble-advertising-init

    https://github.com/bjornspockeli/custom_ble_service_example/issues/7

    https://devzone.nordicsemi.com/f/nordic-q-a/52390/understanding-advertisement-of-multiple-128-bit-custom-uuid

    and I referred to this project example 

    /cfs-file/__key/communityserver-discussions-components-files/4/8623.custom_5F00_ble_5F00_service_5F00_example_5F00_multiple_5F00_vs_5F00_bases.zip

    I still have the same problem even putting them separately under like this

     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;
    
    m_adv_uuids_more[0].type = m_cus.uuid_type;
    init.srdata.uuids_more_available.uuid_cnt = sizeof(m_adv_uuids_more)/sizeof(m_adv_uuids_more[0]);
    init.srdata.uuids_more_available.p_uuids = m_adv_uuids_more;
    

  • 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

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

    IME, finding the right memory size is rather hit and miss: there's no guidance - just a matter of trying more until it works!

    Disappointed

  • awneil said:
    IME, finding the right memory size is rather hit and miss: there's no guidance - just a matter of trying more until it works!

    Could you elaborate on what you are referring to here?
    I think the issue with the NRF_ERROR_DATA_SIZE error that coyodha is seeing here might be with the size of the dataset they are trying to advertise.

    When it comes to setting the right RAM start address we've taken some steps in the nrf_sdh_ble.c to make this a little easier by having the debug logging output what you should change the RAM start address to. If you start out by setting the RAM start address unnaturally high before compiling and running it, you'll get the appropriate start address written to the logger, and then you can change it from there. Have you experienced some issues with this?

    I would also argue that calculating the required flash on the one hand is also pretty straight forward, since the size of the SoftDevice is given in its particular specification. On the other hand you will also need to keep control yourself on what else your application uses the flash for.
    There is indeed no guidance for the latter, but it might be helpful to have a look at the device memory layout when working with this, or checking out the FDS / flash storage examples.

    I would love to hear any input or feedback you might have on this, @awneil !

    Best regards,
    Karl

  • Could you elaborate on what you are referring to here?

    I was referring to the RAM required for extra Services & Characteristics.

    And it would have been back in SDK v15, IIRC - so maybe things have improved now?

Related