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.

  • You need to be disconnected from any peers you want to delete, and make sure they aren't able to connect during the small time-period you are deleting the bonds. You can remove all bonds on the device by running pm_peers_delete(), but the same warning applies to this function. 

  • is any simple way to disconnect all connected to central devices?

    and to guaranty disabling of connecting?

    disabling ble operating for some time at all for example...

  • Hi

    As Ivan says, pm_peers_delete() is a function deleting all data stored for all peers. As for the disconnections, you do this however you like, for example by calling a sd_ble_gap_disconnect event.

    Best regards,

    Simon

  • Good day!

    Could you show example how to disconnect all peripherals from central.

    Before using pm_peers_delete().

  • Hi

    An example on how to disconnect using button 4 on the DK can be seen in the ble_app_ipsp_initiator example. Please see the button_event_handler() function, more specifically the BSP_BUTTON_3. I have also added the snippet below. It will also return a log message "No physical link exits with peer" if there are no current connections.

    /**@brief Function for handling button events.
     *
     * @param[in]   pin_no         The pin number of the button pressed.
     * @param[in]   button_action  The action performed on button.
     */
    static void button_event_handler(uint8_t pin_no, uint8_t button_action)
    {
        uint32_t err_code;
        if (button_action == APP_BUTTON_PUSH)
        {
            switch (pin_no)
            {
                case BSP_BUTTON_0:
                {
                    if (m_conn_handle == BLE_CONN_HANDLE_INVALID)
                    {
                        err_code = sd_ble_gap_connect(&m_peer_addr,
                                                      &m_scan_param,
                                                      &m_connection_param,
                                                      APP_IPSP_TAG);
    
                        if (err_code != NRF_SUCCESS)
                        {
                            APPL_LOG("Connection Request Failed, reason 0x%08lX", err_code);
                        }
                        APP_ERROR_CHECK(err_code);
                    }
                    else
                    {
                         APPL_LOG("Connection exists with peer");
                    }
    
                    break;
                }
                case BSP_BUTTON_1:
                {
                    if (m_conn_handle != BLE_CONN_HANDLE_INVALID)
                    {
                        ble_ipsp_handle_t ipsp_handle;
                        ipsp_handle.conn_handle = m_conn_handle;
                        err_code = ble_ipsp_connect(&ipsp_handle);
                        APP_ERROR_CHECK_BOOL((err_code == NRF_SUCCESS) ||
                                             (err_code == NRF_ERROR_BLE_IPSP_CHANNEL_ALREADY_EXISTS));
                    }
                    else
                    {
                         APPL_LOG("No physical link exists with peer");
                    }
                    break;
                }
                case BSP_BUTTON_2:
                {
                    err_code = ble_ipsp_disconnect(&m_handle);
                    APPL_LOG("ble_ipsp_disconnect result %08lX", err_code);
                    break;
                }
                case BSP_BUTTON_3:
                {
                    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");
                    }
                    break;
                }
                default:
                    break;
            }
        }
    }

    Best regards,

    Simon

Related