Do not send security request as peripheral if bonded to peer

I have a requirement that my peripheral device should only rely on the central to start any security operation.  Right now I see a problem when the central side removes the bonding but my side still has the bonding information.  The peripheral still sends a security request by calling pm_conn_secure().  I prevent this request by commenting out one line in peer_manager_handler.c which calls conn_secure.  Is this the correct way to do it?  I am using SDK 15.3.

void pm_handler_on_pm_evt(pm_evt_t const * p_pm_evt)
{
    pm_handler_pm_evt_log(p_pm_evt);

    if (p_pm_evt->evt_id == PM_EVT_BONDED_PEER_CONNECTED)
    {
        //conn_secure(p_pm_evt->conn_handle, false);
    }
    else if (p_pm_evt->evt_id == PM_EVT_ERROR_UNEXPECTED)
    {
        NRF_LOG_ERROR("Asserting.");
        APP_ERROR_CHECK(p_pm_evt->params.error_unexpected.error);
    }
}

Related