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

Deleting peers

Hi

I have a question about peers deleting.

It is saying in documentation about pm_peer_delete:

"Warning Use this function only when not connected to or connectable for the peer that is being deleted. If the peer is or becomes connected or data is manually written in flash during this procedure (until the success or failure event happens), the behavior is undefined."

So do i need to disconnect device, to wait end of disconnecting, then run pm_peer_delete?

And if i need to delete many devices, procedure is long and complex.


Perhaps You advice more obvious way ?

Thanks.

  • Hello!

    Thanks for replay.

     if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
                    {
                        err_code = sd_ble_gap_disconnect(m_conn_handle, 0x13);
                        APPL_LOG("sd_ble_gap_disconnect result %08lX", err_code);
                    }
                    else
                    {
                        APPL_LOG("No physical link exists with peer");
                    }

    do I need to wait event of disconnecting before delete ?

    could i run ten times this sd_ble_gap_disconnect(m_conn_handle, 0x13) for ten connected handles in central simultaenously ?

  • Yes, you need to wait before the actual disconnected event before you can delete the bond. You should be able to run sd_ble_gap_disconnect in rapid succession for all your current handles without any issue, but you should always verify the return code.

  • Deleting one by one device is working (pm_peers_delete()).
    But deleting all devices by pm_peers_delete() hangs up all system without any logs.

  • Hi

    Can you please specify where exactly the system "hangs up"? Do you get any error in return when trying to debug this? Please make sure you are not connected to any of the peer devices you're trying to delete as there's a chance you end up in an undefined state if you're trying to delete the bonding information of a connected device.

    Best regards,

    Simon

  • Log below shows how system hangs up.

    Firstly were connected two devices.
    Disconnections were performed.
    pm_peers_delete was executed.
    After that system is in hang up state.

    <info> app: BLE_GAP_EVT_RSSI_CHANGED: 1 rssi=--63dBm ch_index=0x6
    <info> app: BLE_GAP_EVT_RSSI_CHANGED: 0 rssi=--56dBm ch_index=0x6
    
    <info> app: sd_ble_gap_disconnect result 0
    <info> app: BLE_GAP_EVT_RSSI_CHANGED: 0 rssi=--50dBm ch_index=0x29
    <info> app: ble_nus_c_evt_handler(): conn_handle=0x2000, evt_type=0x2
    <info> app: Scanning start
    <info> app: BLE_GAP_EVT_DISCONNECTED: 0 , reason=0x16
    
    <info> app: sd_ble_gap_disconnect result 0
    <info> app: Scanning start
    <info> app: BLE_GAP_EVT_ADV_REPORT peer_id=0x0
    <info> app: Start_connection for Bonded peer
    <info> app: BLE_GAP_EVT_RSSI_CHANGED: 1 rssi=--62dBm ch_index=0x6
    <info> app: ble_nus_c_evt_handler(): conn_handle=0x2000, evt_type=0x2
    <info> app: Scanning start
    <info> app: BLE_GAP_EVT_DISCONNECTED: 1 , reason=0x16
    
    <info> app: pm_peers_delete result 0
    <info> app: Scanning start
    <error> peer_manager_handler: Peer deleted successfully: peer_id: 0
    <info> app: PM_EVT_PEER_DELETE_SUCCEEDED: peer_id=0x0
    <info> app: Deleted File_id=0x5500
    <info> app: Event: FDS_EVT_DEL_FILE received (FDS_SUCCESS)
    <error> peer_manager_handler: Peer deleted successfully: peer_id: 0
    <info> app: PM_EVT_PEER_DELETE_SUCCEEDED: peer_id=0x0
    <info> app: Deleted File_id=0x5500
    <info> app: Event: FDS_EVT_DEL_FILE received (FDS_SUCCESS)
    

Related