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

BLE_UART example and manufacturer specific data issue (sdk15&15.1)

I am new to Nordic and have a simple question. I followed the instructions about setting up manufacturer specific data with BLE_Template example here: https://devzone.nordicsemi.com/tutorials/b/bluetooth-low-energy/posts/ble-advertising-a-beginners-tutorial. It worked fine with the modified advertising_init() function. However, when I tried it with BLE_UART example, it did not work. It seemed to have an error code 0x0000000c. I didn't change anything of the examples, except the advertising_init() function. Can anyone repeat this and explain what might go wrong and how to make it work with BLE_UART example? Thanks.

Parents
  • Hi.

    If you add a breakpoint in the function you find out what the error code means. In this case the error code 0x0000000c is listed in nrf_error.h as NRF_ERROR_DATA_SIZE, which means you have an invalid data size. If you then jump into the function and add a breakpoint inside, you can navigate to the part of the code which triggered the error. I found it to be the if-sentence in line 115 in ble_advdata.c . The error triggered because the variable init.advdata.short_name_len is to large, it cannot be larger than 4 due to the available bytes in the packet, which is 31.

    - Andreas

  • Thanks Andreas. I have set init.advdata.short_name_len to 3 and the DEVICE_NAME to "nor",  data[] to be “S” only with BLE_UART example, still got the same error. Do you know how to make it work with BLE_UART? Thank you for your help.

  • Hi.

    You need to add breakpoints in the function and debug your code and find the place in your code where the code fails. It's quite hard for me to know exactly where your code fails with the information you provide.  When I only changed advertising_init() to the same as the tutorial the code worked. I replaced the code in advertising_init() from the BLE_UART example with the code from BLE_Template example, this code:

    static void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;  // Struct containing advertising parameters
        // Build advertising data struct to pass into @ref ble_advertising_init.
        memset(&init, 0, sizeof(init));
     
        init.advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
        init.advdata.short_name_len          = 4; //Cannot be larger than 4
        init.advdata.include_appearance      = true;
        init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    
        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);
    }

    - Andreas

  • Thanks Andreas. I think I have tried to make it clear how it fails because I modified very little of the original codes from the examples. I need to make the manufacturer specific data to work with BLE-
    UART example. When I replaced the original advertising_init() function with this from tutorial, it failed. It seems it failed at ble_advdata.c around line 422. 

    static void advertising_init(void)
    {
        ret_code_t             err_code;
        ble_advertising_init_t init;  // Struct containing advertising parameters
        // Build advertising data struct to pass into @ref ble_advertising_init.
        memset(&init, 0, sizeof(init));
    
        ble_advdata_manuf_data_t                  manuf_data; //Variable to hold manufacturer specific data
        uint8_t data[]                            = "SomeData!"; //Our data to advertise
        manuf_data.company_identifier             =  0x0059; //Nordics company ID
        manuf_data.data.p_data                    = data;
        manuf_data.data.size                      = sizeof(data);
        init.advdata.p_manuf_specific_data = &manuf_data;
    
        init.advdata.name_type = BLE_ADVDATA_FULL_NAME; // Use a shortened name
        init.advdata.short_name_len = 6; // Advertise only first 6 letters of name
        init.advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
        init.advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
        init.advdata.uuids_complete.p_uuids  = m_adv_uuids;
    
        init.config.ble_adv_fast_enabled  = true;
        init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;
        init.config.ble_adv_fast_timeout  = APP_ADV_DURATION;
    
        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);
    }

    After I tried to minimize the data length by changing  init.advdata.short_name_len to 3 and the DEVICE_NAME to "nor",  data[] to be “S” , it failed at ble_advdata.c around line 115. Sure without manuf_data the code works. Thank you for your help.

  • Hi.

    You still have to much data since you get NRF_ERROR_DATA_SIZE. What do you have inside m_adv_uuids in main.c? Could you perhaps upload the project as a zip file?

    - Andreas

  • It is defined as 

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

    I have uploaded the zip file here. Thanks.

    3817.ble_app_uart.zip

Reply Children
  • Hi.

    I have looked at your code, and you still have to much advertising data. You can have maximum 31 bytes in your advertising data.

    I suggest you put your manufacturer specific data in the scan response data by changing line 620 in your main.c file, this one:

    init.advdata.p_manuf_specific_data = &manuf_data;

    And change that line to this:

    init.srdata.p_manuf_specific_data = &manuf_data;

    That should do the trick and make the code work.

    - Andreas

Related