Hi,
I'm using SDK 17.02 and using the ble_app_buttonless_dfu as a template, but merged in the code from ble_hid_keyboard for the whitelist. EDIT: also need to add that I'm using SoftDevice S112 7.2.0 and NRF52810.
In the event BLE_ADV_EVT_WHITELIST_REQUEST I changed whitelist_addrs[BLE_GAP_WHITELIST_ADDR_MAX_COUNT] to whitelist_addrs[1] and other instances (addr_cnt, irk_cnt) to reflect that I only want 1 phone to be able to bond to it.
However, during testing I can still use the NRF Connect app from 3 different phones to bond to the device. How can I make it so that once a phone is bonded to it, it will reject all other connection or bonding requests from different phones?
case BLE_ADV_EVT_WHITELIST_REQUEST:
{
ble_gap_addr_t whitelist_addrs[1];
ble_gap_irk_t whitelist_irks[1];
uint32_t addr_cnt = 1;
uint32_t irk_cnt = 1;
err_code = pm_whitelist_get(whitelist_addrs, &addr_cnt,
whitelist_irks, &irk_cnt);
APP_ERROR_CHECK(err_code);
NRF_LOG_DEBUG("pm_whitelist_get returns %d addr in whitelist and %d irk whitelist",
addr_cnt, irk_cnt);
// Set the correct identities list (no excluding peers with no Central Address Resolution).
identities_set(PM_PEER_ID_LIST_SKIP_NO_IRK);
// Apply the whitelist.
err_code = ble_advertising_whitelist_reply(&m_advertising,
whitelist_addrs,
addr_cnt,
whitelist_irks,
irk_cnt);
APP_ERROR_CHECK(err_code);
} break; //BLE_ADV_EVT_WHITELIST_REQUEST
and advertising_init:
static void advertising_init(void)
{
uint32_t err_code;
ble_advertising_init_t init;
memset(&init, 0, sizeof(init));
init.advdata.name_type = BLE_ADVDATA_FULL_NAME;
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_whitelist_enabled = true;
init.config.ble_adv_directed_high_duty_enabled = true;
init.config.ble_adv_directed_enabled = false;
init.config.ble_adv_directed_interval = 0;
init.config.ble_adv_directed_timeout = 0;
init.config.ble_adv_fast_enabled = true;
init.config.ble_adv_fast_interval = APP_ADV_FAST_INTERVAL;
init.config.ble_adv_fast_timeout = APP_ADV_FAST_DURATION;
init.config.ble_adv_slow_enabled = true;
init.config.ble_adv_slow_interval = APP_ADV_SLOW_INTERVAL;
init.config.ble_adv_slow_timeout = APP_ADV_SLOW_DURATION;
advertising_config_get(&init.config);
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);
}