iOSのBLEコントローラアプリ「RCBController」と接続し、コントローラの操作を取得するサンプルプログラムです。 mbed HRM1017で動作を確認しています。 2014.08.20時点でのBLEライブラリに対応しました。

Dependencies:   BLE_API mbed

Fork of BLE_RCBController by Junichi Katsu

Committer:
jksoft
Date:
Wed Aug 20 13:41:01 2014 +0000
Revision:
4:ebda47d22091
Parent:
nRF51822/nordic/nrf-sdk/s110/ble_gap.h@1:48f6e08a3ac2
?????????

Who changed what in which revision?

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