Committer:
jinu
Date:
Thu Feb 09 06:08:17 2017 +0000
Revision:
0:6ba9b94b8997
NRF51 serialization libraries for mDot

Who changed what in which revision?

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