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

Confusion with the call of sd_ble_gap_sec_params_reply

Hi,

I'd like to enable paring/bonding for a minute only when a button is pressed. So I need to disable pairing. I've learned that it should be done with

case BLE_GAP_EVT_SEC_PARAMS_REQUEST:
            // Pairing not supported
            err_code = sd_ble_gap_sec_params_reply(m_conn_handle,
                                                   BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP,
                                                   NULL,
                                                   NULL);
            APP_ERROR_CHECK(err_code);
            break;

in "ble_evt_handler". But it returns with "NRF_ERROR_INVALID_STATE". From this topic and from the code I know that it's because "sd_ble_gap_sec_params_reply" is alraedy called in "security_dispatcher.c -> smd_params_reply". 

But then how to refuse to pair if I can't call "sd_ble_gap_sec_params_reply"?

Soft device: s132

SDK: 15.2

Thank you in advance!

Related