The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
emilmont
Date:
Fri Feb 21 12:21:39 2014 +0000
Revision:
80:8e73be2a2ac1
First alpha release for the NRF51822 target (to be tested in the online IDE)

Who changed what in which revision?

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