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

ble_advertising_advdata_update stops device from advertising

Hi Nordic Team,

I am using ble_advertising_advdata_update() to update some of the advertising data. I am doing every time the device is asked to advertise. In my code I do at the event 'BLE_ADV_EVT_FAST' in the advertising events handler. See below my code.

The issue I am facing is when I include the adv_data_update() to the code, the device doesn't advertise. When it's not there, the device advertises. 

Is this expected? Am I doing something wrong?

I am using SDK 17.0.2 and nRF Connect Desktop to see and connect to my device.

Many thanks

/* Code */

1/ advertising events handler

static void on_adv_evt(ble_adv_evt_t ble_adv_evt)
{
  ret_code_t err_code;

  switch (ble_adv_evt)
  {
  case BLE_ADV_EVT_FAST:
  {
    NRF_LOG_INFO("start - advertising.");
    adv_data_update();
    break;
  }
  case BLE_ADV_EVT_IDLE:
  {
    NRF_LOG_INFO("stop - advertising.");
    break;
  }
  default:
    break;
  }
  NRF_LOG_FLUSH();
}

2/ advertising data update function

void adv_data_update(void)
{
    ret_code_t                  err_code;
    ble_advdata_manuf_data_t    manuf_data;

    new_advdata.p_manuf_specific_data = &manuf_data;

    NRF_LOG_INFO("Updating advertising data!");
    
    manuf_data.company_identifier = APP_COMPANY_IDENTIFIER;

    manuf_data.data.p_data = (uint8_t *)&adv_data;
    manuf_data.data.size = sizeof(adv_data);
    
    err_code = ble_advertising_advdata_update(&m_advertising, &new_advdata, NULL);
    APP_ERROR_CHECK(err_code);  
  

    NRF_LOG_INFO("Advertising data updated!");
    NRF_LOG_FLUSH();
}

  • Hello again Katie22,

    I am terribly sorry that it has been so long since last you received a reply here!
    I have been out of office since last we spoke. I though another engineer was assigned to your ticket in my absence, my apologies.

    Katie Newell said:

    I am not sure I understand when you said "...then you do perhaps not need to 'update' the advertising data, since you will be starting the advertising anew every time you wake up..."

    My advertising data is dynamic - such as battery level -  so I need to update it every time I wake up. 

    Katie Newell said:
    The advertising data is updated in advertising_init which is executed at the start of my program in the main function and not every time I wake up.

    Could you confirm for me whether you mean SYSTEM OFF or SYSTEM ON sleep from which the device is waking? In case of the former then the entire application will be ran from the start every time, in case of the latter this will not happen and you will need to call the advdata update function for each wakeup.

    Katie Newell said:

    When I remove the update data function, my device can be seen. 

    Please advise. I am not sure I can use the update data function or maybe I am using it in the wrong place. 

    This sounds very strange. It would be very helpful to see a sniffer trace of the on-air BLE traffic here, to better understand what is going on.
    Are you familiar with the nRF Sniffer tool? It is a powerful tool to wield when developing with BLE.

    It would also be helpful to see a more complete version of your code, if possible. It is hard for me to comment on whether you are using the update function in the right place, without having seen a more complete version.

    I again apologize for the major delay in answers on this ticker.

    I look forward to resolving this issue together!

    Best regards,
    Karl

Related