project for nrf51822 qfab

Dependencies:   eddystone_URL mbed

Fork of eddystone_URL by vo dung

Committer:
jksoft
Date:
Wed Nov 12 02:40:34 2014 +0000
Revision:
0:76dfa9657d9d
????????

Who changed what in which revision?

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