S132 SoftDevice v5.0.0-1.alpha
Functions

Functions

uint32_t sd_ble_gap_addr_set (ble_gap_addr_t const *p_addr)
 Set the local Bluetooth identity address. More...
 
uint32_t sd_ble_gap_addr_get (ble_gap_addr_t *p_addr)
 Get local Bluetooth identity address. More...
 
uint32_t sd_ble_gap_whitelist_set (ble_gap_addr_t const *const *pp_wl_addrs, uint8_t len)
 Set the active whitelist in the SoftDevice. More...
 
uint32_t sd_ble_gap_device_identities_set (ble_gap_id_key_t const *const *pp_id_keys, ble_gap_irk_t const *const *pp_local_irks, uint8_t len)
 Set device identity list. More...
 
uint32_t sd_ble_gap_privacy_set (ble_gap_privacy_params_t const *p_privacy_params)
 Set privacy settings. More...
 
uint32_t sd_ble_gap_privacy_get (ble_gap_privacy_params_t *p_privacy_params)
 Get privacy settings. More...
 
uint32_t sd_ble_gap_adv_data_set (uint8_t const *p_data, uint8_t dlen, uint8_t const *p_sr_data, uint8_t srdlen)
 Set, clear or update advertising and scan response data. More...
 
uint32_t sd_ble_gap_adv_start (ble_gap_adv_params_t const *p_adv_params)
 Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). More...
 
uint32_t sd_ble_gap_adv_stop (void)
 Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). More...
 
uint32_t sd_ble_gap_conn_param_update (uint16_t conn_handle, ble_gap_conn_params_t const *p_conn_params)
 Update connection parameters. More...
 
uint32_t sd_ble_gap_disconnect (uint16_t conn_handle, uint8_t hci_status_code)
 Disconnect (GAP Link Termination). More...
 
uint32_t sd_ble_gap_tx_power_set (int8_t tx_power)
 Set the radio's transmit power. More...
 
uint32_t sd_ble_gap_appearance_set (uint16_t appearance)
 Set GAP Appearance value. More...
 
uint32_t sd_ble_gap_appearance_get (uint16_t *p_appearance)
 Get GAP Appearance value. More...
 
uint32_t sd_ble_gap_ppcp_set (ble_gap_conn_params_t const *p_conn_params)
 Set GAP Peripheral Preferred Connection Parameters. More...
 
uint32_t sd_ble_gap_ppcp_get (ble_gap_conn_params_t *p_conn_params)
 Get GAP Peripheral Preferred Connection Parameters. More...
 
uint32_t sd_ble_gap_device_name_set (ble_gap_conn_sec_mode_t const *p_write_perm, uint8_t const *p_dev_name, uint16_t len)
 Set GAP device name. More...
 
uint32_t sd_ble_gap_device_name_get (uint8_t *p_dev_name, uint16_t *p_len)
 Get GAP device name. More...
 
uint32_t sd_ble_gap_authenticate (uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params)
 Initiate the GAP Authentication procedure. More...
 
uint32_t sd_ble_gap_sec_params_reply (uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const *p_sec_params, ble_gap_sec_keyset_t const *p_sec_keyset)
 Reply with GAP security parameters. More...
 
uint32_t sd_ble_gap_auth_key_reply (uint16_t conn_handle, uint8_t key_type, uint8_t const *p_key)
 Reply with an authentication key. More...
 
uint32_t sd_ble_gap_lesc_dhkey_reply (uint16_t conn_handle, ble_gap_lesc_dhkey_t const *p_dhkey)
 Reply with an LE Secure connections DHKey. More...
 
uint32_t sd_ble_gap_keypress_notify (uint16_t conn_handle, uint8_t kp_not)
 Notify the peer of a local keypress. More...
 
uint32_t sd_ble_gap_lesc_oob_data_get (uint16_t conn_handle, ble_gap_lesc_p256_pk_t const *p_pk_own, ble_gap_lesc_oob_data_t *p_oobd_own)
 Generate a set of OOB data to send to a peer out of band. More...
 
uint32_t sd_ble_gap_lesc_oob_data_set (uint16_t conn_handle, ble_gap_lesc_oob_data_t const *p_oobd_own, ble_gap_lesc_oob_data_t const *p_oobd_peer)
 Provide the OOB data sent/received out of band. More...
 
uint32_t sd_ble_gap_encrypt (uint16_t conn_handle, ble_gap_master_id_t const *p_master_id, ble_gap_enc_info_t const *p_enc_info)
 Initiate GAP Encryption procedure. More...
 
uint32_t sd_ble_gap_sec_info_reply (uint16_t conn_handle, ble_gap_enc_info_t const *p_enc_info, ble_gap_irk_t const *p_id_info, ble_gap_sign_info_t const *p_sign_info)
 Reply with GAP security information. More...
 
uint32_t sd_ble_gap_conn_sec_get (uint16_t conn_handle, ble_gap_conn_sec_t *p_conn_sec)
 Get the current connection security. More...
 
uint32_t sd_ble_gap_rssi_start (uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count)
 Start reporting the received signal strength to the application. More...
 
