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

Meaning of error codes

I have modified the template's code so ble_advertising_init should setup manufacturer data, once I have this assignment:

advdata.p_manuf_specific_data = &manuf_data;

then a call to ble_advertising_init fails with error code 0x0000000C but the documentation for that function doesn't say anything about that error, how do I figure out what 0x0C means in this case? I suspect I will have a lot cases like this when the doc is silent about the error so would be good to have really reliable way to find the meaning for the errors.

Below is my function which will fail if the above line is present, if it is commented out then the function returns NRF_SUCCESS

static void advertising_init(void)
{
    uint32_t               err_code;
    ble_advdata_t          advdata;
    ble_adv_modes_config_t options;

    // Build advertising data struct to pass into @ref ble_advertising_init.
    memset(&advdata, 0, sizeof(advdata));

    // *** Manufacturer Data *******	
	  ble_advdata_manuf_data_t        manuf_data; // Variable to hold manufacturer specific data
	  memset(&manuf_data, 0, sizeof(manuf_data));
    #define MyData                   "SomeData!" // Our data to adverise
    manuf_data.company_identifier       = 0x0059; // Nordics company ID
    manuf_data.data.p_data              = (uint8_t *)MyData;     
    manuf_data.data.size                = strlen(MyData);
    // *** Manufcaturer Data ***

    advdata.name_type               = BLE_ADVDATA_SHORT_NAME;
		advdata.p_manuf_specific_data = &manuf_data;
		advdata.short_name_len = 6;
    advdata.include_appearance      = true;
    advdata.flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
    advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]);
    advdata.uuids_complete.p_uuids  = m_adv_uuids;

    memset(&options, 0, sizeof(options));
    options.ble_adv_fast_enabled  = true;
    options.ble_adv_fast_interval = APP_ADV_INTERVAL;
    options.ble_adv_fast_timeout  = APP_ADV_TIMEOUT_IN_SECONDS;

    err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL);
		
    APP_ERROR_CHECK(err_code);
}

I looked into the Keil's debugger to observe what manuf_data.data contain in size and p_data and the values there seem correct to me: the size = 9 the pointers points to a string SomeData!

  • You probably need to step inside that function. Most likely ble_advdata_set() returns error and it is

    NRF_ERROR_DATA_SIZE                   (NRF_ERROR_BASE_NUM + 12) ///< Data size exceeds limit
    

    in nrf_error.h, your manuf_data is too big, check size of your advertising packet, what is included in it and how much adata you can add as manuf_data

  • Thank you Alex, you are right, I debugged the function and saw that NRF_ERROR_DATA_SIZE is indeed returned but it was returned from within name_encode rather than from manuf_specific_data_encode, so, in fact it could not encode the Name because Manufacturer Specific Data was long but what is interesting is that shortening the name didn't help at all - I was only able to get rid of the error by shortening the Manufacturer Data OR setting advdata.include_appearance to false.

    Is this expected? I assumed that it should not matter whether I reduce the Name or Manufacturer data as long as total of my advertising data fits into 31 bytes.

  • I figured out why my attempt to shorten the DEVICE_NAME didn't help at that time - that is because I specified name_type as BLE_ADVDATA_SHORT_NAME and short_name_len was already small enough which resulted in the name shorter than even my shortened full name that is why I didn't see a difference. Once I replaced BLE_ADVDATA_FULL_NAME with BLE_ADVDATA_SHORT_NAME - then I can confirm that I was able to reduce Adv Packet Size by reducing DEVICE_NAME or Manufacturer Data.

Related