BLE FOTA APP

Dependencies:   BLE_API mbed

It doesn't work with the default FOTA bootloader. It use NVIC_SystemReset() to enter a bootloader.

Committer:
yihui
Date:
Fri Oct 10 03:36:28 2014 +0000
Revision:
1:a607cd9655d7
use NVIC_SystemReset() to run bootloader

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yihui 1:a607cd9655d7 1 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
yihui 1:a607cd9655d7 2 *
yihui 1:a607cd9655d7 3 * The information contained herein is confidential property of Nordic Semiconductor. The use,
yihui 1:a607cd9655d7 4 * copying, transfer or disclosure of such information is prohibited except by express written
yihui 1:a607cd9655d7 5 * agreement with Nordic Semiconductor.
yihui 1:a607cd9655d7 6 *
yihui 1:a607cd9655d7 7 */
yihui 1:a607cd9655d7 8 /**
yihui 1:a607cd9655d7 9 @addtogroup BLE_GAP Generic Access Profile (GAP)
yihui 1:a607cd9655d7 10 @{
yihui 1:a607cd9655d7 11 @brief Definitions and prototypes for the GAP interface.
yihui 1:a607cd9655d7 12 */
yihui 1:a607cd9655d7 13
yihui 1:a607cd9655d7 14 #ifndef BLE_GAP_H__
yihui 1:a607cd9655d7 15 #define BLE_GAP_H__
yihui 1:a607cd9655d7 16
yihui 1:a607cd9655d7 17 #include "ble_types.h"
yihui 1:a607cd9655d7 18 #include "ble_ranges.h"
yihui 1:a607cd9655d7 19 #include "nrf_svc.h"
yihui 1:a607cd9655d7 20
yihui 1:a607cd9655d7 21
yihui 1:a607cd9655d7 22 /**@addtogroup BLE_GAP_ENUMERATIONS Enumerations
yihui 1:a607cd9655d7 23 * @{ */
yihui 1:a607cd9655d7 24
yihui 1:a607cd9655d7 25 /**@brief GAP API SVC numbers.
yihui 1:a607cd9655d7 26 */
yihui 1:a607cd9655d7 27 enum BLE_GAP_SVCS
yihui 1:a607cd9655d7 28 {
yihui 1:a607cd9655d7 29 SD_BLE_GAP_ADDRESS_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */
yihui 1:a607cd9655d7 30 SD_BLE_GAP_ADDRESS_GET, /**< Get own Bluetooth Address. */
yihui 1:a607cd9655d7 31 SD_BLE_GAP_ADV_DATA_SET, /**< Set Advertisement Data. */
yihui 1:a607cd9655d7 32 SD_BLE_GAP_ADV_START, /**< Start Advertising. */
yihui 1:a607cd9655d7 33 SD_BLE_GAP_ADV_STOP, /**< Stop Advertising. */
yihui 1:a607cd9655d7 34 SD_BLE_GAP_CONN_PARAM_UPDATE, /**< Connection Parameter Update. */
yihui 1:a607cd9655d7 35 SD_BLE_GAP_DISCONNECT, /**< Disconnect. */
yihui 1:a607cd9655d7 36 SD_BLE_GAP_TX_POWER_SET, /**< Set TX Power. */
yihui 1:a607cd9655d7 37 SD_BLE_GAP_APPEARANCE_SET, /**< Set Appearance. */
yihui 1:a607cd9655d7 38 SD_BLE_GAP_APPEARANCE_GET, /**< Get Appearance. */
yihui 1:a607cd9655d7 39 SD_BLE_GAP_PPCP_SET, /**< Set PPCP. */
yihui 1:a607cd9655d7 40 SD_BLE_GAP_PPCP_GET, /**< Get PPCP. */
yihui 1:a607cd9655d7 41 SD_BLE_GAP_DEVICE_NAME_SET, /**< Set Device Name. */
yihui 1:a607cd9655d7 42 SD_BLE_GAP_DEVICE_NAME_GET, /**< Get Device Name. */
yihui 1:a607cd9655d7 43 SD_BLE_GAP_AUTHENTICATE, /**< Initiate Pairing/Bonding. */
yihui 1:a607cd9655d7 44 SD_BLE_GAP_SEC_PARAMS_REPLY, /**< Reply with Security Parameters. */
yihui 1:a607cd9655d7 45 SD_BLE_GAP_AUTH_KEY_REPLY, /**< Reply with an authentication key. */
yihui 1:a607cd9655d7 46 SD_BLE_GAP_SEC_INFO_REPLY, /**< Reply with Security Information. */
yihui 1:a607cd9655d7 47 SD_BLE_GAP_CONN_SEC_GET, /**< Obtain connection security level. */
yihui 1:a607cd9655d7 48 SD_BLE_GAP_RSSI_START, /**< Start reporting of changes in RSSI. */
yihui 1:a607cd9655d7 49 SD_BLE_GAP_RSSI_STOP, /**< Stop reporting of changes in RSSI. */
yihui 1:a607cd9655d7 50 };
yihui 1:a607cd9655d7 51 /**@} */
yihui 1:a607cd9655d7 52
yihui 1:a607cd9655d7 53 /**@addtogroup BLE_GAP_DEFINES Defines
yihui 1:a607cd9655d7 54 * @{ */
yihui 1:a607cd9655d7 55
yihui 1:a607cd9655d7 56 /**@defgroup BLE_ERRORS_GAP SVC return values specific to GAP
yihui 1:a607cd9655d7 57 * @{ */
yihui 1:a607cd9655d7 58 #define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */
yihui 1:a607cd9655d7 59 #define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */
yihui 1:a607cd9655d7 60 #define BLE_ERROR_GAP_INVALID_BLE_ADDR (NRF_GAP_ERR_BASE + 0x002) /**< The upper two bits of the address do not correspond to the specified address type. */
yihui 1:a607cd9655d7 61 /**@} */
yihui 1:a607cd9655d7 62
yihui 1:a607cd9655d7 63
yihui 1:a607cd9655d7 64 /**@defgroup BLE_GAP_ROLES GAP Roles
yihui 1:a607cd9655d7 65 * @note Not explicitly used in peripheral API, but will be relevant for central API.
yihui 1:a607cd9655d7 66 * @{ */
yihui 1:a607cd9655d7 67 #define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */
yihui 1:a607cd9655d7 68 #define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */
yihui 1:a607cd9655d7 69 #define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */
yihui 1:a607cd9655d7 70 /**@} */
yihui 1:a607cd9655d7 71
yihui 1:a607cd9655d7 72
yihui 1:a607cd9655d7 73 /**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources
yihui 1:a607cd9655d7 74 * @{ */
yihui 1:a607cd9655d7 75 #define BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT 0x00 /**< Advertisement timeout. */
yihui 1:a607cd9655d7 76 #define BLE_GAP_TIMEOUT_SRC_SECURITY_REQUEST 0x01 /**< Security request timeout. */
yihui 1:a607cd9655d7 77 /**@} */
yihui 1:a607cd9655d7 78
yihui 1:a607cd9655d7 79
yihui 1:a607cd9655d7 80 /**@defgroup BLE_GAP_ADDR_TYPES GAP Address types
yihui 1:a607cd9655d7 81 * @{ */
yihui 1:a607cd9655d7 82 #define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public address. */
yihui 1:a607cd9655d7 83 #define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random Static address. */
yihui 1:a607cd9655d7 84 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Private Resolvable address. */
yihui 1:a607cd9655d7 85 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Private Non-Resolvable address. */
yihui 1:a607cd9655d7 86 /**@} */
yihui 1:a607cd9655d7 87
yihui 1:a607cd9655d7 88 /**@defgroup BLE_GAP_ADDR_CYCLE_MODES GAP Address cycle modes
yihui 1:a607cd9655d7 89 * @{ */
yihui 1:a607cd9655d7 90 #define BLE_GAP_ADDR_CYCLE_MODE_NONE 0x00 /**< Set addresses directly, no automatic address cycling. */
yihui 1:a607cd9655d7 91 #define BLE_GAP_ADDR_CYCLE_MODE_AUTO 0x01 /**< Automatically generate and update private addresses. */
yihui 1:a607cd9655d7 92 /** @} */
yihui 1:a607cd9655d7 93
yihui 1:a607cd9655d7 94 /**@brief The default interval in seconds at which a private address is refreshed when address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO. */
yihui 1:a607cd9655d7 95 #define BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S (60 * 15)
yihui 1:a607cd9655d7 96
yihui 1:a607cd9655d7 97 /** @brief BLE address length. */
yihui 1:a607cd9655d7 98 #define BLE_GAP_ADDR_LEN 6
yihui 1:a607cd9655d7 99
yihui 1:a607cd9655d7 100
yihui 1:a607cd9655d7 101 /**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format
yihui 1:a607cd9655d7 102 * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm
yihui 1:a607cd9655d7 103 * @{ */
yihui 1:a607cd9655d7 104 #define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */
yihui 1:a607cd9655d7 105 #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */
yihui 1:a607cd9655d7 106 #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */
yihui 1:a607cd9655d7 107 #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */
yihui 1:a607cd9655d7 108 #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */
yihui 1:a607cd9655d7 109 #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */
yihui 1:a607cd9655d7 110 #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */
yihui 1:a607cd9655d7 111 #define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */
yihui 1:a607cd9655d7 112 #define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */
yihui 1:a607cd9655d7 113 #define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */
yihui 1:a607cd9655d7 114 #define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */
yihui 1:a607cd9655d7 115 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */
yihui 1:a607cd9655d7 116 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */
yihui 1:a607cd9655d7 117 #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */
yihui 1:a607cd9655d7 118 #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */
yihui 1:a607cd9655d7 119 #define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */
yihui 1:a607cd9655d7 120 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */
yihui 1:a607cd9655d7 121 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */
yihui 1:a607cd9655d7 122 #define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data - 16-bit UUID. */
yihui 1:a607cd9655d7 123 #define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */
yihui 1:a607cd9655d7 124 #define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */
yihui 1:a607cd9655d7 125 #define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */
yihui 1:a607cd9655d7 126 #define BLE_GAP_AD_TYPE_ADVERTISING_INTERVAL 0x1A /**< Advertising Interval. */
yihui 1:a607cd9655d7 127 #define BLE_GAP_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS 0x1B /**< LE Bluetooth Device Address. */
yihui 1:a607cd9655d7 128 #define BLE_GAP_AD_TYPE_LE_ROLE 0x1C /**< LE Role. */
yihui 1:a607cd9655d7 129 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C256 0x1D /**< Simple Pairing Hash C-256. */
yihui 1:a607cd9655d7 130 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 0x1E /**< Simple Pairing Randomizer R-256. */
yihui 1:a607cd9655d7 131 #define BLE_GAP_AD_TYPE_SERVICE_DATA_32BIT_UUID 0x20 /**< Service Data - 32-bit UUID. */
yihui 1:a607cd9655d7 132 #define BLE_GAP_AD_TYPE_SERVICE_DATA_128BIT_UUID 0x21 /**< Service Data - 128-bit UUID. */
yihui 1:a607cd9655d7 133 #define BLE_GAP_AD_TYPE_3D_INFORMATION_DATA 0x3D /**< 3D Information Data. */
yihui 1:a607cd9655d7 134 #define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */
yihui 1:a607cd9655d7 135 /**@} */
yihui 1:a607cd9655d7 136
yihui 1:a607cd9655d7 137
yihui 1:a607cd9655d7 138 /**@defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags
yihui 1:a607cd9655d7 139 * @{ */
yihui 1:a607cd9655d7 140 #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */
yihui 1:a607cd9655d7 141 #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */
yihui 1:a607cd9655d7 142 #define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */
yihui 1:a607cd9655d7 143 #define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */
yihui 1:a607cd9655d7 144 #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */
yihui 1:a607cd9655d7 145 #define BLE_GAP_ADV_FLAGS_LE_ONLY_LIMITED_DISC_MODE (BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE Limited Discoverable Mode, BR/EDR not supported. */
yihui 1:a607cd9655d7 146 #define BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE (BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE | BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED) /**< LE General Discoverable Mode, BR/EDR not supported. */
yihui 1:a607cd9655d7 147 /**@} */
yihui 1:a607cd9655d7 148
yihui 1:a607cd9655d7 149
yihui 1:a607cd9655d7 150 /**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min
yihui 1:a607cd9655d7 151 * @{ */
yihui 1:a607cd9655d7 152 #define BLE_GAP_ADV_INTERVAL_MIN 0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */
yihui 1:a607cd9655d7 153 #define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */
yihui 1:a607cd9655d7 154 #define BLE_GAP_ADV_INTERVAL_MAX 0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */
yihui 1:a607cd9655d7 155 /**@} */
yihui 1:a607cd9655d7 156
yihui 1:a607cd9655d7 157
yihui 1:a607cd9655d7 158 /**@brief Maximum size of advertising data in octets. */
yihui 1:a607cd9655d7 159 #define BLE_GAP_ADV_MAX_SIZE 31
yihui 1:a607cd9655d7 160
yihui 1:a607cd9655d7 161
yihui 1:a607cd9655d7 162 /**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types
yihui 1:a607cd9655d7 163 * @{ */
yihui 1:a607cd9655d7 164 #define BLE_GAP_ADV_TYPE_ADV_IND 0x00 /**< Connectable undirected. */
yihui 1:a607cd9655d7 165 #define BLE_GAP_ADV_TYPE_ADV_DIRECT_IND 0x01 /**< Connectable directed. */
yihui 1:a607cd9655d7 166 #define BLE_GAP_ADV_TYPE_ADV_SCAN_IND 0x02 /**< Scannable undirected. */
yihui 1:a607cd9655d7 167 #define BLE_GAP_ADV_TYPE_ADV_NONCONN_IND 0x03 /**< Non connectable undirected. */
yihui 1:a607cd9655d7 168 /**@} */
yihui 1:a607cd9655d7 169
yihui 1:a607cd9655d7 170
yihui 1:a607cd9655d7 171 /**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies
yihui 1:a607cd9655d7 172 * @{ */
yihui 1:a607cd9655d7 173 #define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */
yihui 1:a607cd9655d7 174 #define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */
yihui 1:a607cd9655d7 175 #define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */
yihui 1:a607cd9655d7 176 #define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */
yihui 1:a607cd9655d7 177 /**@} */
yihui 1:a607cd9655d7 178
yihui 1:a607cd9655d7 179
yihui 1:a607cd9655d7 180 /**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values
yihui 1:a607cd9655d7 181 * @{ */
yihui 1:a607cd9655d7 182 #define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX 180 /**< Maximum advertising time in limited discoverable mode (TGAP(lim_adv_timeout) = 180s in spec (Addendum 2)). */
yihui 1:a607cd9655d7 183 #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED 0 /**< Unlimited advertising in general discoverable mode. */
yihui 1:a607cd9655d7 184 /**@} */
yihui 1:a607cd9655d7 185
yihui 1:a607cd9655d7 186
yihui 1:a607cd9655d7 187 /**@defgroup BLE_GAP_DISC_MODES GAP Discovery modes
yihui 1:a607cd9655d7 188 * @{ */
yihui 1:a607cd9655d7 189 #define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */
yihui 1:a607cd9655d7 190 #define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */
yihui 1:a607cd9655d7 191 #define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */
yihui 1:a607cd9655d7 192 /**@} */
yihui 1:a607cd9655d7 193
yihui 1:a607cd9655d7 194 /**@defgroup BLE_GAP_IO_CAPS GAP IO Capabilities
yihui 1:a607cd9655d7 195 * @{ */
yihui 1:a607cd9655d7 196 #define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */
yihui 1:a607cd9655d7 197 #define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */
yihui 1:a607cd9655d7 198 #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */
yihui 1:a607cd9655d7 199 #define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */
yihui 1:a607cd9655d7 200 #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */
yihui 1:a607cd9655d7 201 /**@} */
yihui 1:a607cd9655d7 202
yihui 1:a607cd9655d7 203
yihui 1:a607cd9655d7 204 /**@defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types
yihui 1:a607cd9655d7 205 * @{ */
yihui 1:a607cd9655d7 206 #define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */
yihui 1:a607cd9655d7 207 #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */
yihui 1:a607cd9655d7 208 #define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */
yihui 1:a607cd9655d7 209 /**@} */
yihui 1:a607cd9655d7 210
yihui 1:a607cd9655d7 211 /**@defgroup BLE_GAP_SEC_STATUS GAP Security status
yihui 1:a607cd9655d7 212 * @{ */
yihui 1:a607cd9655d7 213 #define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Successful parameters. */
yihui 1:a607cd9655d7 214 #define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */
yihui 1:a607cd9655d7 215 #define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */
yihui 1:a607cd9655d7 216 #define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user cancelled or other). */
yihui 1:a607cd9655d7 217 #define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */
yihui 1:a607cd9655d7 218 #define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */
yihui 1:a607cd9655d7 219 #define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */
yihui 1:a607cd9655d7 220 #define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */
yihui 1:a607cd9655d7 221 #define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */
yihui 1:a607cd9655d7 222 #define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */
yihui 1:a607cd9655d7 223 #define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */
yihui 1:a607cd9655d7 224 #define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */
yihui 1:a607cd9655d7 225 #define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */
yihui 1:a607cd9655d7 226 /**@} */
yihui 1:a607cd9655d7 227
yihui 1:a607cd9655d7 228 /**@defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources
yihui 1:a607cd9655d7 229 * @{ */
yihui 1:a607cd9655d7 230 #define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */
yihui 1:a607cd9655d7 231 #define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */
yihui 1:a607cd9655d7 232 /**@} */
yihui 1:a607cd9655d7 233
yihui 1:a607cd9655d7 234 /**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
yihui 1:a607cd9655d7 235 * @{ */
yihui 1:a607cd9655d7 236 #define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connction interval specified in connect parameters. */
yihui 1:a607cd9655d7 237 #define BLE_GAP_CP_MIN_CONN_INTVL_MIN 0x0006 /**< Lowest mimimum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */
yihui 1:a607cd9655d7 238 #define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
yihui 1:a607cd9655d7 239 #define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connction interval specified in connect parameters. */
yihui 1:a607cd9655d7 240 #define BLE_GAP_CP_MAX_CONN_INTVL_MIN 0x0006 /**< Lowest maximum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */
yihui 1:a607cd9655d7 241 #define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
yihui 1:a607cd9655d7 242 #define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x03E8 /**< Highest slave latency permitted, in connection events. */
yihui 1:a607cd9655d7 243 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */
yihui 1:a607cd9655d7 244 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */
yihui 1:a607cd9655d7 245 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */
yihui 1:a607cd9655d7 246 /**@} */
yihui 1:a607cd9655d7 247
yihui 1:a607cd9655d7 248
yihui 1:a607cd9655d7 249 /**@brief GAP device name maximum length. */
yihui 1:a607cd9655d7 250 #define BLE_GAP_DEVNAME_MAX_LEN 31
yihui 1:a607cd9655d7 251
yihui 1:a607cd9655d7 252
yihui 1:a607cd9655d7 253 /**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
yihui 1:a607cd9655d7 254 *
yihui 1:a607cd9655d7 255 * See @ref ble_gap_conn_sec_mode_t.
yihui 1:a607cd9655d7 256 * @{ */
yihui 1:a607cd9655d7 257 /**@brief Set sec_mode pointed to by ptr to have no access rights.*/
yihui 1:a607cd9655d7 258 #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0)
yihui 1:a607cd9655d7 259 /**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/
yihui 1:a607cd9655d7 260 #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0)
yihui 1:a607cd9655d7 261 /**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
yihui 1:a607cd9655d7 262 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0)
yihui 1:a607cd9655d7 263 /**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
yihui 1:a607cd9655d7 264 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0)
yihui 1:a607cd9655d7 265 /**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
yihui 1:a607cd9655d7 266 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0)
yihui 1:a607cd9655d7 267 /**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
yihui 1:a607cd9655d7 268 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0)
yihui 1:a607cd9655d7 269 /**@} */
yihui 1:a607cd9655d7 270
yihui 1:a607cd9655d7 271
yihui 1:a607cd9655d7 272 /**@brief GAP Security Key Length. */
yihui 1:a607cd9655d7 273 #define BLE_GAP_SEC_KEY_LEN 16
yihui 1:a607cd9655d7 274
yihui 1:a607cd9655d7 275 /**@brief GAP Passkey Length. */
yihui 1:a607cd9655d7 276 #define BLE_GAP_PASSKEY_LEN 6
yihui 1:a607cd9655d7 277
yihui 1:a607cd9655d7 278 /**@brief Maximum amount of addresses in a whitelist. */
yihui 1:a607cd9655d7 279 #define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8)
yihui 1:a607cd9655d7 280
yihui 1:a607cd9655d7 281 /**@brief Maximum amount of IRKs in a whitelist.
yihui 1:a607cd9655d7 282 * @note The number of IRKs is limited to 8, even if the hardware supports more.
yihui 1:a607cd9655d7 283 */
yihui 1:a607cd9655d7 284 #define BLE_GAP_WHITELIST_IRK_MAX_COUNT (8)
yihui 1:a607cd9655d7 285
yihui 1:a607cd9655d7 286 /**@defgroup GAP_SEC_MODES GAP Security Modes
yihui 1:a607cd9655d7 287 * @{ */
yihui 1:a607cd9655d7 288 #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */
yihui 1:a607cd9655d7 289 /**@} */
yihui 1:a607cd9655d7 290
yihui 1:a607cd9655d7 291 /**@} */
yihui 1:a607cd9655d7 292
yihui 1:a607cd9655d7 293 /**@addtogroup BLE_GAP_STRUCTURES Structures
yihui 1:a607cd9655d7 294 * @{ */
yihui 1:a607cd9655d7 295
yihui 1:a607cd9655d7 296 /**@brief Bluetooth Low Energy address. */
yihui 1:a607cd9655d7 297 typedef struct
yihui 1:a607cd9655d7 298 {
yihui 1:a607cd9655d7 299 uint8_t addr_type; /**< See @ref BLE_GAP_ADDR_TYPES. */
yihui 1:a607cd9655d7 300 uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */
yihui 1:a607cd9655d7 301 } ble_gap_addr_t;
yihui 1:a607cd9655d7 302
yihui 1:a607cd9655d7 303
yihui 1:a607cd9655d7 304 /**@brief GAP connection parameters.
yihui 1:a607cd9655d7 305 *
yihui 1:a607cd9655d7 306 * @note When ble_conn_params_t is received in an event, both min_conn_interval and
yihui 1:a607cd9655d7 307 * max_conn_interval will be equal to the connection interval set by the central.
yihui 1:a607cd9655d7 308 */
yihui 1:a607cd9655d7 309 typedef struct
yihui 1:a607cd9655d7 310 {
yihui 1:a607cd9655d7 311 uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
yihui 1:a607cd9655d7 312 uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
yihui 1:a607cd9655d7 313 uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
yihui 1:a607cd9655d7 314 uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
yihui 1:a607cd9655d7 315 } ble_gap_conn_params_t;
yihui 1:a607cd9655d7 316
yihui 1:a607cd9655d7 317
yihui 1:a607cd9655d7 318 /**@brief GAP link requirements.
yihui 1:a607cd9655d7 319 *
yihui 1:a607cd9655d7 320 * See Bluetooth Core specification, Volume 3 Part C 10.2 for details.
yihui 1:a607cd9655d7 321 *
yihui 1:a607cd9655d7 322 * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n
yihui 1:a607cd9655d7 323 * Security Mode 1 Level 1: No security is needed (aka open link).\n
yihui 1:a607cd9655d7 324 * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n
yihui 1:a607cd9655d7 325 * Security Mode 1 Level 3: MITM protected encrypted link required.\n
yihui 1:a607cd9655d7 326 * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n
yihui 1:a607cd9655d7 327 * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n
yihui 1:a607cd9655d7 328 */
yihui 1:a607cd9655d7 329 typedef struct
yihui 1:a607cd9655d7 330 {
yihui 1:a607cd9655d7 331 uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */
yihui 1:a607cd9655d7 332 uint8_t lv : 4; /**< Level (1, 2 or 3), 0 for no permissions at all. */
yihui 1:a607cd9655d7 333
yihui 1:a607cd9655d7 334 } ble_gap_conn_sec_mode_t;
yihui 1:a607cd9655d7 335
yihui 1:a607cd9655d7 336
yihui 1:a607cd9655d7 337 /**@brief GAP connection security status.*/
yihui 1:a607cd9655d7 338 typedef struct
yihui 1:a607cd9655d7 339 {
yihui 1:a607cd9655d7 340 ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/
yihui 1:a607cd9655d7 341 uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets (only applicable for bonding procedures). */
yihui 1:a607cd9655d7 342 } ble_gap_conn_sec_t;
yihui 1:a607cd9655d7 343
yihui 1:a607cd9655d7 344
yihui 1:a607cd9655d7 345 /**@brief Identity Resolving Key. */
yihui 1:a607cd9655d7 346 typedef struct
yihui 1:a607cd9655d7 347 {
yihui 1:a607cd9655d7 348 uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */
yihui 1:a607cd9655d7 349 } ble_gap_irk_t;
yihui 1:a607cd9655d7 350
yihui 1:a607cd9655d7 351
yihui 1:a607cd9655d7 352 /**@brief Whitelist structure. */
yihui 1:a607cd9655d7 353 typedef struct
yihui 1:a607cd9655d7 354 {
yihui 1:a607cd9655d7 355 ble_gap_addr_t ** pp_addrs; /**< Pointer to array of device address pointers, pointing to addresses to be used in whitelist. NULL if none are given. */
yihui 1:a607cd9655d7 356 uint8_t addr_count; /**< Count of device addresses in array, up to @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. */
yihui 1:a607cd9655d7 357 ble_gap_irk_t ** pp_irks; /**< Pointer to array of Identity Resolving Key (IRK) pointers, each pointing to an IRK in the whitelist. NULL if none are given. */
yihui 1:a607cd9655d7 358 uint8_t irk_count; /**< Count of IRKs in array, up to @ref BLE_GAP_WHITELIST_IRK_MAX_COUNT. */
yihui 1:a607cd9655d7 359 } ble_gap_whitelist_t;
yihui 1:a607cd9655d7 360
yihui 1:a607cd9655d7 361
yihui 1:a607cd9655d7 362 /**@brief GAP advertising parameters.*/
yihui 1:a607cd9655d7 363 typedef struct
yihui 1:a607cd9655d7 364 {
yihui 1:a607cd9655d7 365 uint8_t type; /**< See @ref BLE_GAP_ADV_TYPES. */
yihui 1:a607cd9655d7 366 ble_gap_addr_t* p_peer_addr; /**< For BLE_GAP_CONN_MODE_DIRECTED mode only, known peer address. */
yihui 1:a607cd9655d7 367 uint8_t fp; /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */
yihui 1:a607cd9655d7 368 ble_gap_whitelist_t * p_whitelist; /**< Pointer to whitelist, NULL if none is given. */
yihui 1:a607cd9655d7 369 uint16_t interval; /**< Advertising interval between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s), see @ref BLE_GAP_ADV_INTERVALS. This parameter must be set to 0 if type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND. */
yihui 1:a607cd9655d7 370 uint16_t timeout; /**< Advertising timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. See also @ref BLE_GAP_ADV_TIMEOUT_VALUES. This parameter must be set to 0 if type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND. */
yihui 1:a607cd9655d7 371 } ble_gap_adv_params_t;
yihui 1:a607cd9655d7 372
yihui 1:a607cd9655d7 373
yihui 1:a607cd9655d7 374 /**@brief GAP scanning parameters. */
yihui 1:a607cd9655d7 375 typedef struct
yihui 1:a607cd9655d7 376 {
yihui 1:a607cd9655d7 377 uint8_t filter; /**< Filter based on discovery mode, see @ref BLE_GAP_DISC_MODES. */
yihui 1:a607cd9655d7 378 uint8_t active : 1; /**< If 1, perform active scanning (scan requests). */
yihui 1:a607cd9655d7 379 uint8_t selective : 1; /**< If 1, ignore unknown devices (non whitelisted). */
yihui 1:a607cd9655d7 380 uint16_t interval; /**< Scan interval between 0x0020 and 0x4000 in 0.625ms units (20ms to 10.24s). */
yihui 1:a607cd9655d7 381 uint16_t window; /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
yihui 1:a607cd9655d7 382 uint16_t timeout; /**< Scan timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. */
yihui 1:a607cd9655d7 383 } ble_gap_scan_params_t;
yihui 1:a607cd9655d7 384
yihui 1:a607cd9655d7 385
yihui 1:a607cd9655d7 386 /**@brief GAP security parameters. */
yihui 1:a607cd9655d7 387 typedef struct
yihui 1:a607cd9655d7 388 {
yihui 1:a607cd9655d7 389 uint16_t timeout; /**< Timeout for SMP transactions or Security Request in seconds, see @ref sd_ble_gap_authenticate and @ref sd_ble_gap_sec_params_reply for more information. */
yihui 1:a607cd9655d7 390 uint8_t bond : 1; /**< Perform bonding. */
yihui 1:a607cd9655d7 391 uint8_t mitm : 1; /**< Man In The Middle protection required. */
yihui 1:a607cd9655d7 392 uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */
yihui 1:a607cd9655d7 393 uint8_t oob : 1; /**< Out Of Band data available. */
yihui 1:a607cd9655d7 394 uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. */
yihui 1:a607cd9655d7 395 uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */
yihui 1:a607cd9655d7 396 } ble_gap_sec_params_t;
yihui 1:a607cd9655d7 397
yihui 1:a607cd9655d7 398
yihui 1:a607cd9655d7 399 /**@brief GAP Encryption Information. */
yihui 1:a607cd9655d7 400 typedef struct
yihui 1:a607cd9655d7 401 {
yihui 1:a607cd9655d7 402 uint16_t div; /**< Encryption Diversifier. */
yihui 1:a607cd9655d7 403 uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */
yihui 1:a607cd9655d7 404 uint8_t auth : 1; /**< Authenticated Key. */
yihui 1:a607cd9655d7 405 uint8_t ltk_len : 7; /**< LTK length in octets. */
yihui 1:a607cd9655d7 406 } ble_gap_enc_info_t;
yihui 1:a607cd9655d7 407
yihui 1:a607cd9655d7 408
yihui 1:a607cd9655d7 409 /**@brief GAP Master Identification. */
yihui 1:a607cd9655d7 410 typedef struct
yihui 1:a607cd9655d7 411 {
yihui 1:a607cd9655d7 412 uint16_t ediv; /**< Encrypted Diversifier. */
yihui 1:a607cd9655d7 413 uint8_t rand[8]; /**< Random Number. */
yihui 1:a607cd9655d7 414 } ble_gap_master_id_t;
yihui 1:a607cd9655d7 415
yihui 1:a607cd9655d7 416
yihui 1:a607cd9655d7 417 /**@brief GAP Identity Information. */
yihui 1:a607cd9655d7 418 typedef struct
yihui 1:a607cd9655d7 419 {
yihui 1:a607cd9655d7 420 ble_gap_addr_t addr; /**< Bluetooth address to which this key applies. */
yihui 1:a607cd9655d7 421 uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Identity Resolution Key. */
yihui 1:a607cd9655d7 422 } ble_gap_id_info_t;
yihui 1:a607cd9655d7 423
yihui 1:a607cd9655d7 424
yihui 1:a607cd9655d7 425 /**@brief GAP Signing Information. */
yihui 1:a607cd9655d7 426 typedef struct
yihui 1:a607cd9655d7 427 {
yihui 1:a607cd9655d7 428 uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /* Connection Signature Resolving Key. */
yihui 1:a607cd9655d7 429 } ble_gap_sign_info_t;
yihui 1:a607cd9655d7 430
yihui 1:a607cd9655d7 431
yihui 1:a607cd9655d7 432 /**@brief GAP Event IDs.
yihui 1:a607cd9655d7 433 * Those IDs uniquely identify an event coming from the stack to the application.
yihui 1:a607cd9655d7 434 */
yihui 1:a607cd9655d7 435 enum BLE_GAP_EVTS
yihui 1:a607cd9655d7 436 {
yihui 1:a607cd9655d7 437 BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connection established. */
yihui 1:a607cd9655d7 438 BLE_GAP_EVT_DISCONNECTED, /**< Disconnected from peer. */
yihui 1:a607cd9655d7 439 BLE_GAP_EVT_CONN_PARAM_UPDATE, /**< Connection Parameters updated. */
yihui 1:a607cd9655d7 440 BLE_GAP_EVT_SEC_PARAMS_REQUEST, /**< Request to provide security parameters. */
yihui 1:a607cd9655d7 441 BLE_GAP_EVT_SEC_INFO_REQUEST, /**< Request to provide security information. */
yihui 1:a607cd9655d7 442 BLE_GAP_EVT_PASSKEY_DISPLAY, /**< Request to display a passkey to the user. */
yihui 1:a607cd9655d7 443 BLE_GAP_EVT_AUTH_KEY_REQUEST, /**< Request to provide an authentication key. */
yihui 1:a607cd9655d7 444 BLE_GAP_EVT_AUTH_STATUS, /**< Authentication procedure completed with status. */
yihui 1:a607cd9655d7 445 BLE_GAP_EVT_CONN_SEC_UPDATE, /**< Connection security updated. */
yihui 1:a607cd9655d7 446 BLE_GAP_EVT_TIMEOUT, /**< Timeout expired. */
yihui 1:a607cd9655d7 447 BLE_GAP_EVT_RSSI_CHANGED, /**< Signal strength measurement report. */
yihui 1:a607cd9655d7 448 };
yihui 1:a607cd9655d7 449
yihui 1:a607cd9655d7 450
yihui 1:a607cd9655d7 451 /**
yihui 1:a607cd9655d7 452 * @brief GAP Option IDs.
yihui 1:a607cd9655d7 453 * IDs that uniquely identify a GAP option.
yihui 1:a607cd9655d7 454 */
yihui 1:a607cd9655d7 455 enum BLE_GAP_OPTS
yihui 1:a607cd9655d7 456 {
yihui 1:a607cd9655d7 457 BLE_GAP_OPT_LOCAL_CONN_LATENCY = BLE_GAP_OPT_BASE, /**< Local connection latency. */
yihui 1:a607cd9655d7 458 BLE_GAP_OPT_PASSKEY, /**< Set passkey to be used during pairing. This option can be used to make the SoftDevice use an application provided passkey instead of generating a random passkey.*/
yihui 1:a607cd9655d7 459 BLE_GAP_OPT_PRIVACY, /**< Set or get custom IRK or custom private address cycle interval. */
yihui 1:a607cd9655d7 460 };
yihui 1:a607cd9655d7 461 /**@} */
yihui 1:a607cd9655d7 462
yihui 1:a607cd9655d7 463
yihui 1:a607cd9655d7 464 /**@brief Event data for connected event. */
yihui 1:a607cd9655d7 465 typedef struct
yihui 1:a607cd9655d7 466 {
yihui 1:a607cd9655d7 467 ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
yihui 1:a607cd9655d7 468 uint8_t irk_match :1; /**< If 1, peer device's address resolved using an IRK. */
yihui 1:a607cd9655d7 469 uint8_t irk_match_idx :7; /**< Index in IRK list where the address was matched. */
yihui 1:a607cd9655d7 470 ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
yihui 1:a607cd9655d7 471 } ble_gap_evt_connected_t;
yihui 1:a607cd9655d7 472
yihui 1:a607cd9655d7 473
yihui 1:a607cd9655d7 474 /**@brief Event data for disconnected event. */
yihui 1:a607cd9655d7 475 typedef struct
yihui 1:a607cd9655d7 476 {
yihui 1:a607cd9655d7 477 uint8_t reason; /**< HCI error code. */
yihui 1:a607cd9655d7 478 } ble_gap_evt_disconnected_t;
yihui 1:a607cd9655d7 479
yihui 1:a607cd9655d7 480
yihui 1:a607cd9655d7 481 /**@brief Event data for connection parameter update event. */
yihui 1:a607cd9655d7 482 typedef struct
yihui 1:a607cd9655d7 483 {
yihui 1:a607cd9655d7 484 ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
yihui 1:a607cd9655d7 485 } ble_gap_evt_conn_param_update_t;
yihui 1:a607cd9655d7 486
yihui 1:a607cd9655d7 487
yihui 1:a607cd9655d7 488 /**@brief Event data for security parameters request event. */
yihui 1:a607cd9655d7 489 typedef struct
yihui 1:a607cd9655d7 490 {
yihui 1:a607cd9655d7 491 ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */
yihui 1:a607cd9655d7 492 } ble_gap_evt_sec_params_request_t;
yihui 1:a607cd9655d7 493
yihui 1:a607cd9655d7 494
yihui 1:a607cd9655d7 495 /**@brief Event data for security info request event. */
yihui 1:a607cd9655d7 496 typedef struct
yihui 1:a607cd9655d7 497 {
yihui 1:a607cd9655d7 498 ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
yihui 1:a607cd9655d7 499 uint16_t div; /**< Encryption diversifier for LTK lookup. */
yihui 1:a607cd9655d7 500 uint8_t enc_info : 1; /**< If 1, Encryption Information required. */
yihui 1:a607cd9655d7 501 uint8_t id_info : 1; /**< If 1, Identity Information required. */
yihui 1:a607cd9655d7 502 uint8_t sign_info : 1; /**< If 1, Signing Information required. */
yihui 1:a607cd9655d7 503 } ble_gap_evt_sec_info_request_t;
yihui 1:a607cd9655d7 504
yihui 1:a607cd9655d7 505
yihui 1:a607cd9655d7 506 /**@brief Event data for passkey display event. */
yihui 1:a607cd9655d7 507 typedef struct
yihui 1:a607cd9655d7 508 {
yihui 1:a607cd9655d7 509 uint8_t passkey[BLE_GAP_PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
yihui 1:a607cd9655d7 510 } ble_gap_evt_passkey_display_t;
yihui 1:a607cd9655d7 511
yihui 1:a607cd9655d7 512
yihui 1:a607cd9655d7 513 /**@brief Event data for authentication key request event. */
yihui 1:a607cd9655d7 514 typedef struct
yihui 1:a607cd9655d7 515 {
yihui 1:a607cd9655d7 516 uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */
yihui 1:a607cd9655d7 517 } ble_gap_evt_auth_key_request_t;
yihui 1:a607cd9655d7 518
yihui 1:a607cd9655d7 519
yihui 1:a607cd9655d7 520 /**@brief Security levels supported.
yihui 1:a607cd9655d7 521 * @note See Bluetooth Specification Version 4.1 Volume 3, Part C, Chapter 10.
yihui 1:a607cd9655d7 522 */
yihui 1:a607cd9655d7 523 typedef struct
yihui 1:a607cd9655d7 524 {
yihui 1:a607cd9655d7 525 uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */
yihui 1:a607cd9655d7 526 uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */
yihui 1:a607cd9655d7 527 uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */
yihui 1:a607cd9655d7 528 } ble_gap_sec_levels_t;
yihui 1:a607cd9655d7 529
yihui 1:a607cd9655d7 530
yihui 1:a607cd9655d7 531 /**@brief Keys that have been exchanged. */
yihui 1:a607cd9655d7 532 typedef struct
yihui 1:a607cd9655d7 533 {
yihui 1:a607cd9655d7 534 uint8_t ltk : 1; /**< Long Term Key. */
yihui 1:a607cd9655d7 535 uint8_t ediv_rand : 1; /**< Encrypted Diversifier and Random value. */
yihui 1:a607cd9655d7 536 uint8_t irk : 1; /**< Identity Resolving Key. */
yihui 1:a607cd9655d7 537 uint8_t address : 1; /**< Public or static random address. */
yihui 1:a607cd9655d7 538 uint8_t csrk : 1; /**< Connection Signature Resolving Key. */
yihui 1:a607cd9655d7 539 } ble_gap_sec_keys_t;
yihui 1:a607cd9655d7 540
yihui 1:a607cd9655d7 541
yihui 1:a607cd9655d7 542 /**@brief Event data for authentication status event. */
yihui 1:a607cd9655d7 543 typedef struct
yihui 1:a607cd9655d7 544 {
yihui 1:a607cd9655d7 545 uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */
yihui 1:a607cd9655d7 546 uint8_t error_src; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */
yihui 1:a607cd9655d7 547 ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */
yihui 1:a607cd9655d7 548 ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */
yihui 1:a607cd9655d7 549 ble_gap_sec_keys_t periph_kex; /**< Bitmap stating which keys were exchanged (distributed) by the peripheral. */
yihui 1:a607cd9655d7 550 ble_gap_sec_keys_t central_kex; /**< Bitmap stating which keys were exchanged (distributed) by the central. */
yihui 1:a607cd9655d7 551 struct periph_keys_t
yihui 1:a607cd9655d7 552 {
yihui 1:a607cd9655d7 553 ble_gap_enc_info_t enc_info; /**< Peripheral's Encryption information. */
yihui 1:a607cd9655d7 554 } periph_keys; /**< Actual keys distributed from the Peripheral to the Central. */
yihui 1:a607cd9655d7 555 struct central_keys_t
yihui 1:a607cd9655d7 556 {
yihui 1:a607cd9655d7 557 ble_gap_irk_t irk; /**< Central's IRK. */
yihui 1:a607cd9655d7 558 ble_gap_addr_t id_info; /**< Central's Identity Info. */
yihui 1:a607cd9655d7 559 } central_keys; /**< Actual keys distributed from the Central to the Peripheral. */
yihui 1:a607cd9655d7 560 } ble_gap_evt_auth_status_t;
yihui 1:a607cd9655d7 561
yihui 1:a607cd9655d7 562
yihui 1:a607cd9655d7 563 /**@brief Event data for connection security update event. */
yihui 1:a607cd9655d7 564 typedef struct
yihui 1:a607cd9655d7 565 {
yihui 1:a607cd9655d7 566 ble_gap_conn_sec_t conn_sec; /**< Connection security level. */
yihui 1:a607cd9655d7 567 } ble_gap_evt_conn_sec_update_t;
yihui 1:a607cd9655d7 568
yihui 1:a607cd9655d7 569
yihui 1:a607cd9655d7 570 /**@brief Event data for timeout event. */
yihui 1:a607cd9655d7 571 typedef struct
yihui 1:a607cd9655d7 572 {
yihui 1:a607cd9655d7 573 uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */
yihui 1:a607cd9655d7 574 } ble_gap_evt_timeout_t;
yihui 1:a607cd9655d7 575
yihui 1:a607cd9655d7 576
yihui 1:a607cd9655d7 577 /**@brief Event data for advertisement report event. */
yihui 1:a607cd9655d7 578 typedef struct
yihui 1:a607cd9655d7 579 {
yihui 1:a607cd9655d7 580 int8_t rssi; /**< Received Signal Strength Indication in dBm. */
yihui 1:a607cd9655d7 581 } ble_gap_evt_rssi_changed_t;
yihui 1:a607cd9655d7 582
yihui 1:a607cd9655d7 583
yihui 1:a607cd9655d7 584 /**@brief GAP event callback event structure. */
yihui 1:a607cd9655d7 585 typedef struct
yihui 1:a607cd9655d7 586 {
yihui 1:a607cd9655d7 587 uint16_t conn_handle; /**< Connection Handle on which event occured. */
yihui 1:a607cd9655d7 588 union /**< union alternative identified by evt_id in enclosing struct. */
yihui 1:a607cd9655d7 589 {
yihui 1:a607cd9655d7 590 ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */
yihui 1:a607cd9655d7 591 ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */
yihui 1:a607cd9655d7 592 ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */
yihui 1:a607cd9655d7 593 ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */
yihui 1:a607cd9655d7 594 ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */
yihui 1:a607cd9655d7 595 ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */
yihui 1:a607cd9655d7 596 ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */
yihui 1:a607cd9655d7 597 ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */
yihui 1:a607cd9655d7 598 ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */
yihui 1:a607cd9655d7 599 ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */
yihui 1:a607cd9655d7 600 ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event parameters. */
yihui 1:a607cd9655d7 601 } params;
yihui 1:a607cd9655d7 602
yihui 1:a607cd9655d7 603 } ble_gap_evt_t;
yihui 1:a607cd9655d7 604
yihui 1:a607cd9655d7 605
yihui 1:a607cd9655d7 606 /**@brief Local connection latency option.
yihui 1:a607cd9655d7 607 *
yihui 1:a607cd9655d7 608 * Local connection latency is a feature which enables the slave to improve
yihui 1:a607cd9655d7 609 * current consumption by ignoring the slave latency set by the peer. The
yihui 1:a607cd9655d7 610 * local connection latency can only be set to a multiple of the slave latency,
yihui 1:a607cd9655d7 611 * and cannot be longer than half of the supervision timeout.
yihui 1:a607cd9655d7 612 *
yihui 1:a607cd9655d7 613 * Used with @ref sd_ble_opt_set to set the local connection latency. The
yihui 1:a607cd9655d7 614 * @ref sd_ble_opt_get is not supported for this option, but the actual
yihui 1:a607cd9655d7 615 * local connection latency (unless set to NULL) is set as a return parameter
yihui 1:a607cd9655d7 616 * when setting the option.
yihui 1:a607cd9655d7 617 *
yihui 1:a607cd9655d7 618 * @note The latency set will be truncated down to the closest slave latency event
yihui 1:a607cd9655d7 619 * multiple, or the nearest multiple before half of the supervision timeout.
yihui 1:a607cd9655d7 620 *
yihui 1:a607cd9655d7 621 * @note The local connection latency is default off, and needs to be set for new
yihui 1:a607cd9655d7 622 * connections and whenever the connection is updated.
yihui 1:a607cd9655d7 623 *
yihui 1:a607cd9655d7 624 * @retval ::NRF_SUCCESS Set successfully.
yihui 1:a607cd9655d7 625 * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
yihui 1:a607cd9655d7 626 * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
yihui 1:a607cd9655d7 627 */
yihui 1:a607cd9655d7 628 typedef struct
yihui 1:a607cd9655d7 629 {
yihui 1:a607cd9655d7 630 uint16_t conn_handle; /**< Connection Handle */
yihui 1:a607cd9655d7 631 uint16_t requested_latency; /**< Requested local connection latency. */
yihui 1:a607cd9655d7 632 uint16_t * p_actual_latency; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
yihui 1:a607cd9655d7 633 } ble_gap_opt_local_conn_latency_t;
yihui 1:a607cd9655d7 634
yihui 1:a607cd9655d7 635
yihui 1:a607cd9655d7 636 /**@brief Passkey Option.
yihui 1:a607cd9655d7 637 *
yihui 1:a607cd9655d7 638 * Structure containing the passkey to be used during pairing. This can be used with @ref
yihui 1:a607cd9655d7 639 * sd_ble_opt_set to make the SoftDevice use a pre-programmed passkey for authentication
yihui 1:a607cd9655d7 640 * instead of generating a random one.
yihui 1:a607cd9655d7 641 *
yihui 1:a607cd9655d7 642 * @note @ref sd_ble_opt_get is not supported for this option.
yihui 1:a607cd9655d7 643 *
yihui 1:a607cd9655d7 644 */
yihui 1:a607cd9655d7 645 typedef struct
yihui 1:a607cd9655d7 646 {
yihui 1:a607cd9655d7 647 uint8_t * p_passkey; /**< Pointer to 6-digit ASCII string (digit 0..9 only, no NULL termination) passkey to be used during pairing. If this is NULL, the SoftDevice will generate a random passkey if required.*/
yihui 1:a607cd9655d7 648 } ble_gap_opt_passkey_t;
yihui 1:a607cd9655d7 649
yihui 1:a607cd9655d7 650
yihui 1:a607cd9655d7 651 /**@brief Custom Privacy Options.
yihui 1:a607cd9655d7 652 *
yihui 1:a607cd9655d7 653 * @note The specified address cycle interval is used when the address cycle mode is
yihui 1:a607cd9655d7 654 * @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO. If 0 is given, the address will not be refreshed at any
yihui 1:a607cd9655d7 655 * interval, and not at start of advertising. A new address can be generated manually by calling
yihui 1:a607cd9655d7 656 * @ref sd_ble_gap_address_set with the same type again. The default interval is
yihui 1:a607cd9655d7 657 * @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S.
yihui 1:a607cd9655d7 658 *
yihui 1:a607cd9655d7 659 * @note If cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO, the address will immediately be
yihui 1:a607cd9655d7 660 * refreshed when this option is set.
yihui 1:a607cd9655d7 661 */
yihui 1:a607cd9655d7 662 typedef struct
yihui 1:a607cd9655d7 663 {
yihui 1:a607cd9655d7 664 ble_gap_irk_t * p_irk; /**< When input: Pointer to custom IRK, or NULL to use/reset to the device's default IRK. When output: Pointer to where the current IRK is to be stored, or NULL to not read out the IRK. */
yihui 1:a607cd9655d7 665 uint16_t interval_s; /**< When input: Custom private address cycle interval in seconds. When output: The current private address cycle interval. */
yihui 1:a607cd9655d7 666 } ble_gap_opt_privacy_t;
yihui 1:a607cd9655d7 667
yihui 1:a607cd9655d7 668
yihui 1:a607cd9655d7 669 /**@brief Option structure for GAP options. */
yihui 1:a607cd9655d7 670 typedef union
yihui 1:a607cd9655d7 671 {
yihui 1:a607cd9655d7 672 ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Local connection latency. */
yihui 1:a607cd9655d7 673 ble_gap_opt_passkey_t passkey; /**< Passkey to be used for pairing.*/
yihui 1:a607cd9655d7 674 ble_gap_opt_privacy_t privacy; /**< Custom privacy options. */
yihui 1:a607cd9655d7 675 } ble_gap_opt_t;
yihui 1:a607cd9655d7 676 /**@} */
yihui 1:a607cd9655d7 677
yihui 1:a607cd9655d7 678
yihui 1:a607cd9655d7 679 /**@addtogroup BLE_GAP_FUNCTIONS Functions
yihui 1:a607cd9655d7 680 * @{ */
yihui 1:a607cd9655d7 681
yihui 1:a607cd9655d7 682 /**@brief Set local Bluetooth address.
yihui 1:a607cd9655d7 683 *
yihui 1:a607cd9655d7 684 * If the address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO, the address type is required to
yihui 1:a607cd9655d7 685 * be @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE or
yihui 1:a607cd9655d7 686 * @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. The given address is ignored and the
yihui 1:a607cd9655d7 687 * SoftDevice will generate a new private address automatically every time advertising is
yihui 1:a607cd9655d7 688 * (re)started, and every @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S seconds. If this API
yihui 1:a607cd9655d7 689 * call is used again with the same parameters while advertising, the SoftDevice will immediately
yihui 1:a607cd9655d7 690 * generate a new private address to replace the current address.
yihui 1:a607cd9655d7 691 *
yihui 1:a607cd9655d7 692 * If the application wishes to use a @ref BLE_GAP_ADDR_TYPE_PUBLIC or
yihui 1:a607cd9655d7 693 * @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC address, the cycle mode must be
yihui 1:a607cd9655d7 694 * @ref BLE_GAP_ADDR_CYCLE_MODE_NONE.
yihui 1:a607cd9655d7 695 *
yihui 1:a607cd9655d7 696 * If this API function is called while advertising, the softdevice will immediately update the
yihui 1:a607cd9655d7 697 * advertising address without the need to stop advertising in the following cases:
yihui 1:a607cd9655d7 698 * - If the previously set address is of type @ref BLE_GAP_ADDR_TYPE_PUBLIC and the new address
yihui 1:a607cd9655d7 699 * is also of type @ref BLE_GAP_ADDR_TYPE_PUBLIC
yihui 1:a607cd9655d7 700 * - If the previously set address is not @ref BLE_GAP_ADDR_TYPE_PUBLIC and the new address is
yihui 1:a607cd9655d7 701 * also not @ref BLE_GAP_ADDR_TYPE_PUBLIC.
yihui 1:a607cd9655d7 702 *
yihui 1:a607cd9655d7 703 * If the address is changed from a @ref BLE_GAP_ADDR_TYPE_PUBLIC address to another type or from
yihui 1:a607cd9655d7 704 * another type to a @ref BLE_GAP_ADDR_TYPE_PUBLIC address, the change will take effect the next
yihui 1:a607cd9655d7 705 * time advertising is started.
yihui 1:a607cd9655d7 706 *
yihui 1:a607cd9655d7 707 * @note If the address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_NONE and the application is
yihui 1:a607cd9655d7 708 * using privacy, the application must take care to generate and set new private addresses
yihui 1:a607cd9655d7 709 * periodically to comply with the Privacy specification in Bluetooth Core Spec.
yihui 1:a607cd9655d7 710 *
yihui 1:a607cd9655d7 711 * @param[in] addr_cycle_mode Address cycle mode, see @ref BLE_GAP_ADDR_CYCLE_MODES.
yihui 1:a607cd9655d7 712 * @param[in] p_addr Pointer to address structure.
yihui 1:a607cd9655d7 713 *
yihui 1:a607cd9655d7 714 * @return @ref NRF_SUCCESS Address successfully set.
yihui 1:a607cd9655d7 715 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 716 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameters.
yihui 1:a607cd9655d7 717 * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address.
yihui 1:a607cd9655d7 718 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
yihui 1:a607cd9655d7 719 */
yihui 1:a607cd9655d7 720 SVCALL(SD_BLE_GAP_ADDRESS_SET, uint32_t, sd_ble_gap_address_set(uint8_t addr_cycle_mode, ble_gap_addr_t const * const p_addr));
yihui 1:a607cd9655d7 721
yihui 1:a607cd9655d7 722
yihui 1:a607cd9655d7 723 /**@brief Get local Bluetooth address.
yihui 1:a607cd9655d7 724 *
yihui 1:a607cd9655d7 725 * @param[out] p_addr Pointer to address structure.
yihui 1:a607cd9655d7 726 *
yihui 1:a607cd9655d7 727 * @return @ref NRF_SUCCESS Address successfully retrieved.
yihui 1:a607cd9655d7 728 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 729 */
yihui 1:a607cd9655d7 730 SVCALL(SD_BLE_GAP_ADDRESS_GET, uint32_t, sd_ble_gap_address_get(ble_gap_addr_t * const p_addr));
yihui 1:a607cd9655d7 731
yihui 1:a607cd9655d7 732
yihui 1:a607cd9655d7 733 /**@brief Set, clear or update advertisement and scan response data.
yihui 1:a607cd9655d7 734 *
yihui 1:a607cd9655d7 735 * @note The format of the advertisement data will be checked by this call to ensure interoperability.
yihui 1:a607cd9655d7 736 * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
yihui 1:a607cd9655d7 737 * duplicating the local name in the advertisement data and scan response data.
yihui 1:a607cd9655d7 738 *
yihui 1:a607cd9655d7 739 * @note: To clear the advertisement data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding
yihui 1:a607cd9655d7 740 * length (dlen/srdlen) set to 0.
yihui 1:a607cd9655d7 741 *
yihui 1:a607cd9655d7 742 * @note: The call will fail if p_data and p_sr_data are both NULL since this would have no effect.
yihui 1:a607cd9655d7 743 *
yihui 1:a607cd9655d7 744 * @param[in] p_data Raw data to be placed in advertisement packet. If NULL, no changes are made to the current advertisement packet data.
yihui 1:a607cd9655d7 745 * @param[in] dlen Data length for p_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_data is NULL, can be 0 if p_data is not NULL.
yihui 1:a607cd9655d7 746 * @param[in] p_sr_data Raw data to be placed in scan response packet. If NULL, no changes are made to the current scan response packet data.
yihui 1:a607cd9655d7 747 * @param[in] srdlen Data length for p_sr_data. Max size: @ref BLE_GAP_ADV_MAX_SIZE octets. Should be 0 if p_sr_data is NULL, can be 0 if p_data is not NULL.
yihui 1:a607cd9655d7 748 *
yihui 1:a607cd9655d7 749 * @return @ref NRF_SUCCESS Advertisement data successfully updated or cleared.
yihui 1:a607cd9655d7 750 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 751 * @return @ref NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied.
yihui 1:a607cd9655d7 752 * @return @ref NRF_ERROR_INVALID_DATA Invalid data type(s) supplied, check the advertising data format specification.
yihui 1:a607cd9655d7 753 * @return @ref NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied.
yihui 1:a607cd9655d7 754 * @return @ref BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied.
yihui 1:a607cd9655d7 755 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
yihui 1:a607cd9655d7 756 */
yihui 1:a607cd9655d7 757 SVCALL(SD_BLE_GAP_ADV_DATA_SET, uint32_t, sd_ble_gap_adv_data_set(uint8_t const * const p_data, uint8_t dlen, uint8_t const * const p_sr_data, uint8_t srdlen));
yihui 1:a607cd9655d7 758
yihui 1:a607cd9655d7 759
yihui 1:a607cd9655d7 760 /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
yihui 1:a607cd9655d7 761 *
yihui 1:a607cd9655d7 762 * @param[in] p_adv_params Pointer to advertising parameters structure.
yihui 1:a607cd9655d7 763 *
yihui 1:a607cd9655d7 764 * @return @ref NRF_SUCCESS The BLE stack has started advertising.
yihui 1:a607cd9655d7 765 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 766 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
yihui 1:a607cd9655d7 767 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check the accepted ranges and limits.
yihui 1:a607cd9655d7 768 * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Bluetooth address supplied.
yihui 1:a607cd9655d7 769 * @return @ref BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible.
yihui 1:a607cd9655d7 770 */
yihui 1:a607cd9655d7 771 SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(ble_gap_adv_params_t const * const p_adv_params));
yihui 1:a607cd9655d7 772
yihui 1:a607cd9655d7 773
yihui 1:a607cd9655d7 774 /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
yihui 1:a607cd9655d7 775 *
yihui 1:a607cd9655d7 776 * @return @ref NRF_SUCCESS The BLE stack has stopped advertising.
yihui 1:a607cd9655d7 777 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in advertising state).
yihui 1:a607cd9655d7 778 */
yihui 1:a607cd9655d7 779 SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(void));
yihui 1:a607cd9655d7 780
yihui 1:a607cd9655d7 781
yihui 1:a607cd9655d7 782 /**@brief Update connection parameters.
yihui 1:a607cd9655d7 783 *
yihui 1:a607cd9655d7 784 * @details In the central role this will initiate a Link Layer connection parameter update procedure,
yihui 1:a607cd9655d7 785 * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for
yihui 1:a607cd9655d7 786 * the central to perform the procedure. In both cases, and regardless of success or failure, the application
yihui 1:a607cd9655d7 787 * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event.
yihui 1:a607cd9655d7 788 *
yihui 1:a607cd9655d7 789 * @note If both a connection supervision timeout and a maximum connection interval are specified, then the following constraint
yihui 1:a607cd9655d7 790 * applies: (conn_sup_timeout * 8) >= (max_conn_interval * (slave_latency + 1))
yihui 1:a607cd9655d7 791 *
yihui 1:a607cd9655d7 792 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 793 * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role,
yihui 1:a607cd9655d7 794 * the parameters in the PPCP characteristic of the GAP service will be used instead.
yihui 1:a607cd9655d7 795 *
yihui 1:a607cd9655d7 796 * @return @ref NRF_SUCCESS The Connection Update procedure has been started successfully.
yihui 1:a607cd9655d7 797 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 798 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
yihui 1:a607cd9655d7 799 * @return @ref NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, process pending events and retry.
yihui 1:a607cd9655d7 800 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 801 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation.
yihui 1:a607cd9655d7 802 */
yihui 1:a607cd9655d7 803 SVCALL(SD_BLE_GAP_CONN_PARAM_UPDATE, uint32_t, sd_ble_gap_conn_param_update(uint16_t conn_handle, ble_gap_conn_params_t const * const p_conn_params));
yihui 1:a607cd9655d7 804
yihui 1:a607cd9655d7 805
yihui 1:a607cd9655d7 806 /**@brief Disconnect (GAP Link Termination).
yihui 1:a607cd9655d7 807 *
yihui 1:a607cd9655d7 808 * @details This call initiates the disconnection procedure, and its completion will be communicated to the application
yihui 1:a607cd9655d7 809 * with a BLE_GAP_EVT_DISCONNECTED event.
yihui 1:a607cd9655d7 810 *
yihui 1:a607cd9655d7 811 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 812 * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are BTLE_REMOTE_USER_TERMINATED_CONNECTION and BTLE_CONN_INTERVAL_UNACCEPTABLE).
yihui 1:a607cd9655d7 813 *
yihui 1:a607cd9655d7 814 * @return @ref NRF_SUCCESS The disconnection procedure has been started successfully.
yihui 1:a607cd9655d7 815 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 816 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 817 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress or not connected at all).
yihui 1:a607cd9655d7 818 */
yihui 1:a607cd9655d7 819 SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
yihui 1:a607cd9655d7 820
yihui 1:a607cd9655d7 821
yihui 1:a607cd9655d7 822 /**@brief Set the radio's transmit power.
yihui 1:a607cd9655d7 823 *
yihui 1:a607cd9655d7 824 * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm).
yihui 1:a607cd9655d7 825 *
yihui 1:a607cd9655d7 826 * @note -40 dBm will not actually give -40 dBm, but will instead be remapped to -30 dBm.
yihui 1:a607cd9655d7 827 *
yihui 1:a607cd9655d7 828 * @return @ref NRF_SUCCESS Successfully changed the transmit power.
yihui 1:a607cd9655d7 829 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 830 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
yihui 1:a607cd9655d7 831 */
yihui 1:a607cd9655d7 832 SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(int8_t tx_power));
yihui 1:a607cd9655d7 833
yihui 1:a607cd9655d7 834
yihui 1:a607cd9655d7 835 /**@brief Set GAP Appearance value.
yihui 1:a607cd9655d7 836 *
yihui 1:a607cd9655d7 837 * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
yihui 1:a607cd9655d7 838 *
yihui 1:a607cd9655d7 839 * @return @ref NRF_SUCCESS Appearance value set successfully.
yihui 1:a607cd9655d7 840 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 841 */
yihui 1:a607cd9655d7 842 SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance));
yihui 1:a607cd9655d7 843
yihui 1:a607cd9655d7 844
yihui 1:a607cd9655d7 845 /**@brief Get GAP Appearance value.
yihui 1:a607cd9655d7 846 *
yihui 1:a607cd9655d7 847 * @param[out] p_appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
yihui 1:a607cd9655d7 848 *
yihui 1:a607cd9655d7 849 * @return @ref NRF_SUCCESS Appearance value retrieved successfully.
yihui 1:a607cd9655d7 850 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 851 */
yihui 1:a607cd9655d7 852 SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t * const p_appearance));
yihui 1:a607cd9655d7 853
yihui 1:a607cd9655d7 854
yihui 1:a607cd9655d7 855 /**@brief Set GAP Peripheral Preferred Connection Parameters.
yihui 1:a607cd9655d7 856 *
yihui 1:a607cd9655d7 857 * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters.
yihui 1:a607cd9655d7 858 *
yihui 1:a607cd9655d7 859 * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully.
yihui 1:a607cd9655d7 860 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 861 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 862 */
yihui 1:a607cd9655d7 863 SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const * const p_conn_params));
yihui 1:a607cd9655d7 864
yihui 1:a607cd9655d7 865
yihui 1:a607cd9655d7 866 /**@brief Get GAP Peripheral Preferred Connection Parameters.
yihui 1:a607cd9655d7 867 *
yihui 1:a607cd9655d7 868 * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored.
yihui 1:a607cd9655d7 869 *
yihui 1:a607cd9655d7 870 * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully.
yihui 1:a607cd9655d7 871 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 872 */
yihui 1:a607cd9655d7 873 SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t * const p_conn_params));
yihui 1:a607cd9655d7 874
yihui 1:a607cd9655d7 875
yihui 1:a607cd9655d7 876 /**@brief Set GAP device name.
yihui 1:a607cd9655d7 877 *
yihui 1:a607cd9655d7 878 * @param[in] p_write_perm Write permissions for the Device Name characteristic see @ref ble_gap_conn_sec_mode_t.
yihui 1:a607cd9655d7 879 * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string.
yihui 1:a607cd9655d7 880 * @param[in] len Length of the UTF-8, <b>non NULL-terminated</b> string pointed to by p_dev_name in octets (must be smaller or equal than @ref BLE_GAP_DEVNAME_MAX_LEN).
yihui 1:a607cd9655d7 881 *
yihui 1:a607cd9655d7 882 * @return @ref NRF_SUCCESS GAP device name and permissions set successfully.
yihui 1:a607cd9655d7 883 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 884 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 885 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
yihui 1:a607cd9655d7 886 */
yihui 1:a607cd9655d7 887 SVCALL(SD_BLE_GAP_DEVICE_NAME_SET, uint32_t, sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const * const p_write_perm, uint8_t const * const p_dev_name, uint16_t len));
yihui 1:a607cd9655d7 888
yihui 1:a607cd9655d7 889
yihui 1:a607cd9655d7 890 /**@brief Get GAP device name.
yihui 1:a607cd9655d7 891 *
yihui 1:a607cd9655d7 892 * @param[in] p_dev_name Pointer to an empty buffer where the UTF-8 <b>non NULL-terminated</b> string will be placed. Set to NULL to obtain the complete device name length.
yihui 1:a607cd9655d7 893 * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output.
yihui 1:a607cd9655d7 894 *
yihui 1:a607cd9655d7 895 * @note If the device name is longer than the size of the supplied buffer,
yihui 1:a607cd9655d7 896 * p_len will return the complete device name length,
yihui 1:a607cd9655d7 897 * and not the number of bytes actually returned in p_dev_name.
yihui 1:a607cd9655d7 898 * The application may use this information to allocate a suitable buffer size.
yihui 1:a607cd9655d7 899 *
yihui 1:a607cd9655d7 900 * @return @ref NRF_SUCCESS GAP device name retrieved successfully.
yihui 1:a607cd9655d7 901 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 902 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
yihui 1:a607cd9655d7 903 */
yihui 1:a607cd9655d7 904 SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t * const p_dev_name, uint16_t * const p_len));
yihui 1:a607cd9655d7 905
yihui 1:a607cd9655d7 906
yihui 1:a607cd9655d7 907 /**@brief Initiate GAP Authentication procedure.
yihui 1:a607cd9655d7 908 *
yihui 1:a607cd9655d7 909 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 910 * @param[in] p_sec_params Pointer to the @ref ble_gap_sec_params_t structure with the security parameters to be used during the pairing procedure.
yihui 1:a607cd9655d7 911 *
yihui 1:a607cd9655d7 912 * @details In the central role, this function will send an SMP Pairing Request, otherwise in the peripheral role, an SMP Security Request will be sent.
yihui 1:a607cd9655d7 913 * In the peripheral role, only the timeout, bond and mitm fields of @ref ble_gap_sec_params_t are used.
yihui 1:a607cd9655d7 914 *
yihui 1:a607cd9655d7 915 * @note The GAP Authentication procedure may be triggered by the central without calling this function when accessing a secure service.
yihui 1:a607cd9655d7 916 * @note Calling this function may result in the following events depending on the outcome and parameters: @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST,
yihui 1:a607cd9655d7 917 * @ref BLE_GAP_EVT_SEC_INFO_REQUEST, @ref BLE_GAP_EVT_AUTH_KEY_REQUEST, @ref BLE_GAP_EVT_AUTH_STATUS.
yihui 1:a607cd9655d7 918 * @note The timeout parameter in @ref ble_gap_sec_params_t is interpreted here as the Security Request timeout
yihui 1:a607cd9655d7 919 *
yihui 1:a607cd9655d7 920 *
yihui 1:a607cd9655d7 921 * @return @ref NRF_SUCCESS Successfully initiated authentication procedure.
yihui 1:a607cd9655d7 922 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 923 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 924 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
yihui 1:a607cd9655d7 925 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 926 */
yihui 1:a607cd9655d7 927 SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const * const p_sec_params));
yihui 1:a607cd9655d7 928
yihui 1:a607cd9655d7 929
yihui 1:a607cd9655d7 930 /**@brief Reply with GAP security parameters.
yihui 1:a607cd9655d7 931 *
yihui 1:a607cd9655d7 932 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 933 * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS.
yihui 1:a607cd9655d7 934 * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure.
yihui 1:a607cd9655d7 935 *
yihui 1:a607cd9655d7 936 * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE.
yihui 1:a607cd9655d7 937 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
yihui 1:a607cd9655d7 938 * @note The timeout parameter in @ref ble_gap_sec_params_t is interpreted here as the SMP procedure timeout, and must be 30 seconds. The function will fail
yihui 1:a607cd9655d7 939 * if the application supplies a different value.
yihui 1:a607cd9655d7 940 *
yihui 1:a607cd9655d7 941 * @return @ref NRF_SUCCESS Successfully accepted security parameter from the application.
yihui 1:a607cd9655d7 942 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 943 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 944 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
yihui 1:a607cd9655d7 945 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 946 */
yihui 1:a607cd9655d7 947 SVCALL(SD_BLE_GAP_SEC_PARAMS_REPLY, uint32_t, sd_ble_gap_sec_params_reply(uint16_t conn_handle, uint8_t sec_status, ble_gap_sec_params_t const * const p_sec_params));
yihui 1:a607cd9655d7 948
yihui 1:a607cd9655d7 949
yihui 1:a607cd9655d7 950 /**@brief Reply with an authentication key.
yihui 1:a607cd9655d7 951 *
yihui 1:a607cd9655d7 952 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 953 * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES.
yihui 1:a607cd9655d7 954 * @param[in] key If key type is BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL.
yihui 1:a607cd9655d7 955 * If key type is BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination).
yihui 1:a607cd9655d7 956 * If key type is BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in Little Endian format.
yihui 1:a607cd9655d7 957 *
yihui 1:a607cd9655d7 958 * @details This function is only used to reply to a @ref BLE_GAP_EVT_AUTH_KEY_REQUEST, calling it at other times will result in an NRF_ERROR_INVALID_STATE.
yihui 1:a607cd9655d7 959 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
yihui 1:a607cd9655d7 960 *
yihui 1:a607cd9655d7 961 * @return @ref NRF_SUCCESS Authentication key successfully set.
yihui 1:a607cd9655d7 962 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 963 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 964 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
yihui 1:a607cd9655d7 965 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 966 */
yihui 1:a607cd9655d7 967 SVCALL(SD_BLE_GAP_AUTH_KEY_REPLY, uint32_t, sd_ble_gap_auth_key_reply(uint16_t conn_handle, uint8_t key_type, uint8_t const * const key));
yihui 1:a607cd9655d7 968
yihui 1:a607cd9655d7 969
yihui 1:a607cd9655d7 970 /**@brief Reply with GAP security information.
yihui 1:a607cd9655d7 971 *
yihui 1:a607cd9655d7 972 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 973 * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure. May be NULL to signal none is available.
yihui 1:a607cd9655d7 974 * @param[in] p_sign_info Pointer to a @ref ble_gap_sign_info_t signing information structure. May be NULL to signal none is available.
yihui 1:a607cd9655d7 975 *
yihui 1:a607cd9655d7 976 * @details This function is only used to reply to a @ref BLE_GAP_EVT_SEC_INFO_REQUEST, calling it at other times will result in NRF_ERROR_INVALID_STATE.
yihui 1:a607cd9655d7 977 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
yihui 1:a607cd9655d7 978 * @note Data signing is not implemented yet. p_sign_info must therefore be NULL.
yihui 1:a607cd9655d7 979 *
yihui 1:a607cd9655d7 980 * @return @ref NRF_SUCCESS Successfully accepted security information.
yihui 1:a607cd9655d7 981 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
yihui 1:a607cd9655d7 982 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
yihui 1:a607cd9655d7 983 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 984 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry.
yihui 1:a607cd9655d7 985 */
yihui 1:a607cd9655d7 986 SVCALL(SD_BLE_GAP_SEC_INFO_REPLY, uint32_t, sd_ble_gap_sec_info_reply(uint16_t conn_handle, ble_gap_enc_info_t const * const p_enc_info, ble_gap_sign_info_t const * const p_sign_info));
yihui 1:a607cd9655d7 987
yihui 1:a607cd9655d7 988
yihui 1:a607cd9655d7 989 /**@brief Get the current connection security.
yihui 1:a607cd9655d7 990 *
yihui 1:a607cd9655d7 991 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 992 * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in.
yihui 1:a607cd9655d7 993 *
yihui 1:a607cd9655d7 994 * @return @ref NRF_SUCCESS Current connection security successfully retrieved.
yihui 1:a607cd9655d7 995 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
yihui 1:a607cd9655d7 996 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 997 */
yihui 1:a607cd9655d7 998 SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t * const p_conn_sec));
yihui 1:a607cd9655d7 999
yihui 1:a607cd9655d7 1000
yihui 1:a607cd9655d7 1001 /**@brief Start reporting the received signal strength to the application.
yihui 1:a607cd9655d7 1002 *
yihui 1:a607cd9655d7 1003 * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
yihui 1:a607cd9655d7 1004 *
yihui 1:a607cd9655d7 1005 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 1006 *
yihui 1:a607cd9655d7 1007 * @return @ref NRF_SUCCESS Successfully activated RSSI reporting.
yihui 1:a607cd9655d7 1008 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
yihui 1:a607cd9655d7 1009 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 1010 */
yihui 1:a607cd9655d7 1011 SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle));
yihui 1:a607cd9655d7 1012
yihui 1:a607cd9655d7 1013
yihui 1:a607cd9655d7 1014 /**@brief Stop reporting the received singnal strength.
yihui 1:a607cd9655d7 1015 *
yihui 1:a607cd9655d7 1016 * An RSSI change detected before the call but not yet received by the application
yihui 1:a607cd9655d7 1017 * may be reported after @ref sd_ble_gap_rssi_stop has been called.
yihui 1:a607cd9655d7 1018 *
yihui 1:a607cd9655d7 1019 * @param[in] conn_handle Connection handle.
yihui 1:a607cd9655d7 1020 *
yihui 1:a607cd9655d7 1021 * @return @ref NRF_SUCCESS Successfully deactivated RSSI reporting.
yihui 1:a607cd9655d7 1022 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation.
yihui 1:a607cd9655d7 1023 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
yihui 1:a607cd9655d7 1024 */
yihui 1:a607cd9655d7 1025 SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle));
yihui 1:a607cd9655d7 1026 /**@} */
yihui 1:a607cd9655d7 1027
yihui 1:a607cd9655d7 1028 #endif // BLE_GAP_H__
yihui 1:a607cd9655d7 1029
yihui 1:a607cd9655d7 1030 /**
yihui 1:a607cd9655d7 1031 @}
yihui 1:a607cd9655d7 1032 */