ble_gap.h 93 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742
  1. /*
  2. * Copyright (c) Nordic Semiconductor ASA
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without modification,
  6. * are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice, this
  12. * list of conditions and the following disclaimer in the documentation and/or
  13. * other materials provided with the distribution.
  14. *
  15. * 3. Neither the name of Nordic Semiconductor ASA nor the names of other
  16. * contributors to this software may be used to endorse or promote products
  17. * derived from this software without specific prior written permission.
  18. *
  19. * 4. This software must only be used in a processor manufactured by Nordic
  20. * Semiconductor ASA, or in a processor manufactured by a third party that
  21. * is used in combination with a processor manufactured by Nordic Semiconductor.
  22. *
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  25. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  26. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  28. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  29. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  30. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  31. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  33. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. */
  36. /**
  37. @addtogroup BLE_GAP Generic Access Profile (GAP)
  38. @{
  39. @brief Definitions and prototypes for the GAP interface.
  40. */
  41. #ifndef BLE_GAP_H__
  42. #define BLE_GAP_H__
  43. #include "ble_types.h"
  44. #include "ble_ranges.h"
  45. #include "nrf_svc.h"
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49. /**@addtogroup BLE_GAP_ENUMERATIONS Enumerations
  50. * @{ */
  51. /**@brief GAP API SVC numbers.
  52. */
  53. enum BLE_GAP_SVCS
  54. {
  55. SD_BLE_GAP_ADDRESS_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */
  56. SD_BLE_GAP_ADDRESS_GET, /**< Get own Bluetooth Address. */
  57. SD_BLE_GAP_ADV_DATA_SET, /**< Set Advertising Data. */
  58. SD_BLE_GAP_ADV_START, /**< Start Advertising. */
  59. SD_BLE_GAP_ADV_STOP, /**< Stop Advertising. */
  60. SD_BLE_GAP_CONN_PARAM_UPDATE, /**< Connection Parameter Update. */
  61. SD_BLE_GAP_DISCONNECT, /**< Disconnect. */
  62. SD_BLE_GAP_TX_POWER_SET, /**< Set TX Power. */
  63. SD_BLE_GAP_APPEARANCE_SET, /**< Set Appearance. */
  64. SD_BLE_GAP_APPEARANCE_GET, /**< Get Appearance. */
  65. SD_BLE_GAP_PPCP_SET, /**< Set PPCP. */
  66. SD_BLE_GAP_PPCP_GET, /**< Get PPCP. */
  67. SD_BLE_GAP_DEVICE_NAME_SET, /**< Set Device Name. */
  68. SD_BLE_GAP_DEVICE_NAME_GET, /**< Get Device Name. */
  69. SD_BLE_GAP_AUTHENTICATE, /**< Initiate Pairing/Bonding. */
  70. SD_BLE_GAP_SEC_PARAMS_REPLY, /**< Reply with Security Parameters. */
  71. SD_BLE_GAP_AUTH_KEY_REPLY, /**< Reply with an authentication key. */
  72. SD_BLE_GAP_LESC_DHKEY_REPLY, /**< Reply with an LE Secure Connections DHKey. */
  73. SD_BLE_GAP_KEYPRESS_NOTIFY, /**< Notify of a keypress during an authentication procedure. */
  74. SD_BLE_GAP_LESC_OOB_DATA_GET, /**< Get the local LE Secure Connections OOB data. */
  75. SD_BLE_GAP_LESC_OOB_DATA_SET, /**< Set the remote LE Secure Connections OOB data. */
  76. SD_BLE_GAP_ENCRYPT, /**< Initiate encryption procedure. */
  77. SD_BLE_GAP_SEC_INFO_REPLY, /**< Reply with Security Information. */
  78. SD_BLE_GAP_CONN_SEC_GET, /**< Obtain connection security level. */
  79. SD_BLE_GAP_RSSI_START, /**< Start reporting of changes in RSSI. */
  80. SD_BLE_GAP_RSSI_STOP, /**< Stop reporting of changes in RSSI. */
  81. SD_BLE_GAP_SCAN_START, /**< Start Scanning. */
  82. SD_BLE_GAP_SCAN_STOP, /**< Stop Scanning. */
  83. SD_BLE_GAP_CONNECT, /**< Connect. */
  84. SD_BLE_GAP_CONNECT_CANCEL, /**< Cancel ongoing connection procedure. */
  85. SD_BLE_GAP_RSSI_GET, /**< Get the last RSSI sample. */
  86. };
  87. /**@brief GAP Event IDs.
  88. * IDs that uniquely identify an event coming from the stack to the application.
  89. */
  90. enum BLE_GAP_EVTS
  91. {
  92. BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connection established. \n See @ref ble_gap_evt_connected_t. */
  93. BLE_GAP_EVT_DISCONNECTED, /**< Disconnected from peer. \n See @ref ble_gap_evt_disconnected_t. */
  94. BLE_GAP_EVT_CONN_PARAM_UPDATE, /**< Connection Parameters updated. \n See @ref ble_gap_evt_conn_param_update_t. */
  95. BLE_GAP_EVT_SEC_PARAMS_REQUEST, /**< Request to provide security parameters. \n Reply with @ref sd_ble_gap_sec_params_reply. \n See @ref ble_gap_evt_sec_params_request_t. */
  96. BLE_GAP_EVT_SEC_INFO_REQUEST, /**< Request to provide security information. \n Reply with @ref sd_ble_gap_sec_info_reply. \n See @ref ble_gap_evt_sec_info_request_t. */
  97. BLE_GAP_EVT_PASSKEY_DISPLAY, /**< Request to display a passkey to the user. \n In LESC Numeric Comparison, reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_passkey_display_t. */
  98. BLE_GAP_EVT_KEY_PRESSED, /**< Notification of a keypress on the remote device.\n See @ref ble_gap_evt_key_pressed_t */
  99. BLE_GAP_EVT_AUTH_KEY_REQUEST, /**< Request to provide an authentication key. \n Reply with @ref sd_ble_gap_auth_key_reply. \n See @ref ble_gap_evt_auth_key_request_t. */
  100. BLE_GAP_EVT_LESC_DHKEY_REQUEST, /**< Request to calculate an LE Secure Connections DHKey. \n Reply with @ref sd_ble_gap_lesc_dhkey_reply. \n See @ref ble_gap_evt_lesc_dhkey_request_t */
  101. BLE_GAP_EVT_AUTH_STATUS, /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */
  102. BLE_GAP_EVT_CONN_SEC_UPDATE, /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */
  103. BLE_GAP_EVT_TIMEOUT, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */
  104. BLE_GAP_EVT_RSSI_CHANGED, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */
  105. BLE_GAP_EVT_ADV_REPORT, /**< Advertising report. \n See @ref ble_gap_evt_adv_report_t. */
  106. BLE_GAP_EVT_SEC_REQUEST, /**< Security Request. \n See @ref ble_gap_evt_sec_request_t. */
  107. BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, /**< Connection Parameter Update Request. \n Reply with @ref sd_ble_gap_conn_param_update. \n See @ref ble_gap_evt_conn_param_update_request_t. */
  108. BLE_GAP_EVT_SCAN_REQ_REPORT, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */
  109. };
  110. /**@brief GAP Option IDs.
  111. * IDs that uniquely identify a GAP option.
  112. */
  113. enum BLE_GAP_OPTS
  114. {
  115. BLE_GAP_OPT_CH_MAP = BLE_GAP_OPT_BASE, /**< Channel Map. @ref ble_gap_opt_ch_map_t */
  116. BLE_GAP_OPT_LOCAL_CONN_LATENCY, /**< Local connection latency. @ref ble_gap_opt_local_conn_latency_t */
  117. BLE_GAP_OPT_PASSKEY, /**< Set passkey. @ref ble_gap_opt_passkey_t */
  118. BLE_GAP_OPT_PRIVACY, /**< Custom privacy. @ref ble_gap_opt_privacy_t */
  119. BLE_GAP_OPT_SCAN_REQ_REPORT, /**< Scan request report. @ref ble_gap_opt_scan_req_report_t */
  120. BLE_GAP_OPT_COMPAT_MODE /**< Compatibility mode. @ref ble_gap_opt_compat_mode_t */
  121. };
  122. /** @} */
  123. /**@addtogroup BLE_GAP_DEFINES Defines
  124. * @{ */
  125. /**@defgroup BLE_ERRORS_GAP SVC return values specific to GAP
  126. * @{ */
  127. #define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */
  128. #define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */
  129. #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. */
  130. #define BLE_ERROR_GAP_WHITELIST_IN_USE (NRF_GAP_ERR_BASE + 0x003) /**< Attempt to overwrite the whitelist while already in use by another operation. */
  131. /**@} */
  132. /**@defgroup BLE_GAP_ROLES GAP Roles
  133. * @note Not explicitly used in peripheral API, but will be relevant for central API.
  134. * @{ */
  135. #define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */
  136. #define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */
  137. #define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */
  138. /**@} */
  139. /**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources
  140. * @{ */
  141. #define BLE_GAP_TIMEOUT_SRC_ADVERTISING 0x00 /**< Advertising timeout. */
  142. #define BLE_GAP_TIMEOUT_SRC_SECURITY_REQUEST 0x01 /**< Security request timeout. */
  143. #define BLE_GAP_TIMEOUT_SRC_SCAN 0x02 /**< Scanning timeout. */
  144. #define BLE_GAP_TIMEOUT_SRC_CONN 0x03 /**< Connection timeout. */
  145. /**@} */
  146. /**@defgroup BLE_GAP_ADDR_TYPES GAP Address types
  147. * @{ */
  148. #define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public address. */
  149. #define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random Static address. */
  150. #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Private Resolvable address. */
  151. #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Private Non-Resolvable address. */
  152. /**@} */
  153. /**@defgroup BLE_GAP_ADDR_CYCLE_MODES GAP Address cycle modes
  154. * @{ */
  155. #define BLE_GAP_ADDR_CYCLE_MODE_NONE 0x00 /**< Set addresses directly, no automatic address cycling. */
  156. #define BLE_GAP_ADDR_CYCLE_MODE_AUTO 0x01 /**< Automatically generate and update private addresses. */
  157. /** @} */
  158. /**@brief The default interval in seconds at which a private address is refreshed when address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO. */
  159. #define BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S (60 * 15)
  160. /** @brief BLE address length. */
  161. #define BLE_GAP_ADDR_LEN 6
  162. /**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format
  163. * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm
  164. * @{ */
  165. #define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */
  166. #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */
  167. #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */
  168. #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */
  169. #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */
  170. #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */
  171. #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */
  172. #define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */
  173. #define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */
  174. #define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */
  175. #define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */
  176. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */
  177. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */
  178. #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */
  179. #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */
  180. #define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */
  181. #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */
  182. #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */
  183. #define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data - 16-bit UUID. */
  184. #define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */
  185. #define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */
  186. #define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */
  187. #define BLE_GAP_AD_TYPE_ADVERTISING_INTERVAL 0x1A /**< Advertising Interval. */
  188. #define BLE_GAP_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS 0x1B /**< LE Bluetooth Device Address. */
  189. #define BLE_GAP_AD_TYPE_LE_ROLE 0x1C /**< LE Role. */
  190. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C256 0x1D /**< Simple Pairing Hash C-256. */
  191. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 0x1E /**< Simple Pairing Randomizer R-256. */
  192. #define BLE_GAP_AD_TYPE_SERVICE_DATA_32BIT_UUID 0x20 /**< Service Data - 32-bit UUID. */
  193. #define BLE_GAP_AD_TYPE_SERVICE_DATA_128BIT_UUID 0x21 /**< Service Data - 128-bit UUID. */
  194. #define BLE_GAP_AD_TYPE_URI 0x24 /**< URI */
  195. #define BLE_GAP_AD_TYPE_3D_INFORMATION_DATA 0x3D /**< 3D Information Data. */
  196. #define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */
  197. /**@} */
  198. /**@defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags
  199. * @{ */
  200. #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */
  201. #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */
  202. #define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */
  203. #define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */
  204. #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */
  205. #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. */
  206. #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. */
  207. /**@} */
  208. /**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min
  209. * @{ */
  210. #define BLE_GAP_ADV_INTERVAL_MIN 0x0020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */
  211. #define BLE_GAP_ADV_NONCON_INTERVAL_MIN 0x00A0 /**< Minimum Advertising interval in 625 us units for non connectable mode, i.e. 100 ms. */
  212. #define BLE_GAP_ADV_INTERVAL_MAX 0x4000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */
  213. /**@} */
  214. /**@defgroup BLE_GAP_SCAN_INTERVALS GAP Scan interval max and min
  215. * @{ */
  216. #define BLE_GAP_SCAN_INTERVAL_MIN 0x0004 /**< Minimum Scan interval in 625 us units, i.e. 2.5 ms. */
  217. #define BLE_GAP_SCAN_INTERVAL_MAX 0x4000 /**< Maximum Scan interval in 625 us units, i.e. 10.24 s. */
  218. /** @} */
  219. /**@defgroup BLE_GAP_SCAN_WINDOW GAP Scan window max and min
  220. * @{ */
  221. #define BLE_GAP_SCAN_WINDOW_MIN 0x0004 /**< Minimum Scan window in 625 us units, i.e. 2.5 ms. */
  222. #define BLE_GAP_SCAN_WINDOW_MAX 0x4000 /**< Maximum Scan window in 625 us units, i.e. 10.24 s. */
  223. /** @} */
  224. /**@defgroup BLE_GAP_SCAN_TIMEOUT GAP Scan timeout max and min
  225. * @{ */
  226. #define BLE_GAP_SCAN_TIMEOUT_MIN 0x0001 /**< Minimum Scan timeout in seconds. */
  227. #define BLE_GAP_SCAN_TIMEOUT_MAX 0xFFFF /**< Maximum Scan timeout in seconds. */
  228. /** @} */
  229. /**@brief Maximum size of advertising data in octets. */
  230. #define BLE_GAP_ADV_MAX_SIZE 31
  231. /**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types
  232. * @{ */
  233. #define BLE_GAP_ADV_TYPE_ADV_IND 0x00 /**< Connectable undirected. */
  234. #define BLE_GAP_ADV_TYPE_ADV_DIRECT_IND 0x01 /**< Connectable directed. */
  235. #define BLE_GAP_ADV_TYPE_ADV_SCAN_IND 0x02 /**< Scannable undirected. */
  236. #define BLE_GAP_ADV_TYPE_ADV_NONCONN_IND 0x03 /**< Non connectable undirected. */
  237. /**@} */
  238. /**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies
  239. * @{ */
  240. #define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */
  241. #define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */
  242. #define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */
  243. #define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */
  244. /**@} */
  245. /**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values
  246. * @{ */
  247. #define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX 180 /**< Maximum advertising time in limited discoverable mode (TGAP(lim_adv_timeout) = 180s). */
  248. #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED 0 /**< Unlimited advertising in general discoverable mode. */
  249. /**@} */
  250. /**@defgroup BLE_GAP_DISC_MODES GAP Discovery modes
  251. * @{ */
  252. #define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */
  253. #define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */
  254. #define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */
  255. /**@} */
  256. /**@defgroup BLE_GAP_IO_CAPS GAP IO Capabilities
  257. * @{ */
  258. #define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */
  259. #define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */
  260. #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */
  261. #define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */
  262. #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */
  263. /**@} */
  264. /**@defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types
  265. * @{ */
  266. #define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */
  267. #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */
  268. #define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */
  269. /**@} */
  270. /**@defgroup BLE_GAP_KP_NOT_TYPES GAP Keypress Notification Types
  271. * @{ */
  272. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_START 0x00 /**< Passkey entry started. */
  273. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_IN 0x01 /**< Passkey digit entered. */
  274. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_OUT 0x02 /**< Passkey digit erased. */
  275. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_CLEAR 0x03 /**< Passkey cleared. */
  276. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_END 0x04 /**< Passkey entry completed. */
  277. /**@} */
  278. /**@defgroup BLE_GAP_SEC_STATUS GAP Security status
  279. * @{ */
  280. #define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Procedure completed with success. */
  281. #define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */
  282. #define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */
  283. #define BLE_GAP_SEC_STATUS_RFU_RANGE1_BEGIN 0x03 /**< Reserved for Future Use range #1 begin. */
  284. #define BLE_GAP_SEC_STATUS_RFU_RANGE1_END 0x80 /**< Reserved for Future Use range #1 end. */
  285. #define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user cancelled or other). */
  286. #define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */
  287. #define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */
  288. #define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */
  289. #define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */
  290. #define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */
  291. #define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */
  292. #define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */
  293. #define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */
  294. #define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */
  295. #define BLE_GAP_SEC_STATUS_DHKEY_FAILURE 0x8B /**< DHKey check failure. */
  296. #define BLE_GAP_SEC_STATUS_NUM_COMP_FAILURE 0x8C /**< Numeric Comparison failure. */
  297. #define BLE_GAP_SEC_STATUS_BR_EDR_IN_PROG 0x8D /**< BR/EDR pairing in progress. */
  298. #define BLE_GAP_SEC_STATUS_X_TRANS_KEY_DISALLOWED 0x8E /**< BR/EDR Link Key cannot be used for LE keys. */
  299. #define BLE_GAP_SEC_STATUS_RFU_RANGE2_BEGIN 0x8F /**< Reserved for Future Use range #2 begin. */
  300. #define BLE_GAP_SEC_STATUS_RFU_RANGE2_END 0xFF /**< Reserved for Future Use range #2 end. */
  301. /**@} */
  302. /**@defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources
  303. * @{ */
  304. #define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */
  305. #define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */
  306. /**@} */
  307. /**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
  308. * @{ */
  309. #define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connection interval specified in connect parameters. */
  310. #define BLE_GAP_CP_MIN_CONN_INTVL_MIN 0x0006 /**< Lowest minimum connection interval permitted, in units of 1.25 ms, i.e. 7.5 ms. */
  311. #define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
  312. #define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connection interval specified in connect parameters. */
  313. #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. */
  314. #define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
  315. #define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x01F3 /**< Highest slave latency permitted, in connection events. */
  316. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */
  317. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */
  318. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */
  319. /**@} */
  320. /**@brief GAP device name maximum length. */
  321. #define BLE_GAP_DEVNAME_MAX_LEN 31
  322. /**@brief Disable RSSI events for connections */
  323. #define BLE_GAP_RSSI_THRESHOLD_INVALID 0xFF
  324. /**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
  325. *
  326. * See @ref ble_gap_conn_sec_mode_t.
  327. * @{ */
  328. /**@brief Set sec_mode pointed to by ptr to have no access rights.*/
  329. #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0)
  330. /**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/
  331. #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0)
  332. /**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
  333. #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0)
  334. /**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
  335. #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0)
  336. /**@brief Set sec_mode pointed to by ptr to require LESC encryption and MITM protection.*/
  337. #define BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 4;} while(0)
  338. /**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
  339. #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0)
  340. /**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
  341. #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0)
  342. /**@} */
  343. /**@brief GAP Security Random Number Length. */
  344. #define BLE_GAP_SEC_RAND_LEN 8
  345. /**@brief GAP Security Key Length. */
  346. #define BLE_GAP_SEC_KEY_LEN 16
  347. /**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key Length. */
  348. #define BLE_GAP_LESC_P256_PK_LEN 64
  349. /**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman DHKey Length. */
  350. #define BLE_GAP_LESC_DHKEY_LEN 32
  351. /**@brief GAP Passkey Length. */
  352. #define BLE_GAP_PASSKEY_LEN 6
  353. /**@brief Maximum amount of addresses in a whitelist. */
  354. #define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8)
  355. /**@brief Maximum amount of IRKs in a whitelist.
  356. * @note The number of IRKs is limited to 8, even if the hardware supports more.
  357. */
  358. #define BLE_GAP_WHITELIST_IRK_MAX_COUNT (8)
  359. /**@defgroup GAP_SEC_MODES GAP Security Modes
  360. * @{ */
  361. #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */
  362. /**@} */
  363. /** @} */
  364. /**@addtogroup BLE_GAP_STRUCTURES Structures
  365. * @{ */
  366. /**
  367. * @brief BLE GAP initialization parameters.
  368. */
  369. typedef struct
  370. {
  371. uint8_t periph_conn_count; /**< Number of connections acting as a peripheral */
  372. uint8_t central_conn_count; /**< Number of connections acting as a central */
  373. uint8_t central_sec_count; /**< Number of SMP instances for all connections acting as a central. */
  374. } ble_gap_enable_params_t;
  375. /**@brief Bluetooth Low Energy address. */
  376. typedef struct
  377. {
  378. uint8_t addr_type; /**< See @ref BLE_GAP_ADDR_TYPES. */
  379. uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */
  380. } ble_gap_addr_t;
  381. /**@brief GAP connection parameters.
  382. *
  383. * @note When ble_conn_params_t is received in an event, both min_conn_interval and
  384. * max_conn_interval will be equal to the connection interval set by the central.
  385. *
  386. * @note If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies:
  387. * conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval
  388. * that corresponds to the following Bluetooth Spec requirement:
  389. * The Supervision_Timeout in milliseconds shall be larger than
  390. * (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds.
  391. */
  392. typedef struct
  393. {
  394. uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  395. uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  396. uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
  397. uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  398. } ble_gap_conn_params_t;
  399. /**@brief GAP connection security modes.
  400. *
  401. * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n
  402. * Security Mode 1 Level 1: No security is needed (aka open link).\n
  403. * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n
  404. * Security Mode 1 Level 3: MITM protected encrypted link required.\n
  405. * Security Mode 1 Level 4: LESC MITM protected encrypted link required.\n
  406. * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n
  407. * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n
  408. */
  409. typedef struct
  410. {
  411. uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */
  412. uint8_t lv : 4; /**< Level (1, 2, 3 or 4), 0 for no permissions at all. */
  413. } ble_gap_conn_sec_mode_t;
  414. /**@brief GAP connection security status.*/
  415. typedef struct
  416. {
  417. ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/
  418. uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets (only applicable for bonding procedures). */
  419. } ble_gap_conn_sec_t;
  420. /**@brief Identity Resolving Key. */
  421. typedef struct
  422. {
  423. uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */
  424. } ble_gap_irk_t;
  425. /**@brief Whitelist structure. */
  426. typedef struct
  427. {
  428. ble_gap_addr_t **pp_addrs; /**< Pointer to an array of device address pointers, pointing to addresses to be used in whitelist. NULL if none are given. */
  429. uint8_t addr_count; /**< Count of device addresses in array, up to @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT. */
  430. ble_gap_irk_t **pp_irks; /**< Pointer to an array of Identity Resolving Key (IRK) pointers, each pointing to an IRK in the whitelist. NULL if none are given. */
  431. uint8_t irk_count; /**< Count of IRKs in array, up to @ref BLE_GAP_WHITELIST_IRK_MAX_COUNT. */
  432. } ble_gap_whitelist_t;
  433. /**@brief Channel mask for RF channels used in advertising. */
  434. typedef struct
  435. {
  436. uint8_t ch_37_off : 1; /**< Setting this bit to 1 will turn off advertising on channel 37 */
  437. uint8_t ch_38_off : 1; /**< Setting this bit to 1 will turn off advertising on channel 38 */
  438. uint8_t ch_39_off : 1; /**< Setting this bit to 1 will turn off advertising on channel 39 */
  439. } ble_gap_adv_ch_mask_t;
  440. /**@brief GAP advertising parameters.*/
  441. typedef struct
  442. {
  443. uint8_t type; /**< See @ref BLE_GAP_ADV_TYPES. */
  444. ble_gap_addr_t *p_peer_addr; /**< For @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND mode only, known peer address. */
  445. uint8_t fp; /**< Filter Policy, see @ref BLE_GAP_ADV_FILTER_POLICIES. */
  446. ble_gap_whitelist_t *p_whitelist; /**< Pointer to whitelist, NULL if no whitelist or the current active whitelist is to be used. */
  447. uint16_t interval; /**< Advertising interval between 0x0020 and 0x4000 in 0.625 ms units (20ms to 10.24s), see @ref BLE_GAP_ADV_INTERVALS.
  448. - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for high duty cycle directed advertising.
  449. - If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, set @ref BLE_GAP_ADV_INTERVAL_MIN <= interval <= @ref BLE_GAP_ADV_INTERVAL_MAX for low duty cycle advertising.*/
  450. uint16_t timeout; /**< Advertising timeout between 0x0001 and 0x3FFF in seconds, 0x0000 disables timeout. See also @ref BLE_GAP_ADV_TIMEOUT_VALUES. If type equals @ref BLE_GAP_ADV_TYPE_ADV_DIRECT_IND, this parameter must be set to 0 for High duty cycle directed advertising. */
  451. ble_gap_adv_ch_mask_t channel_mask; /**< Advertising channel mask. See @ref ble_gap_adv_ch_mask_t. */
  452. } ble_gap_adv_params_t;
  453. /**@brief GAP scanning parameters. */
  454. typedef struct
  455. {
  456. uint8_t active : 1; /**< If 1, perform active scanning (scan requests). */
  457. uint8_t selective : 1; /**< If 1, ignore unknown devices (non whitelisted). */
  458. ble_gap_whitelist_t * p_whitelist; /**< Pointer to whitelist, NULL if no whitelist or the current active whitelist is to be used. */
  459. uint16_t interval; /**< Scan interval between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
  460. uint16_t window; /**< Scan window between 0x0004 and 0x4000 in 0.625ms units (2.5ms to 10.24s). */
  461. uint16_t timeout; /**< Scan timeout between 0x0001 and 0xFFFF in seconds, 0x0000 disables timeout. */
  462. } ble_gap_scan_params_t;
  463. /** @brief Keys that can be exchanged during a bonding procedure. */
  464. typedef struct
  465. {
  466. uint8_t enc : 1; /**< Long Term Key and Master Identification. */
  467. uint8_t id : 1; /**< Identity Resolving Key and Identity Address Information. */
  468. uint8_t sign : 1; /**< Connection Signature Resolving Key. */
  469. uint8_t link : 1; /**< Derive the Link Key from the LTK. */
  470. } ble_gap_sec_kdist_t;
  471. /**@brief GAP security parameters. */
  472. typedef struct
  473. {
  474. uint8_t bond : 1; /**< Perform bonding. */
  475. uint8_t mitm : 1; /**< Enable Man In The Middle protection. */
  476. uint8_t lesc : 1; /**< Enable LE Secure Connection pairing. */
  477. uint8_t keypress : 1; /**< Enable generation of keypress notifications. */
  478. uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */
  479. uint8_t oob : 1; /**< Out Of Band data available. */
  480. uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance. */
  481. uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */
  482. ble_gap_sec_kdist_t kdist_own; /**< Key distribution bitmap: keys that the local device will distribute. */
  483. ble_gap_sec_kdist_t kdist_peer; /**< Key distribution bitmap: keys that the remote device will distribute. */
  484. } ble_gap_sec_params_t;
  485. /**@brief GAP Encryption Information. */
  486. typedef struct
  487. {
  488. uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */
  489. uint8_t lesc : 1; /**< Key generated using LE Secure Connections. */
  490. uint8_t auth : 1; /**< Authenticated Key. */
  491. uint8_t ltk_len : 6; /**< LTK length in octets. */
  492. } ble_gap_enc_info_t;
  493. /**@brief GAP Master Identification. */
  494. typedef struct
  495. {
  496. uint16_t ediv; /**< Encrypted Diversifier. */
  497. uint8_t rand[BLE_GAP_SEC_RAND_LEN]; /**< Random Number. */
  498. } ble_gap_master_id_t;
  499. /**@brief GAP Signing Information. */
  500. typedef struct
  501. {
  502. uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /**< Connection Signature Resolving Key. */
  503. } ble_gap_sign_info_t;
  504. /**@brief GAP LE Secure Connections P-256 Public Key. */
  505. typedef struct
  506. {
  507. uint8_t pk[BLE_GAP_LESC_P256_PK_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key. Stored in the standard SMP protocol format: {X,Y} both in little-endian. */
  508. } ble_gap_lesc_p256_pk_t;
  509. /**@brief GAP LE Secure Connections DHKey. */
  510. typedef struct
  511. {
  512. uint8_t key[BLE_GAP_LESC_DHKEY_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman Key. Stored in little-endian. */
  513. } ble_gap_lesc_dhkey_t;
  514. /**@brief GAP LE Secure Connections OOB data. */
  515. typedef struct
  516. {
  517. ble_gap_addr_t addr; /**< Bluetooth address of the device. */
  518. uint8_t r[BLE_GAP_SEC_KEY_LEN]; /**< Random Number. */
  519. uint8_t c[BLE_GAP_SEC_KEY_LEN]; /**< Confirm Value. */
  520. } ble_gap_lesc_oob_data_t;
  521. /**@brief Event structure for @ref BLE_GAP_EVT_CONNECTED. */
  522. typedef struct
  523. {
  524. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
  525. ble_gap_addr_t own_addr; /**< Bluetooth address of the local device used during connection setup. */
  526. uint8_t role; /**< BLE role for this connection, see @ref BLE_GAP_ROLES */
  527. uint8_t irk_match :1; /**< If 1, peer device's address resolved using an IRK. */
  528. uint8_t irk_match_idx :7; /**< Index in IRK list where the address was matched. */
  529. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  530. } ble_gap_evt_connected_t;
  531. /**@brief Event structure for @ref BLE_GAP_EVT_DISCONNECTED. */
  532. typedef struct
  533. {
  534. uint8_t reason; /**< HCI error code, see @ref BLE_HCI_STATUS_CODES. */
  535. } ble_gap_evt_disconnected_t;
  536. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE. */
  537. typedef struct
  538. {
  539. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  540. } ble_gap_evt_conn_param_update_t;
  541. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. */
  542. typedef struct
  543. {
  544. ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */
  545. } ble_gap_evt_sec_params_request_t;
  546. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_INFO_REQUEST. */
  547. typedef struct
  548. {
  549. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
  550. ble_gap_master_id_t master_id; /**< Master Identification for LTK lookup. */
  551. uint8_t enc_info : 1; /**< If 1, Encryption Information required. */
  552. uint8_t id_info : 1; /**< If 1, Identity Information required. */
  553. uint8_t sign_info : 1; /**< If 1, Signing Information required. */
  554. } ble_gap_evt_sec_info_request_t;
  555. /**@brief Event structure for @ref BLE_GAP_EVT_PASSKEY_DISPLAY. */
  556. typedef struct
  557. {
  558. uint8_t passkey[BLE_GAP_PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
  559. uint8_t match_request : 1; /**< If 1 requires the application to report the match using @ref sd_ble_gap_auth_key_reply
  560. with either @ref BLE_GAP_AUTH_KEY_TYPE_NONE if there is no match or
  561. @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY if there is a match. */
  562. } ble_gap_evt_passkey_display_t;
  563. /**@brief Event structure for @ref BLE_GAP_EVT_KEY_PRESSED. */
  564. typedef struct
  565. {
  566. uint8_t kp_not; /**< Keypress notification type, see @ref BLE_GAP_KP_NOT_TYPES. */
  567. } ble_gap_evt_key_pressed_t;
  568. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_KEY_REQUEST. */
  569. typedef struct
  570. {
  571. uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */
  572. } ble_gap_evt_auth_key_request_t;
  573. /**@brief Event structure for @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST. */
  574. typedef struct
  575. {
  576. ble_gap_lesc_p256_pk_t *p_pk_peer; /**< LE Secure Connections remote P-256 Public Key. This will point to the application-supplied memory
  577. inside the keyset during the call to @ref sd_ble_gap_sec_params_reply. */
  578. uint8_t oobd_req :1; /**< LESC OOB data required. A call to @ref sd_ble_gap_lesc_oob_data_set is required to complete the procedure. */
  579. } ble_gap_evt_lesc_dhkey_request_t;
  580. /**@brief Security levels supported.
  581. * @note See Bluetooth Specification Version 4.2 Volume 3, Part C, Chapter 10, Section 10.2.1.
  582. */
  583. typedef struct
  584. {
  585. uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */
  586. uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */
  587. uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */
  588. uint8_t lv4 : 1; /**< If 1: Level 4 is supported. */
  589. } ble_gap_sec_levels_t;
  590. /**@brief Encryption Key. */
  591. typedef struct
  592. {
  593. ble_gap_enc_info_t enc_info; /**< Encryption Information. */
  594. ble_gap_master_id_t master_id; /**< Master Identification. */
  595. } ble_gap_enc_key_t;
  596. /**@brief Identity Key. */
  597. typedef struct
  598. {
  599. ble_gap_irk_t id_info; /**< Identity Information. */
  600. ble_gap_addr_t id_addr_info; /**< Identity Address Information. */
  601. } ble_gap_id_key_t;
  602. /**@brief Security Keys. */
  603. typedef struct
  604. {
  605. ble_gap_enc_key_t *p_enc_key; /**< Encryption Key, or NULL. */
  606. ble_gap_id_key_t *p_id_key; /**< Identity Key, or NULL. */
  607. ble_gap_sign_info_t *p_sign_key; /**< Signing Key, or NULL. */
  608. ble_gap_lesc_p256_pk_t *p_pk; /**< LE Secure Connections P-256 Public Key. When in debug mode the application must use the value defined
  609. in the Core Bluetooth Specification v4.2 Vol.3, Part H, Section 2.3.5.6.1 */
  610. } ble_gap_sec_keys_t;
  611. /**@brief Security key set for both local and peer keys. */
  612. typedef struct
  613. {
  614. ble_gap_sec_keys_t keys_own; /**< Keys distributed by the local device. For LE Secure Connections the encryption key will be generated locally and will always be stored if bonding. */
  615. ble_gap_sec_keys_t keys_peer; /**< Keys distributed by the remote device. For LE Secure Connections, p_enc_key must always be NULL. */
  616. } ble_gap_sec_keyset_t;
  617. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_STATUS. */
  618. typedef struct
  619. {
  620. uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */
  621. uint8_t error_src : 2; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */
  622. uint8_t bonded : 1; /**< Procedure resulted in a bond. */
  623. ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */
  624. ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */
  625. ble_gap_sec_kdist_t kdist_own; /**< Bitmap stating which keys were exchanged (distributed) by the local device. If bonding with LE Secure Connections, the enc bit will be always set. */
  626. ble_gap_sec_kdist_t kdist_peer; /**< Bitmap stating which keys were exchanged (distributed) by the remote device. If bonding with LE Secure Connections, the enc bit will never be set. */
  627. } ble_gap_evt_auth_status_t;
  628. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_SEC_UPDATE. */
  629. typedef struct
  630. {
  631. ble_gap_conn_sec_t conn_sec; /**< Connection security level. */
  632. } ble_gap_evt_conn_sec_update_t;
  633. /**@brief Event structure for @ref BLE_GAP_EVT_TIMEOUT. */
  634. typedef struct
  635. {
  636. uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */
  637. } ble_gap_evt_timeout_t;
  638. /**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */
  639. typedef struct
  640. {
  641. int8_t rssi; /**< Received Signal Strength Indication in dBm. */
  642. } ble_gap_evt_rssi_changed_t;
  643. /**@brief Event structure for @ref BLE_GAP_EVT_ADV_REPORT. */
  644. typedef struct
  645. {
  646. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
  647. int8_t rssi; /**< Received Signal Strength Indication in dBm. */
  648. uint8_t scan_rsp : 1; /**< If 1, the report corresponds to a scan response and the type field may be ignored. */
  649. uint8_t type : 2; /**< See @ref BLE_GAP_ADV_TYPES. Only valid if the scan_rsp field is 0. */
  650. uint8_t dlen : 5; /**< Advertising or scan response data length. */
  651. uint8_t data[BLE_GAP_ADV_MAX_SIZE]; /**< Advertising or scan response data. */
  652. } ble_gap_evt_adv_report_t;
  653. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_REQUEST. */
  654. typedef struct
  655. {
  656. uint8_t bond : 1; /**< Perform bonding. */
  657. uint8_t mitm : 1; /**< Man In The Middle protection requested. */
  658. uint8_t lesc : 1; /**< LE Secure Connections requested. */
  659. uint8_t keypress : 1; /**< Generation of keypress notifications requested. */
  660. } ble_gap_evt_sec_request_t;
  661. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST. */
  662. typedef struct
  663. {
  664. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  665. } ble_gap_evt_conn_param_update_request_t;
  666. /**@brief Event structure for @ref BLE_GAP_EVT_SCAN_REQ_REPORT. */
  667. typedef struct
  668. {
  669. int8_t rssi; /**< Received Signal Strength Indication in dBm. */
  670. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
  671. } ble_gap_evt_scan_req_report_t;
  672. /**@brief GAP event structure. */
  673. typedef struct
  674. {
  675. uint16_t conn_handle; /**< Connection Handle on which event occurred. */
  676. union /**< union alternative identified by evt_id in enclosing struct. */
  677. {
  678. ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */
  679. ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */
  680. ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */
  681. ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */
  682. ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */
  683. ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */
  684. ble_gap_evt_key_pressed_t key_pressed; /**< Key Pressed Event Parameters. */
  685. ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */
  686. ble_gap_evt_lesc_dhkey_request_t lesc_dhkey_request; /**< LE Secure Connections DHKey calculation request. */
  687. ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */
  688. ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */
  689. ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */
  690. ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event parameters. */
  691. ble_gap_evt_adv_report_t adv_report; /**< Advertising Report Event Parameters. */
  692. ble_gap_evt_sec_request_t sec_request; /**< Security Request Event Parameters. */
  693. ble_gap_evt_conn_param_update_request_t conn_param_update_request; /**< Connection Parameter Update Parameters. */
  694. ble_gap_evt_scan_req_report_t scan_req_report; /**< Scan Request Report parameters. */
  695. } params; /**< Event Parameters. */
  696. } ble_gap_evt_t;
  697. /**@brief Channel Map option.
  698. * Used with @ref sd_ble_opt_get to get the current channel map
  699. * or @ref sd_ble_opt_set to set a new channel map. When setting the
  700. * channel map, it applies to all current and future connections. When getting the
  701. * current channel map, it applies to a single connection and the connection handle
  702. * must be supplied.
  703. *
  704. * @note Setting the channel map may take some time, depending on connection parameters.
  705. * The time taken may be different for each connection and the get operation will
  706. * return the previous channel map until the new one has taken effect.
  707. *
  708. * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed.
  709. * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46.
  710. *
  711. * @retval ::NRF_SUCCESS Get or set successful.
  712. * @retval ::NRF_ERROR_BUSY Channel map was set again before enough time had passed.
  713. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  714. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied for get.
  715. * @retval ::NRF_ERROR_NOT_SUPPORTED Returned by sd_ble_opt_set in peripheral-only SoftDevices.
  716. *
  717. */
  718. typedef struct
  719. {
  720. uint16_t conn_handle; /**< Connection Handle (only applicable for get) */
  721. uint8_t ch_map[5]; /**< Channel Map (37-bit). */
  722. } ble_gap_opt_ch_map_t;
  723. /**@brief Local connection latency option.
  724. *
  725. * Local connection latency is a feature which enables the slave to improve
  726. * current consumption by ignoring the slave latency set by the peer. The
  727. * local connection latency can only be set to a multiple of the slave latency,
  728. * and cannot be longer than half of the supervision timeout.
  729. *
  730. * Used with @ref sd_ble_opt_set to set the local connection latency. The
  731. * @ref sd_ble_opt_get is not supported for this option, but the actual
  732. * local connection latency (unless set to NULL) is set as a return parameter
  733. * when setting the option.
  734. *
  735. * @note The latency set will be truncated down to the closest slave latency event
  736. * multiple, or the nearest multiple before half of the supervision timeout.
  737. *
  738. * @note The local connection latency is disabled by default, and needs to be enabled for new
  739. * connections and whenever the connection is updated.
  740. *
  741. * @retval ::NRF_SUCCESS Set successfully.
  742. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
  743. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  744. */
  745. typedef struct
  746. {
  747. uint16_t conn_handle; /**< Connection Handle */
  748. uint16_t requested_latency; /**< Requested local connection latency. */
  749. uint16_t * p_actual_latency; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
  750. } ble_gap_opt_local_conn_latency_t;
  751. /**@brief Passkey Option.
  752. *
  753. * Structure containing the passkey to be used during pairing. This can be used with @ref
  754. * sd_ble_opt_set to make the SoftDevice use a pre-programmed passkey for authentication
  755. * instead of generating a random one.
  756. *
  757. * @note @ref sd_ble_opt_get is not supported for this option.
  758. *
  759. */
  760. typedef struct
  761. {
  762. uint8_t * p_passkey; /**< Pointer to 6-digit ASCII string (digit 0..9 only, no NULL termination) passkey to be used during pairing. If this is NULL, the SoftDevice will generate a random passkey if required.*/
  763. } ble_gap_opt_passkey_t;
  764. /**@brief Custom Privacy Option.
  765. *
  766. * This structure is used with both @ref sd_ble_opt_set (as input) and with
  767. * @ref sd_ble_opt_get (as output).
  768. *
  769. * Structure containing:
  770. * - A pointer to an IRK to set (if input), or a place to store a read IRK (if output).
  771. * - A private address refresh cycle.
  772. *
  773. * @note The specified address cycle interval is used when the address cycle mode is
  774. * @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO. If 0 is given, the address will not be automatically
  775. * refreshed at all. The default interval is @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S.
  776. *
  777. * @note If the current address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO, the address will immediately be
  778. * refreshed when a custom privacy option is set. A new address can be generated manually by calling
  779. * @ref sd_ble_gap_address_set with the same type again.
  780. *
  781. * @note If the IRK is updated, the new IRK becomes the one to be distributed in all
  782. * bonding procedures performed after @ref sd_ble_opt_set returns.
  783. *
  784. * @retval ::NRF_SUCCESS Set or read successfully.
  785. * @retval ::NRF_ERROR_INVALID_ADDR The pointer to IRK storage is invalid.
  786. */
  787. typedef struct
  788. {
  789. ble_gap_irk_t * p_irk; /**< When input: Pointer to custom IRK, or NULL to use/reset to the device's default IRK. When output: Pointer to where the current IRK is to be stored, or NULL to not read out the IRK. */
  790. uint16_t interval_s; /**< When input: Custom private address cycle interval in seconds. When output: The current private address cycle interval. */
  791. } ble_gap_opt_privacy_t;
  792. /**@brief Scan request report option.
  793. *
  794. * This can be used with @ref sd_ble_opt_set to make the SoftDevice send
  795. * @ref BLE_GAP_EVT_SCAN_REQ_REPORT events.
  796. *
  797. * @note Due to the limited space reserved for scan request report events,
  798. * not all received scan requests will be reported.
  799. *
  800. * @note If whitelisting is used, only whitelisted requests are reported.
  801. *
  802. * @retval ::NRF_SUCCESS Set successfully.
  803. * @retval ::NRF_ERROR_INVALID_STATE When advertising is ongoing while the option is set.
  804. */
  805. typedef struct
  806. {
  807. uint8_t enable : 1; /**< Enable scan request reports. */
  808. } ble_gap_opt_scan_req_report_t;
  809. /**@brief Compatibility mode option.
  810. *
  811. * This can be used with @ref sd_ble_opt_set to enable and disable
  812. * compatibility modes. Compatibility modes are disabled by default.
  813. *
  814. * @note Compatibility mode 1 enables interoperability with devices that do not support
  815. * a value of 0 for the WinOffset parameter in the Link Layer CONNECT_REQ packet.
  816. *
  817. * @retval ::NRF_SUCCESS Set successfully.
  818. * @retval ::NRF_ERROR_INVALID_STATE When connection creation is ongoing while mode 1 is set.
  819. */
  820. typedef struct
  821. {
  822. uint8_t mode_1_enable : 1; /**< Enable compatibility mode 1.*/
  823. } ble_gap_opt_compat_mode_t;
  824. /**@brief Option structure for GAP options. */
  825. typedef union
  826. {
  827. ble_gap_opt_ch_map_t ch_map; /**< Parameters for the Channel Map option. */
  828. ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Parameters for the Local connection latency option */
  829. ble_gap_opt_passkey_t passkey; /**< Parameters for the Passkey option.*/
  830. ble_gap_opt_privacy_t privacy; /**< Parameters for the Custom privacy option. */
  831. ble_gap_opt_scan_req_report_t scan_req_report; /**< Parameters for the scan request report option.*/
  832. ble_gap_opt_compat_mode_t compat_mode; /**< Parameters for the compatibility mode option.*/
  833. } ble_gap_opt_t;
  834. /**@} */
  835. /**@addtogroup BLE_GAP_FUNCTIONS Functions
  836. * @{ */
  837. /**@brief Set local Bluetooth address.
  838. *
  839. * @note If the address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_AUTO, the address type is required to
  840. * be @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE or
  841. * @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. The given address is ignored and the
  842. * SoftDevice will generate a new private address automatically every
  843. * @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S seconds. If this API
  844. * call is used again with the same parameters, the SoftDevice will immediately
  845. * generate a new private address to replace the current address.
  846. *
  847. * @note If the application wishes to use a @ref BLE_GAP_ADDR_TYPE_PUBLIC or
  848. * @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC address, the cycle mode must be
  849. * @ref BLE_GAP_ADDR_CYCLE_MODE_NONE.
  850. *
  851. * @note By default the SoftDevice will set an address of type @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC upon being
  852. * enabled. The address is a random number populated during the IC manufacturing process and remains unchanged
  853. * for the lifetime of each IC.
  854. *
  855. * @note If this API function is called while advertising or scanning, the softdevice will immediately update the
  856. * advertising or scanning address without the need to stop the procedure in the following cases:
  857. * - If the previously set address is of type @ref BLE_GAP_ADDR_TYPE_PUBLIC and the new address
  858. * is also of type @ref BLE_GAP_ADDR_TYPE_PUBLIC
  859. * - If the previously set address is not @ref BLE_GAP_ADDR_TYPE_PUBLIC and the new address is
  860. * also not @ref BLE_GAP_ADDR_TYPE_PUBLIC.
  861. * If the address is changed from a @ref BLE_GAP_ADDR_TYPE_PUBLIC address to another type or from
  862. * another type to a @ref BLE_GAP_ADDR_TYPE_PUBLIC address, the change will take effect the next
  863. * time an advertising or scanning procedure is started.
  864. *
  865. * @note If the address cycle mode is @ref BLE_GAP_ADDR_CYCLE_MODE_NONE and the application is
  866. * using privacy, the application must take care to generate and set new private addresses
  867. * periodically to comply with the Privacy specification in Bluetooth Core Spec.
  868. *
  869. * @mscs
  870. * @mmsc{@ref BLE_GAP_ADV_MSC}
  871. * @endmscs
  872. *
  873. * @param[in] addr_cycle_mode Address cycle mode, see @ref BLE_GAP_ADDR_CYCLE_MODES.
  874. * @param[in] p_addr Pointer to address structure.
  875. *
  876. * @retval ::NRF_SUCCESS Address successfully set.
  877. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  878. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters.
  879. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address.
  880. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  881. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  882. */
  883. SVCALL(SD_BLE_GAP_ADDRESS_SET, uint32_t, sd_ble_gap_address_set(uint8_t addr_cycle_mode, ble_gap_addr_t const *p_addr));
  884. /**@brief Get local Bluetooth address.
  885. *
  886. * @param[out] p_addr Pointer to address structure to be filled in.
  887. *
  888. * @retval ::NRF_SUCCESS Address successfully retrieved.
  889. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  890. */
  891. SVCALL(SD_BLE_GAP_ADDRESS_GET, uint32_t, sd_ble_gap_address_get(ble_gap_addr_t *p_addr));
  892. /**@brief Set, clear or update advertising and scan response data.
  893. *
  894. * @note The format of the advertising data will be checked by this call to ensure interoperability.
  895. * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
  896. * duplicating the local name in the advertising data and scan response data.
  897. *
  898. * @note To clear the advertising data and set it to a 0-length packet, simply provide a valid pointer (p_data/p_sr_data) with its corresponding
  899. * length (dlen/srdlen) set to 0.
  900. *
  901. * @note The call will fail if p_data and p_sr_data are both NULL since this would have no effect.
  902. *
  903. * @mscs
  904. * @mmsc{@ref BLE_GAP_ADV_MSC}
  905. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  906. * @endmscs
  907. *
  908. * @param[in] p_data Raw data to be placed in advertising packet. If NULL, no changes are made to the current advertising packet data.
  909. * @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.
  910. * @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.
  911. * @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.
  912. *
  913. * @retval ::NRF_SUCCESS Advertising data successfully updated or cleared.
  914. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, both p_data and p_sr_data cannot be NULL.
  915. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  916. * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied.
  917. * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied, check the advertising data format specification.
  918. * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied.
  919. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data type.
  920. * @retval ::BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied.
  921. */
  922. SVCALL(SD_BLE_GAP_ADV_DATA_SET, uint32_t, sd_ble_gap_adv_data_set(uint8_t const *p_data, uint8_t dlen, uint8_t const *p_sr_data, uint8_t srdlen));
  923. /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  924. *
  925. * @note An application can start an advertising procedure for broadcasting purposes while a connection
  926. * is active. After a @ref BLE_GAP_EVT_CONNECTED event is received, this function may therefore
  927. * be called to start a broadcast advertising procedure. The advertising procedure
  928. * cannot however be connectable (it must be of type @ref BLE_GAP_ADV_TYPE_ADV_SCAN_IND or
  929. * @ref BLE_GAP_ADV_TYPE_ADV_NONCONN_IND). @note Only one advertiser may be active at any time.
  930. *
  931. * @note To use the currently active whitelist set p_adv_params->p_whitelist to NULL.
  932. *
  933. * @events
  934. * @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.}
  935. * @event{@ref BLE_GAP_EVT_TIMEOUT, Advertisement has timed out.}
  936. * @endevents
  937. *
  938. * @mscs
  939. * @mmsc{@ref BLE_GAP_ADV_MSC}
  940. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  941. * @endmscs
  942. *
  943. * @param[in] p_adv_params Pointer to advertising parameters structure.
  944. *
  945. * @retval ::NRF_SUCCESS The BLE stack has started advertising.
  946. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  947. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  948. * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached; connectable advertiser cannot be started.
  949. * @retval ::NRF_ERROR_NO_MEM The configured memory pools (see @ref ble_conn_bw_counts_t) are not large enough for the
  950. * bandwidth selected for this connection.
  951. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check the accepted ranges and limits.
  952. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Bluetooth address supplied.
  953. * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible.
  954. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  955. * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE Unable to replace the whitelist while another operation is using it.
  956. * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available.
  957. * Stop one or more currently active roles (Central, Peripheral or Observer) and try again
  958. */
  959. SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(ble_gap_adv_params_t const *p_adv_params));
  960. /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  961. *
  962. * @mscs
  963. * @mmsc{@ref BLE_GAP_ADV_MSC}
  964. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  965. * @endmscs
  966. *
  967. * @retval ::NRF_SUCCESS The BLE stack has stopped advertising.
  968. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in advertising state).
  969. */
  970. SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(void));
  971. /**@brief Update connection parameters.
  972. *
  973. * @details In the central role this will initiate a Link Layer connection parameter update procedure,
  974. * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for
  975. * the central to perform the procedure. In both cases, and regardless of success or failure, the application
  976. * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event.
  977. *
  978. * @details This function can be used as a central both to reply to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST or to start the procedure unrequested.
  979. *
  980. * @events
  981. * @event{@ref BLE_GAP_EVT_CONN_PARAM_UPDATE, Result of the connection parameter update procedure.}
  982. * @endevents
  983. *
  984. * @mscs
  985. * @mmsc{@ref BLE_GAP_CPU_MSC}
  986. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  987. * @mmsc{@ref BLE_GAP_MULTILINK_CPU_MSC}
  988. * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC}
  989. * @mmsc{@ref BLE_GAP_CENTRAL_CPU_MSC}
  990. * @endmscs
  991. *
  992. * @param[in] conn_handle Connection handle.
  993. * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role,
  994. * the parameters in the PPCP characteristic of the GAP service will be used instead.
  995. * If NULL is provided on a central role and in response to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request will be rejected
  996. *
  997. * @retval ::NRF_SUCCESS The Connection Update procedure has been started successfully.
  998. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  999. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
  1000. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1001. * @retval ::NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, process pending events and wait for pending procedures to complete and retry.
  1002. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1003. * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
  1004. */
  1005. 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 *p_conn_params));
  1006. /**@brief Disconnect (GAP Link Termination).
  1007. *
  1008. * @details This call initiates the disconnection procedure, and its completion will be communicated to the application
  1009. * with a @ref BLE_GAP_EVT_DISCONNECTED event.
  1010. *
  1011. * @events
  1012. * @event{@ref BLE_GAP_EVT_DISCONNECTED, Generated when disconnection procedure is complete.}
  1013. * @endevents
  1014. *
  1015. * @mscs
  1016. * @mmsc{@ref BLE_GAP_CONN_MSC}
  1017. * @endmscs
  1018. *
  1019. * @param[in] conn_handle Connection handle.
  1020. * @param[in] hci_status_code HCI status code, see @ref BLE_HCI_STATUS_CODES (accepted values are @ref BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION and @ref BLE_HCI_CONN_INTERVAL_UNACCEPTABLE).
  1021. *
  1022. * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully.
  1023. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1024. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1025. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (disconnection is already in progress).
  1026. */
  1027. SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
  1028. /**@brief Set the radio's transmit power.
  1029. *
  1030. * @param[in] tx_power Radio transmit power in dBm (accepted values are -40, -30, -20, -16, -12, -8, -4, 0, and 4 dBm).
  1031. *
  1032. * @note The -30dBm setting is only available on nRF51 series ICs.
  1033. * @note The -40dBm setting is only available on nRF52 series ICs.
  1034. *
  1035. * @retval ::NRF_SUCCESS Successfully changed the transmit power.
  1036. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1037. */
  1038. SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(int8_t tx_power));
  1039. /**@brief Set GAP Appearance value.
  1040. *
  1041. * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
  1042. *
  1043. * @retval ::NRF_SUCCESS Appearance value set successfully.
  1044. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1045. */
  1046. SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance));
  1047. /**@brief Get GAP Appearance value.
  1048. *
  1049. * @param[out] p_appearance Pointer to appearance (16-bit) to be filled in, see @ref BLE_APPEARANCES.
  1050. *
  1051. * @retval ::NRF_SUCCESS Appearance value retrieved successfully.
  1052. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1053. */
  1054. SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t *p_appearance));
  1055. /**@brief Set GAP Peripheral Preferred Connection Parameters.
  1056. *
  1057. * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters.
  1058. *
  1059. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully.
  1060. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1061. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1062. */
  1063. SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params));
  1064. /**@brief Get GAP Peripheral Preferred Connection Parameters.
  1065. *
  1066. * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored.
  1067. *
  1068. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully.
  1069. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1070. */
  1071. SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params));
  1072. /**@brief Set GAP device name.
  1073. *
  1074. * @param[in] p_write_perm Write permissions for the Device Name characteristic, see @ref ble_gap_conn_sec_mode_t.
  1075. * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string.
  1076. * @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).
  1077. *
  1078. * @retval ::NRF_SUCCESS GAP device name and permissions set successfully.
  1079. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1080. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1081. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1082. */
  1083. SVCALL(SD_BLE_GAP_DEVICE_NAME_SET, uint32_t, sd_ble_gap_device_name_set(ble_gap_conn_sec_mode_t const *p_write_perm, uint8_t const *p_dev_name, uint16_t len));
  1084. /**@brief Get GAP device name.
  1085. *
  1086. * @note If the device name is longer than the size of the supplied buffer,
  1087. * p_len will return the complete device name length,
  1088. * and not the number of bytes actually returned in p_dev_name.
  1089. * The application may use this information to allocate a suitable buffer size.
  1090. *
  1091. * @param[out] 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.
  1092. * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output.
  1093. *
  1094. * @retval ::NRF_SUCCESS GAP device name retrieved successfully.
  1095. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1096. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1097. */
  1098. SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t *p_dev_name, uint16_t *p_len));
  1099. /**@brief Initiate the GAP Authentication procedure.
  1100. *
  1101. * @details In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected),
  1102. * otherwise in the peripheral role, an SMP Security Request will be sent.
  1103. *
  1104. * @events
  1105. * @event{Depending on the security parameters set and the packet exchanges with the peer\, the following events may be generated:}
  1106. * @event{@ref BLE_GAP_EVT_SEC_PARAMS_REQUEST}
  1107. * @event{@ref BLE_GAP_EVT_SEC_INFO_REQUEST}
  1108. * @event{@ref BLE_GAP_EVT_PASSKEY_DISPLAY}
  1109. * @event{@ref BLE_GAP_EVT_KEY_PRESSED}
  1110. * @event{@ref BLE_GAP_EVT_AUTH_KEY_REQUEST}
  1111. * @event{@ref BLE_GAP_EVT_LESC_DHKEY_REQUEST}
  1112. * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE}
  1113. * @event{@ref BLE_GAP_EVT_AUTH_STATUS}
  1114. * @event{@ref BLE_GAP_EVT_TIMEOUT}
  1115. * @endevents
  1116. *
  1117. * @mscs
  1118. * @mmsc{@ref BLE_GAP_PERIPH_SEC_REQ_MSC}
  1119. * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC}
  1120. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  1121. * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC}
  1122. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC}
  1123. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC}
  1124. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1125. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1126. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1127. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1128. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1129. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1130. * @endmscs
  1131. *
  1132. * @param[in] conn_handle Connection handle.
  1133. * @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 or bonding procedure.
  1134. * In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used.
  1135. * In the central role, this pointer may be NULL to reject a Security Request.
  1136. *
  1137. * @retval ::NRF_SUCCESS Successfully initiated authentication procedure.
  1138. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1139. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1140. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1141. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1142. * @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached.
  1143. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1144. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
  1145. * @retval ::NRF_ERROR_TIMEOUT A SMP timeout has occurred, and further SMP operations on this link is prohibited.
  1146. */
  1147. SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params));
  1148. /**@brief Reply with GAP security parameters.
  1149. *
  1150. * @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 @ref NRF_ERROR_INVALID_STATE.
  1151. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1152. *
  1153. * @events
  1154. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1155. * @endevents
  1156. *
  1157. * @mscs
  1158. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_JW_MSC}
  1159. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_JW_MSC}
  1160. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_PERIPH_MSC}
  1161. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1162. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
  1163. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_CONFIRM_FAIL_MSC}
  1164. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1165. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1166. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1167. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1168. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1169. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_KS_TOO_SMALL_MSC}
  1170. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_APP_ERROR_MSC}
  1171. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_REMOTE_PAIRING_FAIL_MSC}
  1172. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_TIMEOUT_MSC}
  1173. * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC}
  1174. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC}
  1175. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC}
  1176. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1177. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1178. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1179. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1180. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1181. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1182. * @endmscs
  1183. *
  1184. * @param[in] conn_handle Connection handle.
  1185. * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS.
  1186. * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. In the central role this must be set to NULL, as the parameters have
  1187. * already been provided during a previous call to @ref sd_ble_gap_authenticate.
  1188. * @param[in,out] p_sec_keyset Pointer to a @ref ble_gap_sec_keyset_t security keyset structure. Any keys generated and/or distributed as a result of the ongoing security procedure
  1189. * will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application
  1190. * upon reception of a @ref BLE_GAP_EVT_AUTH_STATUS event.
  1191. * Note that the SoftDevice expects the application to provide memory for storing the
  1192. * peer's keys. So it must be ensured that the relevant pointers inside this structure are not NULL. The pointers to the local key
  1193. * can, however, be NULL, in which case, the local key data will not be available to the application upon reception of the
  1194. * @ref BLE_GAP_EVT_AUTH_STATUS event.
  1195. *
  1196. * @retval ::NRF_SUCCESS Successfully accepted security parameter from the application.
  1197. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1198. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1199. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1200. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1201. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
  1202. */
  1203. 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 *p_sec_params, ble_gap_sec_keyset_t const *p_sec_keyset));
  1204. /**@brief Reply with an authentication key.
  1205. *
  1206. * @details This function is only used to reply to a @ref BLE_GAP_EVT_AUTH_KEY_REQUEST or a @ref BLE_GAP_EVT_PASSKEY_DISPLAY, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE.
  1207. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1208. *
  1209. * @events
  1210. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1211. * @endevents
  1212. *
  1213. * @mscs
  1214. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1215. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1216. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1217. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1218. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1219. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1220. * @endmscs
  1221. *
  1222. * @param[in] conn_handle Connection handle.
  1223. * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES.
  1224. * @param[in] p_key If key type is @ref BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL.
  1225. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination)
  1226. * or NULL when confirming LE Secure Connections Numeric Comparison.
  1227. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in Little Endian format.
  1228. *
  1229. * @retval ::NRF_SUCCESS Authentication key successfully set.
  1230. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1231. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1232. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1233. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1234. */
  1235. 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 *p_key));
  1236. /**@brief Reply with an LE Secure connections DHKey.
  1237. *
  1238. * @details This function is only used to reply to a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST, calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE.
  1239. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1240. *
  1241. * @events
  1242. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1243. * @endevents
  1244. *
  1245. * @mscs
  1246. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1247. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1248. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1249. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1250. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1251. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1252. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1253. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1254. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1255. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1256. * @endmscs
  1257. *
  1258. * @param[in] conn_handle Connection handle.
  1259. * @param[in] p_dhkey LE Secure Connections DHKey.
  1260. *
  1261. * @retval ::NRF_SUCCESS DHKey successfully set.
  1262. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1263. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1264. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1265. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1266. */
  1267. SVCALL(SD_BLE_GAP_LESC_DHKEY_REPLY, uint32_t, sd_ble_gap_lesc_dhkey_reply(uint16_t conn_handle, ble_gap_lesc_dhkey_t const *p_dhkey));
  1268. /**@brief Notify the peer of a local keypress.
  1269. *
  1270. * @details This function can only be used when an authentication procedure using LE Secure Connection is in progress. Calling it at other times will result in an @ref NRF_ERROR_INVALID_STATE.
  1271. *
  1272. * @mscs
  1273. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1274. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1275. * @endmscs
  1276. *
  1277. * @param[in] conn_handle Connection handle.
  1278. * @param[in] kp_not See @ref BLE_GAP_KP_NOT_TYPES.
  1279. *
  1280. * @retval ::NRF_SUCCESS Keypress notification successfully queued for transmission.
  1281. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1282. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either not entering a passkey or keypresses have not been enabled by both peers.
  1283. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1284. * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
  1285. */
  1286. SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not));
  1287. /**@brief Generate a set of OOB data to send to a peer out of band.
  1288. *
  1289. * @note The @ref ble_gap_addr_t included in the OOB data returned will be the currently active one (or, if a connection has already been established,
  1290. * the one used during connection setup). The application may manually overwrite it with an updated value.
  1291. *
  1292. * @mscs
  1293. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1294. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1295. * @endmscs
  1296. *
  1297. * @param[in] conn_handle Connection handle. Can be BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet.
  1298. * @param[in] p_pk_own LE Secure Connections local P-256 Public Key.
  1299. * @param[out] p_oobd_own The OOB data to be sent out of band to a peer.
  1300. *
  1301. * @retval ::NRF_SUCCESS OOB data successfully generated.
  1302. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1303. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1304. */
  1305. SVCALL(SD_BLE_GAP_LESC_OOB_DATA_GET, uint32_t, sd_ble_gap_lesc_oob_data_get(uint16_t conn_handle, ble_gap_lesc_p256_pk_t const *p_pk_own, ble_gap_lesc_oob_data_t *p_oobd_own));
  1306. /**@brief Provide the OOB data sent/received out of band.
  1307. *
  1308. * @note At least one of the 2 pointers provided must be different from NULL.
  1309. * @note An authentication procedure with OOB selected as an algorithm must be in progress when calling this function.
  1310. * @note A @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event with the oobd_req set to 1 must have been received prior to calling this function.
  1311. *
  1312. * @events
  1313. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1314. * @endevents
  1315. *
  1316. * @mscs
  1317. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1318. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1319. * @endmscs
  1320. *
  1321. * @param[in] conn_handle Connection handle.
  1322. * @param[in] p_oobd_own The OOB data sent out of band to a peer or NULL if none sent.
  1323. * @param[in] p_oobd_peer The OOB data received out of band from a peer or NULL if none received.
  1324. *
  1325. * @retval ::NRF_SUCCESS OOB data accepted.
  1326. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1327. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1328. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1329. */
  1330. SVCALL(SD_BLE_GAP_LESC_OOB_DATA_SET, uint32_t, sd_ble_gap_lesc_oob_data_set(uint16_t conn_handle, ble_gap_lesc_oob_data_t const *p_oobd_own, ble_gap_lesc_oob_data_t const *p_oobd_peer));
  1331. /**@brief Initiate GAP Encryption procedure.
  1332. *
  1333. * @details In the central role, this function will initiate the encryption procedure using the encryption information provided.
  1334. *
  1335. * @events
  1336. * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE, The connection security has been updated.}
  1337. * @endevents
  1338. *
  1339. * @mscs
  1340. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  1341. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_MSC}
  1342. * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC}
  1343. * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC}
  1344. * @endmscs
  1345. *
  1346. * @param[in] conn_handle Connection handle.
  1347. * @param[in] p_master_id Pointer to a @ref ble_gap_master_id_t master identification structure.
  1348. * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure.
  1349. *
  1350. * @retval ::NRF_SUCCESS Successfully initiated authentication procedure.
  1351. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1352. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1353. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1354. * @retval ::BLE_ERROR_INVALID_ROLE Operation is not supported in the Peripheral role.
  1355. * @retval ::NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, wait for pending procedures to complete and retry.
  1356. */
  1357. SVCALL(SD_BLE_GAP_ENCRYPT, uint32_t, sd_ble_gap_encrypt(uint16_t conn_handle, ble_gap_master_id_t const *p_master_id, ble_gap_enc_info_t const *p_enc_info));
  1358. /**@brief Reply with GAP security information.
  1359. *
  1360. * @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 @ref NRF_ERROR_INVALID_STATE.
  1361. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1362. * @note Data signing is not yet supported, and p_sign_info must therefore be NULL.
  1363. *
  1364. * @mscs
  1365. * @mmsc{@ref BLE_GAP_PERIPH_ENC_MSC}
  1366. * @endmscs
  1367. *
  1368. * @param[in] conn_handle Connection handle.
  1369. * @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.
  1370. * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t identity information structure. May be NULL to signal none is available.
  1371. * @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.
  1372. *
  1373. * @retval ::NRF_SUCCESS Successfully accepted security information.
  1374. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1375. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1376. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1377. */
  1378. 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 *p_enc_info, ble_gap_irk_t const *p_id_info, ble_gap_sign_info_t const *p_sign_info));
  1379. /**@brief Get the current connection security.
  1380. *
  1381. * @param[in] conn_handle Connection handle.
  1382. * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in.
  1383. *
  1384. * @retval ::NRF_SUCCESS Current connection security successfully retrieved.
  1385. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1386. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1387. */
  1388. SVCALL(SD_BLE_GAP_CONN_SEC_GET, uint32_t, sd_ble_gap_conn_sec_get(uint16_t conn_handle, ble_gap_conn_sec_t *p_conn_sec));
  1389. /**@brief Start reporting the received signal strength to the application.
  1390. *
  1391. * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
  1392. *
  1393. * @events
  1394. * @event{@ref BLE_GAP_EVT_RSSI_CHANGED, New RSSI data available. How often the event is generated is
  1395. dependent on the settings of the <code>threshold_dbm</code>
  1396. and <code>skip_count</code> input parameters.}
  1397. * @endevents
  1398. *
  1399. * @mscs
  1400. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  1401. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  1402. * @endmscs
  1403. *
  1404. * @param[in] conn_handle Connection handle.
  1405. * @param[in] threshold_dbm Minimum change in dBm before triggering the @ref BLE_GAP_EVT_RSSI_CHANGED event. Events are disabled if threshold_dbm equals @ref BLE_GAP_RSSI_THRESHOLD_INVALID.
  1406. * @param[in] skip_count Number of RSSI samples with a change of threshold_dbm or more before sending a new @ref BLE_GAP_EVT_RSSI_CHANGED event.
  1407. *
  1408. * @retval ::NRF_SUCCESS Successfully activated RSSI reporting.
  1409. * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress. Invalid state to perform operation.
  1410. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1411. */
  1412. SVCALL(SD_BLE_GAP_RSSI_START, uint32_t, sd_ble_gap_rssi_start(uint16_t conn_handle, uint8_t threshold_dbm, uint8_t skip_count));
  1413. /**@brief Stop reporting the received signal strength.
  1414. *
  1415. * @note An RSSI change detected before the call but not yet received by the application
  1416. * may be reported after @ref sd_ble_gap_rssi_stop has been called.
  1417. *
  1418. * @mscs
  1419. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  1420. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  1421. * @endmscs
  1422. *
  1423. * @param[in] conn_handle Connection handle.
  1424. *
  1425. * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting.
  1426. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1427. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1428. */
  1429. SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle));
  1430. /**@brief Get the received signal strength for the last connection event.
  1431. *
  1432. * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND
  1433. * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start.
  1434. *
  1435. * @mscs
  1436. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  1437. * @endmscs
  1438. *
  1439. * @param[in] conn_handle Connection handle.
  1440. * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored.
  1441. *
  1442. * @retval ::NRF_SUCCESS Successfully read the RSSI.
  1443. * @retval ::NRF_ERROR_NOT_FOUND No sample is available.
  1444. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1445. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1446. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing, or disconnection in progress.
  1447. */
  1448. SVCALL(SD_BLE_GAP_RSSI_GET, uint32_t, sd_ble_gap_rssi_get(uint16_t conn_handle, int8_t *p_rssi));
  1449. /**@brief Start scanning (GAP Discovery procedure, Observer Procedure).
  1450. *
  1451. * @note To use the currently active whitelist set p_scan_params->p_whitelist to NULL.
  1452. *
  1453. * @events
  1454. * @event{@ref BLE_GAP_EVT_ADV_REPORT, An advertising or scan response packet has been received.}
  1455. * @event{@ref BLE_GAP_EVT_TIMEOUT, Scanner has timed out.}
  1456. * @endevents
  1457. *
  1458. * @mscs
  1459. * @mmsc{@ref BLE_GAP_SCAN_MSC}
  1460. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1461. * @endmscs
  1462. *
  1463. * @param[in] p_scan_params Pointer to scan parameters structure.
  1464. *
  1465. * @retval ::NRF_SUCCESS Successfully initiated scanning procedure.
  1466. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1467. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1468. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1469. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1470. * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE Unable to replace the whitelist while another operation is using it.
  1471. * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available.
  1472. * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again
  1473. */
  1474. SVCALL(SD_BLE_GAP_SCAN_START, uint32_t, sd_ble_gap_scan_start(ble_gap_scan_params_t const *p_scan_params));
  1475. /**@brief Stop scanning (GAP Discovery procedure, Observer Procedure).
  1476. *
  1477. * @mscs
  1478. * @mmsc{@ref BLE_GAP_SCAN_MSC}
  1479. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1480. * @endmscs
  1481. *
  1482. * @retval ::NRF_SUCCESS Successfully stopped scanning procedure.
  1483. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation (most probably not in scanning state).
  1484. */
  1485. SVCALL(SD_BLE_GAP_SCAN_STOP, uint32_t, sd_ble_gap_scan_stop(void));
  1486. /**@brief Create a connection (GAP Link Establishment).
  1487. *
  1488. * @note To use the currently active whitelist set p_scan_params->p_whitelist to NULL.
  1489. * @note If a scanning procedure is currently in progress it will be automatically stopped when calling this function.
  1490. *
  1491. * @mscs
  1492. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1493. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC}
  1494. * @endmscs
  1495. *
  1496. * @param[in] p_peer_addr Pointer to peer address. If the selective bit is set in @ref ble_gap_scan_params_t, then this must be NULL.
  1497. * @param[in] p_scan_params Pointer to scan parameters structure.
  1498. * @param[in] p_conn_params Pointer to desired connection parameters.
  1499. *
  1500. * @retval ::NRF_SUCCESS Successfully initiated connection procedure.
  1501. * @retval ::NRF_ERROR_INVALID_ADDR Invalid parameter(s) pointer supplied.
  1502. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1503. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1504. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Peer address.
  1505. * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached.
  1506. * @retval ::NRF_ERROR_NO_MEM The configured memory pool (see @ref ble_conn_bw_counts_t) is not large enough for the
  1507. * bandwidth selected for this connection.
  1508. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry. If another connection is being established
  1509. * wait for the corresponding @ref BLE_GAP_EVT_CONNECTED event before calling again.
  1510. * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE Unable to replace the whitelist while another operation is using it.
  1511. * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available.
  1512. * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again
  1513. */
  1514. SVCALL(SD_BLE_GAP_CONNECT, uint32_t, sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params));
  1515. /**@brief Cancel a connection establishment.
  1516. *
  1517. * @mscs
  1518. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC}
  1519. * @endmscs
  1520. *
  1521. * @retval ::NRF_SUCCESS Successfully cancelled an ongoing connection procedure.
  1522. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation.
  1523. */
  1524. SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void));
  1525. /** @} */
  1526. #ifdef __cplusplus
  1527. }
  1528. #endif
  1529. #endif // BLE_GAP_H__
  1530. /**
  1531. @}
  1532. */