uint32_t sd_ble_gap_rssi_stop (uint16_t conn_handle)
 Stop reporting the received signal strength. More...
 
uint32_t sd_ble_gap_rssi_get (uint16_t conn_handle, int8_t *p_rssi)
 Get the received signal strength for the last connection event. More...
 
uint32_t sd_ble_gap_scan_start (ble_gap_scan_params_t const *p_scan_params)
 Start scanning (GAP Discovery procedure, Observer Procedure). More...
 
uint32_t sd_ble_gap_scan_stop (void)
 Stop scanning (GAP Discovery procedure, Observer Procedure). More...
 
uint32_t sd_ble_gap_connect (ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params)
 Create a connection (GAP Link Establishment). More...
 
uint32_t sd_ble_gap_connect_cancel (void)
 Cancel a connection establishment. More...
 
uint32_t sd_ble_gap_phy_request (uint16_t conn_handle, ble_gap_phys_t const *p_gap_phys)
 PHY Update Request. More...
 

Detailed Description

Function Documentation

uint32_t sd_ble_gap_addr_get ( ble_gap_addr_t p_addr)

Get local Bluetooth identity address.

Note
This will always return the identity address irrespective of the privacy settings, i.e. the address type will always be either BLE_GAP_ADDR_TYPE_PUBLIC or BLE_GAP_ADDR_TYPE_RANDOM_STATIC.
Parameters
[out]p_addrPointer to address structure to be filled in.
Return values
NRF_SUCCESSAddress successfully retrieved.
NRF_ERROR_INVALID_ADDRInvalid or NULL pointer supplied.
uint32_t sd_ble_gap_addr_set ( ble_gap_addr_t const *  p_addr)

Set the local Bluetooth identity address.

The local Bluetooth identity address is the address that identifies this device to other peers. The address type must be either BLE_GAP_ADDR_TYPE_PUBLIC or BLE_GAP_ADDR_TYPE_RANDOM_STATIC. The identity address cannot be changed while roles are running.

Note
This address will be distributed to the peer during bonding. If the address changes, the address stored in the peer device will not be valid and the ability to reconnect using the old address will be lost.
By default the SoftDevice will set an address of type BLE_GAP_ADDR_TYPE_RANDOM_STATIC upon being enabled. The address is a random number populated during the IC manufacturing process and remains unchanged for the lifetime of each IC.
Relevant Message Sequence Charts
Advertising
Parameters
[in]p_addrPointer to address structure.
Return values
NRF_SUCCESSAddress successfully set.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
BLE_ERROR_GAP_INVALID_BLE_ADDRInvalid address.
NRF_ERROR_BUSYThe stack is busy, process pending events and retry.
NRF_ERROR_INVALID_STATEThe identity address cannot be changed while the roles are running.
uint32_t sd_ble_gap_adv_data_set ( uint8_t const *  p_data,
uint8_t  dlen,
uint8_t const *  p_sr_data,
uint8_t  srdlen 
)

Set, clear or update advertising and scan response data.

Note
The format of the advertising data will be checked by this call to ensure interoperability. Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and duplicating the local name in the advertising data and scan response data.
To clear the advertising data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding length (dlen/srdlen) set to 0.
The call will fail if p_data and p_sr_data are both NULL since this would have no effect.
Relevant Message Sequence Charts
Advertising
Whitelist Sharing
Parameters
[in]p_dataRaw data to be placed in advertising packet. If NULL, no changes are made to the current advertising packet data.
[in]dlenData length for p_data. Max size: BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_data is NULL, can be 0 if p_data is not NULL.
[in]p_sr_dataRaw data to be placed in scan response packet. If NULL, no changes are made to the current scan response packet data.
[in]srdlenData length for p_sr_data. Max size: BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_sr_data is NULL, can be 0 if p_data is not NULL.
Return values
NRF_SUCCESSAdvertising data successfully updated or cleared.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied, both p_data and p_sr_data cannot be NULL.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_FLAGSInvalid combination of advertising flags supplied.
NRF_ERROR_INVALID_DATAInvalid data type(s) supplied, check the advertising data format specification.
NRF_ERROR_INVALID_LENGTHInvalid data length(s) supplied.
NRF_ERROR_NOT_SUPPORTEDUnsupported data type.
BLE_ERROR_GAP_UUID_LIST_MISMATCHInvalid UUID list supplied.
uint32_t sd_ble_gap_adv_start ( ble_gap_adv_params_t const *  p_adv_params)

Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).

