ble_gap.h 124 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150
  1. /*
  2. * Copyright (c) 2011 - 2020, 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, except as embedded into a Nordic
  12. * Semiconductor ASA integrated circuit in a product or a software update for
  13. * such product, must reproduce the above copyright notice, this list of
  14. * conditions and the following disclaimer in the documentation and/or other
  15. * materials provided with the distribution.
  16. *
  17. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  18. * contributors may be used to endorse or promote products derived from this
  19. * software without specific prior written permission.
  20. *
  21. * 4. This software, with or without modification, must only be used with a
  22. * Nordic Semiconductor ASA integrated circuit.
  23. *
  24. * 5. Any software provided in binary form under this license must not be reverse
  25. * engineered, decompiled, modified and/or disassembled.
  26. *
  27. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  28. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  29. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  30. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  31. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  32. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  33. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  34. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  35. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  36. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  37. */
  38. /**
  39. @addtogroup BLE_GAP Generic Access Profile (GAP)
  40. @{
  41. @brief Definitions and prototypes for the GAP interface.
  42. */
  43. #ifndef BLE_GAP_H__
  44. #define BLE_GAP_H__
  45. #include <stdint.h>
  46. #include "nrf_svc.h"
  47. #include "nrf_error.h"
  48. #include "ble_hci.h"
  49. #include "ble_ranges.h"
  50. #include "ble_types.h"
  51. #include "ble_err.h"
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /**@addtogroup BLE_GAP_ENUMERATIONS Enumerations
  56. * @{ */
  57. /**@brief GAP API SVC numbers.
  58. */
  59. enum BLE_GAP_SVCS
  60. {
  61. SD_BLE_GAP_ADDR_SET = BLE_GAP_SVC_BASE, /**< Set own Bluetooth Address. */
  62. SD_BLE_GAP_ADDR_GET = BLE_GAP_SVC_BASE + 1, /**< Get own Bluetooth Address. */
  63. SD_BLE_GAP_WHITELIST_SET = BLE_GAP_SVC_BASE + 2, /**< Set active whitelist. */
  64. SD_BLE_GAP_DEVICE_IDENTITIES_SET = BLE_GAP_SVC_BASE + 3, /**< Set device identity list. */
  65. SD_BLE_GAP_PRIVACY_SET = BLE_GAP_SVC_BASE + 4, /**< Set Privacy settings*/
  66. SD_BLE_GAP_PRIVACY_GET = BLE_GAP_SVC_BASE + 5, /**< Get Privacy settings*/
  67. SD_BLE_GAP_ADV_SET_CONFIGURE = BLE_GAP_SVC_BASE + 6, /**< Configure an advertising set. */
  68. SD_BLE_GAP_ADV_START = BLE_GAP_SVC_BASE + 7, /**< Start Advertising. */
  69. SD_BLE_GAP_ADV_STOP = BLE_GAP_SVC_BASE + 8, /**< Stop Advertising. */
  70. SD_BLE_GAP_CONN_PARAM_UPDATE = BLE_GAP_SVC_BASE + 9, /**< Connection Parameter Update. */
  71. SD_BLE_GAP_DISCONNECT = BLE_GAP_SVC_BASE + 10, /**< Disconnect. */
  72. SD_BLE_GAP_TX_POWER_SET = BLE_GAP_SVC_BASE + 11, /**< Set TX Power. */
  73. SD_BLE_GAP_APPEARANCE_SET = BLE_GAP_SVC_BASE + 12, /**< Set Appearance. */
  74. SD_BLE_GAP_APPEARANCE_GET = BLE_GAP_SVC_BASE + 13, /**< Get Appearance. */
  75. SD_BLE_GAP_PPCP_SET = BLE_GAP_SVC_BASE + 14, /**< Set PPCP. */
  76. SD_BLE_GAP_PPCP_GET = BLE_GAP_SVC_BASE + 15, /**< Get PPCP. */
  77. SD_BLE_GAP_DEVICE_NAME_SET = BLE_GAP_SVC_BASE + 16, /**< Set Device Name. */
  78. SD_BLE_GAP_DEVICE_NAME_GET = BLE_GAP_SVC_BASE + 17, /**< Get Device Name. */
  79. SD_BLE_GAP_AUTHENTICATE = BLE_GAP_SVC_BASE + 18, /**< Initiate Pairing/Bonding. */
  80. SD_BLE_GAP_SEC_PARAMS_REPLY = BLE_GAP_SVC_BASE + 19, /**< Reply with Security Parameters. */
  81. SD_BLE_GAP_AUTH_KEY_REPLY = BLE_GAP_SVC_BASE + 20, /**< Reply with an authentication key. */
  82. SD_BLE_GAP_LESC_DHKEY_REPLY = BLE_GAP_SVC_BASE + 21, /**< Reply with an LE Secure Connections DHKey. */
  83. SD_BLE_GAP_KEYPRESS_NOTIFY = BLE_GAP_SVC_BASE + 22, /**< Notify of a keypress during an authentication procedure. */
  84. SD_BLE_GAP_LESC_OOB_DATA_GET = BLE_GAP_SVC_BASE + 23, /**< Get the local LE Secure Connections OOB data. */
  85. SD_BLE_GAP_LESC_OOB_DATA_SET = BLE_GAP_SVC_BASE + 24, /**< Set the remote LE Secure Connections OOB data. */
  86. SD_BLE_GAP_SEC_INFO_REPLY = BLE_GAP_SVC_BASE + 26, /**< Reply with Security Information. */
  87. SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 27, /**< Obtain connection security level. */
  88. SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 28, /**< Start reporting of changes in RSSI. */
  89. SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 29, /**< Stop reporting of changes in RSSI. */
  90. SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 34, /**< Get the last RSSI sample. */
  91. SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 35, /**< Initiate or respond to a PHY Update Procedure. */
  92. SD_BLE_GAP_ADV_ADDR_GET = BLE_GAP_SVC_BASE + 39, /**< Get the Address used on air while Advertising. */
  93. SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET = BLE_GAP_SVC_BASE + 40, /**< Get the next connection event counter. */
  94. };
  95. /**@brief GAP Event IDs.
  96. * IDs that uniquely identify an event coming from the stack to the application.
  97. */
  98. enum BLE_GAP_EVTS
  99. {
  100. BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connected to peer. \n See @ref ble_gap_evt_connected_t */
  101. BLE_GAP_EVT_DISCONNECTED = BLE_GAP_EVT_BASE + 1, /**< Disconnected from peer. \n See @ref ble_gap_evt_disconnected_t. */
  102. BLE_GAP_EVT_CONN_PARAM_UPDATE = BLE_GAP_EVT_BASE + 2, /**< Connection Parameters updated. \n See @ref ble_gap_evt_conn_param_update_t. */
  103. BLE_GAP_EVT_SEC_PARAMS_REQUEST = BLE_GAP_EVT_BASE + 3, /**< 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. */
  104. BLE_GAP_EVT_SEC_INFO_REQUEST = BLE_GAP_EVT_BASE + 4, /**< 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. */
  105. BLE_GAP_EVT_PASSKEY_DISPLAY = BLE_GAP_EVT_BASE + 5, /**< 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. */
  106. BLE_GAP_EVT_KEY_PRESSED = BLE_GAP_EVT_BASE + 6, /**< Notification of a keypress on the remote device.\n See @ref ble_gap_evt_key_pressed_t */
  107. BLE_GAP_EVT_AUTH_KEY_REQUEST = BLE_GAP_EVT_BASE + 7, /**< 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. */
  108. BLE_GAP_EVT_LESC_DHKEY_REQUEST = BLE_GAP_EVT_BASE + 8, /**< 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 */
  109. BLE_GAP_EVT_AUTH_STATUS = BLE_GAP_EVT_BASE + 9, /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */
  110. BLE_GAP_EVT_CONN_SEC_UPDATE = BLE_GAP_EVT_BASE + 10, /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */
  111. BLE_GAP_EVT_TIMEOUT = BLE_GAP_EVT_BASE + 11, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */
  112. BLE_GAP_EVT_RSSI_CHANGED = BLE_GAP_EVT_BASE + 12, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */
  113. BLE_GAP_EVT_SEC_REQUEST = BLE_GAP_EVT_BASE + 14, /**< Security Request. \n Reply with @ref sd_ble_gap_authenticate
  114. . \n See @ref ble_gap_evt_sec_request_t. */
  115. BLE_GAP_EVT_SCAN_REQ_REPORT = BLE_GAP_EVT_BASE + 16, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */
  116. BLE_GAP_EVT_PHY_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 17, /**< PHY Update Request. \n Reply with @ref sd_ble_gap_phy_update. \n See @ref ble_gap_evt_phy_update_request_t. */
  117. BLE_GAP_EVT_PHY_UPDATE = BLE_GAP_EVT_BASE + 18, /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */
  118. BLE_GAP_EVT_ADV_SET_TERMINATED = BLE_GAP_EVT_BASE + 22, /**< Advertising set terminated. \n See @ref ble_gap_evt_adv_set_terminated_t. */
  119. };
  120. /**@brief GAP Option IDs.
  121. * IDs that uniquely identify a GAP option.
  122. */
  123. enum BLE_GAP_OPTS
  124. {
  125. BLE_GAP_OPT_CH_MAP = BLE_GAP_OPT_BASE, /**< Channel Map. @ref ble_gap_opt_ch_map_t */
  126. BLE_GAP_OPT_LOCAL_CONN_LATENCY = BLE_GAP_OPT_BASE + 1, /**< Local connection latency. @ref ble_gap_opt_local_conn_latency_t */
  127. BLE_GAP_OPT_PASSKEY = BLE_GAP_OPT_BASE + 2, /**< Set passkey. @ref ble_gap_opt_passkey_t */
  128. BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT = BLE_GAP_OPT_BASE + 4, /**< Set Authenticated payload timeout. @ref ble_gap_opt_auth_payload_timeout_t */
  129. BLE_GAP_OPT_SLAVE_LATENCY_DISABLE = BLE_GAP_OPT_BASE + 5, /**< Disable slave latency. @ref ble_gap_opt_slave_latency_disable_t */
  130. };
  131. /**@brief GAP Configuration IDs.
  132. *
  133. * IDs that uniquely identify a GAP configuration.
  134. */
  135. enum BLE_GAP_CFGS
  136. {
  137. BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */
  138. BLE_GAP_CFG_DEVICE_NAME = BLE_GAP_CFG_BASE + 1, /**< Device name configuration. */
  139. BLE_GAP_CFG_PPCP_INCL_CONFIG = BLE_GAP_CFG_BASE + 2, /**< Peripheral Preferred Connection Parameters characteristic
  140. inclusion configuration. */
  141. BLE_GAP_CFG_CAR_INCL_CONFIG = BLE_GAP_CFG_BASE + 3, /**< Central Address Resolution characteristic
  142. inclusion configuration. */
  143. };
  144. /**@brief GAP TX Power roles.
  145. */
  146. enum BLE_GAP_TX_POWER_ROLES
  147. {
  148. BLE_GAP_TX_POWER_ROLE_ADV = 1, /**< Advertiser role. */
  149. BLE_GAP_TX_POWER_ROLE_CONN = 3, /**< Connection role. */
  150. };
  151. /** @} */
  152. /**@addtogroup BLE_GAP_DEFINES Defines
  153. * @{ */
  154. /**@defgroup BLE_ERRORS_GAP SVC return values specific to GAP
  155. * @{ */
  156. #define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */
  157. #define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */
  158. #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. */
  159. #define BLE_ERROR_GAP_WHITELIST_IN_USE (NRF_GAP_ERR_BASE + 0x003) /**< Attempt to modify the whitelist while already in use by another operation. */
  160. #define BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE (NRF_GAP_ERR_BASE + 0x004) /**< Attempt to modify the device identity list while already in use by another operation. */
  161. #define BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE (NRF_GAP_ERR_BASE + 0x005) /**< The device identity list contains entries with duplicate identity addresses. */
  162. /**@} */
  163. /**@defgroup BLE_GAP_ROLES GAP Roles
  164. * @{ */
  165. #define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */
  166. #define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */
  167. /**@} */
  168. /**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources
  169. * @{ */
  170. #define BLE_GAP_TIMEOUT_SRC_CONN 0x02 /**< Connection timeout. */
  171. #define BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD 0x03 /**< Authenticated payload timeout. */
  172. /**@} */
  173. /**@defgroup BLE_GAP_ADDR_TYPES GAP Address types
  174. * @{ */
  175. #define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public (identity) address.*/
  176. #define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random static (identity) address. */
  177. #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Random private resolvable address. */
  178. #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Random private non-resolvable address. */
  179. /**@} */
  180. /**@brief The default interval in seconds at which a private address is refreshed. */
  181. #define BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S (900) /* 15 minutes. */
  182. /**@brief The maximum interval in seconds at which a private address can be refreshed. */
  183. #define BLE_GAP_MAX_PRIVATE_ADDR_CYCLE_INTERVAL_S (41400) /* 11 hours 30 minutes. */
  184. /** @brief BLE address length. */
  185. #define BLE_GAP_ADDR_LEN (6)
  186. /**@defgroup BLE_GAP_PRIVACY_MODES Privacy modes
  187. * @{ */
  188. #define BLE_GAP_PRIVACY_MODE_OFF 0x00 /**< Device will send and accept its identity address for its own address. */
  189. #define BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY 0x01 /**< Device will send and accept only private addresses for its own address. */
  190. #define BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY 0x02 /**< Device will send and accept only private addresses for its own address,
  191. and will not accept a peer using identity address as sender address when
  192. the peer IRK is exchanged, non-zero and added to the identity list. */
  193. /**@} */
  194. /** @brief Invalid power level. */
  195. #define BLE_GAP_POWER_LEVEL_INVALID 127
  196. /** @brief Advertising set handle not set. */
  197. #define BLE_GAP_ADV_SET_HANDLE_NOT_SET (0xFF)
  198. /** @brief The default number of advertising sets. */
  199. #define BLE_GAP_ADV_SET_COUNT_DEFAULT (1)
  200. /** @brief The maximum number of advertising sets supported by this SoftDevice. */
  201. #define BLE_GAP_ADV_SET_COUNT_MAX (1)
  202. /**@defgroup BLE_GAP_ADV_SET_DATA_SIZES Advertising data sizes.
  203. * @{ */
  204. #define BLE_GAP_ADV_SET_DATA_SIZE_MAX (31) /**< Maximum data length for an advertising set.
  205. If more advertising data is required, use extended advertising instead. */
  206. /**@}. */
  207. /** @brief Set ID not available in advertising report. */
  208. #define BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE 0xFF
  209. /**@defgroup BLE_GAP_EVT_ADV_SET_TERMINATED_REASON GAP Advertising Set Terminated reasons
  210. * @{ */
  211. #define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_TIMEOUT 0x01 /**< Timeout value reached. */
  212. #define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_LIMIT_REACHED 0x02 /**< @ref ble_gap_adv_params_t::max_adv_evts was reached. */
  213. /**@} */
  214. /**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format
  215. * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm
  216. * @{ */
  217. #define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */
  218. #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */
  219. #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */
  220. #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */
  221. #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */
  222. #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */
  223. #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */
  224. #define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */
  225. #define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */
  226. #define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */
  227. #define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */
  228. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */
  229. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */
  230. #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */
  231. #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */
  232. #define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */
  233. #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */
  234. #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */
  235. #define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data - 16-bit UUID. */
  236. #define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */
  237. #define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */
  238. #define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */
  239. #define BLE_GAP_AD_TYPE_ADVERTISING_INTERVAL 0x1A /**< Advertising Interval. */
  240. #define BLE_GAP_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS 0x1B /**< LE Bluetooth Device Address. */
  241. #define BLE_GAP_AD_TYPE_LE_ROLE 0x1C /**< LE Role. */
  242. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C256 0x1D /**< Simple Pairing Hash C-256. */
  243. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 0x1E /**< Simple Pairing Randomizer R-256. */
  244. #define BLE_GAP_AD_TYPE_SERVICE_DATA_32BIT_UUID 0x20 /**< Service Data - 32-bit UUID. */
  245. #define BLE_GAP_AD_TYPE_SERVICE_DATA_128BIT_UUID 0x21 /**< Service Data - 128-bit UUID. */
  246. #define BLE_GAP_AD_TYPE_LESC_CONFIRMATION_VALUE 0x22 /**< LE Secure Connections Confirmation Value */
  247. #define BLE_GAP_AD_TYPE_LESC_RANDOM_VALUE 0x23 /**< LE Secure Connections Random Value */
  248. #define BLE_GAP_AD_TYPE_URI 0x24 /**< URI */
  249. #define BLE_GAP_AD_TYPE_3D_INFORMATION_DATA 0x3D /**< 3D Information Data. */
  250. #define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */
  251. /**@} */
  252. /**@defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags
  253. * @{ */
  254. #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */
  255. #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */
  256. #define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */
  257. #define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */
  258. #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */
  259. #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. */
  260. #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. */
  261. /**@} */
  262. /**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min
  263. * @{ */
  264. #define BLE_GAP_ADV_INTERVAL_MIN 0x000020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */
  265. #define BLE_GAP_ADV_INTERVAL_MAX 0x004000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */
  266. /**@} */
  267. /**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types
  268. *
  269. * Advertising types defined in Bluetooth Core Specification v5.0, Vol 6, Part B, Section 4.4.2.
  270. *
  271. * The maximum advertising data length is defined by @ref BLE_GAP_ADV_SET_DATA_SIZE_MAX.
  272. * Note that some of the advertising types do not support advertising data. Non-scannable types do not support
  273. * scan response data.
  274. *
  275. * @note Extended advertising is not supported in this SoftDevice.
  276. * @{ */
  277. #define BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED 0x01 /**< Connectable and scannable undirected
  278. advertising events. */
  279. #define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE 0x02 /**< Connectable non-scannable directed advertising
  280. events. Advertising interval is less that 3.75 ms.
  281. Use this type for fast reconnections.
  282. @note Advertising data is not supported. */
  283. #define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED 0x03 /**< Connectable non-scannable directed advertising
  284. events.
  285. @note Advertising data is not supported. */
  286. #define BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x04 /**< Non-connectable scannable undirected
  287. advertising events. */
  288. #define BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x05 /**< Non-connectable non-scannable undirected
  289. advertising events. */
  290. /**@} */
  291. /**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies
  292. * @{ */
  293. #define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */
  294. #define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */
  295. #define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */
  296. #define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */
  297. /**@} */
  298. /**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values in 10 ms units
  299. * @{ */
  300. #define BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX (128) /**< Maximum high duty advertising time in 10 ms units. Corresponds to 1.28 s. */
  301. #define BLE_GAP_ADV_TIMEOUT_LIMITED_MAX (18000) /**< Maximum advertising time in 10 ms units corresponding to TGAP(lim_adv_timeout) = 180 s in limited discoverable mode. */
  302. #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED (0) /**< Unlimited advertising in general discoverable mode.
  303. For high duty cycle advertising, this corresponds to @ref BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX. */
  304. /**@} */
  305. /**@defgroup BLE_GAP_DISC_MODES GAP Discovery modes
  306. * @{ */
  307. #define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */
  308. #define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */
  309. #define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */
  310. /**@} */
  311. /**@defgroup BLE_GAP_IO_CAPS GAP IO Capabilities
  312. * @{ */
  313. #define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */
  314. #define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */
  315. #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */
  316. #define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */
  317. #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */
  318. /**@} */
  319. /**@defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types
  320. * @{ */
  321. #define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */
  322. #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */
  323. #define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */
  324. /**@} */
  325. /**@defgroup BLE_GAP_KP_NOT_TYPES GAP Keypress Notification Types
  326. * @{ */
  327. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_START 0x00 /**< Passkey entry started. */
  328. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_IN 0x01 /**< Passkey digit entered. */
  329. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_OUT 0x02 /**< Passkey digit erased. */
  330. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_CLEAR 0x03 /**< Passkey cleared. */
  331. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_END 0x04 /**< Passkey entry completed. */
  332. /**@} */
  333. /**@defgroup BLE_GAP_SEC_STATUS GAP Security status
  334. * @{ */
  335. #define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Procedure completed with success. */
  336. #define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */
  337. #define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */
  338. #define BLE_GAP_SEC_STATUS_RFU_RANGE1_BEGIN 0x03 /**< Reserved for Future Use range #1 begin. */
  339. #define BLE_GAP_SEC_STATUS_RFU_RANGE1_END 0x80 /**< Reserved for Future Use range #1 end. */
  340. #define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user canceled or other). */
  341. #define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */
  342. #define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */
  343. #define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */
  344. #define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */
  345. #define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */
  346. #define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */
  347. #define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */
  348. #define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */
  349. #define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */
  350. #define BLE_GAP_SEC_STATUS_DHKEY_FAILURE 0x8B /**< DHKey check failure. */
  351. #define BLE_GAP_SEC_STATUS_NUM_COMP_FAILURE 0x8C /**< Numeric Comparison failure. */
  352. #define BLE_GAP_SEC_STATUS_BR_EDR_IN_PROG 0x8D /**< BR/EDR pairing in progress. */
  353. #define BLE_GAP_SEC_STATUS_X_TRANS_KEY_DISALLOWED 0x8E /**< BR/EDR Link Key cannot be used for LE keys. */
  354. #define BLE_GAP_SEC_STATUS_RFU_RANGE2_BEGIN 0x8F /**< Reserved for Future Use range #2 begin. */
  355. #define BLE_GAP_SEC_STATUS_RFU_RANGE2_END 0xFF /**< Reserved for Future Use range #2 end. */
  356. /**@} */
  357. /**@defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources
  358. * @{ */
  359. #define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */
  360. #define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */
  361. /**@} */
  362. /**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
  363. * @{ */
  364. #define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connection interval specified in connect parameters. */
  365. #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. */
  366. #define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
  367. #define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connection interval specified in connect parameters. */
  368. #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. */
  369. #define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
  370. #define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x01F3 /**< Highest slave latency permitted, in connection events. */
  371. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */
  372. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */
  373. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */
  374. /**@} */
  375. /**@defgroup BLE_GAP_DEVNAME GAP device name defines.
  376. * @{ */
  377. #define BLE_GAP_DEVNAME_DEFAULT "nRF5x" /**< Default device name value. */
  378. #define BLE_GAP_DEVNAME_DEFAULT_LEN 31 /**< Default number of octets in device name. */
  379. #define BLE_GAP_DEVNAME_MAX_LEN 248 /**< Maximum number of octets in device name. */
  380. /**@} */
  381. /**@brief Disable RSSI events for connections */
  382. #define BLE_GAP_RSSI_THRESHOLD_INVALID 0xFF
  383. /**@defgroup BLE_GAP_PHYS GAP PHYs
  384. * @{ */
  385. #define BLE_GAP_PHY_AUTO 0x00 /**< Automatic PHY selection. Refer @ref sd_ble_gap_phy_update for more information.*/
  386. #define BLE_GAP_PHY_1MBPS 0x01 /**< 1 Mbps PHY. */
  387. #define BLE_GAP_PHY_2MBPS 0x02 /**< 2 Mbps PHY. */
  388. #define BLE_GAP_PHY_CODED 0x04 /**< Coded PHY. */
  389. #define BLE_GAP_PHY_NOT_SET 0xFF /**< PHY is not configured. */
  390. /**@brief Supported PHYs in connections and for advertising. */
  391. #define BLE_GAP_PHYS_SUPPORTED (BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS) /**< All PHYs except @ref BLE_GAP_PHY_CODED are supported. */
  392. /**@} */
  393. /**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
  394. *
  395. * See @ref ble_gap_conn_sec_mode_t.
  396. * @{ */
  397. /**@brief Set sec_mode pointed to by ptr to have no access rights.*/
  398. #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0)
  399. /**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/
  400. #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0)
  401. /**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
  402. #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0)
  403. /**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
  404. #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0)
  405. /**@brief Set sec_mode pointed to by ptr to require LESC encryption and MITM protection.*/
  406. #define BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 4;} while(0)
  407. /**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
  408. #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0)
  409. /**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
  410. #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0)
  411. /**@} */
  412. /**@brief GAP Security Random Number Length. */
  413. #define BLE_GAP_SEC_RAND_LEN 8
  414. /**@brief GAP Security Key Length. */
  415. #define BLE_GAP_SEC_KEY_LEN 16
  416. /**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key Length. */
  417. #define BLE_GAP_LESC_P256_PK_LEN 64
  418. /**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman DHKey Length. */
  419. #define BLE_GAP_LESC_DHKEY_LEN 32
  420. /**@brief GAP Passkey Length. */
  421. #define BLE_GAP_PASSKEY_LEN 6
  422. /**@brief Maximum amount of addresses in the whitelist. */
  423. #define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8)
  424. /**@brief Maximum amount of identities in the device identities list. */
  425. #define BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT (8)
  426. /**@brief Default connection count for a configuration. */
  427. #define BLE_GAP_CONN_COUNT_DEFAULT (1)
  428. /**@defgroup BLE_GAP_EVENT_LENGTH GAP event length defines.
  429. * @{ */
  430. #define BLE_GAP_EVENT_LENGTH_MIN (2) /**< Minimum event length, in 1.25 ms units. */
  431. #define BLE_GAP_EVENT_LENGTH_DEFAULT (3) /**< Default event length, in 1.25 ms units. */
  432. /**@} */
  433. /**@defgroup BLE_GAP_ROLE_COUNT GAP concurrent connection count defines.
  434. * @{ */
  435. #define BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT (1) /**< Default maximum number of connections concurrently acting as peripherals. */
  436. #define BLE_GAP_ROLE_COUNT_COMBINED_MAX (20) /**< Maximum supported number of concurrent connections in the peripheral roles. */
  437. /**@} */
  438. /**@defgroup BLE_GAP_AUTH_PAYLOAD_TIMEOUT Authenticated payload timeout defines.
  439. * @{ */
  440. #define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX (48000) /**< Maximum authenticated payload timeout in 10 ms units, i.e. 8 minutes. */
  441. #define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MIN (1) /**< Minimum authenticated payload timeout in 10 ms units, i.e. 10 ms. */
  442. /**@} */
  443. /**@defgroup GAP_SEC_MODES GAP Security Modes
  444. * @{ */
  445. #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */
  446. /**@} */
  447. /** @} */
  448. /** @defgroup BLE_GAP_CHAR_INCL_CONFIG GAP Characteristic inclusion configurations
  449. * @{
  450. */
  451. #define BLE_GAP_CHAR_INCL_CONFIG_INCLUDE (0) /**< Include the characteristic in the Attribute Table */
  452. #define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITH_SPACE (1) /**< Do not include the characteristic in the Attribute table.
  453. The SoftDevice will reserve the attribute handles
  454. which are otherwise used for this characteristic.
  455. By reserving the attribute handles it will be possible
  456. to upgrade the SoftDevice without changing handle of the
  457. Service Changed characteristic. */
  458. #define BLE_GAP_CHAR_INCL_CONFIG_EXCLUDE_WITHOUT_SPACE (2) /**< Do not include the characteristic in the Attribute table.
  459. The SoftDevice will not reserve the attribute handles
  460. which are otherwise used for this characteristic. */
  461. /**@} */
  462. /** @defgroup BLE_GAP_CHAR_INCL_CONFIG_DEFAULTS Characteristic inclusion default values
  463. * @{ */
  464. #define BLE_GAP_PPCP_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */
  465. #define BLE_GAP_CAR_INCL_CONFIG_DEFAULT (BLE_GAP_CHAR_INCL_CONFIG_INCLUDE) /**< Included by default. */
  466. /**@} */
  467. /**@addtogroup BLE_GAP_STRUCTURES Structures
  468. * @{ */
  469. /**@brief Advertising event properties. */
  470. typedef struct
  471. {
  472. uint8_t type; /**< Advertising type. See @ref BLE_GAP_ADV_TYPES. */
  473. uint8_t anonymous : 1; /**< This feature is not supported on this SoftDevice. */
  474. uint8_t include_tx_power : 1; /**< This feature is not supported on this SoftDevice. */
  475. } ble_gap_adv_properties_t;
  476. /**@brief Bluetooth Low Energy address. */
  477. typedef struct
  478. {
  479. uint8_t addr_id_peer : 1; /**< Only valid for peer addresses.
  480. This bit is set by the SoftDevice to indicate whether the address has been resolved from
  481. a Resolvable Private Address (when the peer is using privacy).
  482. If set to 1, @ref addr and @ref addr_type refer to the identity address of the resolved address.
  483. This bit is ignored when a variable of type @ref ble_gap_addr_t is used as input to API functions. */
  484. uint8_t addr_type : 7; /**< See @ref BLE_GAP_ADDR_TYPES. */
  485. uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format. */
  486. } ble_gap_addr_t;
  487. /**@brief GAP connection parameters.
  488. *
  489. * @note When ble_conn_params_t is received in an event, both min_conn_interval and
  490. * max_conn_interval will be equal to the connection interval set by the central.
  491. *
  492. * @note If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies:
  493. * conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval
  494. * that corresponds to the following Bluetooth Spec requirement:
  495. * The Supervision_Timeout in milliseconds shall be larger than
  496. * (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds.
  497. */
  498. typedef struct
  499. {
  500. uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  501. uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  502. uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
  503. uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  504. } ble_gap_conn_params_t;
  505. /**@brief GAP connection security modes.
  506. *
  507. * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n
  508. * Security Mode 1 Level 1: No security is needed (aka open link).\n
  509. * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n
  510. * Security Mode 1 Level 3: MITM protected encrypted link required.\n
  511. * Security Mode 1 Level 4: LESC MITM protected encrypted link using a 128-bit strength encryption key required.\n
  512. * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n
  513. * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n
  514. */
  515. typedef struct
  516. {
  517. uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */
  518. uint8_t lv : 4; /**< Level (1, 2, 3 or 4), 0 for no permissions at all. */
  519. } ble_gap_conn_sec_mode_t;
  520. /**@brief GAP connection security status.*/
  521. typedef struct
  522. {
  523. ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/
  524. uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets (only applicable for bonding procedures). */
  525. } ble_gap_conn_sec_t;
  526. /**@brief Identity Resolving Key. */
  527. typedef struct
  528. {
  529. uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */
  530. } ble_gap_irk_t;
  531. /**@brief Channel mask (40 bits).
  532. * Every channel is represented with a bit positioned as per channel index defined in Bluetooth Core Specification v5.0,
  533. * Vol 6, Part B, Section 1.4.1. The LSB contained in array element 0 represents channel index 0, and bit 39 represents
  534. * channel index 39. If a bit is set to 1, the channel is not used.
  535. */
  536. typedef uint8_t ble_gap_ch_mask_t[5];
  537. /**@brief GAP advertising parameters. */
  538. typedef struct
  539. {
  540. ble_gap_adv_properties_t properties; /**< The properties of the advertising events. */
  541. ble_gap_addr_t const *p_peer_addr; /**< Address of a known peer.
  542. - When privacy is enabled and the local device uses
  543. @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE addresses,
  544. the device identity list is searched for a matching entry. If
  545. the local IRK for that device identity is set, the local IRK
  546. for that device will be used to generate the advertiser address
  547. field in the advertising packet.
  548. - If @ref ble_gap_adv_properties_t::type is directed, this must be
  549. set to the targeted scanner or initiator. If the peer address is
  550. in the device identity list, the peer IRK for that device will be
  551. used to generate @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE
  552. target addresses used in the advertising event PDUs. */
  553. uint32_t interval; /**< Advertising interval in 625 us units. @sa BLE_GAP_ADV_INTERVALS.
  554. @note If @ref ble_gap_adv_properties_t::type is set to
  555. @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE
  556. advertising, this parameter is ignored. */
  557. uint16_t duration; /**< Advertising duration in 10 ms units. When timeout is reached,
  558. an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised.
  559. @sa BLE_GAP_ADV_TIMEOUT_VALUES.
  560. @note The SoftDevice will always complete at least one advertising
  561. event even if the duration is set too low. */
  562. uint8_t max_adv_evts; /**< Maximum advertising events that shall be sent prior to disabling
  563. advertising. Setting the value to 0 disables the limitation. When
  564. the count of advertising events specified by this parameter
  565. (if not 0) is reached, advertising will be automatically stopped
  566. and an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised
  567. @note If @ref ble_gap_adv_properties_t::type is set to
  568. @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE,
  569. this parameter is ignored. */
  570. ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary channels.
  571. At least one of the primary channels, that is channel index 37-39, must be used. */
  572. uint8_t filter_policy; /**< Filter Policy. @sa BLE_GAP_ADV_FILTER_POLICIES. */
  573. uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising channel packets
  574. are transmitted. If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS
  575. will be used.
  576. The only supported value by this SoftDevice is @ref BLE_GAP_PHY_1MBPS. */
  577. uint8_t secondary_phy; /**< This field is ignored on this SoftDevice. */
  578. uint8_t set_id:4; /**< This field is ignored on this SoftDevice. */
  579. uint8_t scan_req_notification:1; /**< Enable scan request notifications for this advertising set. When a
  580. scan request is received and the scanner address is allowed
  581. by the filter policy, @ref BLE_GAP_EVT_SCAN_REQ_REPORT is raised.
  582. @note This parameter will be ignored when
  583. @ref ble_gap_adv_properties_t::type is a non-scannable
  584. advertising type. */
  585. } ble_gap_adv_params_t;
  586. /**@brief GAP advertising data buffers.
  587. *
  588. * The application must provide the buffers for advertisement. The memory shall reside in application RAM, and
  589. * shall never be modified while advertising. The data shall be kept alive until either:
  590. * - @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised.
  591. * - @ref BLE_GAP_EVT_CONNECTED is raised with @ref ble_gap_evt_connected_t::adv_handle set to the corresponding
  592. * advertising handle.
  593. * - Advertising is stopped.
  594. * - Advertising data is changed.
  595. * To update advertising data while advertising, provide new buffers to @ref sd_ble_gap_adv_set_configure. */
  596. typedef struct
  597. {
  598. ble_data_t adv_data; /**< Advertising data.
  599. @note
  600. Advertising data can only be specified for a @ref ble_gap_adv_properties_t::type
  601. that is allowed to contain advertising data. */
  602. ble_data_t scan_rsp_data; /**< Scan response data.
  603. @note
  604. Scan response data can only be specified for a @ref ble_gap_adv_properties_t::type
  605. that is scannable. */
  606. } ble_gap_adv_data_t;
  607. /**@brief Privacy.
  608. *
  609. * The privacy feature provides a way for the device to avoid being tracked over a period of time.
  610. * The privacy feature, when enabled, hides the local device identity and replaces it with a private address
  611. * that is automatically refreshed at a specified interval.
  612. *
  613. * If a device still wants to be recognized by other peers, it needs to share it's Identity Resolving Key (IRK).
  614. * With this key, a device can generate a random private address that can only be recognized by peers in possession of that key,
  615. * and devices can establish connections without revealing their real identities.
  616. *
  617. * Both network privacy (@ref BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY) and device privacy (@ref BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY)
  618. * are supported.
  619. *
  620. * @note If the device IRK is updated, the new IRK becomes the one to be distributed in all
  621. * bonding procedures performed after @ref sd_ble_gap_privacy_set returns.
  622. * The IRK distributed during bonding procedure is the device IRK that is active when @ref sd_ble_gap_sec_params_reply is called.
  623. */
  624. typedef struct
  625. {
  626. uint8_t privacy_mode; /**< Privacy mode, see @ref BLE_GAP_PRIVACY_MODES. Default is @ref BLE_GAP_PRIVACY_MODE_OFF. */
  627. uint8_t private_addr_type; /**< The private address type must be either @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE or @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE. */
  628. uint16_t private_addr_cycle_s; /**< Private address cycle interval in seconds. Providing an address cycle value of 0 will use the default value defined by @ref BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S. */
  629. ble_gap_irk_t *p_device_irk; /**< When used as input, pointer to IRK structure that will be used as the default IRK. If NULL, the device default IRK will be used.
  630. When used as output, pointer to IRK structure where the current default IRK will be written to. If NULL, this argument is ignored.
  631. By default, the default IRK is used to generate random private resolvable addresses for the local device unless instructed otherwise. */
  632. } ble_gap_privacy_params_t;
  633. /**@brief PHY preferences for TX and RX
  634. * @note tx_phys and rx_phys are bit fields. Multiple bits can be set in them to indicate multiple preferred PHYs for each direction.
  635. * @code
  636. * p_gap_phys->tx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS;
  637. * p_gap_phys->rx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS;
  638. * @endcode
  639. *
  640. */
  641. typedef struct
  642. {
  643. uint8_t tx_phys; /**< Preferred transmit PHYs, see @ref BLE_GAP_PHYS. */
  644. uint8_t rx_phys; /**< Preferred receive PHYs, see @ref BLE_GAP_PHYS. */
  645. } ble_gap_phys_t;
  646. /** @brief Keys that can be exchanged during a bonding procedure. */
  647. typedef struct
  648. {
  649. uint8_t enc : 1; /**< Long Term Key and Master Identification. */
  650. uint8_t id : 1; /**< Identity Resolving Key and Identity Address Information. */
  651. uint8_t sign : 1; /**< Connection Signature Resolving Key. */
  652. uint8_t link : 1; /**< Derive the Link Key from the LTK. */
  653. } ble_gap_sec_kdist_t;
  654. /**@brief GAP security parameters. */
  655. typedef struct
  656. {
  657. uint8_t bond : 1; /**< Perform bonding. */
  658. uint8_t mitm : 1; /**< Enable Man In The Middle protection. */
  659. uint8_t lesc : 1; /**< Enable LE Secure Connection pairing. */
  660. uint8_t keypress : 1; /**< Enable generation of keypress notifications. */
  661. uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */
  662. uint8_t oob : 1; /**< The OOB data flag.
  663. - In LE legacy pairing, this flag is set if a device has out of band authentication data.
  664. The OOB method is used if both of the devices have out of band authentication data.
  665. - In LE Secure Connections pairing, this flag is set if a device has the peer device's out of band authentication data.
  666. The OOB method is used if at least one device has the peer device's OOB data available. */
  667. uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance. */
  668. uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */
  669. ble_gap_sec_kdist_t kdist_own; /**< Key distribution bitmap: keys that the local device will distribute. */
  670. ble_gap_sec_kdist_t kdist_peer; /**< Key distribution bitmap: keys that the remote device will distribute. */
  671. } ble_gap_sec_params_t;
  672. /**@brief GAP Encryption Information. */
  673. typedef struct
  674. {
  675. uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */
  676. uint8_t lesc : 1; /**< Key generated using LE Secure Connections. */
  677. uint8_t auth : 1; /**< Authenticated Key. */
  678. uint8_t ltk_len : 6; /**< LTK length in octets. */
  679. } ble_gap_enc_info_t;
  680. /**@brief GAP Master Identification. */
  681. typedef struct
  682. {
  683. uint16_t ediv; /**< Encrypted Diversifier. */
  684. uint8_t rand[BLE_GAP_SEC_RAND_LEN]; /**< Random Number. */
  685. } ble_gap_master_id_t;
  686. /**@brief GAP Signing Information. */
  687. typedef struct
  688. {
  689. uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /**< Connection Signature Resolving Key. */
  690. } ble_gap_sign_info_t;
  691. /**@brief GAP LE Secure Connections P-256 Public Key. */
  692. typedef struct
  693. {
  694. 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. */
  695. } ble_gap_lesc_p256_pk_t;
  696. /**@brief GAP LE Secure Connections DHKey. */
  697. typedef struct
  698. {
  699. uint8_t key[BLE_GAP_LESC_DHKEY_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman Key. Stored in little-endian. */
  700. } ble_gap_lesc_dhkey_t;
  701. /**@brief GAP LE Secure Connections OOB data. */
  702. typedef struct
  703. {
  704. ble_gap_addr_t addr; /**< Bluetooth address of the device. */
  705. uint8_t r[BLE_GAP_SEC_KEY_LEN]; /**< Random Number. */
  706. uint8_t c[BLE_GAP_SEC_KEY_LEN]; /**< Confirm Value. */
  707. } ble_gap_lesc_oob_data_t;
  708. /**@brief Event structure for @ref BLE_GAP_EVT_CONNECTED. */
  709. typedef struct
  710. {
  711. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1
  712. and the address is the device's identity address. */
  713. uint8_t role; /**< BLE role for this connection, see @ref BLE_GAP_ROLES */
  714. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  715. uint8_t adv_handle; /**< Advertising handle in which advertising has ended.
  716. This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */
  717. ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated
  718. advertising set. The advertising buffers provided in
  719. @ref sd_ble_gap_adv_set_configure are now released.
  720. This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */
  721. } ble_gap_evt_connected_t;
  722. /**@brief Event structure for @ref BLE_GAP_EVT_DISCONNECTED. */
  723. typedef struct
  724. {
  725. uint8_t reason; /**< HCI error code, see @ref BLE_HCI_STATUS_CODES. */
  726. } ble_gap_evt_disconnected_t;
  727. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE. */
  728. typedef struct
  729. {
  730. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  731. } ble_gap_evt_conn_param_update_t;
  732. /**@brief Event structure for @ref BLE_GAP_EVT_PHY_UPDATE_REQUEST. */
  733. typedef struct
  734. {
  735. ble_gap_phys_t peer_preferred_phys; /**< The PHYs the peer prefers to use. */
  736. } ble_gap_evt_phy_update_request_t;
  737. /**@brief Event Structure for @ref BLE_GAP_EVT_PHY_UPDATE. */
  738. typedef struct
  739. {
  740. uint8_t status; /**< Status of the procedure, see @ref BLE_HCI_STATUS_CODES.*/
  741. uint8_t tx_phy; /**< TX PHY for this connection, see @ref BLE_GAP_PHYS. */
  742. uint8_t rx_phy; /**< RX PHY for this connection, see @ref BLE_GAP_PHYS. */
  743. } ble_gap_evt_phy_update_t;
  744. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. */
  745. typedef struct
  746. {
  747. ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */
  748. } ble_gap_evt_sec_params_request_t;
  749. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_INFO_REQUEST. */
  750. typedef struct
  751. {
  752. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
  753. ble_gap_master_id_t master_id; /**< Master Identification for LTK lookup. */
  754. uint8_t enc_info : 1; /**< If 1, Encryption Information required. */
  755. uint8_t id_info : 1; /**< If 1, Identity Information required. */
  756. uint8_t sign_info : 1; /**< If 1, Signing Information required. */
  757. } ble_gap_evt_sec_info_request_t;
  758. /**@brief Event structure for @ref BLE_GAP_EVT_PASSKEY_DISPLAY. */
  759. typedef struct
  760. {
  761. uint8_t passkey[BLE_GAP_PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
  762. uint8_t match_request : 1; /**< If 1 requires the application to report the match using @ref sd_ble_gap_auth_key_reply
  763. with either @ref BLE_GAP_AUTH_KEY_TYPE_NONE if there is no match or
  764. @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY if there is a match. */
  765. } ble_gap_evt_passkey_display_t;
  766. /**@brief Event structure for @ref BLE_GAP_EVT_KEY_PRESSED. */
  767. typedef struct
  768. {
  769. uint8_t kp_not; /**< Keypress notification type, see @ref BLE_GAP_KP_NOT_TYPES. */
  770. } ble_gap_evt_key_pressed_t;
  771. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_KEY_REQUEST. */
  772. typedef struct
  773. {
  774. uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */
  775. } ble_gap_evt_auth_key_request_t;
  776. /**@brief Event structure for @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST. */
  777. typedef struct
  778. {
  779. 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
  780. inside the keyset during the call to @ref sd_ble_gap_sec_params_reply. */
  781. 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. */
  782. } ble_gap_evt_lesc_dhkey_request_t;
  783. /**@brief Security levels supported.
  784. * @note See Bluetooth Specification Version 4.2 Volume 3, Part C, Chapter 10, Section 10.2.1.
  785. */
  786. typedef struct
  787. {
  788. uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */
  789. uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */
  790. uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */
  791. uint8_t lv4 : 1; /**< If 1: Level 4 is supported. */
  792. } ble_gap_sec_levels_t;
  793. /**@brief Encryption Key. */
  794. typedef struct
  795. {
  796. ble_gap_enc_info_t enc_info; /**< Encryption Information. */
  797. ble_gap_master_id_t master_id; /**< Master Identification. */
  798. } ble_gap_enc_key_t;
  799. /**@brief Identity Key. */
  800. typedef struct
  801. {
  802. ble_gap_irk_t id_info; /**< Identity Resolving Key. */
  803. ble_gap_addr_t id_addr_info; /**< Identity Address. */
  804. } ble_gap_id_key_t;
  805. /**@brief Security Keys. */
  806. typedef struct
  807. {
  808. ble_gap_enc_key_t *p_enc_key; /**< Encryption Key, or NULL. */
  809. ble_gap_id_key_t *p_id_key; /**< Identity Key, or NULL. */
  810. ble_gap_sign_info_t *p_sign_key; /**< Signing Key, or NULL. */
  811. 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
  812. in the Core Bluetooth Specification v4.2 Vol.3, Part H, Section 2.3.5.6.1 */
  813. } ble_gap_sec_keys_t;
  814. /**@brief Security key set for both local and peer keys. */
  815. typedef struct
  816. {
  817. 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. */
  818. ble_gap_sec_keys_t keys_peer; /**< Keys distributed by the remote device. For LE Secure Connections, p_enc_key must always be NULL. */
  819. } ble_gap_sec_keyset_t;
  820. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_STATUS. */
  821. typedef struct
  822. {
  823. uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */
  824. uint8_t error_src : 2; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */
  825. uint8_t bonded : 1; /**< Procedure resulted in a bond. */
  826. uint8_t lesc : 1; /**< Procedure resulted in a LE Secure Connection. */
  827. ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */
  828. ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */
  829. 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. */
  830. 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. */
  831. } ble_gap_evt_auth_status_t;
  832. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_SEC_UPDATE. */
  833. typedef struct
  834. {
  835. ble_gap_conn_sec_t conn_sec; /**< Connection security level. */
  836. } ble_gap_evt_conn_sec_update_t;
  837. /**@brief Event structure for @ref BLE_GAP_EVT_TIMEOUT. */
  838. typedef struct
  839. {
  840. uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */
  841. } ble_gap_evt_timeout_t;
  842. /**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */
  843. typedef struct
  844. {
  845. int8_t rssi; /**< Received Signal Strength Indication in dBm.
  846. @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */
  847. uint8_t ch_index; /**< Data Channel Index on which the Signal Strength is measured (0-36). */
  848. } ble_gap_evt_rssi_changed_t;
  849. /**@brief Event structure for @ref BLE_GAP_EVT_ADV_SET_TERMINATED */
  850. typedef struct
  851. {
  852. uint8_t reason; /**< Reason for why the advertising set terminated. See
  853. @ref BLE_GAP_EVT_ADV_SET_TERMINATED_REASON. */
  854. uint8_t adv_handle; /**< Advertising handle in which advertising has ended. */
  855. uint8_t num_completed_adv_events; /**< If @ref ble_gap_adv_params_t::max_adv_evts was not set to 0,
  856. this field indicates the number of completed advertising events. */
  857. ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated
  858. advertising set. The advertising buffers provided in
  859. @ref sd_ble_gap_adv_set_configure are now released. */
  860. } ble_gap_evt_adv_set_terminated_t;
  861. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_REQUEST. */
  862. typedef struct
  863. {
  864. uint8_t bond : 1; /**< Perform bonding. */
  865. uint8_t mitm : 1; /**< Man In The Middle protection requested. */
  866. uint8_t lesc : 1; /**< LE Secure Connections requested. */
  867. uint8_t keypress : 1; /**< Generation of keypress notifications requested. */
  868. } ble_gap_evt_sec_request_t;
  869. /**@brief Event structure for @ref BLE_GAP_EVT_SCAN_REQ_REPORT. */
  870. typedef struct
  871. {
  872. uint8_t adv_handle; /**< Advertising handle for the advertising set which received the Scan Request */
  873. int8_t rssi; /**< Received Signal Strength Indication in dBm.
  874. @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement. */
  875. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr resolved: @ref ble_gap_addr_t::addr_id_peer is set to 1
  876. and the address is the device's identity address. */
  877. } ble_gap_evt_scan_req_report_t;
  878. /**@brief GAP event structure. */
  879. typedef struct
  880. {
  881. uint16_t conn_handle; /**< Connection Handle on which event occurred. */
  882. union /**< union alternative identified by evt_id in enclosing struct. */
  883. {
  884. ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */
  885. ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */
  886. ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */
  887. ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */
  888. ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */
  889. ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */
  890. ble_gap_evt_key_pressed_t key_pressed; /**< Key Pressed Event Parameters. */
  891. ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */
  892. ble_gap_evt_lesc_dhkey_request_t lesc_dhkey_request; /**< LE Secure Connections DHKey calculation request. */
  893. ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */
  894. ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */
  895. ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */
  896. ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event Parameters. */
  897. ble_gap_evt_adv_set_terminated_t adv_set_terminated; /**< Advertising Set Terminated Event Parameters. */
  898. ble_gap_evt_sec_request_t sec_request; /**< Security Request Event Parameters. */
  899. ble_gap_evt_scan_req_report_t scan_req_report; /**< Scan Request Report Parameters. */
  900. ble_gap_evt_phy_update_request_t phy_update_request; /**< PHY Update Request Event Parameters. */
  901. ble_gap_evt_phy_update_t phy_update; /**< PHY Update Parameters. */
  902. } params; /**< Event Parameters. */
  903. } ble_gap_evt_t;
  904. /**
  905. * @brief BLE GAP connection configuration parameters, set with @ref sd_ble_cfg_set.
  906. *
  907. * @retval ::NRF_ERROR_CONN_COUNT The connection count for the connection configurations is zero.
  908. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  909. * - The sum of conn_count for all connection configurations combined exceeds UINT8_MAX.
  910. * - The event length is smaller than @ref BLE_GAP_EVENT_LENGTH_MIN.
  911. */
  912. typedef struct
  913. {
  914. uint8_t conn_count; /**< The number of concurrent connections the application can create with this configuration.
  915. The default and minimum value is @ref BLE_GAP_CONN_COUNT_DEFAULT. */
  916. uint16_t event_length; /**< The time set aside for this connection on every connection interval in 1.25 ms units.
  917. The default value is @ref BLE_GAP_EVENT_LENGTH_DEFAULT, the minimum value is @ref BLE_GAP_EVENT_LENGTH_MIN.
  918. The event length and the connection interval are the primary parameters
  919. for setting the throughput of a connection.
  920. See the SoftDevice Specification for details on throughput. */
  921. } ble_gap_conn_cfg_t;
  922. /**
  923. * @brief Configuration of maximum concurrent connections in the peripheral role, set with
  924. * @ref sd_ble_cfg_set.
  925. *
  926. * @retval ::NRF_ERROR_CONN_COUNT The periph_role_count is too large. The maximum
  927. * supported sum of concurrent connections is
  928. * @ref BLE_GAP_ROLE_COUNT_COMBINED_MAX.
  929. * @retval ::NRF_ERROR_RESOURCES The adv_set_count is too large. The maximum
  930. * supported advertising handles is
  931. * @ref BLE_GAP_ADV_SET_COUNT_MAX.
  932. */
  933. typedef struct
  934. {
  935. uint8_t adv_set_count; /**< Maximum number of advertising sets. Default value is @ref BLE_GAP_ADV_SET_COUNT_DEFAULT. */
  936. uint8_t periph_role_count; /**< Maximum number of connections concurrently acting as a peripheral. Default value is @ref BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT. */
  937. } ble_gap_cfg_role_count_t;
  938. /**
  939. * @brief Device name and its properties, set with @ref sd_ble_cfg_set.
  940. *
  941. * @note If the device name is not configured, the default device name will be
  942. * @ref BLE_GAP_DEVNAME_DEFAULT, the maximum device name length will be
  943. * @ref BLE_GAP_DEVNAME_DEFAULT_LEN, vloc will be set to @ref BLE_GATTS_VLOC_STACK and the device name
  944. * will have no write access.
  945. *
  946. * @note If @ref max_len is more than @ref BLE_GAP_DEVNAME_DEFAULT_LEN and vloc is set to @ref BLE_GATTS_VLOC_STACK,
  947. * the attribute table size must be increased to have room for the longer device name (see
  948. * @ref sd_ble_cfg_set and @ref ble_gatts_cfg_attr_tab_size_t).
  949. *
  950. * @note If vloc is @ref BLE_GATTS_VLOC_STACK :
  951. * - p_value must point to non-volatile memory (flash) or be NULL.
  952. * - If p_value is NULL, the device name will initially be empty.
  953. *
  954. * @note If vloc is @ref BLE_GATTS_VLOC_USER :
  955. * - p_value cannot be NULL.
  956. * - If the device name is writable, p_value must point to volatile memory (RAM).
  957. *
  958. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  959. * - Invalid device name location (vloc).
  960. * - Invalid device name security mode.
  961. * @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true:
  962. * - The device name length is invalid (must be between 0 and @ref BLE_GAP_DEVNAME_MAX_LEN).
  963. * - The device name length is too long for the given Attribute Table.
  964. * @retval ::NRF_ERROR_NOT_SUPPORTED Device name security mode is not supported.
  965. */
  966. typedef struct
  967. {
  968. ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
  969. uint8_t vloc:2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
  970. uint8_t *p_value; /**< Pointer to where the value (device name) is stored or will be stored. */
  971. uint16_t current_len; /**< Current length in bytes of the memory pointed to by p_value.*/
  972. uint16_t max_len; /**< Maximum length in bytes of the memory pointed to by p_value.*/
  973. } ble_gap_cfg_device_name_t;
  974. /**@brief Peripheral Preferred Connection Parameters include configuration parameters, set with @ref sd_ble_cfg_set. */
  975. typedef struct
  976. {
  977. uint8_t include_cfg; /**< Inclusion configuration of the Peripheral Preferred Connection Parameters characteristic.
  978. See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_PPCP_INCL_CONFIG_DEFAULT. */
  979. } ble_gap_cfg_ppcp_incl_cfg_t;
  980. /**@brief Central Address Resolution include configuration parameters, set with @ref sd_ble_cfg_set. */
  981. typedef struct
  982. {
  983. uint8_t include_cfg; /**< Inclusion configuration of the Central Address Resolution characteristic.
  984. See @ref BLE_GAP_CHAR_INCL_CONFIG. Default is @ref BLE_GAP_CAR_INCL_CONFIG_DEFAULT. */
  985. } ble_gap_cfg_car_incl_cfg_t;
  986. /**@brief Configuration structure for GAP configurations. */
  987. typedef union
  988. {
  989. ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */
  990. ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */
  991. ble_gap_cfg_ppcp_incl_cfg_t ppcp_include_cfg; /**< Peripheral Preferred Connection Parameters characteristic include
  992. configuration, cfg_id is @ref BLE_GAP_CFG_PPCP_INCL_CONFIG. */
  993. ble_gap_cfg_car_incl_cfg_t car_include_cfg; /**< Central Address Resolution characteristic include configuration,
  994. cfg_id is @ref BLE_GAP_CFG_CAR_INCL_CONFIG. */
  995. } ble_gap_cfg_t;
  996. /**@brief Channel Map option.
  997. *
  998. * @details Used with @ref sd_ble_opt_get to get the current channel map
  999. * or @ref sd_ble_opt_set to set a new channel map. When setting the
  1000. * channel map, it applies to all current and future connections. When getting the
  1001. * current channel map, it applies to a single connection and the connection handle
  1002. * must be supplied.
  1003. *
  1004. * @note Setting the channel map may take some time, depending on connection parameters.
  1005. * The time taken may be different for each connection and the get operation will
  1006. * return the previous channel map until the new one has taken effect.
  1007. *
  1008. * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed.
  1009. * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46.
  1010. *
  1011. * @retval ::NRF_SUCCESS Get or set successful.
  1012. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  1013. * - Less then two bits in @ref ch_map are set.
  1014. * - Bits for primary advertising channels (37-39) are set.
  1015. * @retval ::NRF_ERROR_BUSY Channel map was set again before enough time had passed.
  1016. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied for get.
  1017. * @retval ::NRF_ERROR_NOT_SUPPORTED Returned by @ref sd_ble_opt_set in peripheral-only SoftDevices.
  1018. *
  1019. */
  1020. typedef struct
  1021. {
  1022. uint16_t conn_handle; /**< Connection Handle (only applicable for get) */
  1023. uint8_t ch_map[5]; /**< Channel Map (37-bit). */
  1024. } ble_gap_opt_ch_map_t;
  1025. /**@brief Local connection latency option.
  1026. *
  1027. * @details Local connection latency is a feature which enables the slave to improve
  1028. * current consumption by ignoring the slave latency set by the peer. The
  1029. * local connection latency can only be set to a multiple of the slave latency,
  1030. * and cannot be longer than half of the supervision timeout.
  1031. *
  1032. * @details Used with @ref sd_ble_opt_set to set the local connection latency. The
  1033. * @ref sd_ble_opt_get is not supported for this option, but the actual
  1034. * local connection latency (unless set to NULL) is set as a return parameter
  1035. * when setting the option.
  1036. *
  1037. * @note The latency set will be truncated down to the closest slave latency event
  1038. * multiple, or the nearest multiple before half of the supervision timeout.
  1039. *
  1040. * @note The local connection latency is disabled by default, and needs to be enabled for new
  1041. * connections and whenever the connection is updated.
  1042. *
  1043. * @retval ::NRF_SUCCESS Set successfully.
  1044. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
  1045. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1046. */
  1047. typedef struct
  1048. {
  1049. uint16_t conn_handle; /**< Connection Handle */
  1050. uint16_t requested_latency; /**< Requested local connection latency. */
  1051. uint16_t * p_actual_latency; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
  1052. } ble_gap_opt_local_conn_latency_t;
  1053. /**@brief Disable slave latency
  1054. *
  1055. * @details Used with @ref sd_ble_opt_set to temporarily disable slave latency of a peripheral connection
  1056. * (see @ref ble_gap_conn_params_t::slave_latency). And to re-enable it again. When disabled, the
  1057. * peripheral will ignore the slave_latency set by the central.
  1058. *
  1059. * @note Shall only be called on peripheral links.
  1060. *
  1061. * @retval ::NRF_SUCCESS Set successfully.
  1062. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
  1063. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1064. */
  1065. typedef struct
  1066. {
  1067. uint16_t conn_handle; /**< Connection Handle */
  1068. uint8_t disable : 1; /**< Set to 1 to disable slave latency. Set to 0 enable it again.*/
  1069. } ble_gap_opt_slave_latency_disable_t;
  1070. /**@brief Passkey Option.
  1071. *
  1072. * @mscs
  1073. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
  1074. * @endmscs
  1075. *
  1076. * @details Structure containing the passkey to be used during pairing. This can be used with @ref
  1077. * sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication
  1078. * instead of generating a random one.
  1079. *
  1080. * @note Repeated pairing attempts using the same preprogrammed passkey makes pairing vulnerable to MITM attacks.
  1081. *
  1082. * @note @ref sd_ble_opt_get is not supported for this option.
  1083. *
  1084. */
  1085. typedef struct
  1086. {
  1087. uint8_t const * 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.*/
  1088. } ble_gap_opt_passkey_t;
  1089. /**@brief Authenticated payload timeout option.
  1090. *
  1091. * @details This can be used with @ref sd_ble_opt_set to change the Authenticated payload timeout to a value other
  1092. * than the default of @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX.
  1093. *
  1094. * @note The authenticated payload timeout event ::BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD will be generated
  1095. * if auth_payload_timeout time has elapsed without receiving a packet with a valid MIC on an encrypted
  1096. * link.
  1097. *
  1098. * @note The LE ping procedure will be initiated before the timer expires to give the peer a chance
  1099. * to reset the timer. In addition the stack will try to prioritize running of LE ping over other
  1100. * activities to increase chances of finishing LE ping before timer expires. To avoid side-effects
  1101. * on other activities, it is recommended to use high timeout values.
  1102. * Recommended timeout > 2*(connInterval * (6 + connSlaveLatency)).
  1103. *
  1104. * @retval ::NRF_SUCCESS Set successfully.
  1105. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. auth_payload_timeout was outside of allowed range.
  1106. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1107. */
  1108. typedef struct
  1109. {
  1110. uint16_t conn_handle; /**< Connection Handle */
  1111. uint16_t auth_payload_timeout; /**< Requested timeout in 10 ms unit, see @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT. */
  1112. } ble_gap_opt_auth_payload_timeout_t;
  1113. /**@brief Option structure for GAP options. */
  1114. typedef union
  1115. {
  1116. ble_gap_opt_ch_map_t ch_map; /**< Parameters for the Channel Map option. */
  1117. ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Parameters for the Local connection latency option */
  1118. ble_gap_opt_passkey_t passkey; /**< Parameters for the Passkey option.*/
  1119. ble_gap_opt_auth_payload_timeout_t auth_payload_timeout; /**< Parameters for the authenticated payload timeout option.*/
  1120. ble_gap_opt_slave_latency_disable_t slave_latency_disable; /**< Parameters for the Disable slave latency option */
  1121. } ble_gap_opt_t;
  1122. /**@} */
  1123. /**@addtogroup BLE_GAP_FUNCTIONS Functions
  1124. * @{ */
  1125. /**@brief Set the local Bluetooth identity address.
  1126. *
  1127. * The local Bluetooth identity address is the address that identifies this device to other peers.
  1128. * The address type must be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC.
  1129. *
  1130. * @note The identity address cannot be changed while advertising.
  1131. *
  1132. * @note This address will be distributed to the peer during bonding.
  1133. * If the address changes, the address stored in the peer device will not be valid and the ability to
  1134. * reconnect using the old address will be lost.
  1135. *
  1136. * @note By default the SoftDevice will set an address of type @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC upon being
  1137. * enabled. The address is a random number populated during the IC manufacturing process and remains unchanged
  1138. * for the lifetime of each IC.
  1139. *
  1140. * @mscs
  1141. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1142. * @endmscs
  1143. *
  1144. * @param[in] p_addr Pointer to address structure.
  1145. *
  1146. * @retval ::NRF_SUCCESS Address successfully set.
  1147. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1148. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address.
  1149. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1150. * @retval ::NRF_ERROR_INVALID_STATE The identity address cannot be changed while advertising.
  1151. */
  1152. SVCALL(SD_BLE_GAP_ADDR_SET, uint32_t, sd_ble_gap_addr_set(ble_gap_addr_t const *p_addr));
  1153. /**@brief Get local Bluetooth identity address.
  1154. *
  1155. * @note This will always return the identity address irrespective of the privacy settings,
  1156. * i.e. the address type will always be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC.
  1157. *
  1158. * @param[out] p_addr Pointer to address structure to be filled in.
  1159. *
  1160. * @retval ::NRF_SUCCESS Address successfully retrieved.
  1161. * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
  1162. */
  1163. SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr));
  1164. /**@brief Get the Bluetooth device address used by the advertiser.
  1165. *
  1166. * @note This function will return the local Bluetooth address used in advertising PDUs. When
  1167. * using privacy, the SoftDevice will generate a new private address every
  1168. * @ref ble_gap_privacy_params_t::private_addr_cycle_s configured using
  1169. * @ref sd_ble_gap_privacy_set. Hence depending on when the application calls this API, the
  1170. * address returned may not be the latest address that is used in the advertising PDUs.
  1171. *
  1172. * @param[in] adv_handle The advertising handle to get the address from.
  1173. * @param[out] p_addr Pointer to address structure to be filled in.
  1174. *
  1175. * @retval ::NRF_SUCCESS Address successfully retrieved.
  1176. * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
  1177. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found.
  1178. * @retval ::NRF_ERROR_INVALID_STATE The advertising set is currently not advertising.
  1179. */
  1180. SVCALL(SD_BLE_GAP_ADV_ADDR_GET, uint32_t, sd_ble_gap_adv_addr_get(uint8_t adv_handle, ble_gap_addr_t *p_addr));
  1181. /**@brief Set the active whitelist in the SoftDevice.
  1182. *
  1183. * @note Only one whitelist can be used at a time and the whitelist is shared between the BLE roles.
  1184. * The whitelist cannot be set if a BLE role is using the whitelist.
  1185. *
  1186. * @note If an address is resolved using the information in the device identity list, then the whitelist
  1187. * filter policy applies to the peer identity address and not the resolvable address sent on air.
  1188. *
  1189. * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses, if NULL the whitelist will be cleared.
  1190. * @param[in] len Length of the whitelist, maximum @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT.
  1191. *
  1192. * @retval ::NRF_SUCCESS The whitelist is successfully set/cleared.
  1193. * @retval ::NRF_ERROR_INVALID_ADDR The whitelist (or one of its entries) provided is invalid.
  1194. * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE The whitelist is in use by a BLE role and cannot be set or cleared.
  1195. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1196. * @retval ::NRF_ERROR_DATA_SIZE The given whitelist size is invalid (zero or too large); this can only return when
  1197. * pp_wl_addrs is not NULL.
  1198. */
  1199. SVCALL(SD_BLE_GAP_WHITELIST_SET, uint32_t, sd_ble_gap_whitelist_set(ble_gap_addr_t const * const * pp_wl_addrs, uint8_t len));
  1200. /**@brief Set device identity list.
  1201. *
  1202. * @note Only one device identity list can be used at a time and the list is shared between the BLE roles.
  1203. * The device identity list cannot be set if a BLE role is using the list.
  1204. *
  1205. * @param[in] pp_id_keys Pointer to an array of peer identity addresses and peer IRKs, if NULL the device identity list will be cleared.
  1206. * @param[in] pp_local_irks Pointer to an array of local IRKs. Each entry in the array maps to the entry in pp_id_keys at the same index.
  1207. * To fill in the list with the currently set device IRK for all peers, set to NULL.
  1208. * @param[in] len Length of the device identity list, maximum @ref BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT.
  1209. *
  1210. * @mscs
  1211. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC}
  1212. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1213. * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC}
  1214. * @endmscs
  1215. *
  1216. * @retval ::NRF_SUCCESS The device identity list successfully set/cleared.
  1217. * @retval ::NRF_ERROR_INVALID_ADDR The device identity list (or one of its entries) provided is invalid.
  1218. * This code may be returned if the local IRK list also has an invalid entry.
  1219. * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE The device identity list is in use and cannot be set or cleared.
  1220. * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE The device identity list contains multiple entries with the same identity address.
  1221. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1222. * @retval ::NRF_ERROR_DATA_SIZE The given device identity list size invalid (zero or too large); this can
  1223. * only return when pp_id_keys is not NULL.
  1224. */
  1225. SVCALL(SD_BLE_GAP_DEVICE_IDENTITIES_SET, uint32_t, sd_ble_gap_device_identities_set(ble_gap_id_key_t const * const * pp_id_keys, ble_gap_irk_t const * const * pp_local_irks, uint8_t len));
  1226. /**@brief Set privacy settings.
  1227. *
  1228. * @note Privacy settings cannot be changed while advertising.
  1229. *
  1230. * @param[in] p_privacy_params Privacy settings.
  1231. *
  1232. * @mscs
  1233. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC}
  1234. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1235. * @endmscs
  1236. *
  1237. * @retval ::NRF_SUCCESS Set successfully.
  1238. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1239. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1240. * @retval ::NRF_ERROR_INVALID_ADDR The pointer to privacy settings is NULL or invalid.
  1241. * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
  1242. * @retval ::NRF_ERROR_INVALID_PARAM Out of range parameters are provided.
  1243. * @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising.
  1244. */
  1245. SVCALL(SD_BLE_GAP_PRIVACY_SET, uint32_t, sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params));
  1246. /**@brief Get privacy settings.
  1247. *
  1248. * @note ::ble_gap_privacy_params_t::p_device_irk must be initialized to NULL or a valid address before this function is called.
  1249. * If it is initialized to a valid address, the address pointed to will contain the current device IRK on return.
  1250. *
  1251. * @param[in,out] p_privacy_params Privacy settings.
  1252. *
  1253. * @retval ::NRF_SUCCESS Privacy settings read.
  1254. * @retval ::NRF_ERROR_INVALID_ADDR The pointer given for returning the privacy settings may be NULL or invalid.
  1255. * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
  1256. */
  1257. SVCALL(SD_BLE_GAP_PRIVACY_GET, uint32_t, sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params));
  1258. /**@brief Configure an advertising set. Set, clear or update advertising and scan response data.
  1259. *
  1260. * @note The format of the advertising data will be checked by this call to ensure interoperability.
  1261. * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
  1262. * duplicating the local name in the advertising data and scan response data.
  1263. *
  1264. * @note In order to update advertising data while advertising, new advertising buffers must be provided.
  1265. *
  1266. * @mscs
  1267. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1268. * @endmscs
  1269. *
  1270. * @param[in,out] p_adv_handle Provide a pointer to a handle containing @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to configure
  1271. * a new advertising set. On success, a new handle is then returned through the pointer.
  1272. * Provide a pointer to an existing advertising handle to configure an existing advertising set.
  1273. * @param[in] p_adv_data Advertising data. If set to NULL, no advertising data will be used. See @ref ble_gap_adv_data_t.
  1274. * @param[in] p_adv_params Advertising parameters. When this function is used to update advertising data while advertising,
  1275. * this parameter must be NULL. See @ref ble_gap_adv_params_t.
  1276. *
  1277. * @retval ::NRF_SUCCESS Advertising set successfully configured.
  1278. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied:
  1279. * - Invalid advertising data configuration specified. See @ref ble_gap_adv_data_t.
  1280. * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t.
  1281. * - Use of whitelist requested but whitelist has not been set,
  1282. * see @ref sd_ble_gap_whitelist_set.
  1283. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR ble_gap_adv_params_t::p_peer_addr is invalid.
  1284. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1285. * - It is invalid to provide non-NULL advertising set parameters while advertising.
  1286. * - It is invalid to provide the same data buffers while advertising. To update
  1287. * advertising data, provide new advertising buffers.
  1288. * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible.
  1289. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. Use @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to
  1290. * configure a new advertising handle.
  1291. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1292. * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied.
  1293. * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied. Check the advertising data format specification
  1294. * given in Bluetooth Specification Version 5.0, Volume 3, Part C, Chapter 11.
  1295. * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied.
  1296. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data length or advertising parameter configuration.
  1297. * @retval ::NRF_ERROR_NO_MEM Not enough memory to configure a new advertising handle. Update an
  1298. * existing advertising handle instead.
  1299. * @retval ::BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied.
  1300. */
  1301. SVCALL(SD_BLE_GAP_ADV_SET_CONFIGURE, uint32_t, sd_ble_gap_adv_set_configure(uint8_t *p_adv_handle, ble_gap_adv_data_t const *p_adv_data, ble_gap_adv_params_t const *p_adv_params));
  1302. /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  1303. *
  1304. * @note Only one advertiser may be active at any time.
  1305. *
  1306. * @note If privacy is enabled, the advertiser's private address will be refreshed when this function is called.
  1307. * See @ref sd_ble_gap_privacy_set().
  1308. *
  1309. * @events
  1310. * @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.}
  1311. * @event{@ref BLE_GAP_EVT_ADV_SET_TERMINATED, Advertising set has terminated.}
  1312. * @event{@ref BLE_GAP_EVT_SCAN_REQ_REPORT, A scan request was received.}
  1313. * @endevents
  1314. *
  1315. * @mscs
  1316. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1317. * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC}
  1318. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1319. * @endmscs
  1320. *
  1321. * @param[in] adv_handle Advertising handle to advertise on, received from @ref sd_ble_gap_adv_set_configure.
  1322. * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or
  1323. * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. For non-connectable
  1324. * advertising, this is ignored.
  1325. *
  1326. * @retval ::NRF_SUCCESS The BLE stack has started advertising.
  1327. * @retval ::NRF_ERROR_INVALID_STATE adv_handle is not configured or already advertising.
  1328. * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections for this connection configuration
  1329. * tag has been reached; connectable advertiser cannot be started.
  1330. * To increase the number of available connections,
  1331. * use @ref sd_ble_cfg_set with @ref BLE_GAP_CFG_ROLE_COUNT or @ref BLE_CONN_CFG_GAP.
  1332. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. Configure a new adveriting handle with @ref sd_ble_gap_adv_set_configure.
  1333. * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found.
  1334. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied:
  1335. * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t.
  1336. * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set.
  1337. * @retval ::NRF_ERROR_RESOURCES Either:
  1338. * - adv_handle is configured with connectable advertising, but the event_length parameter
  1339. * associated with conn_cfg_tag is too small to be able to establish a connection on
  1340. * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length.
  1341. * - Not enough BLE role slots available.
  1342. * Stop one or more currently active roles (Peripheral or Broadcaster) and try again
  1343. * - p_adv_params is configured with connectable advertising, but the event_length parameter
  1344. * associated with conn_cfg_tag is too small to be able to establish a connection on
  1345. * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length.
  1346. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call.
  1347. */
  1348. SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag));
  1349. /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  1350. *
  1351. * @mscs
  1352. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1353. * @endmscs
  1354. *
  1355. * @param[in] adv_handle The advertising handle that should stop advertising.
  1356. *
  1357. * @retval ::NRF_SUCCESS The BLE stack has stopped advertising.
  1358. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Invalid advertising handle.
  1359. * @retval ::NRF_ERROR_INVALID_STATE The advertising handle is not advertising.
  1360. */
  1361. SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle));
  1362. /**@brief Update connection parameters.
  1363. *
  1364. * @details In the peripheral role, this will send the corresponding L2CAP request and wait for
  1365. * the central to perform the procedure. Regardless of success or failure, the application
  1366. * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event.
  1367. *
  1368. * @events
  1369. * @event{@ref BLE_GAP_EVT_CONN_PARAM_UPDATE, Result of the connection parameter update procedure.}
  1370. * @endevents
  1371. *
  1372. * @mscs
  1373. * @mmsc{@ref BLE_GAP_CPU_MSC}
  1374. * @endmscs
  1375. *
  1376. * @param[in] conn_handle Connection handle.
  1377. * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role,
  1378. * the parameters in the PPCP characteristic of the GAP service will be used instead.
  1379. *
  1380. * @retval ::NRF_SUCCESS The Connection Update procedure has been started successfully.
  1381. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1382. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
  1383. * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established.
  1384. * @retval ::NRF_ERROR_BUSY Procedure already in progress, wait for pending procedures to complete and retry.
  1385. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1386. * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
  1387. */
  1388. 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));
  1389. /**@brief Disconnect (GAP Link Termination).
  1390. *
  1391. * @details This call initiates the disconnection procedure, and its completion will be communicated to the application
  1392. * with a @ref BLE_GAP_EVT_DISCONNECTED event.
  1393. *
  1394. * @events
  1395. * @event{@ref BLE_GAP_EVT_DISCONNECTED, Generated when disconnection procedure is complete.}
  1396. * @endevents
  1397. *
  1398. * @mscs
  1399. * @mmsc{@ref BLE_GAP_CONN_MSC}
  1400. * @endmscs
  1401. *
  1402. * @param[in] conn_handle Connection handle.
  1403. * @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).
  1404. *
  1405. * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully.
  1406. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1407. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1408. * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established.
  1409. */
  1410. SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
  1411. /**@brief Set the radio's transmit power.
  1412. *
  1413. * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for
  1414. * possible roles.
  1415. * @param[in] handle The handle parameter is interpreted depending on role:
  1416. * - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle.
  1417. * - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle,
  1418. * will use the specified transmit power, and include it in the advertising packet headers if
  1419. * @ref ble_gap_adv_properties_t::include_tx_power set.
  1420. * - For all other roles handle is ignored.
  1421. * @param[in] tx_power Radio transmit power in dBm (see note for accepted values).
  1422. *
  1423. * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +3dBm and +4dBm.
  1424. * In addition, on some chips following values are supported: +2dBm, +5dBm, +6dBm, +7dBm and +8dBm.
  1425. * Setting these values on a chip that does not support them will result in undefined behaviour.
  1426. * @note The initiator will have the same transmit power as the scanner.
  1427. * @note When a connection is created it will inherit the transmit power from the initiator or
  1428. * advertiser leading to the connection.
  1429. *
  1430. * @retval ::NRF_SUCCESS Successfully changed the transmit power.
  1431. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1432. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found.
  1433. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1434. */
  1435. SVCALL(SD_BLE_GAP_TX_POWER_SET, uint32_t, sd_ble_gap_tx_power_set(uint8_t role, uint16_t handle, int8_t tx_power));
  1436. /**@brief Set GAP Appearance value.
  1437. *
  1438. * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
  1439. *
  1440. * @retval ::NRF_SUCCESS Appearance value set successfully.
  1441. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1442. */
  1443. SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance));
  1444. /**@brief Get GAP Appearance value.
  1445. *
  1446. * @param[out] p_appearance Pointer to appearance (16-bit) to be filled in, see @ref BLE_APPEARANCES.
  1447. *
  1448. * @retval ::NRF_SUCCESS Appearance value retrieved successfully.
  1449. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1450. */
  1451. SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t *p_appearance));
  1452. /**@brief Set GAP Peripheral Preferred Connection Parameters.
  1453. *
  1454. * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters.
  1455. *
  1456. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully.
  1457. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1458. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1459. * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table,
  1460. see @ref ble_gap_cfg_ppcp_incl_cfg_t.
  1461. */
  1462. SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params));
  1463. /**@brief Get GAP Peripheral Preferred Connection Parameters.
  1464. *
  1465. * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored.
  1466. *
  1467. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully.
  1468. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1469. * @retval ::NRF_ERROR_NOT_SUPPORTED The characteristic is not included in the Attribute Table,
  1470. see @ref ble_gap_cfg_ppcp_incl_cfg_t.
  1471. */
  1472. SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params));
  1473. /**@brief Set GAP device name.
  1474. *
  1475. * @note If the device name is located in application flash memory (see @ref ble_gap_cfg_device_name_t),
  1476. * it cannot be changed. Then @ref NRF_ERROR_FORBIDDEN will be returned.
  1477. *
  1478. * @param[in] p_write_perm Write permissions for the Device Name characteristic, see @ref ble_gap_conn_sec_mode_t.
  1479. * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string.
  1480. * @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).
  1481. *
  1482. * @retval ::NRF_SUCCESS GAP device name and permissions set successfully.
  1483. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1484. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1485. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1486. * @retval ::NRF_ERROR_FORBIDDEN Device name is not writable.
  1487. */
  1488. 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));
  1489. /**@brief Get GAP device name.
  1490. *
  1491. * @note If the device name is longer than the size of the supplied buffer,
  1492. * p_len will return the complete device name length,
  1493. * and not the number of bytes actually returned in p_dev_name.
  1494. * The application may use this information to allocate a suitable buffer size.
  1495. *
  1496. * @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.
  1497. * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output.
  1498. *
  1499. * @retval ::NRF_SUCCESS GAP device name retrieved successfully.
  1500. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1501. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1502. */
  1503. SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t *p_dev_name, uint16_t *p_len));
  1504. /**@brief Initiate the GAP Authentication procedure.
  1505. *
  1506. * @details In the peripheral role, this function will send an SMP Security Request.
  1507. *
  1508. * @events
  1509. * @event{Depending on the security parameters set and the packet exchanges with the peer\, the following events may be generated:}
  1510. * @event{@ref BLE_GAP_EVT_SEC_PARAMS_REQUEST}
  1511. * @event{@ref BLE_GAP_EVT_SEC_INFO_REQUEST}
  1512. * @event{@ref BLE_GAP_EVT_PASSKEY_DISPLAY}
  1513. * @event{@ref BLE_GAP_EVT_KEY_PRESSED}
  1514. * @event{@ref BLE_GAP_EVT_AUTH_KEY_REQUEST}
  1515. * @event{@ref BLE_GAP_EVT_LESC_DHKEY_REQUEST}
  1516. * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE}
  1517. * @event{@ref BLE_GAP_EVT_AUTH_STATUS}
  1518. * @event{@ref BLE_GAP_EVT_TIMEOUT}
  1519. * @endevents
  1520. *
  1521. * @mscs
  1522. * @mmsc{@ref BLE_GAP_PERIPH_SEC_REQ_MSC}
  1523. * @endmscs
  1524. *
  1525. * @param[in] conn_handle Connection handle.
  1526. * @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.
  1527. * In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used.
  1528. *
  1529. * @retval ::NRF_SUCCESS Successfully initiated authentication procedure.
  1530. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1531. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1532. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1533. * - No link has been established.
  1534. * - An encryption is already executing or queued.
  1535. * @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached.
  1536. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1537. */
  1538. SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params));
  1539. /**@brief Reply with GAP security parameters.
  1540. *
  1541. * @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.
  1542. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1543. *
  1544. * @events
  1545. * @event{This function is used during authentication procedures, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1546. * @endevents
  1547. *
  1548. * @mscs
  1549. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_JW_MSC}
  1550. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_JW_MSC}
  1551. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_PERIPH_MSC}
  1552. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1553. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
  1554. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_CONFIRM_FAIL_MSC}
  1555. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1556. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1557. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1558. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1559. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1560. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_KS_TOO_SMALL_MSC}
  1561. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_APP_ERROR_MSC}
  1562. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_REMOTE_PAIRING_FAIL_MSC}
  1563. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_TIMEOUT_MSC}
  1564. * @endmscs
  1565. *
  1566. * @param[in] conn_handle Connection handle.
  1567. * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS.
  1568. * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure.
  1569. * @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
  1570. * will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application
  1571. * upon reception of a @ref BLE_GAP_EVT_AUTH_STATUS event.
  1572. * Note that the SoftDevice expects the application to provide memory for storing the
  1573. * peer's keys. So it must be ensured that the relevant pointers inside this structure are not NULL. The pointers to the local key
  1574. * can, however, be NULL, in which case, the local key data will not be available to the application upon reception of the
  1575. * @ref BLE_GAP_EVT_AUTH_STATUS event.
  1576. *
  1577. * @retval ::NRF_SUCCESS Successfully accepted security parameter from the application.
  1578. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1579. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1580. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1581. * @retval ::NRF_ERROR_INVALID_STATE Security parameters has not been requested.
  1582. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1583. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
  1584. */
  1585. 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));
  1586. /**@brief Reply with an authentication key.
  1587. *
  1588. * @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.
  1589. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1590. *
  1591. * @events
  1592. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1593. * @endevents
  1594. *
  1595. * @mscs
  1596. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1597. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1598. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1599. * @endmscs
  1600. *
  1601. * @param[in] conn_handle Connection handle.
  1602. * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES.
  1603. * @param[in] p_key If key type is @ref BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL.
  1604. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination)
  1605. * or NULL when confirming LE Secure Connections Numeric Comparison.
  1606. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in little-endian format.
  1607. *
  1608. * @retval ::NRF_SUCCESS Authentication key successfully set.
  1609. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1610. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1611. * @retval ::NRF_ERROR_INVALID_STATE Authentication key has not been requested.
  1612. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1613. */
  1614. 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));
  1615. /**@brief Reply with an LE Secure connections DHKey.
  1616. *
  1617. * @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.
  1618. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1619. *
  1620. * @events
  1621. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1622. * @endevents
  1623. *
  1624. * @mscs
  1625. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1626. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1627. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1628. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1629. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1630. * @endmscs
  1631. *
  1632. * @param[in] conn_handle Connection handle.
  1633. * @param[in] p_dhkey LE Secure Connections DHKey.
  1634. *
  1635. * @retval ::NRF_SUCCESS DHKey successfully set.
  1636. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1637. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1638. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1639. * - The peer is not authenticated.
  1640. * - The application has not pulled a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event.
  1641. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1642. */
  1643. 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));
  1644. /**@brief Notify the peer of a local keypress.
  1645. *
  1646. * @mscs
  1647. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1648. * @endmscs
  1649. *
  1650. * @param[in] conn_handle Connection handle.
  1651. * @param[in] kp_not See @ref BLE_GAP_KP_NOT_TYPES.
  1652. *
  1653. * @retval ::NRF_SUCCESS Keypress notification successfully queued for transmission.
  1654. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1655. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1656. * - Authentication key not requested.
  1657. * - Passkey has not been entered.
  1658. * - Keypresses have not been enabled by both peers.
  1659. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1660. * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
  1661. */
  1662. SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not));
  1663. /**@brief Generate a set of OOB data to send to a peer out of band.
  1664. *
  1665. * @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,
  1666. * the one used during connection setup). The application may manually overwrite it with an updated value.
  1667. *
  1668. * @mscs
  1669. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1670. * @endmscs
  1671. *
  1672. * @param[in] conn_handle Connection handle. Can be @ref BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet.
  1673. * @param[in] p_pk_own LE Secure Connections local P-256 Public Key.
  1674. * @param[out] p_oobd_own The OOB data to be sent out of band to a peer.
  1675. *
  1676. * @retval ::NRF_SUCCESS OOB data successfully generated.
  1677. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1678. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1679. */
  1680. 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));
  1681. /**@brief Provide the OOB data sent/received out of band.
  1682. *
  1683. * @note An authentication procedure with OOB selected as an algorithm must be in progress when calling this function.
  1684. * @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.
  1685. *
  1686. * @events
  1687. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1688. * @endevents
  1689. *
  1690. * @mscs
  1691. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1692. * @endmscs
  1693. *
  1694. * @param[in] conn_handle Connection handle.
  1695. * @param[in] p_oobd_own The OOB data sent out of band to a peer or NULL if the peer has not received OOB data.
  1696. * Must correspond to @ref ble_gap_sec_params_t::oob flag in @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST.
  1697. * @param[in] p_oobd_peer The OOB data received out of band from a peer or NULL if none received.
  1698. * Must correspond to @ref ble_gap_sec_params_t::oob flag
  1699. * in @ref sd_ble_gap_sec_params_reply in the peripheral role.
  1700. *
  1701. * @retval ::NRF_SUCCESS OOB data accepted.
  1702. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1703. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1704. * - Authentication key not requested
  1705. * - Not expecting LESC OOB data
  1706. * - Have not actually exchanged passkeys.
  1707. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1708. */
  1709. 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));
  1710. /**@brief Reply with GAP security information.
  1711. *
  1712. * @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.
  1713. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1714. * @note Data signing is not yet supported, and p_sign_info must therefore be NULL.
  1715. *
  1716. * @mscs
  1717. * @mmsc{@ref BLE_GAP_PERIPH_ENC_MSC}
  1718. * @endmscs
  1719. *
  1720. * @param[in] conn_handle Connection handle.
  1721. * @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.
  1722. * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t identity information structure. May be NULL to signal none is available.
  1723. * @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.
  1724. *
  1725. * @retval ::NRF_SUCCESS Successfully accepted security information.
  1726. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1727. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1728. * - No link has been established.
  1729. * - No @ref BLE_GAP_EVT_SEC_INFO_REQUEST pending.
  1730. * - Encryption information provided by the app without being requested. See @ref ble_gap_evt_sec_info_request_t::enc_info.
  1731. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1732. */
  1733. 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));
  1734. /**@brief Get the current connection security.
  1735. *
  1736. * @param[in] conn_handle Connection handle.
  1737. * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in.
  1738. *
  1739. * @retval ::NRF_SUCCESS Current connection security successfully retrieved.
  1740. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1741. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1742. */
  1743. 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));
  1744. /**@brief Start reporting the received signal strength to the application.
  1745. *
  1746. * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
  1747. *
  1748. * @events
  1749. * @event{@ref BLE_GAP_EVT_RSSI_CHANGED, New RSSI data available. How often the event is generated is
  1750. * dependent on the settings of the <code>threshold_dbm</code>
  1751. * and <code>skip_count</code> input parameters.}
  1752. * @endevents
  1753. *
  1754. * @mscs
  1755. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  1756. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  1757. * @endmscs
  1758. *
  1759. * @param[in] conn_handle Connection handle.
  1760. * @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.
  1761. * @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.
  1762. *
  1763. * @retval ::NRF_SUCCESS Successfully activated RSSI reporting.
  1764. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is already ongoing.
  1765. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1766. */
  1767. 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));
  1768. /**@brief Stop reporting the received signal strength.
  1769. *
  1770. * @note An RSSI change detected before the call but not yet received by the application
  1771. * may be reported after @ref sd_ble_gap_rssi_stop has been called.
  1772. *
  1773. * @mscs
  1774. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  1775. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  1776. * @endmscs
  1777. *
  1778. * @param[in] conn_handle Connection handle.
  1779. *
  1780. * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting.
  1781. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
  1782. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1783. */
  1784. SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle));
  1785. /**@brief Get the received signal strength for the last connection event.
  1786. *
  1787. * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND
  1788. * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start.
  1789. * @note ERRATA-153 and ERRATA-225 require the rssi sample to be compensated based on a temperature measurement.
  1790. * @mscs
  1791. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  1792. * @endmscs
  1793. *
  1794. * @param[in] conn_handle Connection handle.
  1795. * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored.
  1796. * @param[out] p_ch_index Pointer to the location where Channel Index for the RSSI measurement shall be stored.
  1797. *
  1798. * @retval ::NRF_SUCCESS Successfully read the RSSI.
  1799. * @retval ::NRF_ERROR_NOT_FOUND No sample is available.
  1800. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1801. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1802. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
  1803. */
  1804. SVCALL(SD_BLE_GAP_RSSI_GET, uint32_t, sd_ble_gap_rssi_get(uint16_t conn_handle, int8_t *p_rssi, uint8_t *p_ch_index));
  1805. /**@brief Initiate or respond to a PHY Update Procedure
  1806. *
  1807. * @details This function is used to initiate or respond to a PHY Update Procedure. It will always
  1808. * generate a @ref BLE_GAP_EVT_PHY_UPDATE event if successfully executed.
  1809. * If this function is used to initiate a PHY Update procedure and the only option
  1810. * provided in @ref ble_gap_phys_t::tx_phys and @ref ble_gap_phys_t::rx_phys is the
  1811. * currently active PHYs in the respective directions, the SoftDevice will generate a
  1812. * @ref BLE_GAP_EVT_PHY_UPDATE with the current PHYs set and will not initiate the
  1813. * procedure in the Link Layer.
  1814. *
  1815. * If @ref ble_gap_phys_t::tx_phys or @ref ble_gap_phys_t::rx_phys is @ref BLE_GAP_PHY_AUTO,
  1816. * then the stack will select PHYs based on the peer's PHY preferences and the local link
  1817. * configuration. The PHY Update procedure will for this case result in a PHY combination
  1818. * that respects the time constraints configured with @ref sd_ble_cfg_set and the current
  1819. * link layer data length.
  1820. *
  1821. * If the peer does not support the PHY Update Procedure, then the resulting
  1822. * @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to
  1823. * @ref BLE_HCI_UNSUPPORTED_REMOTE_FEATURE.
  1824. *
  1825. * If the PHY Update procedure was rejected by the peer due to a procedure collision, the status
  1826. * will be @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or
  1827. * @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION.
  1828. * If the peer responds to the PHY Update procedure with invalid parameters, the status
  1829. * will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS.
  1830. * If the PHY Update procedure was rejected by the peer for a different reason, the status will
  1831. * contain the reason as specified by the peer.
  1832. *
  1833. * @events
  1834. * @event{@ref BLE_GAP_EVT_PHY_UPDATE, Result of the PHY Update Procedure.}
  1835. * @endevents
  1836. *
  1837. * @mscs
  1838. * @mmsc{@ref BLE_GAP_PERIPHERAL_PHY_UPDATE}
  1839. * @endmscs
  1840. *
  1841. * @param[in] conn_handle Connection handle to indicate the connection for which the PHY Update is requested.
  1842. * @param[in] p_gap_phys Pointer to PHY structure.
  1843. *
  1844. * @retval ::NRF_SUCCESS Successfully requested a PHY Update.
  1845. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1846. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1847. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1848. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported PHYs supplied to the call.
  1849. * @retval ::NRF_ERROR_INVALID_STATE No link has been established.
  1850. * @retval ::NRF_ERROR_BUSY Procedure is already in progress or not allowed at this time. Process pending events and wait for the pending procedure to complete and retry.
  1851. *
  1852. */
  1853. SVCALL(SD_BLE_GAP_PHY_UPDATE, uint32_t, sd_ble_gap_phy_update(uint16_t conn_handle, ble_gap_phys_t const *p_gap_phys));
  1854. /**@brief Obtain the next connection event counter value.
  1855. *
  1856. * @details The connection event counter is initialized to zero on the first connection event. The value is incremented
  1857. * by one for each connection event. For more information see Bluetooth Core Specification v5.0, Vol 6, Part B,
  1858. * Section 4.5.1.
  1859. *
  1860. * @note The connection event counter obtained through this API will be outdated if this API is called
  1861. * at the same time as the connection event counter is incremented.
  1862. *
  1863. * @note This API will always return the last connection event counter + 1.
  1864. * The actual connection event may be multiple connection events later if:
  1865. * - Slave latency is enabled and there is no data to transmit or receive.
  1866. * - Another role is scheduled with a higher priority at the same time as the next connection event.
  1867. *
  1868. * @param[in] conn_handle Connection handle.
  1869. * @param[out] p_counter Pointer to the variable where the next connection event counter will be written.
  1870. *
  1871. * @retval ::NRF_SUCCESS The connection event counter was successfully retrieved.
  1872. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied.
  1873. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1874. */
  1875. SVCALL(SD_BLE_GAP_NEXT_CONN_EVT_COUNTER_GET, uint32_t, sd_ble_gap_next_conn_evt_counter_get(uint16_t conn_handle, uint16_t * p_counter));
  1876. /** @} */
  1877. #ifdef __cplusplus
  1878. }
  1879. #endif
  1880. #endif // BLE_GAP_H__
  1881. /**
  1882. @}
  1883. */