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

remove bond in CTS

Hi, there

     I want to remove the bond in current time service example, because the bond process make me less convenient when I debug. so I changed the code in peer_manager_init 

sec_param.bond = 0;
sec_param.mitm = SEC_PARAM_MITM;
sec_param.lesc = SEC_PARAM_LESC;
sec_param.keypress = SEC_PARAM_KEYPRESS;
sec_param.io_caps = SEC_PARAM_IO_CAPABILITIES;
sec_param.oob = SEC_PARAM_OOB;
sec_param.min_key_size = SEC_PARAM_MIN_KEY_SIZE;
sec_param.max_key_size = SEC_PARAM_MAX_KEY_SIZE;
sec_param.kdist_own.enc = 0;
sec_param.kdist_own.id = 0;
sec_param.kdist_peer.enc = 0;
sec_param.kdist_peer.id = 0;

and comment the peer_manager part in advertising_start

static void advertising_start(bool erase_bonds)
{
if (erase_bonds == true)
{
delete_bonds();
// Advertising is started by PM_EVT_PEERS_DELETE_SUCCEEDED event.
}
else
{
ret_code_t ret;

// memset(m_whitelist_peers, PM_PEER_ID_INVALID, sizeof(m_whitelist_peers));
// m_whitelist_peer_cnt = (sizeof(m_whitelist_peers) / sizeof(pm_peer_id_t));

// peer_list_get(m_whitelist_peers, &m_whitelist_peer_cnt);

// ret = pm_whitelist_set(m_whitelist_peers, m_whitelist_peer_cnt);
// APP_ERROR_CHECK(ret);

// // Setup the device identies list.
// // Some SoftDevices do not support this feature.
// ret = pm_device_identities_list_set(m_whitelist_peers, m_whitelist_peer_cnt);
// if (ret != NRF_ERROR_NOT_SUPPORTED)
// {
// APP_ERROR_CHECK(ret);
// }

ret = ble_advertising_start(&m_advertising, BLE_ADV_EVT_SLOW);
APP_ERROR_CHECK(ret);
}
}

it can advertise, connect and discover service in nRF connect on my phone, but my phone attempt to pairing and bonding , but failed and then the MCU stopped. so how to stop the phone's attempts to pairing and make the cts service work ?

how to remove the bonding procedure   completely?

  • Hi,

    Try this:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Other steps you should do:

    1) In sec_req_timeout_handler() comment out pm_conn_secure().

    Snippet:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    2) On the event BLE_GAP_EVT_CONNECTED, start discovery of peer's services with ble_db_discovery_start()

    Snippet:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    3) In advertising_init(), turn off whitelist advertising by setting ble_adv_whitelist_enabled to false

    Snippet:

    Fullscreen
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I've tried that out. It solved my problem,thank you!! 

  • Is it these three sections on top of luckxiaoer's original attempt or just these three sections? I've tried it both ways in SDK 14.2 on a DK board and the time read function returns no error but I never get the event which calls the print time function. Also disconnect is not cleanly handled, If I close any app that I use to make the connectin the DK thinks it's still connected, only disabling bluetooth will cause the DK to disconnect. Perhaps this 2nd issue is a clue to not getting the time event.

  • I'm interested in what BLE Central you used for testing. I'm using iOS 12.1.1 and finding that the time read function executes (triggered by the button press) without error but I never see the time event return.

  • I am having the same issue with retrieving the time from IOS once I remove bonding. I'm wondering whether IOS doesn't allow access to the characteristic unless the device is bonded? Although, I can't seem to find any documentation to prove or disprove this... With regards to not disconnecting, I believe IOS may hold onto a connection for a period of time even after you initiate the disconnection through core bluetooth's API.