Note
An application can start an advertising procedure for broadcasting purposes while a connection is active. After a BLE_GAP_EVT_CONNECTED event is received, this function may therefore be called to start a broadcast advertising procedure. The advertising procedure cannot however be connectable (it must be of type BLE_GAP_ADV_TYPE_ADV_SCAN_IND or BLE_GAP_ADV_TYPE_ADV_NONCONN_IND).
Only one advertiser may be active at any time.
Events generated
BLE_GAP_EVT_CONNECTEDGenerated after connection has been established through connectable advertising.
BLE_GAP_EVT_TIMEOUTAdvertisement has timed out.
Relevant Message Sequence Charts
Advertising
Peripheral Connection Establishment with Private Peer
Directed Advertising
Whitelist Sharing
Parameters
[in]p_adv_paramsPointer to advertising parameters structure.
Return values
NRF_SUCCESSThe BLE stack has started advertising.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
NRF_ERROR_CONN_COUNTThe limit of available connections has been reached; connectable advertiser cannot be started.
NRF_ERROR_NO_MEMThe configured memory pools (see ble_conn_bw_counts_t) are not large enough for the bandwidth selected for this connection.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied, check the accepted ranges and limits.
BLE_ERROR_GAP_INVALID_BLE_ADDRInvalid Bluetooth address supplied.
BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELISTDiscoverable mode and whitelist incompatible.
NRF_ERROR_BUSYThe stack is busy, process pending events and retry.
NRF_ERROR_RESOURCESNot enough BLE role slots available. Stop one or more currently active roles (Central, Peripheral or Observer) and try again
uint32_t sd_ble_gap_adv_stop ( void  )

Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).

Relevant Message Sequence Charts
Advertising
Whitelist Sharing
Return values
NRF_SUCCESSThe BLE stack has stopped advertising.
NRF_ERROR_INVALID_STATEInvalid state to perform operation (most probably not in advertising state).
uint32_t sd_ble_gap_appearance_get ( uint16_t *  p_appearance)

Get GAP Appearance value.

Parameters
[out]p_appearancePointer to appearance (16-bit) to be filled in, see Bluetooth Appearance values.
Return values
NRF_SUCCESSAppearance value retrieved successfully.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
uint32_t sd_ble_gap_appearance_set ( uint16_t  appearance)

Set GAP Appearance value.

Parameters
[in]appearanceAppearance (16-bit), see Bluetooth Appearance values.
Return values
NRF_SUCCESSAppearance value set successfully.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
uint32_t sd_ble_gap_auth_key_reply ( uint16_t  conn_handle,
uint8_t  key_type,
uint8_t const *  p_key 
)

Reply with an authentication key.

This function is only used to reply to a BLE_GAP_EVT_AUTH_KEY_REQUEST or a BLE_GAP_EVT_PASSKEY_DISPLAY, calling it at other times will result in an NRF_ERROR_INVALID_STATE.

Note
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
Events generated
This function is used during authentication procedures, see the list of events in the documentation of sd_ble_gap_authenticate.
Relevant Message Sequence Charts
Bonding: Passkey Entry, User Inputs on Peripheral or OOB
Bonding: Numeric Comparison
Bonding: Passkey Entry, User Inputs on Peripheral
Bonding: Passkey Entry, User Inputs on Central or OOB
Bonding: Numeric Comparison
Bonding: Passkey Entry: User Inputs on Central
Parameters
[in]conn_handleConnection handle.
[in]key_typeSee GAP Authentication Key Types.
[in]p_keyIf key type is BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL. If key type is BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination) or NULL when confirming LE Secure Connections Numeric Comparison. If key type is BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in Little Endian format.
Return values
NRF_SUCCESSAuthentication key successfully set.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_authenticate ( uint16_t  conn_handle,
ble_gap_sec_params_t const *  p_sec_params 
)

Initiate the GAP Authentication procedure.

In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected), otherwise in the peripheral role, an SMP Security Request will be sent.

Events generated
Depending on the security parameters set and the packet exchanges with the peer, the following events may be generated:
BLE_GAP_EVT_SEC_PARAMS_REQUEST
BLE_GAP_EVT_SEC_INFO_REQUEST
BLE_GAP_EVT_PASSKEY_DISPLAY
BLE_GAP_EVT_KEY_PRESSED
BLE_GAP_EVT_AUTH_KEY_REQUEST
BLE_GAP_EVT_LESC_DHKEY_REQUEST
BLE_GAP_EVT_CONN_SEC_UPDATE
BLE_GAP_EVT_AUTH_STATUS
BLE_GAP_EVT_TIMEOUT
Relevant Message Sequence Charts
Peripheral Security Request
Security Request Reception
Central Encryption and Authentication mutual exclusion
Pairing: Just Works
Bonding: Just Works
Bonding: Passkey Entry, Central displays
Bonding: Passkey Entry, User Inputs on Central or OOB
Pairing: Just Works
Bonding: Numeric Comparison
Bonding: Passkey Entry: Central Displays
Bonding: Passkey Entry: User Inputs on Central
Bonding: Out of Band
Parameters
[in]conn_handleConnection handle.
[in]p_sec_paramsPointer to the ble_gap_sec_params_t structure with the security parameters to be used during the pairing or bonding procedure. In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used. In the central role, this pointer may be NULL to reject a Security Request.
Return values
NRF_SUCCESSSuccessfully initiated authentication procedure.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
NRF_ERROR_BUSYThe stack is busy, process pending events and retry.
NRF_ERROR_NO_MEMThe maximum number of authentication procedures that can run in parallel for the given role is reached.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
NRF_ERROR_NOT_SUPPORTEDSetting of sign or link fields in ble_gap_sec_kdist_t not supported.
NRF_ERROR_TIMEOUTA SMP timeout has occurred, and further SMP operations on this link is prohibited.
uint32_t sd_ble_gap_conn_param_update ( uint16_t  conn_handle,
ble_gap_conn_params_t const *  p_conn_params 
)

