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