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

Forget Device on IOS side handling

Hello,

I am working with nRF52840 and started with SDK15 examples with BLE security mode 1 level 2, No MITM.  I have a question regarding bond handling and the deletion of bond data on the central side which for us is an IOS app.  When the user "Forgets Device" in settings of IOS, the peripheral cannot recognize this and during the next attempt to connect will try to use previous bond keys while the app tries to pair and re bond.  I am attempting to handle this in PM_EVT_CONN_SEC_FAILED with a pm_peer_id_get and then pm_peer_delete.  I want the devices to rebond in one connection so the user does not have to try again.  Is this the right way to handle this / safe place to delete a bond, etc?

        case PM_EVT_CONN_SEC_FAILED:
            m_conn_handle = BLE_CONN_HANDLE_INVALID;

            // Check if failure was because peer was already bonded
            if(pm_peer_id_get(p_evt->conn_handle, p_evt->peer_id) == NRF_SUCCESS)
            {
                NRF_LOG_INFO("PEER ALREADY BONDED...DELETING BOND FOR REBOND");
                err_code = pm_peer_delete(current_bonded_peer);
                APP_ERROR_CHECK(err_code);
            }
            break;

Thanks in advanced,
Bloq

  • I have located the PM_EVT_BONDED_PEER_CONNECTED event from the peer manager.  The only problem with this is that the event occurs whether or not the central is looking to pair or bond.  Is there something that I can check for in the pm_evt that signifies the central is looking to pair instead of re encrypt the link with the bond data so I can delete the current keys and rebond?

    Thanks,
    Bloq

  • I have located the .allow_repairing sec config option but it is still not working.  I have implemented the following:

            case PM_EVT_CONN_SEC_PARAMS_REQ:
            {
                pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
                pm_conn_sec_config_reply(p_evt->conn_handle, &conn_sec_config);
            } break;

    but I still get a "Connection Alert: The peripheral disconnected while being interrogated. Dismiss" message on central IOS app.
    Please help this seems to be the solution for everyone else.

    Thanks,

    Bloq

  • Hi,

    This is almost the correct way, but you need to handle the PM_EVT_CONN_SEC_CONFIG_REQ event:

            case PM_EVT_CONN_SEC_CONFIG_REQ:
            {
                // Allow pairing request from an already bonded peer.
                pm_conn_sec_config_t conn_sec_config = {.allow_repairing = true};
                pm_conn_sec_config_reply(p_evt->conn_handle, &conn_sec_config);
            } break;

Related