Update connection parameters.

In the central role this will initiate a Link Layer connection parameter update procedure, otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for the central to perform the procedure. In both cases, and regardless of success or failure, the application will be informed of the result with a BLE_GAP_EVT_CONN_PARAM_UPDATE event.

This function can be used as a central both to reply to a BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST or to start the procedure unrequested.

Events generated
BLE_GAP_EVT_CONN_PARAM_UPDATEResult of the connection parameter update procedure.
Relevant Message Sequence Charts
Peripheral Connection Parameter Update
Central Encryption and Authentication mutual exclusion
Central Connection Parameter Update on multiple links
Central Control Procedure Serialization on multiple links
Central Connection Parameter Update
Parameters
[in]conn_handleConnection handle.
[in]p_conn_paramsPointer to desired connection parameters. If NULL is provided on a peripheral role, the parameters in the PPCP characteristic of the GAP service will be used instead. If NULL is provided on a central role and in response to a BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request will be rejected
Return values
NRF_SUCCESSThe Connection Update procedure has been started successfully.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied, check parameter limits and constraints.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
NRF_ERROR_BUSYProcedure already in progress or not allowed at this time, process pending events and wait for pending procedures to complete and retry.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
NRF_ERROR_NO_MEMNot enough memory to complete operation.
uint32_t sd_ble_gap_conn_sec_get ( uint16_t  conn_handle,
ble_gap_conn_sec_t p_conn_sec 
)

Get the current connection security.

Parameters
[in]conn_handleConnection handle.
[out]p_conn_secPointer to a ble_gap_conn_sec_t structure to be filled in.
Return values
NRF_SUCCESSCurrent connection security successfully retrieved.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_connect ( ble_gap_addr_t const *  p_peer_addr,
ble_gap_scan_params_t const *  p_scan_params,
ble_gap_conn_params_t const *  p_conn_params 
)

Create a connection (GAP Link Establishment).

Note
If a scanning procedure is currently in progress it will be automatically stopped when calling this function.
Relevant Message Sequence Charts
Whitelist Sharing
Central Connection Establishment with Private Peer
Central Connection Establishment and Termination
Parameters
[in]p_peer_addrPointer to peer address. If the use_whitelist bit is set in ble_gap_scan_params_t, then this is ignored. If ble_gap_addr_t::addr_id_peer is set then p_peer_addr must be present in the device identity list see sd_ble_gap_device_identities_set.
[in]p_scan_paramsPointer to scan parameters structure.
[in]p_conn_paramsPointer to desired connection parameters.
Return values
NRF_SUCCESSSuccessfully initiated connection procedure.
NRF_ERROR_INVALID_ADDRInvalid parameter(s) pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_INVALID_STATEThe SoftDevice is in an invalid state to perform this operation. This may be due to an existing locally initiated connect procedure, which must complete before initiating again.
BLE_ERROR_GAP_INVALID_BLE_ADDRInvalid Peer address.
NRF_ERROR_CONN_COUNTThe limit of available connections has been reached.
NRF_ERROR_NO_MEMThe configured memory pool (see ble_conn_bw_counts_t) is not large enough for the bandwidth selected for this connection.
NRF_ERROR_BUSYThe stack is busy, process pending events and retry. If another connection is being established wait for the corresponding BLE_GAP_EVT_CONNECTED event before calling again.
NRF_ERROR_RESOURCESNot enough BLE role slots available. Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again
uint32_t sd_ble_gap_connect_cancel ( void  )

Cancel a connection establishment.

Relevant Message Sequence Charts
Central Connection Establishment and Termination
Return values
NRF_SUCCESSSuccessfully cancelled an ongoing connection procedure.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
uint32_t sd_ble_gap_device_identities_set ( ble_gap_id_key_t const *const *  pp_id_keys,
ble_gap_irk_t const *const *  pp_local_irks,
uint8_t  len 
)

Set device identity list.

Note
Only one device identity list can be used at a time and the list is shared between the BLE roles. The device identity list cannot be set if a BLE role is using the list.
Parameters
[in]pp_id_keysPointer to an array of peer identity addresses and peer IRKs, if NULL the device identity list will be cleared.
[in]pp_local_irksPointer to an array of local IRKs. Each entry in the array maps to the entry in pp_id_keys at the same index. To fill in the list with the currently set device IRK for all peers, set to NULL.
[in]lenLength of the device identity list, maximum BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT.
Relevant Message Sequence Charts
Private Advertising
Private Scanning
Scan Private Devices
Directed Advertising
Peripheral Connection Establishment with Private Peer
Central Connection Establishment with Private Peer
Return values
NRF_SUCCESSThe device identity list successfully set/cleared.
NRF_ERROR_INVALID_ADDRThe device identity list (or one of its entries) provided is invalid. This code may be returned if the local IRK list also has an invalid entry.
BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USEThe device identity list is in use and cannot be set or cleared.
BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATEThe device identity list contains multiple entries with the same identity address.
BLE_ERROR_GAP_INVALID_BLE_ADDRInvalid address type is supplied.
NRF_ERROR_DATA_SIZEThe given device identity list size invalid (zero or too large); this can only return when pp_id_keys is not NULL.
uint32_t sd_ble_gap_device_name_get ( uint8_t *  p_dev_name,
uint16_t *  p_len 
)

