mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon Apr 07 18:28:36 2014 +0100
Revision:
82:6473597d706e
Release 82 of the mbed library

Main changes:

- support for K64F
- Revisited Nordic code structure
- Test infrastructure improvements
- various bug fixes

Who changed what in which revision?

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