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;
// 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.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;
advdata.uuids_complete.uuid_cnt = sizeof(m_adv_uuids) / sizeof(m_adv_uuids);
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);
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?
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.
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.
Ok. So should we close this?
Yes, you surely can, I didn't find an appropriate closing reason like "No longer useful" so I didn't close it.