Hey,
in our project the nrf is acting as the central and connecting phones.
As part of the connection process:
1) We check if the phone is bonded in the nrf.
2) We check of the connection is encrypted.
If one of the above is not fulfilled, we send a pair request using pm_conn_secure function.
The problem is the pair request timeout is very short. The pair request is shown on the phone for only a second or two and then timeout is received on the nrf.
Can we set the timeout to be longer?
Tnxs for u'r help!
I add the code we use here:
========================================================
BLE_ENCRYPT_ERR BleEncrypt(const pBleEncryptedParameters_t pIsEncryptedPara)
{
uint16_t innerConnHandle = 0;
uint8_t errCode = 0;
pm_conn_sec_status_t status = {0};
assert(NULL != pIsEncryptedPara);
/* Check connection exists */
errCode = GetInnerConnectionHandle(pIsEncryptedPara->m_handle, &innerConnHandle);
assert(CON_HANDLE_ERR_NULL_PTR != errCode);
if( CON_HANDLE_ERR_OK != errCode)
{
return BLE_ENCRYPT_ERR_ILLEGAL_PARAMETERS;
}
/* Get status from MPA */
errCode = pm_conn_sec_status_get(innerConnHandle, &status);
APP_ERROR_CHECK(errCode);
/* Send response to host */
SendIsEncrypted(status.encrypted);
return BLE_ENCRYPT_ERR_OK;
}
==========================================================================
BLE_PAIR_ERR BlePair(const pBlePairParameters_t parameters)
{
uint16_t innerConnHandle = 0;
pm_conn_sec_status_t status = {0};
/* Get inner connection handle */
uint8_t errCode = GetInnerConnectionHandle(parameters->m_connHandle, &innerConnHandle);
assert(CON_HANDLE_ERR_NULL_PTR != errCode);
if( CON_HANDLE_ERR_OK != errCode)
{
return BLE_PAIR_ILLEGAL_PARAMETERS;
}
/* Get Status to know if this is the first bond with specific MPA */
s_bondInitiated = true;
errCode = pm_conn_sec_status_get(innerConnHandle, &status);
APP_ERROR_CHECK(errCode);
/* start bonding process */
errCode = pm_conn_secure(innerConnHandle, status.bonded);
if(NRF_ERROR_BUSY == errCode) {
return BLE_PAIR_ERR_BUSY;
}
if(NRF_ERROR_TIMEOUT == errCode) {
return BLE_PAIR_ERR_TIMEOUT;
}
APP_ERROR_CHECK(errCode);
return BLE_PAIR_ERR_OK;
}
=========================================================
ret_code_t pm_conn_secure(uint16_t conn_handle, bool force_repairing)
{
VERIFY_MODULE_INITIALIZED();
ret_code_t err_code;
err_code = sm_link_secure(conn_handle, force_repairing);
if (err_code == NRF_ERROR_INVALID_STATE)
{
err_code = NRF_ERROR_BUSY;
}
return err_code;
}