Get GAP device name.

Note
If the device name is longer than the size of the supplied buffer, p_len will return the complete device name length, and not the number of bytes actually returned in p_dev_name. The application may use this information to allocate a suitable buffer size.
Parameters
[out]p_dev_namePointer to an empty buffer where the UTF-8 non NULL-terminated string will be placed. Set to NULL to obtain the complete device name length.
[in,out]p_lenLength of the buffer pointed by p_dev_name, complete device name length on output.
Return values
NRF_SUCCESSGAP device name retrieved successfully.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_DATA_SIZEInvalid data size(s) supplied.
uint32_t sd_ble_gap_device_name_set ( ble_gap_conn_sec_mode_t const *  p_write_perm,
uint8_t const *  p_dev_name,
uint16_t  len 
)

Set GAP device name.

Parameters
[in]p_write_permWrite permissions for the Device Name characteristic, see ble_gap_conn_sec_mode_t.
[in]p_dev_namePointer to a UTF-8 encoded, non NULL-terminated string.
[in]lenLength of the UTF-8, non NULL-terminated string pointed to by p_dev_name in octets (must be smaller or equal than BLE_GAP_DEVNAME_MAX_LEN).
Note
If the device name is located in application flash memory (see ble_gap_device_name_t), it cannot be changed. Then NRF_ERROR_FORBIDDEN will be returned.
Return values
NRF_SUCCESSGAP device name and permissions set successfully.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_DATA_SIZEInvalid data size(s) supplied.
NRF_ERROR_FORBIDDENDevice name is not writable.
uint32_t sd_ble_gap_disconnect ( uint16_t  conn_handle,
uint8_t  hci_status_code 
)

Disconnect (GAP Link Termination).

This call initiates the disconnection procedure, and its completion will be communicated to the application with a BLE_GAP_EVT_DISCONNECTED event.

Events generated
BLE_GAP_EVT_DISCONNECTEDGenerated when disconnection procedure is complete.
Relevant Message Sequence Charts
Peripheral Connection Establishment and Termination
Parameters
[in]conn_handleConnection handle.
[in]hci_status_codeHCI status code, see Bluetooth status codes (accepted values are BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and BLE_HCI_CONN_INTERVAL_UNACCEPTABLE).
Return values
NRF_SUCCESSThe disconnection procedure has been started successfully.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation (disconnection is already in progress).
uint32_t sd_ble_gap_encrypt ( uint16_t  conn_handle,
ble_gap_master_id_t const *  p_master_id,
ble_gap_enc_info_t const *  p_enc_info 
)

Initiate GAP Encryption procedure.

In the central role, this function will initiate the encryption procedure using the encryption information provided.

Events generated
BLE_GAP_EVT_CONN_SEC_UPDATEThe connection security has been updated.
Relevant Message Sequence Charts
Central Encryption and Authentication mutual exclusion
Encryption Establishment using stored keys
Central Control Procedure Serialization on multiple links
Security Request Reception
Parameters
[in]conn_handleConnection handle.
[in]p_master_idPointer to a ble_gap_master_id_t master identification structure.
[in]p_enc_infoPointer to a ble_gap_enc_info_t encryption information structure.
Return values
NRF_SUCCESSSuccessfully initiated authentication procedure.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
BLE_ERROR_INVALID_ROLEOperation is not supported in the Peripheral role.
NRF_ERROR_BUSYProcedure already in progress or not allowed at this time, wait for pending procedures to complete and retry.
uint32_t sd_ble_gap_keypress_notify ( uint16_t  conn_handle,
uint8_t  kp_not 
)

Notify the peer of a local keypress.

This function can only be used when an authentication procedure using LE Secure Connection is in progress. Calling it at other times will result in an NRF_ERROR_INVALID_STATE.

Relevant Message Sequence Charts
Bonding: Passkey Entry, User Inputs on Peripheral
Bonding: Passkey Entry: User Inputs on Central
Parameters
[in]conn_handleConnection handle.
[in]kp_notSee GAP Keypress Notification Types.
Return values
NRF_SUCCESSKeypress notification successfully queued for transmission.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation. Either not entering a passkey or keypresses have not been enabled by both peers.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
NRF_ERROR_BUSYThe BLE stack is busy. Retry at later time.
uint32_t sd_ble_gap_lesc_dhkey_reply ( uint16_t  conn_handle,
ble_gap_lesc_dhkey_t const *  p_dhkey 
)

Reply with an LE Secure connections DHKey.

This function is only used to reply to a BLE_GAP_EVT_LESC_DHKEY_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE.

