/**@brief Function for handling the Authentication Status event received from the BLE stack. * * @param[in] p_ble_evt Event received from the BLE stack. */ static void on_auth_status(ble_gap_evt_auth_status_t * p_auth_status) { if (p_auth_status->auth_status != BLE_GAP_SEC_STATUS_SUCCESS) { return; } // Verify if its pairing and not bonding if (!ENCRYPTION_STATUS_GET()) { return; } if (m_master.bond.master_handle == INVALID_MASTER_HANDLE) { uint32_t err_code = master_find_in_db(p_auth_status->periph_keys.enc_info.div); if (err_code == NRF_SUCCESS) { // Possible DIV Collision indicate error to application, // not storing the new LTK err_code = NRF_ERROR_FORBIDDEN; } else { // Add the new device to data base err_code = on_auth_status_from_new_master(p_auth_status); } if (err_code != NRF_SUCCESS) { m_bondmngr_config.error_handler(err_code); } } else { m_bond_loaded = true; // Receiving a auth status again when already in have existing information! auth_status_update(p_auth_status); } }
/**@brief This function handles the Authentication Status event received from the BLE stack. * * @param[in] p_ble_evt Event received from the BLE stack. */ static void on_auth_status(ble_gap_evt_auth_status_t * p_auth_status) { if (p_auth_status->auth_status != BLE_GAP_SEC_STATUS_SUCCESS) { return; } if (m_master.bond.master_handle == INVALID_MASTER_HANDLE) { uint32_t err_code = master_find_in_db(p_auth_status->periph_keys.enc_info.div); switch (err_code) { case NRF_SUCCESS: // Master found in the list of bonded masters. Set the corresponding sys_attr. err_code = master_sys_attr_set(&m_master); break; case NRF_ERROR_NOT_FOUND: // Master not found, add new master err_code = on_auth_status_from_new_master(p_auth_status); break; default: break; } if (err_code != NRF_SUCCESS) { m_bondmngr_config.error_handler(err_code); } } else { auth_status_update(p_auth_status); } }