Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of nRF51822 by
ble_gap.h
00001 /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved. 00002 * 00003 * The information contained herein is confidential property of Nordic Semiconductor. The use, 00004 * copying, transfer or disclosure of such information is prohibited except by express written 00005 * agreement with Nordic Semiconductor. 00006 * 00007 */ 00008 /** 00009 @addtogroup BLE_GAP Generic Access Profile (GAP) 00010 @{ 00011 @brief Definitions and prototypes for the GAP interface. 00012 */ 00013 00014 #ifndef BLE_GAP_H__ 00015 #define BLE_GAP_H__ 00016 00017 #include "nordic_global.h" 00018 #include "ble_types.h" 00019 #include "ble_ranges.h" 00020 #include "nrf_svc.h" 00021 00022 /** 00023 * @brief GAP API SVC numbers. 00024 */ 00025 enum BLE_GAP_SVCS 00026 { 00027 SD_BLE_GAP_ADDRESS_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */ 00028 SD_BLE_GAP_ADDRESS_GET, /**< Get own Bluetooth Address. */ 00029 SD_BLE_GAP_ADV_DATA_SET, /**< Set Advertisement Data. */ 00030 SD_BLE_GAP_ADV_START, /**< Start Advertising. */ 00031 SD_BLE_GAP_ADV_STOP, /**< Stop Advertising. */ 00032 SD_BLE_GAP_CONN_PARAM_UPDATE, /**< Connection Parameter Update. */ 00033 SD_BLE_GAP_DISCONNECT, /**< Disconnect. */ 00034 SD_BLE_GAP_TX_POWER_SET, /**< Set TX Power. */ 00035 SD_BLE_GAP_APPEARANCE_SET, /**< Set Appearance. */ 00036 SD_BLE_GAP_APPEARANCE_GET, /**< Get Appearance. */ 00037 SD_BLE_GAP_PPCP_SET, /**< Set PPCP. */ 00038 SD_BLE_GAP_PPCP_GET, /**< Get PPCP. */ 00039 SD_BLE_GAP_DEVICE_NAME_SET, /**< Set Device Name. */ 00040 SD_BLE_GAP_DEVICE_NAME_GET, /**< Get Device Name. */ 00041 SD_BLE_GAP_AUTHENTICATE, /**< Initiate Pairing/Bonding. */ 00042 SD_BLE_GAP_SEC_PARAMS_REPLY, /**< Reply with Security Parameters. */ 00043 SD_BLE_GAP_AUTH_KEY_REPLY, /**< Reply with an authentication key. */ 00044 SD_BLE_GAP_SEC_INFO_REPLY, /**< Reply with Security Information. */ 00045 SD_BLE_GAP_CONN_SEC_GET, /**< Obtain connection security level. */ 00046 SD_BLE_GAP_RSSI_START, /**< Start reporting of changes in RSSI. */ 00047 SD_BLE_GAP_RSSI_STOP, /**< Stop reporting of changes in RSSI. */ 00048 }; 00049 00050 00051 /** @addtogroup BLE_GAP_DEFINES Defines 00052 * @{ */ 00053 00054 /** @defgroup BLE_ERRORS_GAP SVC return values specific to GAP 00055 * @{ */ 00056 #define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */ 00057 #define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */ 00058 #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. */ 00059 /** @} */ 00060 00061 00062 /** @defgroup BLE_GAP_ROLES GAP Roles 00063 * @note Not explicitly used in peripheral API, but will be relevant for central API. 00064 * @{ */ 00065 #define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */ 00066 #define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */ 00067 #define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */ 00068 /** @} */ 00069 00070 00071 /** @defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources 00072 * @{ */ 00073 #define BLE_GAP_TIMEOUT_SRC_ADVERTISEMENT 0x00 /**< Advertisement timeout. */ 00074 #define BLE_GAP_TIMEOUT_SRC_SECURITY_REQUEST 0x01 /**< Security request timeout. */ 00075 /** @} */ 00076 00077 00078 /** @defgroup BLE_GAP_ADDR_TYPES GAP Address types 00079 * @{ */ 00080 #define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public address. */ 00081 #define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random Static address. */ 00082 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Private Resolvable address. */ 00083 #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Private Non-Resolvable address. */ 00084 /** @} */ 00085 00086 00087 /** @brief BLE address length. */ 00088 #define BLE_GAP_ADDR_LEN 6 00089 00090 00091 /** @defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format 00092 * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm 00093 * @{ */ 00094 #define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */ 00095 #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */ 00096 #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */ 00097 #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */ 00098 #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */ 00099 #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */ 00100 #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */ 00101 #define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */ 00102 #define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */ 00103 #define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */ 00104 #define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */ 00105 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */ 00106 #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */ 00107 #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */ 00108 #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */ 00109 #define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */ 00110 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */ 00111 #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */ 00112 #define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data. */ 00113 #define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */ 00114 #define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */ 00115 #define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */ 00116 #define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */ 00117 /** @} */ 00118 00119 00120 /** @defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags 00121 * @{ */ 00122 #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */ 00123 #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */ 00124 #define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */ 00125 #define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */ 00126 #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */ 00127 #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. */ 00128 #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. */ 00129 /** @} */ 00130 00131 00132 /** @defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min 00133 * @{ */ 00134 #define BLE_GAP_ADV_INTERVAL_MIN 0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */ 00135 #define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */ 00136 #define BLE_GAP_ADV_INTERVAL_MAX 0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */ 00137 /** @} */ 00138 00139 00140 /** @brief Maximum size of advertising data in octets. */ 00141 #define BLE_GAP_ADV_MAX_SIZE 31 00142 00143 00144 /** @defgroup BLE_GAP_ADV_TYPES GAP Advertising types 00145 * @{ */ 00146 #define BLE_GAP_ADV_TYPE_ADV_IND 0x00 /**< Connectable undirected. */ 00147 #define BLE_GAP_ADV_TYPE_ADV_DIRECT_IND 0x01 /**< Connectable directed. */ 00148 #define BLE_GAP_ADV_TYPE_ADV_SCAN_IND 0x02 /**< Scannable undirected. */ 00149 #define BLE_GAP_ADV_TYPE_ADV_NONCONN_IND 0x03 /**< Non connectable undirected. */ 00150 /** @} */ 00151 00152 00153 /** @defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies 00154 * @{ */ 00155 #define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */ 00156 #define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */ 00157 #define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */ 00158 #define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */ 00159 /** @} */ 00160 00161 00162 /** @defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values 00163 * @{ */ 00164 #define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX 180 /**< Maximum advertising time in limited discoverable mode (TGAP(lim_adv_timeout) = 180s in spec (Addendum 2)). */ 00165 #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED 0 /**< Unlimited advertising in general discoverable mode. */ 00166 /** @} */ 00167 00168 00169 /** @defgroup BLE_GAP_DISC_MODES GAP Discovery modes 00170 * @{ */ 00171 #define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */ 00172 #define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */ 00173 #define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */ 00174 /** @} */ 00175 00176 /** @defgroup BLE_GAP_IO_CAPS GAP IO Capabilities 00177 * @{ */ 00178 #define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */ 00179 #define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */ 00180 #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */ 00181 #define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */ 00182 #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */ 00183 /** @} */ 00184 00185 00186 /** @defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types 00187 * @{ */ 00188 #define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */ 00189 #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */ 00190 #define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */ 00191 /** @} */ 00192 00193 /** @defgroup BLE_GAP_SEC_STATUS GAP Security status 00194 * @{ */ 00195 #define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Successful parameters. */ 00196 #define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */ 00197 #define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */ 00198 #define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user cancelled or other). */ 00199 #define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */ 00200 #define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */ 00201 #define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */ 00202 #define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */ 00203 #define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */ 00204 #define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */ 00205 #define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */ 00206 #define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */ 00207 #define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */ 00208 /** @} */ 00209 00210 /** @defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources 00211 * @{ */ 00212 #define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */ 00213 #define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */ 00214 /** @} */ 00215 00216 /** @defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits 00217 * @{ */ 00218 #define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connction interval specified in connect parameters. */ 00219 #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. */ 00220 #define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ 00221 #define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connction interval specified in connect parameters. */ 00222 #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. */ 00223 #define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */ 00224 #define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x03E8 /**< Highest slave latency permitted, in connection events. */ 00225 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */ 00226 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */ 00227 #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */ 00228 /** @} */ 00229 00230 00231 /**@brief GAP device name maximum length. */ 00232 #define BLE_GAP_DEVNAME_MAX_LEN 31 00233 00234 00235 /** @defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters 00236 * 00237 * See @ref ble_gap_conn_sec_mode_t. 00238 * @{ */ 00239 /** @brief Set sec_mode pointed to by ptr to have no access rights.*/ 00240 #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0) 00241 /** @brief Set sec_mode pointed to by ptr to require no protection, open link.*/ 00242 #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0) 00243 /** @brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/ 00244 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0) 00245 /** @brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/ 00246 #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0) 00247 /** @brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/ 00248 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0) 00249 /** @brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/ 00250 #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0) 00251 /** @} */ 00252 00253 00254 /**@brief GAP Security Key Length. */ 00255 #define BLE_GAP_SEC_KEY_LEN 16 00256 00257 /**@brief Maximum amount of addresses in a whitelist. */ 00258 #define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8) 00259 00260 /**@brief Maximum amount of IRKs in a whitelist. 00261 * @note The number of IRKs is limited to 8, even if the hardware supports more. 00262 */ 00263 #define BLE_GAP_WHITELIST_IRK_MAX_COUNT (8) 00264 00265 /** @defgroup GAP_SEC_MODES GAP Security Modes 00266 * @{ */ 00267 #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */ 00268 00269 /** @} */ 00270 00271 00272 /** @} */ 00273 00274 /**@brief Bluetooth Low Energy address. */ 00275 typedef struct 00276 { 00277 uint8_t addr_type; /**< See @ref BLE_GAP_ADDR_TYPES. */ 00278 uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */ 00279 } ble_gap_addr_t; 00280 00281 00282 /**@brief GAP connection parameters. 00283 * 00284 * @note When ble_conn_params_t is received in an event, both min_conn_interval and 00285 * max_conn_interval will be equal to the connection interval set by the central. 00286 */ 00287 typedef struct 00288 { 00289 uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ 00290 uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/ 00291 uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/ 00292 uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/ 00293 } ble_gap_conn_params_t; 00294 00295 00296 /**@brief GAP link requirements. 00297 * 00298 * See Bluetooth Core specification, Volume 3 Part C 10.2 for details. 00299 * 00300 * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n 00301 * Security Mode 1 Level 1: No security is needed (aka open link).\n 00302 * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n 00303 * Security Mode 1 Level 3: MITM protected encrypted link required.\n 00304 * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n 00305 * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n 00306 */ 00307 typedef struct 00308 { 00309 uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */ 00310 uint8_t lv : 4; /**< Level (1, 2 or 3), 0 for no permissions at all. */ 00311 00312 } ble_gap_conn_sec_mode_t; 00313 00314 00315 00316 /**@brief GAP connection security status.*/ 00317 typedef struct 00318 { 00319 ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/ 00320 uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets.*/ 00321 } ble_gap_conn_sec_t; 00322 00323 00324 00325 /**@brief Identity Resolving Key. */ 00326 typedef struct 00327 { 00328 uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */ 00329 } ble_gap_irk_t; 00330 00331 00332 /**@brief Whitelist structure. */ 00333 typedef struct 00334 { 00335 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. */ 00336 uint8_t addr_count; /**< Count of device addresses in array, up to @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. */ 00337 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. */ 00338 uint8_t irk_count; /**< Count of IRKs in array, up to @ref BLE_GAP_WHITELIST_IRK_MAX_COUNT. */ 00339 } ble_gap_whitelist_t; 00340 00341 00342 /**@brief GAP advertising parameters.*/ 00343 typedef struct 00344 { 00345 uint8_t type; /**< See @ref BLE_GAP_ADV_TYPES. */ 00346 ble_gap_addr_t* p_peer_addr; /**< For BLE_GAP_CONN_MODE_DIRECTED mode only, known peer address. */ 00347 uint8_t fp; /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */ 00348 ble_gap_whitelist_t * p_whitelist; /**< Pointer to whitelist, NULL if none is given. */ 00349 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. */ 00350 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. */ 00351 } ble_gap_adv_params_t; 00352 00353 00354 /**@brief GAP scanning parameters. */ 00355 typedef struct 00356 { 00357 uint8_t filter; /**< Filter based on discovery mode, see @ref BLE_GAP_DISC_MODES. */ 00358 uint8_t active : 1; /**< If 1, perform active scanning (scan requests). */ 00359 uint8_t selective : 1; /**< If 1, ignore unknown devices (non whitelisted). */ 00360 uint16_t interval; /**< Scan interval between 0x0020 and 0x4000 in 0.625ms units (20ms to 10.24s). */ 00361 uint16_t window; /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */ 00362 uint16_t timeout; /**< Scan timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. */ 00363 } ble_gap_scan_params_t; 00364 00365 00366 /**@brief GAP security parameters. */ 00367 typedef struct 00368 { 00369 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. */ 00370 uint8_t bond : 1; /**< Perform bonding. */ 00371 uint8_t mitm : 1; /**< Man In The Middle protection required. */ 00372 uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */ 00373 uint8_t oob : 1; /**< Out Of Band data available. */ 00374 uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. */ 00375 uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */ 00376 } ble_gap_sec_params_t; 00377 00378 00379 /**@brief GAP Encryption Information. */ 00380 typedef struct 00381 { 00382 uint16_t div; /**< Encryption Diversifier. */ 00383 uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */ 00384 uint8_t auth : 1; /**< Authenticated Key. */ 00385 uint8_t ltk_len : 7; /**< LTK length in octets. */ 00386 } ble_gap_enc_info_t; 00387 00388 00389 /**@brief GAP Master Identification. */ 00390 typedef struct 00391 { 00392 uint16_t ediv; /**< Encrypted Diversifier. */ 00393 uint8_t rand[8]; /**< Random Number. */ 00394 } ble_gap_master_id_t; 00395 00396 00397 /**@brief GAP Identity Information. */ 00398 typedef struct 00399 { 00400 ble_gap_addr_t addr; /**< Bluetooth address to which this key applies. */ 00401 uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Identity Resolution Key. */ 00402 } ble_gap_id_info_t; 00403 00404 00405 /**@brief GAP Signing Information. */ 00406 typedef struct 00407 { 00408 uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /* Connection Signature Resolving Key. */ 00409 } ble_gap_sign_info_t; 00410 00411 00412 00413 /** 00414 * @brief GAP Event IDs. 00415 * Those IDs uniquely identify an event coming from the stack to the application. 00416 */ 00417 enum BLE_GAP_EVTS 00418 { 00419 BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connection established. */ 00420 BLE_GAP_EVT_DISCONNECTED, /**< Disconnected from peer. */ 00421 BLE_GAP_EVT_CONN_PARAM_UPDATE, /**< Connection Parameters updated. */ 00422 BLE_GAP_EVT_SEC_PARAMS_REQUEST, /**< Request to provide security parameters. */ 00423 BLE_GAP_EVT_SEC_INFO_REQUEST, /**< Request to provide security information. */ 00424 BLE_GAP_EVT_PASSKEY_DISPLAY, /**< Request to display a passkey to the user. */ 00425 BLE_GAP_EVT_AUTH_KEY_REQUEST, /**< Request to provide an authentication key. */ 00426 BLE_GAP_EVT_AUTH_STATUS, /**< Authentication procedure completed with status. */ 00427 BLE_GAP_EVT_CONN_SEC_UPDATE, /**< Connection security updated. */ 00428 BLE_GAP_EVT_TIMEOUT, /**< Timeout expired. */ 00429 BLE_GAP_EVT_RSSI_CHANGED, /**< Signal strength measurement report. */ 00430 }; 00431 00432 00433 /** @brief Event data for connected event. */ 00434 typedef struct 00435 { 00436 ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */ 00437 uint8_t irk_match :1; /**< If 1, peer device's address resolved using an IRK. */ 00438 uint8_t irk_match_idx :7; /**< Index in IRK list where the address was matched. */ 00439 ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ 00440 } ble_gap_evt_connected_t; 00441 00442 00443 /** @brief Event data for disconnected event. */ 00444 typedef struct 00445 { 00446 uint8_t reason; /**< HCI error code. */ 00447 } ble_gap_evt_disconnected_t; 00448 00449 00450 /** @brief Event data for connection parameter update event. */ 00451 typedef struct 00452 { 00453 ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */ 00454 } ble_gap_evt_conn_param_update_t; 00455 00456 00457 /** @brief Event data for security parameters request event. */ 00458 typedef struct 00459 { 00460 ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */ 00461 } ble_gap_evt_sec_params_request_t; 00462 00463 00464 /** @brief Event data for securito info request event. */ 00465 typedef struct 00466 { 00467 ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */ 00468 uint16_t div; /**< Encryption diversifier for LTK lookup. */ 00469 uint8_t enc_info : 1; /**< If 1, Encryption Information required. */ 00470 uint8_t id_info : 1; /**< If 1, Identity Information required. */ 00471 uint8_t sign_info : 1; /**< If 1, Signing Information required. */ 00472 } ble_gap_evt_sec_info_request_t; 00473 00474 00475 /** @brief Event data for passkey display event. */ 00476 typedef struct 00477 { 00478 uint8_t passkey[6]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */ 00479 } ble_gap_evt_passkey_display_t; 00480 00481 00482 /** @brief Event data for authentication key request event. */ 00483 typedef struct 00484 { 00485 uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */ 00486 } ble_gap_evt_auth_key_request_t; 00487 00488 00489 /** @brief Security levels supported. 00490 * @note See Bluetooth Specification Version 4.0 Volume 3, Chapter 10. 00491 */ 00492 typedef struct 00493 { 00494 uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */ 00495 uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */ 00496 uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */ 00497 } ble_gap_sec_levels_t; 00498 00499 00500 /** @brief Keys that have been exchanged. */ 00501 typedef struct 00502 { 00503 uint8_t ltk : 1; /**< Long Term Key. */ 00504 uint8_t ediv_rand : 1; /**< Encrypted Diversifier and Random value. */ 00505 uint8_t irk : 1; /**< Identity Resolving Key. */ 00506 uint8_t address : 1; /**< Public or static random address. */ 00507 uint8_t csrk : 1; /**< Connection Signature Resolving Key. */ 00508 } ble_gap_sec_keys_t; 00509 00510 00511 /** @brief Event data for authentication status event. */ 00512 typedef struct 00513 { 00514 uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */ 00515 uint8_t error_src; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */ 00516 ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */ 00517 ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */ 00518 ble_gap_sec_keys_t periph_kex; /**< Bitmap stating which keys were exchanged (distributed) by the peripheral. */ 00519 ble_gap_sec_keys_t central_kex; /**< Bitmap stating which keys were exchanged (distributed) by the central. */ 00520 struct periph_keys_t 00521 { 00522 ble_gap_enc_info_t enc_info; /**< Peripheral's Encryption information. */ 00523 } periph_keys; /**< Actual keys distributed from the Peripheral to the Central. */ 00524 struct central_keys_t 00525 { 00526 ble_gap_irk_t irk; /**< Central's IRK. */ 00527 ble_gap_addr_t id_info; /**< Central's Identity Info. */ 00528 } central_keys; /**< Actual keys distributed from the Central to the Peripheral. */ 00529 } ble_gap_evt_auth_status_t; 00530 00531 00532 /** @brief Event data for connection security update event. */ 00533 typedef struct 00534 { 00535 ble_gap_conn_sec_t conn_sec; /**< Connection security level. */ 00536 } ble_gap_evt_conn_sec_update_t; 00537 00538 00539 /** @brief Event data for timeout event. */ 00540 typedef struct 00541 { 00542 uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */ 00543 } ble_gap_evt_timeout_t; 00544 00545 00546 /** @brief Event data for advertisement report event. */ 00547 typedef struct 00548 { 00549 int8_t rssi; /**< Received Signal Strength Indication in dBm. */ 00550 } ble_gap_evt_rssi_changed_t; 00551 00552 00553 00554 /**@brief GAP event callback event structure. */ 00555 typedef struct 00556 { 00557 uint16_t conn_handle; /**< Connection Handle on which event occured. */ 00558 union /**< union alternative identified by evt_id in enclosing struct. */ 00559 { 00560 ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */ 00561 ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */ 00562 ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */ 00563 ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */ 00564 ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */ 00565 ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */ 00566 ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */ 00567 ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */ 00568 ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */ 00569 ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */ 00570 ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event parameters. */ 00571 } params; 00572 00573 } ble_gap_evt_t; 00574 00575 00576 /**@brief Set local Bluetooth address. 00577 * 00578 * @param[in] p_addr Pointer to address structure. 00579 * 00580 * @return @ref NRF_SUCCESS Address successfully set. 00581 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00582 * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address. 00583 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. 00584 */ 00585 SVCALL(SD_BLE_GAP_ADDRESS_SET, uint32_t, sd_ble_gap_address_set(ble_gap_addr_t const * const p_addr)); 00586 00587 00588 /**@brief Get local Bluetooth address. 00589 * 00590 * @param[out] p_addr Pointer to address structure. 00591 * 00592 * @return @ref NRF_SUCCESS Address successfully retrieved. 00593 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00594 */ 00595 SVCALL(SD_BLE_GAP_ADDRESS_GET, uint32_t, sd_ble_gap_address_get(ble_gap_addr_t * const p_addr)); 00596 00597 00598 /**@brief Set, clear or update advertisement and scan response data. 00599 * 00600 * @note The format of the advertisement data will be checked by this call to ensure interoperability. 00601 * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and 00602 * duplicating the local name in the advertisement data and scan response data. 00603 * 00604 * @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 00605 * length (dlen/srdlen) set to 0. 00606 * 00607 * @note: The call will fail if p_data and p_sr_data are both NULL since this would have no effect. 00608 * 00609 * @param[in] p_data Raw data to be placed in advertisement packet. If NULL, no changes are made to the current advertisement packet data. 00610 * @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. 00611 * @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. 00612 * @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. 00613 * 00614 * @return @ref NRF_SUCCESS Advertisement data successfully updated or cleared. 00615 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00616 * @return @ref NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied. 00617 * @return @ref NRF_ERROR_INVALID_DATA Invalid data type(s) supplied, check the advertising data format specification. 00618 * @return @ref NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied. 00619 * @return @ref BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied. 00620 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. 00621 */ 00622 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)); 00623 00624 00625 /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). 00626 * 00627 * @param[in] p_adv_params Pointer to advertising parameters structure. 00628 * 00629 * @return @ref NRF_SUCCESS The BLE stack has started advertising. 00630 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00631 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. 00632 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check the accepted ranges and limits. 00633 * @return @ref BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Bluetooth address supplied. 00634 * @return @ref BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible. 00635 */ 00636 SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(ble_gap_adv_params_t const * const p_adv_params)); 00637 00638 00639 /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure). 00640 * 00641 * @return @ref NRF_SUCCESS The BLE stack has stopped advertising. 00642 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in advertising state). 00643 */ 00644 SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(void)); 00645 00646 00647 /**@brief Update connection parameters. 00648 * 00649 * @details In the central role this will initiate a Link Layer connection parameter update procedure, 00650 * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for 00651 * the central to perform the procedure. In both cases, and regardless of success or failure, the application 00652 * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event. 00653 * 00654 * @note If both a connection supervision timeout and a maximum connection interval are specified, then the following constraint 00655 * applies: (conn_sup_timeout * 8) >= (max_conn_interval * (slave_latency + 1)) 00656 * 00657 * @param[in] conn_handle Connection handle. 00658 * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role, 00659 * the parameters in the PPCP characteristic of the GAP service will be used instead. 00660 * 00661 * @return @ref NRF_SUCCESS The Connection Update procedure has been started successfully. 00662 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00663 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints. 00664 * @return @ref NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, process pending events and retry. 00665 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00666 * @return @ref NRF_ERROR_NO_MEM Not enough memory to complete operation. 00667 */ 00668 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)); 00669 00670 00671 /**@brief Disconnect (GAP Link Termination). 00672 * 00673 * @details This call initiates the disconnection procedure, and its completion will be communicated to the application 00674 * with a BLE_GAP_EVT_DISCONNECTED event. 00675 * 00676 * @param[in] conn_handle Connection handle. 00677 * @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). 00678 * 00679 * @return @ref NRF_SUCCESS The disconnection procedure has been started successfully. 00680 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00681 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00682 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress or not connected at all). 00683 */ 00684 SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code)); 00685 00686 00687 /**@brief Set the radio's transmit power. 00688 * 00689 * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm). 00690 * 00691 * @note -40 dBm will not actually give -40 dBm, but will instead be remapped to -30 dBm. 00692 * 00693 * @return @ref NRF_SUCCESS Successfully changed the transmit power. 00694 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00695 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. 00696 */ 00697 SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(int8_t tx_power)); 00698 00699 00700 /**@brief Set GAP Appearance value. 00701 * 00702 * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES. 00703 * 00704 * @return @ref NRF_SUCCESS Appearance value set successfully. 00705 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00706 */ 00707 SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance)); 00708 00709 00710 /**@brief Get GAP Appearance value. 00711 * 00712 * @param[out] p_appearance Appearance (16-bit), see @ref BLE_APPEARANCES. 00713 * 00714 * @return @ref NRF_SUCCESS Appearance value retrieved successfully. 00715 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00716 */ 00717 SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t * const p_appearance)); 00718 00719 00720 /**@brief Set GAP Peripheral Preferred Connection Parameters. 00721 * 00722 * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters. 00723 * 00724 * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully. 00725 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00726 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00727 */ 00728 SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const * const p_conn_params)); 00729 00730 00731 /**@brief Get GAP Peripheral Preferred Connection Parameters. 00732 * 00733 * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored. 00734 * 00735 * @return @ref NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully. 00736 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00737 */ 00738 SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t * const p_conn_params)); 00739 00740 00741 /**@brief Set GAP device name. 00742 * 00743 * @param[in] p_write_perm Write permissions for the Device Name characteristic see @ref ble_gap_conn_sec_mode_t. 00744 * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string. 00745 * @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). 00746 * 00747 * @return @ref NRF_SUCCESS GAP device name and permissions set successfully. 00748 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00749 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00750 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. 00751 */ 00752 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)); 00753 00754 00755 /**@brief Get GAP device name. 00756 * 00757 * @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. 00758 * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output. 00759 * 00760 * @note If the device name is longer than the size of the supplied buffer, 00761 * p_len will return the complete device name length, 00762 * and not the number of bytes actually returned in p_dev_name. 00763 * The application may use this information to allocate a suitable buffer size. 00764 * 00765 * @return @ref NRF_SUCCESS GAP device name retrieved successfully. 00766 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00767 * @return @ref NRF_ERROR_DATA_SIZE Invalid data size(s) supplied. 00768 */ 00769 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)); 00770 00771 00772 /**@brief Initiate GAP Authentication procedure. 00773 * 00774 * @param[in] conn_handle Connection handle. 00775 * @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. 00776 * 00777 * @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. 00778 * In the peripheral role, only the timeout, bond and mitm fields of @ref ble_gap_sec_params_t are used. 00779 * 00780 * @note The GAP Authentication procedure may be triggered by the central without calling this function when accessing a secure service. 00781 * @note Calling this function may result in the following events depending on the outcome and parameters: @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST, 00782 * @ref BLE_GAP_EVT_SEC_INFO_REQUEST, @ref BLE_GAP_EVT_AUTH_KEY_REQUEST, @ref BLE_GAP_EVT_AUTH_STATUS. 00783 * @note The timeout parameter in @ref ble_gap_sec_params_t is interpreted here as the Security Request timeout 00784 * 00785 * 00786 * @return @ref NRF_SUCCESS Successfully initiated authentication procedure. 00787 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00788 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00789 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. 00790 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00791 */ 00792 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)); 00793 00794 00795 /**@brief Reply with GAP security parameters. 00796 * 00797 * @param[in] conn_handle Connection handle. 00798 * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS. 00799 * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. 00800 * 00801 * @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. 00802 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. 00803 * @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 00804 * if the application supplies a different value. 00805 * 00806 * @return @ref NRF_SUCCESS Successfully accepted security parameter from the application. 00807 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00808 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00809 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. 00810 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00811 */ 00812 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)); 00813 00814 00815 /**@brief Reply with an authentication key. 00816 * 00817 * @param[in] conn_handle Connection handle. 00818 * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES. 00819 * @param[in] key If key type is BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL. 00820 * If key type is BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination). 00821 * If key type is BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in Little Endian format. 00822 * 00823 * @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. 00824 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. 00825 * 00826 * @return @ref NRF_SUCCESS Authentication key successfully set. 00827 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00828 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00829 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. 00830 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00831 */ 00832 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)); 00833 00834 00835 /**@brief Reply with GAP security information. 00836 * 00837 * @param[in] conn_handle Connection handle. 00838 * @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. 00839 * @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. 00840 * 00841 * @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. 00842 * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters. 00843 * @note Data signing is not implemented yet. p_sign_info must therefore be NULL. 00844 * 00845 * @return @ref NRF_SUCCESS Successfully accepted security information. 00846 * @return @ref NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. 00847 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. 00848 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00849 * @return @ref NRF_ERROR_BUSY The stack is busy, process pending events and retry. 00850 */ 00851 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)); 00852 00853 00854 /**@brief Get the current connection security. 00855 * 00856 * @param[in] conn_handle Connection handle. 00857 * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in. 00858 * 00859 * @return @ref NRF_SUCCESS Current connection security successfully retrieved. 00860 * @return @ref NRF_ERROR_INVALID_ADDR Invalid pointer supplied. 00861 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00862 */ 00863 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)); 00864 00865 00866 /**@brief Start reporting the received signal strength to the application. 00867 * 00868 * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called. 00869 * 00870 * @param[in] conn_handle Connection handle. 00871 * 00872 * @return @ref NRF_SUCCESS Successfully activated RSSI reporting. 00873 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. 00874 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00875 */ 00876 SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle)); 00877 00878 00879 /**@brief Stop reporting the received singnal strength. 00880 * 00881 * An RSSI change detected before the call but not yet received by the application 00882 * may be reported after @ref sd_ble_gap_rssi_stop has been called. 00883 * 00884 * @param[in] conn_handle Connection handle. 00885 * 00886 * @return @ref NRF_SUCCESS Successfully deactivated RSSI reporting. 00887 * @return @ref NRF_ERROR_INVALID_STATE Invalid state to perform operation. 00888 * @return @ref BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied. 00889 */ 00890 SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle)); 00891 00892 #endif // BLE_GAP_H__ 00893 00894 /** 00895 @} 00896 */
Generated on Tue Jul 12 2022 19:00:52 by