Note
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
Events generated
This function is used during authentication procedures, see the list of events in the documentation of sd_ble_gap_authenticate.
Relevant Message Sequence Charts
Pairing: Just Works
Bonding: Numeric Comparison
Bonding: Passkey Entry, Peripheral Displays
Bonding: Passkey Entry, User Inputs on Peripheral
Bonding: Out of Band
Pairing: Just Works
Bonding: Numeric Comparison
Bonding: Passkey Entry: Central Displays
Bonding: Passkey Entry: User Inputs on Central
Bonding: Out of Band
Parameters
[in]conn_handleConnection handle.
[in]p_dhkeyLE Secure Connections DHKey.
Return values
NRF_SUCCESSDHKey successfully set.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_lesc_oob_data_get ( uint16_t  conn_handle,
ble_gap_lesc_p256_pk_t const *  p_pk_own,
ble_gap_lesc_oob_data_t p_oobd_own 
)

Generate a set of OOB data to send to a peer out of band.

Note
The ble_gap_addr_t included in the OOB data returned will be the currently active one (or, if a connection has already been established, the one used during connection setup). The application may manually overwrite it with an updated value.
Relevant Message Sequence Charts
Bonding: Out of Band
Bonding: Out of Band
Parameters
[in]conn_handleConnection handle. Can be BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet.
[in]p_pk_ownLE Secure Connections local P-256 Public Key.
[out]p_oobd_ownThe OOB data to be sent out of band to a peer.
Return values
NRF_SUCCESSOOB data successfully generated.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_lesc_oob_data_set ( uint16_t  conn_handle,
ble_gap_lesc_oob_data_t const *  p_oobd_own,
ble_gap_lesc_oob_data_t const *  p_oobd_peer 
)

Provide the OOB data sent/received out of band.

Note
An authentication procedure with OOB selected as an algorithm must be in progress when calling this function.
A BLE_GAP_EVT_LESC_DHKEY_REQUEST event with the oobd_req set to 1 must have been received prior to calling this function.
Events generated
This function is used during authentication procedures, see the list of events in the documentation of sd_ble_gap_authenticate.
Relevant Message Sequence Charts
Bonding: Out of Band
Bonding: Out of Band
Parameters
[in]conn_handleConnection handle.
[in]p_oobd_ownThe OOB data sent out of band to a peer or NULL if the peer has not received OOB data. Must correspond to ble_gap_sec_params_t::oob flag in BLE_GAP_EVT_SEC_PARAMS_REQUEST.
[in]p_oobd_peerThe OOB data received out of band from a peer or NULL if none received. Must correspond to ble_gap_sec_params_t::oob flag in sd_ble_gap_authenticate in the central role or sd_ble_gap_sec_params_reply in the peripheral role.
Return values
NRF_SUCCESSOOB data accepted.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_phy_request ( uint16_t  conn_handle,
ble_gap_phys_t const *  p_gap_phys 
)

PHY Update Request.

This function is used to request a new PHY configuration for a central or a peripheral connection. It will always generate a BLE_GAP_EVT_PHY_UPDATE event if successfully executed. If ble_gap_phys_t::tx_phys or ble_gap_phys_t::rx_phys is 0, then the stack will select PHYs based on the peer requirements on that specific direction. If the peer does not support the PHY Update procedure, then the resulting BLE_GAP_EVT_PHY_UPDATE event will have a status different from BLE_HCI_STATUS_CODE_SUCCESS.

Note
The requested PHYs does not have to be within the set of the preferred PHYs.
Events generated
BLE_GAP_EVT_PHY_UPDATEResult of the PHY Update procedure procedure.
Relevant Message Sequence Charts
Central PHY Request
Peripheral PHY Request
Parameters
[in]conn_handleConnection handle to indicate the connection for which the PHY Update is requested.
[in]p_gap_physPointer to PHY structure.
Return values
NRF_SUCCESSSuccessfully requested a PHY Update.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
NRF_ERROR_INVALID_PARAMUnsupported PHYs supplied to the call.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
NRF_ERROR_BUSYProcedure is already in progress or not allowed at this time. Process pending events and wait for the pending procedure to complete and retry.
uint32_t sd_ble_gap_ppcp_get ( ble_gap_conn_params_t p_conn_params)

Get GAP Peripheral Preferred Connection Parameters.

Parameters
[out]p_conn_paramsPointer to a ble_gap_conn_params_t structure where the parameters will be stored.
Return values
NRF_SUCCESSPeripheral Preferred Connection Parameters retrieved successfully.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
uint32_t sd_ble_gap_ppcp_set ( ble_gap_conn_params_t const *  p_conn_params)

Set GAP Peripheral Preferred Connection Parameters.

Parameters
[in]p_conn_paramsPointer to a ble_gap_conn_params_t structure with the desired parameters.
Return values
NRF_SUCCESSPeripheral Preferred Connection Parameters set successfully.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
uint32_t sd_ble_gap_privacy_get ( ble_gap_privacy_params_t p_privacy_params)

Get privacy settings.

