nRF51 SDK v10.0.0
Data Structures | Typedefs | Enumerations | Functions
Security Dispatcher

An internal module of Peer Manager. A module for streamlining pairing, bonding, and encryption, including flash storage of shared data. More...

Data Structures

struct  smd_evt_slave_security_req_t
 Events parameters specific to the SMD_EVT_SLAVE_SECURITY_REQ event. More...
 
struct  smd_evt_sec_procedure_start_t
 Events parameters specific to the SMD_EVT_SEC_PROCEDURE_START event. More...
 
struct  smd_evt_pairing_success_t
 Events parameters specific to the SMD_EVT_PAIRING_SUCCESS event. More...
 
struct  smd_evt_pairing_failed_t
 Events parameters specific to the SMD_EVT_PAIRING_FAIL event. More...
 
struct  smd_evt_link_encryption_update_t
 Events parameters specific to the SMD_EVT_LINK_ENCRYPTION_UPDATE event. More...
 
struct  smd_evt_link_encryption_failed_t
 Events parameters specific to the SMD_EVT_LINK_ENCRYPTION_FAILED event. More...
 
struct  smd_evt_bonding_info_stored_t
 Events parameters specific to the SMD_EVT_BONDING_INFO_STORED event. More...
 
struct  smd_evt_error_bonding_info_t
 Events parameters specific to the SMD_EVT_ERROR_BONDING_INFO event. More...
 
struct  smd_evt_error_unexpected_t
 Events parameters specific to the SMD_EVT_ERROR_UNEXPECTED event. More...
 
union  smd_evt_params_t
 
struct  smd_evt_t
 Structure describing events from the Security Dispatcher module. More...
 

Typedefs

typedef void(* smd_evt_handler_t )(smd_evt_t const *p_event)
 Event handler for events from the Security Dispatcher module. More...
 

Enumerations

enum  smd_evt_id_t {
  SMD_EVT_PARAMS_REQ,
  SMD_EVT_SLAVE_SECURITY_REQ,
  SMD_EVT_SEC_PROCEDURE_START,
  SMD_EVT_PAIRING_SUCCESS,
  SMD_EVT_PAIRING_FAIL,
  SMD_EVT_LINK_ENCRYPTION_UPDATE,
  SMD_EVT_LINK_ENCRYPTION_FAILED,
  SMD_EVT_BONDING_INFO_STORED,
  SMD_EVT_ERROR_BONDING_INFO,
  SMD_EVT_ERROR_UNEXPECTED
}
 Events that can come from the Security Dispatcher module. More...
 

Functions

ret_code_t smd_register (smd_evt_handler_t evt_handler)
 Function for registering with the Security Dispatcher module. This function also initializes the module if uninitialized. More...
 
void smd_ble_evt_handler (ble_evt_t *ble_evt)
 Function for dispatching SoftDevice events to the Security Dispatcher module. More...
 
ret_code_t smd_params_reply (uint16_t conn_handle, ble_gap_sec_params_t *p_sec_params)
 Function for providing pairing and bonding parameters to use for the current pairing procedure on a connection. More...
 
ret_code_t smd_link_secure (uint16_t conn_handle, ble_gap_sec_params_t *p_sec_params, bool force_repairing)
 Function for initiating security on the link, with the specified parameters. More...
 

Detailed Description

An internal module of Peer Manager. A module for streamlining pairing, bonding, and encryption, including flash storage of shared data.

Typedef Documentation

typedef void(* smd_evt_handler_t)(smd_evt_t const *p_event)

Event handler for events from the Security Dispatcher module.

Parameters
[in]p_eventThe event that has happened.

Enumeration Type Documentation

Events that can come from the Security Dispatcher module.

Enumerator
SMD_EVT_PARAMS_REQ 

Parameters are required for a pairing procedure on the specified connection. The user must provide them using smd_params_reply.

SMD_EVT_SLAVE_SECURITY_REQ 

The peer (slave) has requested link encryption. Call smd_link_secure to honor the request. The data in the event structure must be used in the parameters.

SMD_EVT_SEC_PROCEDURE_START 

A security procedure has started.

SMD_EVT_PAIRING_SUCCESS 

A pairing procedure (and bonding if applicable) has completed with success.

SMD_EVT_PAIRING_FAIL 

