テスト用です。

Dependencies:   mbed

Committer:
jksoft
Date:
Tue Oct 11 11:09:42 2016 +0000
Revision:
0:8468a4403fea
SB??ver;

Who changed what in which revision?

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