Note
The privacy settings returned include the current device irk as well.
Parameters
[in]p_privacy_paramsPrivacy settings.
Return values
NRF_SUCCESSPrivacy settings read.
NRF_ERROR_INVALID_ADDRThe pointer given for returning the privacy settings may be NULL or invalid. Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
uint32_t sd_ble_gap_privacy_set ( ble_gap_privacy_params_t const *  p_privacy_params)

Set privacy settings.

Note
Privacy settings cannot be set while BLE roles are running.
Parameters
[in]p_privacy_paramsPrivacy settings.
Relevant Message Sequence Charts
Private Advertising
Private Scanning
Directed Advertising
Return values
NRF_SUCCESSSet successfully.
NRF_ERROR_BUSYThe stack is busy, process pending events and retry.
BLE_ERROR_GAP_INVALID_BLE_ADDRInvalid address type is supplied.
NRF_ERROR_INVALID_ADDRThe pointer to privacy settings is NULL or invalid. Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
NRF_ERROR_INVALID_PARAMOut of range parameters are provided.
NRF_ERROR_INVALID_STATEPrivacy settings cannot be changed while BLE roles using privacy are enabled.
uint32_t sd_ble_gap_rssi_get ( uint16_t  conn_handle,
int8_t *  p_rssi 
)

Get the received signal strength for the last connection event.

sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. NRF_ERROR_NOT_FOUND will be returned until RSSI was sampled for the first time after calling sd_ble_gap_rssi_start.

Relevant Message Sequence Charts
RSSI get sample
Parameters
[in]conn_handleConnection handle.
[out]p_rssiPointer to the location where the RSSI measurement shall be stored.
Return values
NRF_SUCCESSSuccessfully read the RSSI.
NRF_ERROR_NOT_FOUNDNo sample is available.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
NRF_ERROR_INVALID_STATERSSI reporting is not ongoing, or disconnection in progress.
uint32_t sd_ble_gap_rssi_start ( uint16_t  conn_handle,
uint8_t  threshold_dbm,
uint8_t  skip_count 
)

Start reporting the received signal strength to the application.

A new event is reported whenever the RSSI value changes, until sd_ble_gap_rssi_stop is called.

Events generated
BLE_GAP_EVT_RSSI_CHANGEDNew RSSI data available. How often the event is generated is dependent on the settings of the threshold_dbm and skip_count input parameters.
Relevant Message Sequence Charts
RSSI get sample
RSSI for connections with event filter
Parameters
[in]conn_handleConnection handle.
[in]threshold_dbmMinimum change in dBm before triggering the BLE_GAP_EVT_RSSI_CHANGED event. Events are disabled if threshold_dbm equals BLE_GAP_RSSI_THRESHOLD_INVALID.
[in]skip_countNumber of RSSI samples with a change of threshold_dbm or more before sending a new BLE_GAP_EVT_RSSI_CHANGED event.
Return values
NRF_SUCCESSSuccessfully activated RSSI reporting.
NRF_ERROR_INVALID_STATEDisconnection in progress. Invalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_rssi_stop ( uint16_t  conn_handle)

Stop reporting the received signal strength.

Note
An RSSI change detected before the call but not yet received by the application may be reported after sd_ble_gap_rssi_stop has been called.
Relevant Message Sequence Charts
RSSI get sample
RSSI for connections with event filter
Parameters
[in]conn_handleConnection handle.
Return values
NRF_SUCCESSSuccessfully deactivated RSSI reporting.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_scan_start ( ble_gap_scan_params_t const *  p_scan_params)

Start scanning (GAP Discovery procedure, Observer Procedure).

Events generated
BLE_GAP_EVT_ADV_REPORTAn advertising or scan response packet has been received.
BLE_GAP_EVT_TIMEOUTScanner has timed out.
Relevant Message Sequence Charts
Scanning
Whitelist Sharing
Parameters
[in]p_scan_paramsPointer to scan parameters structure.
Return values
NRF_SUCCESSSuccessfully initiated scanning procedure.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_BUSYThe stack is busy, process pending events and retry.
NRF_ERROR_RESOURCESNot enough BLE role slots available. Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again
uint32_t sd_ble_gap_scan_stop ( void  )

Stop scanning (GAP Discovery procedure, Observer Procedure).

Relevant Message Sequence Charts
Scanning
Whitelist Sharing
Return values
NRF_SUCCESSSuccessfully stopped scanning procedure.
NRF_ERROR_INVALID_STATEInvalid state to perform operation (most probably not in scanning state).
uint32_t sd_ble_gap_sec_info_reply ( uint16_t  conn_handle,
ble_gap_enc_info_t const *  p_enc_info,
ble_gap_irk_t const *  p_id_info,
ble_gap_sign_info_t const *  p_sign_info 
)

Reply with GAP security information.

This function is only used to reply to a BLE_GAP_EVT_SEC_INFO_REQUEST, calling it at other times will result in NRF_ERROR_INVALID_STATE.