A pairing procedure has failed which means no encryption and no bond could be established.

SMD_EVT_LINK_ENCRYPTION_UPDATE 

The security level of the link has been updated. The link is encrypted.

SMD_EVT_LINK_ENCRYPTION_FAILED 

An attempt to start encryption on an unencrypted link failed because the peripheral did not have the correct keys. If the peer is the peripheral, the force_repairing flag should be set when reattempting smd_link_secure.

SMD_EVT_BONDING_INFO_STORED 

Information exchanged during bonding with a peer has been stored persistently.

SMD_EVT_ERROR_BONDING_INFO 

Information exchanged during bonding with a peer could not be stored persistently, because of an unexpected error.

SMD_EVT_ERROR_UNEXPECTED 

An operation failed with an unexpected error. The error is provided. This is possibly a fatal error.

Function Documentation

void smd_ble_evt_handler ( ble_evt_t ble_evt)

Function for dispatching SoftDevice events to the Security Dispatcher module.

Parameters
[in]ble_evtThe SoftDevice event.
ret_code_t smd_link_secure ( uint16_t  conn_handle,
ble_gap_sec_params_t p_sec_params,
bool  force_repairing 
)

Function for initiating security on the link, with the specified parameters.

Note
If the connection is a peripheral connection, this will send a security request to the master, but the master is not obligated to initiate pairing or encryption in response.
If the connection is a central connection and a key is available, the parameters will be used to determine whether to re-pair or to encrypt using the existing key. If no key is available, pairing will be started.
Parameters
[in]conn_handleHandle of the connection to initiate pairing on.
[in]p_sec_paramsThe security parameters to use for this link. As a central, this can be NULL to reject a slave security request.
[in]force_repairingWhether to force a pairing procedure to happen regardless of whether an encryption key already exists. This argument is only relevant for the central role. Recommended value: false
Return values
NRF_SUCCESSSuccess.
NRF_ERROR_NULLp_sec_params was NULL (peripheral only).
NRF_ERROR_INVALID_STATEModule is not initialized, or this error originates from the SoftDevice.
NRF_ERROR_INVALID_PARAMInvalid combination of parameters (not including conn_handle).
NRF_ERROR_BUSYUnable to initiate procedure at this time.
NRF_ERROR_TIMEOUTThere has been an SMP timeout, so no more SMP operations can be performed on this link.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle.
NRF_ERROR_NO_MEMNo more room in flash, or no space in RAM for peer_database to use.
NRF_ERROR_INTERNALNo more available peer IDs.
ret_code_t smd_params_reply ( uint16_t  conn_handle,
ble_gap_sec_params_t p_sec_params 
)

Function for providing pairing and bonding parameters to use for the current pairing procedure on a connection.

Note
If this function returns an NRF_ERROR_NULL, NRF_ERROR_INVALID_PARAM, BLE_ERROR_INVALID_CONN_HANDLE, or NRF_ERROR_NO_MEM, this function can be called again after corrective action.
To reject a request, call this function with NULL p_sec_params.
Parameters
[in]conn_handleThe connection handle of the connection the pairing is happening on.
[in]p_sec_paramsThe security parameters to use for this link.
Return values
NRF_SUCCESSSuccess.
NRF_ERROR_INVALID_STATEModule is not initialized, or no parameters have been requested on that conn_handle, or this error originates from the SoftDevice.
NRF_ERROR_INVALID_PARAMInvalid combination of parameters (not including conn_handle).
NRF_ERROR_TIMEOUTThere has been an SMP timeout, so no more SMP operations can be performed on this link.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle.
NRF_ERROR_NO_MEMNo more room in flash. Fix and reattempt later.
NRF_ERROR_BUSYNo write buffer. Reattempt later.
ret_code_t smd_register ( smd_evt_handler_t  evt_handler)

Function for registering with the Security Dispatcher module. This function also initializes the module if uninitialized.

Parameters
[in]evt_handlerCallback for events from the Security Dispatcher module.
Return values
NRF_SUCCESSRegistration was successful.
NRF_ERROR_NO_MEMNo more registrations possible.
NRF_ERROR_NULLevt_handler was NULL.

This document was last updated on Mon Nov 9 2015.
Please send us your feedback about the documentation! For technical questions, visit the Nordic Developer Zone.