Change advertisement interval after first connection [closed]

xlp512 gravatar image

asked 2017-10-07 16:59:58 +0100

Using SD130 v2.0.1 on nRF51822, I would like to be able to change the advertisment interval after first connection.

My app is based on the HRS sample, with a modified avertising_init:

static void advertising_init_interval(uint32_t advertInterval)

  static bool inited = false;

  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));

  advdata.name_type = BLE_ADVDATA_FULL_NAME;
  advdata.include_appearance = true;
  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 = advertInterval == 0 ? APP_ADV_INTERVAL : advertInterval;
  options.ble_adv_fast_timeout = APP_ADV_TIMEOUT_IN_SECONDS;

  LOGVA("Setting adv interval to %d units", options.ble_adv_fast_interval);

  if (!inited)
    inited = true;
    err_code = ble_advertising_init(&advdata, NULL, &options, on_adv_evt, NULL);
    err_code = ble_advdata_set(&advdata, NULL);

When receiving BLE_GAP_EVT_DISCONNECTED, I call avertising_init_interval with 200 units as parameters. Log is ok, no error happens, however when I measure the timing using oscilloscope, I get my initial interval (~320 ms) instead of the expected ~125 ms. What am I doing wrong?

edit retag flag offensive reopen delete report spam

Closed as "question is not relevant or outdated" by Jonathan at 2017-10-30 14:33:18 +0100


I'm assuming you are calling advertising start after you change the interval? Are you actually doing fast advertising? Not slow? Since this is the interval you are changing.

Petter Myhre ( 2017-10-09 15:42:52 +0100 )editconvert to answer

Indeed, stopping advertising if applicable and then restarting in fast mode. Seems the thing to do, but wouldn't work. Might have missed something. But my specification has now changed so I no longer need to do it.

Jonathan ( 2017-10-10 18:20:57 +0100 )editconvert to answer

Ok. So should we close this?

Petter Myhre ( 2017-10-10 22:13:46 +0100 )editconvert to answer

Yes, you surely can, I didn't find an appropriate closing reason like "No longer useful" so I didn't close it.

Jonathan ( 2017-10-30 14:32:34 +0100 )editconvert to answer