Note
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
Data signing is not yet supported, and p_sign_info must therefore be NULL.
Relevant Message Sequence Charts
Peripheral Encryption Establishment using stored keys
Parameters
[in]conn_handleConnection handle.
[in]p_enc_infoPointer to a ble_gap_enc_info_t encryption information structure. May be NULL to signal none is available.
[in]p_id_infoPointer to a ble_gap_irk_t identity information structure. May be NULL to signal none is available.
[in]p_sign_infoPointer to a ble_gap_sign_info_t signing information structure. May be NULL to signal none is available.
Return values
NRF_SUCCESSSuccessfully accepted security information.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
uint32_t sd_ble_gap_sec_params_reply ( uint16_t  conn_handle,
uint8_t  sec_status,
ble_gap_sec_params_t const *  p_sec_params,
ble_gap_sec_keyset_t const *  p_sec_keyset 
)

Reply with GAP security parameters.

This function is only used to reply to a BLE_GAP_EVT_SEC_PARAMS_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE.

Note
If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
Events generated
This function is used during authentication procedures, see the list of events in the documentation of sd_ble_gap_authenticate.
Relevant Message Sequence Charts
Pairing: Just Works
Bonding: Just Works
Bonding: Passkey Entry, Peripheral displays
Bonding: Passkey Entry, User Inputs on Peripheral or OOB
Bonding: Passkey Entry with static passkey
Pairing failure: Confirm failed
Pairing: Just Works
Bonding: Numeric Comparison
Bonding: Passkey Entry, Peripheral Displays
Bonding: Passkey Entry, User Inputs on Peripheral
Bonding: Out of Band
GAP Failed Pairing: Keysize too small
Pairing failure: Pairing aborted by the application
Pairing failure: Pairing failed from central
Pairing failure: Timeout
Pairing: Just Works
Bonding: Just Works
Bonding: Passkey Entry, Central displays
Bonding: Passkey Entry, User Inputs on Central or OOB
Pairing: Just Works
Bonding: Numeric Comparison
Bonding: Passkey Entry: Central Displays
Bonding: Passkey Entry: User Inputs on Central
Bonding: Out of Band
Parameters
[in]conn_handleConnection handle.
[in]sec_statusSecurity status, see GAP Security status.
[in]p_sec_paramsPointer to a ble_gap_sec_params_t security parameters structure. In the central role this must be set to NULL, as the parameters have already been provided during a previous call to sd_ble_gap_authenticate.
[in,out]p_sec_keysetPointer to a ble_gap_sec_keyset_t security keyset structure. Any keys generated and/or distributed as a result of the ongoing security procedure will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application upon reception of a BLE_GAP_EVT_AUTH_STATUS event. Note that the SoftDevice expects the application to provide memory for storing the peer's keys. So it must be ensured that the relevant pointers inside this structure are not NULL. The pointers to the local key can, however, be NULL, in which case, the local key data will not be available to the application upon reception of the BLE_GAP_EVT_AUTH_STATUS event.
Return values
NRF_SUCCESSSuccessfully accepted security parameter from the application.
NRF_ERROR_INVALID_ADDRInvalid pointer supplied.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
NRF_ERROR_INVALID_STATEInvalid state to perform operation.
BLE_ERROR_INVALID_CONN_HANDLEInvalid connection handle supplied.
NRF_ERROR_NOT_SUPPORTEDSetting of sign or link fields in ble_gap_sec_kdist_t not supported.
uint32_t sd_ble_gap_tx_power_set ( int8_t  tx_power)

Set the radio's transmit power.

Parameters
[in]tx_powerRadio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, 3, and 4 dBm).
Note
The +3dBm setting is only available on nRF52 series ICs.
The -30dBm setting is only available on nRF51 series ICs.
The -40dBm setting is only available on nRF52 series ICs.
Return values
NRF_SUCCESSSuccessfully changed the transmit power.
NRF_ERROR_INVALID_PARAMInvalid parameter(s) supplied.
uint32_t sd_ble_gap_whitelist_set ( ble_gap_addr_t const *const *  pp_wl_addrs,
uint8_t  len 
)

Set the active whitelist in the SoftDevice.

Note
Only one whitelist can be used at a time and the whitelist is shared between the BLE roles. The whitelist cannot be set if a BLE role is using the whitelist.
If an address is resolved using the information in the device identity list, then the whitelist filter policy applies to the peer identity address and not the resolvable address sent on air.
Relevant Message Sequence Charts
Whitelist Sharing
Scan Private Devices
Parameters
[in]pp_wl_addrsPointer to a whitelist of peer addresses, if NULL the whitelist will be cleared.
[in]lenLength of the whitelist, maximum BLE_GAP_WHITELIST_ADDR_MAX_COUNT.
Return values
NRF_SUCCESSThe whitelist is successfully set/cleared.
NRF_ERROR_INVALID_ADDRThe whitelist (or one of its entries) provided is invalid.
BLE_ERROR_GAP_WHITELIST_IN_USEThe whitelist is in use by a BLE role and cannot be set or cleared.
BLE_ERROR_GAP_INVALID_BLE_ADDRInvalid address type is supplied.
NRF_ERROR_DATA_SIZEThe given whitelist size is invalid (zero or too large); this can only return when pp_wl_addrs is not NULL.

Documentation feedback | Developer Zone | Subscribe | Updated