ble_gap.h 164 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696
  1. /*
  2. * Copyright (c) 2011 - 2018, 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_ENCRYPT = BLE_GAP_SVC_BASE + 25, /**< Initiate encryption procedure. */
  87. SD_BLE_GAP_SEC_INFO_REPLY = BLE_GAP_SVC_BASE + 26, /**< Reply with Security Information. */
  88. SD_BLE_GAP_CONN_SEC_GET = BLE_GAP_SVC_BASE + 27, /**< Obtain connection security level. */
  89. SD_BLE_GAP_RSSI_START = BLE_GAP_SVC_BASE + 28, /**< Start reporting of changes in RSSI. */
  90. SD_BLE_GAP_RSSI_STOP = BLE_GAP_SVC_BASE + 29, /**< Stop reporting of changes in RSSI. */
  91. SD_BLE_GAP_SCAN_START = BLE_GAP_SVC_BASE + 30, /**< Start Scanning. */
  92. SD_BLE_GAP_SCAN_STOP = BLE_GAP_SVC_BASE + 31, /**< Stop Scanning. */
  93. SD_BLE_GAP_CONNECT = BLE_GAP_SVC_BASE + 32, /**< Connect. */
  94. SD_BLE_GAP_CONNECT_CANCEL = BLE_GAP_SVC_BASE + 33, /**< Cancel ongoing connection procedure. */
  95. SD_BLE_GAP_RSSI_GET = BLE_GAP_SVC_BASE + 34, /**< Get the last RSSI sample. */
  96. SD_BLE_GAP_PHY_UPDATE = BLE_GAP_SVC_BASE + 35, /**< Initiate or respond to a PHY Update Procedure. */
  97. SD_BLE_GAP_DATA_LENGTH_UPDATE = BLE_GAP_SVC_BASE + 36, /**< Initiate or respond to a Data Length Update Procedure. */
  98. SD_BLE_GAP_QOS_CHANNEL_SURVEY_START = BLE_GAP_SVC_BASE + 37, /**< Start Quality of Service (QoS) channel survey module. */
  99. SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP = BLE_GAP_SVC_BASE + 38, /**< Stop Quality of Service (QoS) channel survey module. */
  100. SD_BLE_GAP_ADV_ADDR_GET = BLE_GAP_SVC_BASE + 39, /**< Get the Address used on air while Advertising. */
  101. };
  102. /**@brief GAP Event IDs.
  103. * IDs that uniquely identify an event coming from the stack to the application.
  104. */
  105. enum BLE_GAP_EVTS
  106. {
  107. BLE_GAP_EVT_CONNECTED = BLE_GAP_EVT_BASE, /**< Connected to peer. \n See @ref ble_gap_evt_connected_t */
  108. BLE_GAP_EVT_DISCONNECTED = BLE_GAP_EVT_BASE + 1, /**< Disconnected from peer. \n See @ref ble_gap_evt_disconnected_t. */
  109. BLE_GAP_EVT_CONN_PARAM_UPDATE = BLE_GAP_EVT_BASE + 2, /**< Connection Parameters updated. \n See @ref ble_gap_evt_conn_param_update_t. */
  110. 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. */
  111. 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. */
  112. 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. */
  113. 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 */
  114. 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. */
  115. 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 */
  116. BLE_GAP_EVT_AUTH_STATUS = BLE_GAP_EVT_BASE + 9, /**< Authentication procedure completed with status. \n See @ref ble_gap_evt_auth_status_t. */
  117. BLE_GAP_EVT_CONN_SEC_UPDATE = BLE_GAP_EVT_BASE + 10, /**< Connection security updated. \n See @ref ble_gap_evt_conn_sec_update_t. */
  118. BLE_GAP_EVT_TIMEOUT = BLE_GAP_EVT_BASE + 11, /**< Timeout expired. \n See @ref ble_gap_evt_timeout_t. */
  119. BLE_GAP_EVT_RSSI_CHANGED = BLE_GAP_EVT_BASE + 12, /**< RSSI report. \n See @ref ble_gap_evt_rssi_changed_t. */
  120. BLE_GAP_EVT_ADV_REPORT = BLE_GAP_EVT_BASE + 13, /**< Advertising report. \n See @ref ble_gap_evt_adv_report_t. */
  121. BLE_GAP_EVT_SEC_REQUEST = BLE_GAP_EVT_BASE + 14, /**< Security Request. \n See @ref ble_gap_evt_sec_request_t. */
  122. BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 15, /**< Connection Parameter Update Request. \n Reply with @ref sd_ble_gap_conn_param_update. \n See @ref ble_gap_evt_conn_param_update_request_t. */
  123. BLE_GAP_EVT_SCAN_REQ_REPORT = BLE_GAP_EVT_BASE + 16, /**< Scan request report. \n See @ref ble_gap_evt_scan_req_report_t. */
  124. 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. */
  125. BLE_GAP_EVT_PHY_UPDATE = BLE_GAP_EVT_BASE + 18, /**< PHY Update Procedure is complete. \n See @ref ble_gap_evt_phy_update_t. */
  126. BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST = BLE_GAP_EVT_BASE + 19, /**< Data Length Update Request. \n Reply with @ref sd_ble_gap_data_length_update.\n See @ref ble_gap_evt_data_length_update_request_t. */
  127. BLE_GAP_EVT_DATA_LENGTH_UPDATE = BLE_GAP_EVT_BASE + 20, /**< LL Data Channel PDU payload length updated. \n See @ref ble_gap_evt_data_length_update_t. */
  128. BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT = BLE_GAP_EVT_BASE + 21, /**< Channel survey report. \n See @ref ble_gap_evt_qos_channel_survey_report_t. */
  129. BLE_GAP_EVT_ADV_SET_TERMINATED = BLE_GAP_EVT_BASE + 22, /**< Advertising set terminated. \n See @ref ble_gap_evt_adv_set_terminated_t. */
  130. };
  131. /**@brief GAP Option IDs.
  132. * IDs that uniquely identify a GAP option.
  133. */
  134. enum BLE_GAP_OPTS
  135. {
  136. BLE_GAP_OPT_CH_MAP = BLE_GAP_OPT_BASE, /**< Channel Map. @ref ble_gap_opt_ch_map_t */
  137. BLE_GAP_OPT_LOCAL_CONN_LATENCY = BLE_GAP_OPT_BASE + 1, /**< Local connection latency. @ref ble_gap_opt_local_conn_latency_t */
  138. BLE_GAP_OPT_PASSKEY = BLE_GAP_OPT_BASE + 2, /**< Set passkey. @ref ble_gap_opt_passkey_t */
  139. BLE_GAP_OPT_COMPAT_MODE_1 = BLE_GAP_OPT_BASE + 3, /**< Compatibility mode. @ref ble_gap_opt_compat_mode_1_t */
  140. BLE_GAP_OPT_AUTH_PAYLOAD_TIMEOUT = BLE_GAP_OPT_BASE + 4, /**< Set Authenticated payload timeout. @ref ble_gap_opt_auth_payload_timeout_t */
  141. BLE_GAP_OPT_SLAVE_LATENCY_DISABLE = BLE_GAP_OPT_BASE + 5, /**< Disable slave latency. @ref ble_gap_opt_slave_latency_disable_t */
  142. };
  143. /**@brief GAP Configuration IDs.
  144. *
  145. * IDs that uniquely identify a GAP configuration.
  146. */
  147. enum BLE_GAP_CFGS
  148. {
  149. BLE_GAP_CFG_ROLE_COUNT = BLE_GAP_CFG_BASE, /**< Role count configuration. */
  150. BLE_GAP_CFG_DEVICE_NAME = BLE_GAP_CFG_BASE + 1, /**< Device name configuration. */
  151. };
  152. /**@brief GAP TX Power roles.
  153. */
  154. enum BLE_GAP_TX_POWER_ROLES
  155. {
  156. BLE_GAP_TX_POWER_ROLE_ADV = 1, /**< Advertiser role. */
  157. BLE_GAP_TX_POWER_ROLE_SCAN_INIT = 2, /**< Scanner and initiator role. */
  158. BLE_GAP_TX_POWER_ROLE_CONN = 3, /**< Connection role. */
  159. };
  160. /** @} */
  161. /**@addtogroup BLE_GAP_DEFINES Defines
  162. * @{ */
  163. /**@defgroup BLE_ERRORS_GAP SVC return values specific to GAP
  164. * @{ */
  165. #define BLE_ERROR_GAP_UUID_LIST_MISMATCH (NRF_GAP_ERR_BASE + 0x000) /**< UUID list does not contain an integral number of UUIDs. */
  166. #define BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST (NRF_GAP_ERR_BASE + 0x001) /**< Use of Whitelist not permitted with discoverable advertising. */
  167. #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. */
  168. #define BLE_ERROR_GAP_WHITELIST_IN_USE (NRF_GAP_ERR_BASE + 0x003) /**< Attempt to modify the whitelist while already in use by another operation. */
  169. #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. */
  170. #define BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE (NRF_GAP_ERR_BASE + 0x005) /**< The device identity list contains entries with duplicate identity addresses. */
  171. /**@} */
  172. /**@defgroup BLE_GAP_ROLES GAP Roles
  173. * @{ */
  174. #define BLE_GAP_ROLE_INVALID 0x0 /**< Invalid Role. */
  175. #define BLE_GAP_ROLE_PERIPH 0x1 /**< Peripheral Role. */
  176. #define BLE_GAP_ROLE_CENTRAL 0x2 /**< Central Role. */
  177. /**@} */
  178. /**@defgroup BLE_GAP_TIMEOUT_SOURCES GAP Timeout sources
  179. * @{ */
  180. #define BLE_GAP_TIMEOUT_SRC_SCAN 0x01 /**< Scanning timeout. */
  181. #define BLE_GAP_TIMEOUT_SRC_CONN 0x02 /**< Connection timeout. */
  182. #define BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD 0x03 /**< Authenticated payload timeout. */
  183. /**@} */
  184. /**@defgroup BLE_GAP_ADDR_TYPES GAP Address types
  185. * @{ */
  186. #define BLE_GAP_ADDR_TYPE_PUBLIC 0x00 /**< Public (identity) address.*/
  187. #define BLE_GAP_ADDR_TYPE_RANDOM_STATIC 0x01 /**< Random static (identity) address. */
  188. #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE 0x02 /**< Random private resolvable address. */
  189. #define BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_NON_RESOLVABLE 0x03 /**< Random private non-resolvable address. */
  190. #define BLE_GAP_ADDR_TYPE_ANONYMOUS 0x7F /**< An advertiser may advertise without its address.
  191. This type of advertising is called anonymous. */
  192. /**@} */
  193. /**@brief The default interval in seconds at which a private address is refreshed. */
  194. #define BLE_GAP_DEFAULT_PRIVATE_ADDR_CYCLE_INTERVAL_S (900) /* 15 minutes. */
  195. /**@brief The maximum interval in seconds at which a private address can be refreshed. */
  196. #define BLE_GAP_MAX_PRIVATE_ADDR_CYCLE_INTERVAL_S (41400) /* 11 hours 30 minutes. */
  197. /** @brief BLE address length. */
  198. #define BLE_GAP_ADDR_LEN (6)
  199. /**@defgroup BLE_GAP_PRIVACY_MODES Privacy modes
  200. * @{ */
  201. #define BLE_GAP_PRIVACY_MODE_OFF 0x00 /**< Device will send and accept its identity address for its own address. */
  202. #define BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY 0x01 /**< Device will send and accept only private addresses for its own address. */
  203. #define BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY 0x02 /**< Device will send and accept only private addresses for its own address,
  204. and will not accept a peer using identity address as sender address when
  205. the peer IRK is exchanged, non-zero and added to the identity list. */
  206. /**@} */
  207. /** @brief Invalid power level. */
  208. #define BLE_GAP_POWER_LEVEL_INVALID 127
  209. /** @brief Advertising set handle not set. */
  210. #define BLE_GAP_ADV_SET_HANDLE_NOT_SET (0xFF)
  211. /** @brief The default number of advertising sets. */
  212. #define BLE_GAP_ADV_SET_COUNT_DEFAULT (1)
  213. /** @brief The maximum number of advertising sets supported by this SoftDevice. */
  214. #define BLE_GAP_ADV_SET_COUNT_MAX (1)
  215. /**@defgroup BLE_GAP_ADV_SET_DATA_SIZES Advertising data sizes.
  216. * @{ */
  217. #define BLE_GAP_ADV_SET_DATA_SIZE_MAX (31) /**< Maximum data length for an advertising set.
  218. If more advertising data is required, use extended advertising instead. */
  219. #define BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED (255) /**< Maximum supported data length for an extended advertising set. */
  220. #define BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_CONNECTABLE_MAX_SUPPORTED (238) /**< Maximum supported data length for an extended connectable advertising set. */
  221. /**@}. */
  222. /** @brief Set ID not available in advertising report. */
  223. #define BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE 0xFF
  224. /**@defgroup BLE_GAP_EVT_ADV_SET_TERMINATED_REASON GAP Advertising Set Terminated reasons
  225. * @{ */
  226. #define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_TIMEOUT 0x01 /**< Timeout value reached. */
  227. #define BLE_GAP_EVT_ADV_SET_TERMINATED_REASON_LIMIT_REACHED 0x02 /**< @ref ble_gap_adv_params_t::max_adv_evts was reached. */
  228. /**@} */
  229. /**@defgroup BLE_GAP_AD_TYPE_DEFINITIONS GAP Advertising and Scan Response Data format
  230. * @note Found at https://www.bluetooth.org/Technical/AssignedNumbers/generic_access_profile.htm
  231. * @{ */
  232. #define BLE_GAP_AD_TYPE_FLAGS 0x01 /**< Flags for discoverability. */
  233. #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_MORE_AVAILABLE 0x02 /**< Partial list of 16 bit service UUIDs. */
  234. #define BLE_GAP_AD_TYPE_16BIT_SERVICE_UUID_COMPLETE 0x03 /**< Complete list of 16 bit service UUIDs. */
  235. #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_MORE_AVAILABLE 0x04 /**< Partial list of 32 bit service UUIDs. */
  236. #define BLE_GAP_AD_TYPE_32BIT_SERVICE_UUID_COMPLETE 0x05 /**< Complete list of 32 bit service UUIDs. */
  237. #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_MORE_AVAILABLE 0x06 /**< Partial list of 128 bit service UUIDs. */
  238. #define BLE_GAP_AD_TYPE_128BIT_SERVICE_UUID_COMPLETE 0x07 /**< Complete list of 128 bit service UUIDs. */
  239. #define BLE_GAP_AD_TYPE_SHORT_LOCAL_NAME 0x08 /**< Short local device name. */
  240. #define BLE_GAP_AD_TYPE_COMPLETE_LOCAL_NAME 0x09 /**< Complete local device name. */
  241. #define BLE_GAP_AD_TYPE_TX_POWER_LEVEL 0x0A /**< Transmit power level. */
  242. #define BLE_GAP_AD_TYPE_CLASS_OF_DEVICE 0x0D /**< Class of device. */
  243. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C 0x0E /**< Simple Pairing Hash C. */
  244. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R 0x0F /**< Simple Pairing Randomizer R. */
  245. #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_TK_VALUE 0x10 /**< Security Manager TK Value. */
  246. #define BLE_GAP_AD_TYPE_SECURITY_MANAGER_OOB_FLAGS 0x11 /**< Security Manager Out Of Band Flags. */
  247. #define BLE_GAP_AD_TYPE_SLAVE_CONNECTION_INTERVAL_RANGE 0x12 /**< Slave Connection Interval Range. */
  248. #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_16BIT 0x14 /**< List of 16-bit Service Solicitation UUIDs. */
  249. #define BLE_GAP_AD_TYPE_SOLICITED_SERVICE_UUIDS_128BIT 0x15 /**< List of 128-bit Service Solicitation UUIDs. */
  250. #define BLE_GAP_AD_TYPE_SERVICE_DATA 0x16 /**< Service Data - 16-bit UUID. */
  251. #define BLE_GAP_AD_TYPE_PUBLIC_TARGET_ADDRESS 0x17 /**< Public Target Address. */
  252. #define BLE_GAP_AD_TYPE_RANDOM_TARGET_ADDRESS 0x18 /**< Random Target Address. */
  253. #define BLE_GAP_AD_TYPE_APPEARANCE 0x19 /**< Appearance. */
  254. #define BLE_GAP_AD_TYPE_ADVERTISING_INTERVAL 0x1A /**< Advertising Interval. */
  255. #define BLE_GAP_AD_TYPE_LE_BLUETOOTH_DEVICE_ADDRESS 0x1B /**< LE Bluetooth Device Address. */
  256. #define BLE_GAP_AD_TYPE_LE_ROLE 0x1C /**< LE Role. */
  257. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_HASH_C256 0x1D /**< Simple Pairing Hash C-256. */
  258. #define BLE_GAP_AD_TYPE_SIMPLE_PAIRING_RANDOMIZER_R256 0x1E /**< Simple Pairing Randomizer R-256. */
  259. #define BLE_GAP_AD_TYPE_SERVICE_DATA_32BIT_UUID 0x20 /**< Service Data - 32-bit UUID. */
  260. #define BLE_GAP_AD_TYPE_SERVICE_DATA_128BIT_UUID 0x21 /**< Service Data - 128-bit UUID. */
  261. #define BLE_GAP_AD_TYPE_LESC_CONFIRMATION_VALUE 0x22 /**< LE Secure Connections Confirmation Value */
  262. #define BLE_GAP_AD_TYPE_LESC_RANDOM_VALUE 0x23 /**< LE Secure Connections Random Value */
  263. #define BLE_GAP_AD_TYPE_URI 0x24 /**< URI */
  264. #define BLE_GAP_AD_TYPE_3D_INFORMATION_DATA 0x3D /**< 3D Information Data. */
  265. #define BLE_GAP_AD_TYPE_MANUFACTURER_SPECIFIC_DATA 0xFF /**< Manufacturer Specific Data. */
  266. /**@} */
  267. /**@defgroup BLE_GAP_ADV_FLAGS GAP Advertisement Flags
  268. * @{ */
  269. #define BLE_GAP_ADV_FLAG_LE_LIMITED_DISC_MODE (0x01) /**< LE Limited Discoverable Mode. */
  270. #define BLE_GAP_ADV_FLAG_LE_GENERAL_DISC_MODE (0x02) /**< LE General Discoverable Mode. */
  271. #define BLE_GAP_ADV_FLAG_BR_EDR_NOT_SUPPORTED (0x04) /**< BR/EDR not supported. */
  272. #define BLE_GAP_ADV_FLAG_LE_BR_EDR_CONTROLLER (0x08) /**< Simultaneous LE and BR/EDR, Controller. */
  273. #define BLE_GAP_ADV_FLAG_LE_BR_EDR_HOST (0x10) /**< Simultaneous LE and BR/EDR, Host. */
  274. #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. */
  275. #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. */
  276. /**@} */
  277. /**@defgroup BLE_GAP_ADV_INTERVALS GAP Advertising interval max and min
  278. * @{ */
  279. #define BLE_GAP_ADV_INTERVAL_MIN 0x000020 /**< Minimum Advertising interval in 625 us units, i.e. 20 ms. */
  280. #define BLE_GAP_ADV_INTERVAL_MAX 0x004000 /**< Maximum Advertising interval in 625 us units, i.e. 10.24 s. */
  281. /**@} */
  282. /**@defgroup BLE_GAP_SCAN_INTERVALS GAP Scan interval max and min
  283. * @{ */
  284. #define BLE_GAP_SCAN_INTERVAL_MIN 0x0004 /**< Minimum Scan interval in 625 us units, i.e. 2.5 ms. */
  285. #define BLE_GAP_SCAN_INTERVAL_MAX 0xFFFF /**< Maximum Scan interval in 625 us units, i.e. 40,959.375 s. */
  286. /** @} */
  287. /**@defgroup BLE_GAP_SCAN_WINDOW GAP Scan window max and min
  288. * @{ */
  289. #define BLE_GAP_SCAN_WINDOW_MIN 0x0004 /**< Minimum Scan window in 625 us units, i.e. 2.5 ms. */
  290. #define BLE_GAP_SCAN_WINDOW_MAX 0xFFFF /**< Maximum Scan window in 625 us units, i.e. 40,959.375 s. */
  291. /** @} */
  292. /**@defgroup BLE_GAP_SCAN_TIMEOUT GAP Scan timeout max and min
  293. * @{ */
  294. #define BLE_GAP_SCAN_TIMEOUT_MIN 0x0001 /**< Minimum Scan timeout in 10 ms units, i.e 10 ms. */
  295. #define BLE_GAP_SCAN_TIMEOUT_UNLIMITED 0x0000 /**< Continue to scan forever. */
  296. /** @} */
  297. /**@defgroup BLE_GAP_SCAN_BUFFER_SIZE GAP Minimum scanner buffer size
  298. *
  299. * Scan buffers are used for storing advertising data received from an advertiser.
  300. * If ble_gap_scan_params_t::extended is set to 0, @ref BLE_GAP_SCAN_BUFFER_MIN is the minimum scan buffer length.
  301. * else the minimum scan buffer size is @ref BLE_GAP_SCAN_BUFFER_EXTENDED_MIN.
  302. * @{ */
  303. #define BLE_GAP_SCAN_BUFFER_MIN (31) /**< Minimum data length for an
  304. advertising set. */
  305. #define BLE_GAP_SCAN_BUFFER_MAX (31) /**< Maximum data length for an
  306. advertising set. */
  307. #define BLE_GAP_SCAN_BUFFER_EXTENDED_MIN (255) /**< Minimum data length for an
  308. extended advertising set. */
  309. #define BLE_GAP_SCAN_BUFFER_EXTENDED_MAX (1650) /**< Maximum data length for an
  310. extended advertising set. */
  311. #define BLE_GAP_SCAN_BUFFER_EXTENDED_MAX_SUPPORTED (255) /**< Maximum supported data length for
  312. an extended advertising set. */
  313. /** @} */
  314. /**@defgroup BLE_GAP_ADV_TYPES GAP Advertising types
  315. *
  316. * Advertising types defined in Bluetooth Core Specification v5.0, Vol 6, Part B, Section 4.4.2.
  317. *
  318. * The maximum advertising data length is defined by @ref BLE_GAP_ADV_SET_DATA_SIZE_MAX.
  319. * The maximum supported data length for an extended advertiser is defined by
  320. * @ref BLE_GAP_ADV_SET_DATA_SIZE_EXTENDED_MAX_SUPPORTED
  321. * Note that some of the advertising types do not support advertising data. Non-scannable types do not support
  322. * scan response data.
  323. *
  324. * @{ */
  325. #define BLE_GAP_ADV_TYPE_CONNECTABLE_SCANNABLE_UNDIRECTED 0x01 /**< Connectable and scannable undirected
  326. advertising events. */
  327. #define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE 0x02 /**< Connectable non-scannable directed advertising
  328. events. Advertising interval is less that 3.75 ms.
  329. Use this type for fast reconnections.
  330. @note Advertising data is not supported. */
  331. #define BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED 0x03 /**< Connectable non-scannable directed advertising
  332. events.
  333. @note Advertising data is not supported. */
  334. #define BLE_GAP_ADV_TYPE_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x04 /**< Non-connectable scannable undirected
  335. advertising events. */
  336. #define BLE_GAP_ADV_TYPE_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x05 /**< Non-connectable non-scannable undirected
  337. advertising events. */
  338. #define BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_UNDIRECTED 0x06 /**< Connectable non-scannable undirected advertising
  339. events using extended advertising PDUs. */
  340. #define BLE_GAP_ADV_TYPE_EXTENDED_CONNECTABLE_NONSCANNABLE_DIRECTED 0x07 /**< Connectable non-scannable directed advertising
  341. events using extended advertising PDUs. */
  342. #define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_UNDIRECTED 0x08 /**< Non-connectable scannable undirected advertising
  343. events using extended advertising PDUs.
  344. @note Only scan response data is supported. */
  345. #define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_SCANNABLE_DIRECTED 0x09 /**< Non-connectable scannable directed advertising
  346. events using extended advertising PDUs.
  347. @note Only scan response data is supported. */
  348. #define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED 0x0A /**< Non-connectable non-scannable undirected advertising
  349. events using extended advertising PDUs. */
  350. #define BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_DIRECTED 0x0B /**< Non-connectable non-scannable directed advertising
  351. events using extended advertising PDUs. */
  352. /**@} */
  353. /**@defgroup BLE_GAP_ADV_FILTER_POLICIES GAP Advertising filter policies
  354. * @{ */
  355. #define BLE_GAP_ADV_FP_ANY 0x00 /**< Allow scan requests and connect requests from any device. */
  356. #define BLE_GAP_ADV_FP_FILTER_SCANREQ 0x01 /**< Filter scan requests with whitelist. */
  357. #define BLE_GAP_ADV_FP_FILTER_CONNREQ 0x02 /**< Filter connect requests with whitelist. */
  358. #define BLE_GAP_ADV_FP_FILTER_BOTH 0x03 /**< Filter both scan and connect requests with whitelist. */
  359. /**@} */
  360. /**@defgroup BLE_GAP_ADV_DATA_STATUS GAP Advertising data status
  361. * @{ */
  362. #define BLE_GAP_ADV_DATA_STATUS_COMPLETE 0x00 /**< All data in the advertising event have been received. */
  363. #define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA 0x01 /**< More data to be received.
  364. @note This value will only be used if
  365. @ref ble_gap_scan_params_t::report_incomplete_evts and
  366. @ref ble_gap_adv_report_type_t::extended_pdu are set to true. */
  367. #define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_TRUNCATED 0x02 /**< Incomplete data. Buffer size insufficient to receive more.
  368. @note This value will only be used if
  369. @ref ble_gap_adv_report_type_t::extended_pdu is set to true. */
  370. #define BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MISSED 0x03 /**< Failed to receive the remaining data.
  371. @note This value will only be used if
  372. @ref ble_gap_adv_report_type_t::extended_pdu is set to true. */
  373. /**@} */
  374. /**@defgroup BLE_GAP_SCAN_FILTER_POLICIES GAP Scanner filter policies
  375. * @{ */
  376. #define BLE_GAP_SCAN_FP_ACCEPT_ALL 0x00 /**< Accept all advertising packets except directed advertising packets
  377. not addressed to this device. */
  378. #define BLE_GAP_SCAN_FP_WHITELIST 0x01 /**< Accept advertising packets from devices in the whitelist except directed
  379. packets not addressed to this device. */
  380. #define BLE_GAP_SCAN_FP_ALL_NOT_RESOLVED_DIRECTED 0x02 /**< Accept all advertising packets specified in @ref BLE_GAP_SCAN_FP_ACCEPT_ALL.
  381. In addition, accept directed advertising packets, where the advertiser's
  382. address is a resolvable private address that cannot be resolved. */
  383. #define BLE_GAP_SCAN_FP_WHITELIST_NOT_RESOLVED_DIRECTED 0x03 /**< Accept all advertising packets specified in @ref BLE_GAP_SCAN_FP_WHITELIST.
  384. In addition, accept directed advertising packets, where the advertiser's
  385. address is a resolvable private address that cannot be resolved. */
  386. /**@} */
  387. /**@defgroup BLE_GAP_ADV_TIMEOUT_VALUES GAP Advertising timeout values in 10 ms units
  388. * @{ */
  389. #define BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX (128) /**< Maximum high duty advertising time in 10 ms units. Corresponds to 1.28 s. */
  390. #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. */
  391. #define BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED (0) /**< Unlimited advertising in general discoverable mode.
  392. For high duty cycle advertising, this corresponds to @ref BLE_GAP_ADV_TIMEOUT_HIGH_DUTY_MAX. */
  393. /**@} */
  394. /**@defgroup BLE_GAP_DISC_MODES GAP Discovery modes
  395. * @{ */
  396. #define BLE_GAP_DISC_MODE_NOT_DISCOVERABLE 0x00 /**< Not discoverable discovery Mode. */
  397. #define BLE_GAP_DISC_MODE_LIMITED 0x01 /**< Limited Discovery Mode. */
  398. #define BLE_GAP_DISC_MODE_GENERAL 0x02 /**< General Discovery Mode. */
  399. /**@} */
  400. /**@defgroup BLE_GAP_IO_CAPS GAP IO Capabilities
  401. * @{ */
  402. #define BLE_GAP_IO_CAPS_DISPLAY_ONLY 0x00 /**< Display Only. */
  403. #define BLE_GAP_IO_CAPS_DISPLAY_YESNO 0x01 /**< Display and Yes/No entry. */
  404. #define BLE_GAP_IO_CAPS_KEYBOARD_ONLY 0x02 /**< Keyboard Only. */
  405. #define BLE_GAP_IO_CAPS_NONE 0x03 /**< No I/O capabilities. */
  406. #define BLE_GAP_IO_CAPS_KEYBOARD_DISPLAY 0x04 /**< Keyboard and Display. */
  407. /**@} */
  408. /**@defgroup BLE_GAP_AUTH_KEY_TYPES GAP Authentication Key Types
  409. * @{ */
  410. #define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00 /**< No key (may be used to reject). */
  411. #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01 /**< 6-digit Passkey. */
  412. #define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02 /**< Out Of Band data. */
  413. /**@} */
  414. /**@defgroup BLE_GAP_KP_NOT_TYPES GAP Keypress Notification Types
  415. * @{ */
  416. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_START 0x00 /**< Passkey entry started. */
  417. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_IN 0x01 /**< Passkey digit entered. */
  418. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_DIGIT_OUT 0x02 /**< Passkey digit erased. */
  419. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_CLEAR 0x03 /**< Passkey cleared. */
  420. #define BLE_GAP_KP_NOT_TYPE_PASSKEY_END 0x04 /**< Passkey entry completed. */
  421. /**@} */
  422. /**@defgroup BLE_GAP_SEC_STATUS GAP Security status
  423. * @{ */
  424. #define BLE_GAP_SEC_STATUS_SUCCESS 0x00 /**< Procedure completed with success. */
  425. #define BLE_GAP_SEC_STATUS_TIMEOUT 0x01 /**< Procedure timed out. */
  426. #define BLE_GAP_SEC_STATUS_PDU_INVALID 0x02 /**< Invalid PDU received. */
  427. #define BLE_GAP_SEC_STATUS_RFU_RANGE1_BEGIN 0x03 /**< Reserved for Future Use range #1 begin. */
  428. #define BLE_GAP_SEC_STATUS_RFU_RANGE1_END 0x80 /**< Reserved for Future Use range #1 end. */
  429. #define BLE_GAP_SEC_STATUS_PASSKEY_ENTRY_FAILED 0x81 /**< Passkey entry failed (user canceled or other). */
  430. #define BLE_GAP_SEC_STATUS_OOB_NOT_AVAILABLE 0x82 /**< Out of Band Key not available. */
  431. #define BLE_GAP_SEC_STATUS_AUTH_REQ 0x83 /**< Authentication requirements not met. */
  432. #define BLE_GAP_SEC_STATUS_CONFIRM_VALUE 0x84 /**< Confirm value failed. */
  433. #define BLE_GAP_SEC_STATUS_PAIRING_NOT_SUPP 0x85 /**< Pairing not supported. */
  434. #define BLE_GAP_SEC_STATUS_ENC_KEY_SIZE 0x86 /**< Encryption key size. */
  435. #define BLE_GAP_SEC_STATUS_SMP_CMD_UNSUPPORTED 0x87 /**< Unsupported SMP command. */
  436. #define BLE_GAP_SEC_STATUS_UNSPECIFIED 0x88 /**< Unspecified reason. */
  437. #define BLE_GAP_SEC_STATUS_REPEATED_ATTEMPTS 0x89 /**< Too little time elapsed since last attempt. */
  438. #define BLE_GAP_SEC_STATUS_INVALID_PARAMS 0x8A /**< Invalid parameters. */
  439. #define BLE_GAP_SEC_STATUS_DHKEY_FAILURE 0x8B /**< DHKey check failure. */
  440. #define BLE_GAP_SEC_STATUS_NUM_COMP_FAILURE 0x8C /**< Numeric Comparison failure. */
  441. #define BLE_GAP_SEC_STATUS_BR_EDR_IN_PROG 0x8D /**< BR/EDR pairing in progress. */
  442. #define BLE_GAP_SEC_STATUS_X_TRANS_KEY_DISALLOWED 0x8E /**< BR/EDR Link Key cannot be used for LE keys. */
  443. #define BLE_GAP_SEC_STATUS_RFU_RANGE2_BEGIN 0x8F /**< Reserved for Future Use range #2 begin. */
  444. #define BLE_GAP_SEC_STATUS_RFU_RANGE2_END 0xFF /**< Reserved for Future Use range #2 end. */
  445. /**@} */
  446. /**@defgroup BLE_GAP_SEC_STATUS_SOURCES GAP Security status sources
  447. * @{ */
  448. #define BLE_GAP_SEC_STATUS_SOURCE_LOCAL 0x00 /**< Local failure. */
  449. #define BLE_GAP_SEC_STATUS_SOURCE_REMOTE 0x01 /**< Remote failure. */
  450. /**@} */
  451. /**@defgroup BLE_GAP_CP_LIMITS GAP Connection Parameters Limits
  452. * @{ */
  453. #define BLE_GAP_CP_MIN_CONN_INTVL_NONE 0xFFFF /**< No new minimum connection interval specified in connect parameters. */
  454. #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. */
  455. #define BLE_GAP_CP_MIN_CONN_INTVL_MAX 0x0C80 /**< Highest minimum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
  456. #define BLE_GAP_CP_MAX_CONN_INTVL_NONE 0xFFFF /**< No new maximum connection interval specified in connect parameters. */
  457. #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. */
  458. #define BLE_GAP_CP_MAX_CONN_INTVL_MAX 0x0C80 /**< Highest maximum connection interval permitted, in units of 1.25 ms, i.e. 4 s. */
  459. #define BLE_GAP_CP_SLAVE_LATENCY_MAX 0x01F3 /**< Highest slave latency permitted, in connection events. */
  460. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_NONE 0xFFFF /**< No new supervision timeout specified in connect parameters. */
  461. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MIN 0x000A /**< Lowest supervision timeout permitted, in units of 10 ms, i.e. 100 ms. */
  462. #define BLE_GAP_CP_CONN_SUP_TIMEOUT_MAX 0x0C80 /**< Highest supervision timeout permitted, in units of 10 ms, i.e. 32 s. */
  463. /**@} */
  464. /**@defgroup BLE_GAP_DEVNAME GAP device name defines.
  465. * @{ */
  466. #define BLE_GAP_DEVNAME_DEFAULT "nRF5x" /**< Default device name value. */
  467. #define BLE_GAP_DEVNAME_DEFAULT_LEN 31 /**< Default number of octets in device name. */
  468. #define BLE_GAP_DEVNAME_MAX_LEN 248 /**< Maximum number of octets in device name. */
  469. /**@} */
  470. /**@brief Disable RSSI events for connections */
  471. #define BLE_GAP_RSSI_THRESHOLD_INVALID 0xFF
  472. /**@defgroup BLE_GAP_PHYS GAP PHYs
  473. * @{ */
  474. #define BLE_GAP_PHY_AUTO 0x00 /**< Automatic PHY selection. Refer @ref sd_ble_gap_phy_update for more information.*/
  475. #define BLE_GAP_PHY_1MBPS 0x01 /**< 1 Mbps PHY. */
  476. #define BLE_GAP_PHY_2MBPS 0x02 /**< 2 Mbps PHY. */
  477. #define BLE_GAP_PHY_CODED 0x04 /**< Coded PHY. */
  478. #define BLE_GAP_PHY_NOT_SET 0xFF /**< PHY is not configured. */
  479. /**@brief Supported PHYs in connections, for scanning, and for advertising. */
  480. #define BLE_GAP_PHYS_SUPPORTED (BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS | BLE_GAP_PHY_CODED) /**< All PHYs are supported. */
  481. /**@} */
  482. /**@defgroup BLE_GAP_CONN_SEC_MODE_SET_MACROS GAP attribute security requirement setters
  483. *
  484. * See @ref ble_gap_conn_sec_mode_t.
  485. * @{ */
  486. /**@brief Set sec_mode pointed to by ptr to have no access rights.*/
  487. #define BLE_GAP_CONN_SEC_MODE_SET_NO_ACCESS(ptr) do {(ptr)->sm = 0; (ptr)->lv = 0;} while(0)
  488. /**@brief Set sec_mode pointed to by ptr to require no protection, open link.*/
  489. #define BLE_GAP_CONN_SEC_MODE_SET_OPEN(ptr) do {(ptr)->sm = 1; (ptr)->lv = 1;} while(0)
  490. /**@brief Set sec_mode pointed to by ptr to require encryption, but no MITM protection.*/
  491. #define BLE_GAP_CONN_SEC_MODE_SET_ENC_NO_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 2;} while(0)
  492. /**@brief Set sec_mode pointed to by ptr to require encryption and MITM protection.*/
  493. #define BLE_GAP_CONN_SEC_MODE_SET_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 3;} while(0)
  494. /**@brief Set sec_mode pointed to by ptr to require LESC encryption and MITM protection.*/
  495. #define BLE_GAP_CONN_SEC_MODE_SET_LESC_ENC_WITH_MITM(ptr) do {(ptr)->sm = 1; (ptr)->lv = 4;} while(0)
  496. /**@brief Set sec_mode pointed to by ptr to require signing or encryption, no MITM protection needed.*/
  497. #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_NO_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 1;} while(0)
  498. /**@brief Set sec_mode pointed to by ptr to require signing or encryption with MITM protection.*/
  499. #define BLE_GAP_CONN_SEC_MODE_SET_SIGNED_WITH_MITM(ptr) do {(ptr)->sm = 2; (ptr)->lv = 2;} while(0)
  500. /**@} */
  501. /**@brief GAP Security Random Number Length. */
  502. #define BLE_GAP_SEC_RAND_LEN 8
  503. /**@brief GAP Security Key Length. */
  504. #define BLE_GAP_SEC_KEY_LEN 16
  505. /**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman P-256 Public Key Length. */
  506. #define BLE_GAP_LESC_P256_PK_LEN 64
  507. /**@brief GAP LE Secure Connections Elliptic Curve Diffie-Hellman DHKey Length. */
  508. #define BLE_GAP_LESC_DHKEY_LEN 32
  509. /**@brief GAP Passkey Length. */
  510. #define BLE_GAP_PASSKEY_LEN 6
  511. /**@brief Maximum amount of addresses in the whitelist. */
  512. #define BLE_GAP_WHITELIST_ADDR_MAX_COUNT (8)
  513. /**@brief Maximum amount of identities in the device identities list. */
  514. #define BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT (8)
  515. /**@brief Default connection count for a configuration. */
  516. #define BLE_GAP_CONN_COUNT_DEFAULT (1)
  517. /**@defgroup BLE_GAP_EVENT_LENGTH GAP event length defines.
  518. * @{ */
  519. #define BLE_GAP_EVENT_LENGTH_MIN (2) /**< Minimum event length, in 1.25 ms units. */
  520. #define BLE_GAP_EVENT_LENGTH_CODED_PHY_MIN (6) /**< The shortest event length in 1.25 ms units supporting LE Coded PHY. */
  521. #define BLE_GAP_EVENT_LENGTH_DEFAULT (3) /**< Default event length, in 1.25 ms units. */
  522. /**@} */
  523. /**@defgroup BLE_GAP_ROLE_COUNT GAP concurrent connection count defines.
  524. * @{ */
  525. #define BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT (1) /**< Default maximum number of connections concurrently acting as peripherals. */
  526. #define BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT (3) /**< Default maximum number of connections concurrently acting as centrals. */
  527. #define BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT (1) /**< Default number of SMP instances shared between all connections acting as centrals. */
  528. #define BLE_GAP_ROLE_COUNT_COMBINED_MAX (20) /**< Maximum supported number of concurrent connections in the peripheral and central roles combined. */
  529. /**@} */
  530. /**@brief Automatic data length parameter. */
  531. #define BLE_GAP_DATA_LENGTH_AUTO 0
  532. /**@defgroup BLE_GAP_AUTH_PAYLOAD_TIMEOUT Authenticated payload timeout defines.
  533. * @{ */
  534. #define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX (48000) /**< Maximum authenticated payload timeout in 10 ms units, i.e. 8 minutes. */
  535. #define BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MIN (1) /**< Minimum authenticated payload timeout in 10 ms units, i.e. 10 ms. */
  536. /**@} */
  537. /**@defgroup GAP_SEC_MODES GAP Security Modes
  538. * @{ */
  539. #define BLE_GAP_SEC_MODE 0x00 /**< No key (may be used to reject). */
  540. /**@} */
  541. /**@brief The total number of channels in Bluetooth Low Energy. */
  542. #define BLE_GAP_CHANNEL_COUNT (40)
  543. /**@defgroup BLE_GAP_QOS_CHANNEL_SURVEY_INTERVALS Quality of Service (QoS) Channel survey interval defines
  544. * @{ */
  545. #define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_CONTINUOUS (0) /**< Continuous channel survey. */
  546. #define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_MIN_US (7500) /**< Minimum channel survey interval in microseconds (7.5 ms). */
  547. #define BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_MAX_US (4000000) /**< Maximum channel survey interval in microseconds (4 s). */
  548. /**@} */
  549. /** @} */
  550. /**@addtogroup BLE_GAP_STRUCTURES Structures
  551. * @{ */
  552. /**@brief Advertising event properties. */
  553. typedef struct
  554. {
  555. uint8_t type; /**< Advertising type. See @ref BLE_GAP_ADV_TYPES. */
  556. uint8_t anonymous : 1; /**< Omit advertiser's address from all PDUs.
  557. @note Anonymous advertising is only available for
  558. @ref BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_UNDIRECTED and
  559. @ref BLE_GAP_ADV_TYPE_EXTENDED_NONCONNECTABLE_NONSCANNABLE_DIRECTED. */
  560. uint8_t include_tx_power : 1; /**< This feature is not supported on this SoftDevice. */
  561. } ble_gap_adv_properties_t;
  562. /**@brief Advertising report type. */
  563. typedef struct
  564. {
  565. uint16_t connectable : 1; /**< Connectable advertising event type. */
  566. uint16_t scannable : 1; /**< Scannable advertising event type. */
  567. uint16_t directed : 1; /**< Directed advertising event type. */
  568. uint16_t scan_response : 1; /**< Received a scan response. */
  569. uint16_t extended_pdu : 1; /**< Received an extended advertising set. */
  570. uint16_t status : 2; /**< Data status. See @ref BLE_GAP_ADV_DATA_STATUS. */
  571. uint16_t reserved : 9; /**< Reserved for future use. */
  572. } ble_gap_adv_report_type_t;
  573. /**@brief Advertising Auxiliary Pointer. */
  574. typedef struct
  575. {
  576. uint16_t aux_offset; /**< Time offset from the beginning of advertising packet to the auxiliary packet in 100 us units. */
  577. uint8_t aux_phy; /**< Indicates the PHY on which the auxiliary advertising packet is sent. See @ref BLE_GAP_PHYS. */
  578. } ble_gap_aux_pointer_t;
  579. /**@brief Bluetooth Low Energy address. */
  580. typedef struct
  581. {
  582. uint8_t addr_id_peer : 1; /**< Only valid for peer addresses.
  583. This bit is set by the SoftDevice to indicate whether the address has been resolved from
  584. a Resolvable Private Address (when the peer is using privacy).
  585. If set to 1, @ref addr and @ref addr_type refer to the identity address of the resolved address.
  586. This bit is ignored when a variable of type @ref ble_gap_addr_t is used as input to API functions. */
  587. uint8_t addr_type : 7; /**< See @ref BLE_GAP_ADDR_TYPES. */
  588. uint8_t addr[BLE_GAP_ADDR_LEN]; /**< 48-bit address, LSB format.
  589. @ref addr is not used if @ref addr_type is @ref BLE_GAP_ADDR_TYPE_ANONYMOUS. */
  590. } ble_gap_addr_t;
  591. /**@brief GAP connection parameters.
  592. *
  593. * @note When ble_conn_params_t is received in an event, both min_conn_interval and
  594. * max_conn_interval will be equal to the connection interval set by the central.
  595. *
  596. * @note If both conn_sup_timeout and max_conn_interval are specified, then the following constraint applies:
  597. * conn_sup_timeout * 4 > (1 + slave_latency) * max_conn_interval
  598. * that corresponds to the following Bluetooth Spec requirement:
  599. * The Supervision_Timeout in milliseconds shall be larger than
  600. * (1 + Conn_Latency) * Conn_Interval_Max * 2, where Conn_Interval_Max is given in milliseconds.
  601. */
  602. typedef struct
  603. {
  604. uint16_t min_conn_interval; /**< Minimum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  605. uint16_t max_conn_interval; /**< Maximum Connection Interval in 1.25 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  606. uint16_t slave_latency; /**< Slave Latency in number of connection events, see @ref BLE_GAP_CP_LIMITS.*/
  607. uint16_t conn_sup_timeout; /**< Connection Supervision Timeout in 10 ms units, see @ref BLE_GAP_CP_LIMITS.*/
  608. } ble_gap_conn_params_t;
  609. /**@brief GAP connection security modes.
  610. *
  611. * Security Mode 0 Level 0: No access permissions at all (this level is not defined by the Bluetooth Core specification).\n
  612. * Security Mode 1 Level 1: No security is needed (aka open link).\n
  613. * Security Mode 1 Level 2: Encrypted link required, MITM protection not necessary.\n
  614. * Security Mode 1 Level 3: MITM protected encrypted link required.\n
  615. * Security Mode 1 Level 4: LESC MITM protected encrypted link using a 128-bit strength encryption key required.\n
  616. * Security Mode 2 Level 1: Signing or encryption required, MITM protection not necessary.\n
  617. * Security Mode 2 Level 2: MITM protected signing required, unless link is MITM protected encrypted.\n
  618. */
  619. typedef struct
  620. {
  621. uint8_t sm : 4; /**< Security Mode (1 or 2), 0 for no permissions at all. */
  622. uint8_t lv : 4; /**< Level (1, 2, 3 or 4), 0 for no permissions at all. */
  623. } ble_gap_conn_sec_mode_t;
  624. /**@brief GAP connection security status.*/
  625. typedef struct
  626. {
  627. ble_gap_conn_sec_mode_t sec_mode; /**< Currently active security mode for this connection.*/
  628. uint8_t encr_key_size; /**< Length of currently active encryption key, 7 to 16 octets (only applicable for bonding procedures). */
  629. } ble_gap_conn_sec_t;
  630. /**@brief Identity Resolving Key. */
  631. typedef struct
  632. {
  633. uint8_t irk[BLE_GAP_SEC_KEY_LEN]; /**< Array containing IRK. */
  634. } ble_gap_irk_t;
  635. /**@brief Channel mask (40 bits).
  636. * Every channel is represented with a bit positioned as per channel index defined in Bluetooth Core Specification v5.0,
  637. * Vol 6, Part B, Section 1.4.1. The LSB contained in array element 0 represents channel index 0, and bit 39 represents
  638. * channel index 39. If a bit is set to 1, the channel is not used.
  639. */
  640. typedef uint8_t ble_gap_ch_mask_t[5];
  641. /**@brief GAP advertising parameters. */
  642. typedef struct
  643. {
  644. ble_gap_adv_properties_t properties; /**< The properties of the advertising events. */
  645. ble_gap_addr_t const *p_peer_addr; /**< Address of a known peer.
  646. @note ble_gap_addr_t::addr_type cannot be
  647. @ref BLE_GAP_ADDR_TYPE_ANONYMOUS.
  648. - When privacy is enabled and the local device uses
  649. @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE addresses,
  650. the device identity list is searched for a matching entry. If
  651. the local IRK for that device identity is set, the local IRK
  652. for that device will be used to generate the advertiser address
  653. field in the advertising packet.
  654. - If @ref ble_gap_adv_properties_t::type is directed, this must be
  655. set to the targeted scanner or initiator. If the peer address is
  656. in the device identity list, the peer IRK for that device will be
  657. used to generate @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE
  658. target addresses used in the advertising event PDUs. */
  659. uint32_t interval; /**< Advertising interval in 625 us units. @sa BLE_GAP_ADV_INTERVALS.
  660. @note If @ref ble_gap_adv_properties_t::type is set to
  661. @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE
  662. advertising, this parameter is ignored. */
  663. uint16_t duration; /**< Advertising duration in 10 ms units. When timeout is reached,
  664. an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised.
  665. @sa BLE_GAP_ADV_TIMEOUT_VALUES.
  666. @note The SoftDevice will always complete at least one advertising
  667. event even if the duration is set too low. */
  668. uint8_t max_adv_evts; /**< Maximum advertising events that shall be sent prior to disabling
  669. advertising. Setting the value to 0 disables the limitation. When
  670. the count of advertising events specified by this parameter
  671. (if not 0) is reached, advertising will be automatically stopped
  672. and an event of type @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised
  673. @note If @ref ble_gap_adv_properties_t::type is set to
  674. @ref BLE_GAP_ADV_TYPE_CONNECTABLE_NONSCANNABLE_DIRECTED_HIGH_DUTY_CYCLE,
  675. this parameter is ignored. */
  676. ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels.
  677. At least one of the primary channels, that is channel index 37-39, must be used.
  678. Masking away secondary advertising channels is not supported. */
  679. uint8_t filter_policy; /**< Filter Policy. @sa BLE_GAP_ADV_FILTER_POLICIES. */
  680. uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising channel packets
  681. are transmitted. If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS
  682. will be used.
  683. Valid values are @ref BLE_GAP_PHY_1MBPS and @ref BLE_GAP_PHY_CODED.
  684. @note The primary_phy shall indicate @ref BLE_GAP_PHY_1MBPS if
  685. @ref ble_gap_adv_properties_t::type is not an extended advertising type. */
  686. uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising channel packets
  687. are transmitted.
  688. If set to @ref BLE_GAP_PHY_AUTO, @ref BLE_GAP_PHY_1MBPS will be used.
  689. Valid values are
  690. @ref BLE_GAP_PHY_1MBPS, @ref BLE_GAP_PHY_2MBPS, and @ref BLE_GAP_PHY_CODED.
  691. If @ref ble_gap_adv_properties_t::type is an extended advertising type
  692. and connectable, this is the PHY that will be used to establish a
  693. connection and send AUX_ADV_IND packets on.
  694. @note This parameter will be ignored when
  695. @ref ble_gap_adv_properties_t::type is not an extended advertising type. */
  696. uint8_t set_id:4; /**< The advertising set identifier distinguishes this advertising set from other
  697. advertising sets transmitted by this and other devices.
  698. @note This parameter will be ignored when
  699. @ref ble_gap_adv_properties_t::type is not an extended advertising type. */
  700. uint8_t scan_req_notification:1; /**< Enable scan request notifications for this advertising set. When a
  701. scan request is received and the scanner address is allowed
  702. by the filter policy, @ref BLE_GAP_EVT_SCAN_REQ_REPORT is raised.
  703. @note This parameter will be ignored when
  704. @ref ble_gap_adv_properties_t::type is a non-scannable
  705. advertising type. */
  706. } ble_gap_adv_params_t;
  707. /**@brief GAP advertising data buffers.
  708. *
  709. * The application must provide the buffers for advertisement. The memory shall reside in application RAM, and
  710. * shall never be modified while advertising. The data shall be kept alive until either:
  711. * - @ref BLE_GAP_EVT_ADV_SET_TERMINATED is raised.
  712. * - @ref BLE_GAP_EVT_CONNECTED is raised with @ref ble_gap_evt_connected_t::adv_handle set to the corresponding
  713. * advertising handle.
  714. * - Advertising is stopped.
  715. * - Advertising data is changed.
  716. * To update advertising data while advertising, provide new buffers to @ref sd_ble_gap_adv_set_configure. */
  717. typedef struct
  718. {
  719. ble_data_t adv_data; /**< Advertising data.
  720. @note
  721. Advertising data can only be specified for a @ref ble_gap_adv_properties_t::type
  722. that is allowed to contain advertising data. */
  723. ble_data_t scan_rsp_data; /**< Scan response data.
  724. @note
  725. Scan response data can only be specified for a @ref ble_gap_adv_properties_t::type
  726. that is scannable. */
  727. } ble_gap_adv_data_t;
  728. /**@brief GAP scanning parameters. */
  729. typedef struct
  730. {
  731. uint8_t extended : 1; /**< If 1, the scanner will accept extended advertising packets.
  732. If set to 0, the scanner will not receive advertising packets
  733. on secondary advertising channels, and will not be able
  734. to receive long advertising PDUs. */
  735. uint8_t report_incomplete_evts : 1; /**< If 1, events of type @ref ble_gap_evt_adv_report_t may have
  736. @ref ble_gap_adv_report_type_t::status set to
  737. @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA.
  738. This parameter is ignored when used with @ref sd_ble_gap_connect
  739. @note This may be used to abort receiving more packets from an extended
  740. advertising event, and is only available for extended
  741. scanning, see @ref sd_ble_gap_scan_start.
  742. @note This feature is not supported by this SoftDevice. */
  743. uint8_t active : 1; /**< If 1, perform active scanning by sending scan requests.
  744. This parameter is ignored when used with @ref sd_ble_gap_connect. */
  745. uint8_t filter_policy : 2; /**< Scanning filter policy. @sa BLE_GAP_SCAN_FILTER_POLICIES.
  746. @note Only @ref BLE_GAP_SCAN_FP_ACCEPT_ALL and
  747. @ref BLE_GAP_SCAN_FP_WHITELIST are valid when used with
  748. @ref sd_ble_gap_connect */
  749. uint8_t scan_phys; /**< Bitfield of PHYs to scan on. If set to @ref BLE_GAP_PHY_AUTO,
  750. scan_phys will default to @ref BLE_GAP_PHY_1MBPS.
  751. - If @ref ble_gap_scan_params_t::extended is set to 0, the only
  752. supported PHY is @ref BLE_GAP_PHY_1MBPS.
  753. - When used with @ref sd_ble_gap_scan_start,
  754. the bitfield indicates the PHYs the scanner will use for scanning
  755. on primary advertising channels. The scanner will accept
  756. @ref BLE_GAP_PHYS_SUPPORTED as secondary advertising channel PHYs.
  757. - When used with @ref sd_ble_gap_connect, the bitfield indicates
  758. the PHYs the initiator will use for scanning on primary advertising
  759. channels. The initiator will accept connections initiated on either
  760. of the @ref BLE_GAP_PHYS_SUPPORTED PHYs.
  761. If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS,
  762. the primary scan PHY is @ref BLE_GAP_PHY_1MBPS.
  763. If scan_phys also contains @ref BLE_GAP_PHY_CODED, the primary scan
  764. PHY will also contain @ref BLE_GAP_PHY_CODED. If the only scan PHY is
  765. @ref BLE_GAP_PHY_CODED, the primary scan PHY is
  766. @ref BLE_GAP_PHY_CODED only. */
  767. uint16_t interval; /**< Scan interval in 625 us units. @sa BLE_GAP_SCAN_INTERVALS. */
  768. uint16_t window; /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW.
  769. If scan_phys contains both @ref BLE_GAP_PHY_1MBPS and
  770. @ref BLE_GAP_PHY_CODED interval shall be larger than or
  771. equal to twice the scan window. */
  772. uint16_t timeout; /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */
  773. ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels.
  774. At least one of the primary channels, that is channel index 37-39, must be
  775. set to 0.
  776. Masking away secondary channels is not supported. */
  777. } ble_gap_scan_params_t;
  778. /**@brief Privacy.
  779. *
  780. * The privacy feature provides a way for the device to avoid being tracked over a period of time.
  781. * The privacy feature, when enabled, hides the local device identity and replaces it with a private address
  782. * that is automatically refreshed at a specified interval.
  783. *
  784. * If a device still wants to be recognized by other peers, it needs to share it's Identity Resolving Key (IRK).
  785. * With this key, a device can generate a random private address that can only be recognized by peers in possession of that key,
  786. * and devices can establish connections without revealing their real identities.
  787. *
  788. * Both network privacy (@ref BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY) and device privacy (@ref BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY)
  789. * are supported.
  790. *
  791. * @note If the device IRK is updated, the new IRK becomes the one to be distributed in all
  792. * bonding procedures performed after @ref sd_ble_gap_privacy_set returns.
  793. * The IRK distributed during bonding procedure is the device IRK that is active when @ref sd_ble_gap_sec_params_reply is called.
  794. */
  795. typedef struct
  796. {
  797. uint8_t privacy_mode; /**< Privacy mode, see @ref BLE_GAP_PRIVACY_MODES. Default is @ref BLE_GAP_PRIVACY_MODE_OFF. */
  798. 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. */
  799. 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. */
  800. 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.
  801. When used as output, pointer to IRK structure where the current default IRK will be written to. If NULL, this argument is ignored.
  802. By default, the default IRK is used to generate random private resolvable addresses for the local device unless instructed otherwise. */
  803. } ble_gap_privacy_params_t;
  804. /**@brief PHY preferences for TX and RX
  805. * @note tx_phys and rx_phys are bit fields. Multiple bits can be set in them to indicate multiple preferred PHYs for each direction.
  806. * @code
  807. * p_gap_phys->tx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS;
  808. * p_gap_phys->rx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS;
  809. * @endcode
  810. *
  811. */
  812. typedef struct
  813. {
  814. uint8_t tx_phys; /**< Preferred transmit PHYs, see @ref BLE_GAP_PHYS. */
  815. uint8_t rx_phys; /**< Preferred receive PHYs, see @ref BLE_GAP_PHYS. */
  816. } ble_gap_phys_t;
  817. /** @brief Keys that can be exchanged during a bonding procedure. */
  818. typedef struct
  819. {
  820. uint8_t enc : 1; /**< Long Term Key and Master Identification. */
  821. uint8_t id : 1; /**< Identity Resolving Key and Identity Address Information. */
  822. uint8_t sign : 1; /**< Connection Signature Resolving Key. */
  823. uint8_t link : 1; /**< Derive the Link Key from the LTK. */
  824. } ble_gap_sec_kdist_t;
  825. /**@brief GAP security parameters. */
  826. typedef struct
  827. {
  828. uint8_t bond : 1; /**< Perform bonding. */
  829. uint8_t mitm : 1; /**< Enable Man In The Middle protection. */
  830. uint8_t lesc : 1; /**< Enable LE Secure Connection pairing. */
  831. uint8_t keypress : 1; /**< Enable generation of keypress notifications. */
  832. uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */
  833. uint8_t oob : 1; /**< The OOB data flag.
  834. - In LE legacy pairing, this flag is set if a device has out of band authentication data.
  835. The OOB method is used if both of the devices have out of band authentication data.
  836. - In LE Secure Connections pairing, this flag is set if a device has the peer device's out of band authentication data.
  837. The OOB method is used if at least one device has the peer device's OOB data available. */
  838. uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance. */
  839. uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */
  840. ble_gap_sec_kdist_t kdist_own; /**< Key distribution bitmap: keys that the local device will distribute. */
  841. ble_gap_sec_kdist_t kdist_peer; /**< Key distribution bitmap: keys that the remote device will distribute. */
  842. } ble_gap_sec_params_t;
  843. /**@brief GAP Encryption Information. */
  844. typedef struct
  845. {
  846. uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */
  847. uint8_t lesc : 1; /**< Key generated using LE Secure Connections. */
  848. uint8_t auth : 1; /**< Authenticated Key. */
  849. uint8_t ltk_len : 6; /**< LTK length in octets. */
  850. } ble_gap_enc_info_t;
  851. /**@brief GAP Master Identification. */
  852. typedef struct
  853. {
  854. uint16_t ediv; /**< Encrypted Diversifier. */
  855. uint8_t rand[BLE_GAP_SEC_RAND_LEN]; /**< Random Number. */
  856. } ble_gap_master_id_t;
  857. /**@brief GAP Signing Information. */
  858. typedef struct
  859. {
  860. uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /**< Connection Signature Resolving Key. */
  861. } ble_gap_sign_info_t;
  862. /**@brief GAP LE Secure Connections P-256 Public Key. */
  863. typedef struct
  864. {
  865. 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. */
  866. } ble_gap_lesc_p256_pk_t;
  867. /**@brief GAP LE Secure Connections DHKey. */
  868. typedef struct
  869. {
  870. uint8_t key[BLE_GAP_LESC_DHKEY_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman Key. Stored in little-endian. */
  871. } ble_gap_lesc_dhkey_t;
  872. /**@brief GAP LE Secure Connections OOB data. */
  873. typedef struct
  874. {
  875. ble_gap_addr_t addr; /**< Bluetooth address of the device. */
  876. uint8_t r[BLE_GAP_SEC_KEY_LEN]; /**< Random Number. */
  877. uint8_t c[BLE_GAP_SEC_KEY_LEN]; /**< Confirm Value. */
  878. } ble_gap_lesc_oob_data_t;
  879. /**@brief Event structure for @ref BLE_GAP_EVT_CONNECTED. */
  880. typedef struct
  881. {
  882. 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
  883. and the address is the device's identity address. */
  884. uint8_t role; /**< BLE role for this connection, see @ref BLE_GAP_ROLES */
  885. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  886. uint8_t adv_handle; /**< Advertising handle in which advertising has ended.
  887. This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */
  888. ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated
  889. advertising set. The advertising buffers provided in
  890. @ref sd_ble_gap_adv_set_configure are now released.
  891. This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */
  892. } ble_gap_evt_connected_t;
  893. /**@brief Event structure for @ref BLE_GAP_EVT_DISCONNECTED. */
  894. typedef struct
  895. {
  896. uint8_t reason; /**< HCI error code, see @ref BLE_HCI_STATUS_CODES. */
  897. } ble_gap_evt_disconnected_t;
  898. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE. */
  899. typedef struct
  900. {
  901. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  902. } ble_gap_evt_conn_param_update_t;
  903. /**@brief Event structure for @ref BLE_GAP_EVT_PHY_UPDATE_REQUEST. */
  904. typedef struct
  905. {
  906. ble_gap_phys_t peer_preferred_phys; /**< The PHYs the peer prefers to use. */
  907. } ble_gap_evt_phy_update_request_t;
  908. /**@brief Event Structure for @ref BLE_GAP_EVT_PHY_UPDATE. */
  909. typedef struct
  910. {
  911. uint8_t status; /**< Status of the procedure, see @ref BLE_HCI_STATUS_CODES.*/
  912. uint8_t tx_phy; /**< TX PHY for this connection, see @ref BLE_GAP_PHYS. */
  913. uint8_t rx_phy; /**< RX PHY for this connection, see @ref BLE_GAP_PHYS. */
  914. } ble_gap_evt_phy_update_t;
  915. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. */
  916. typedef struct
  917. {
  918. ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */
  919. } ble_gap_evt_sec_params_request_t;
  920. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_INFO_REQUEST. */
  921. typedef struct
  922. {
  923. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
  924. ble_gap_master_id_t master_id; /**< Master Identification for LTK lookup. */
  925. uint8_t enc_info : 1; /**< If 1, Encryption Information required. */
  926. uint8_t id_info : 1; /**< If 1, Identity Information required. */
  927. uint8_t sign_info : 1; /**< If 1, Signing Information required. */
  928. } ble_gap_evt_sec_info_request_t;
  929. /**@brief Event structure for @ref BLE_GAP_EVT_PASSKEY_DISPLAY. */
  930. typedef struct
  931. {
  932. uint8_t passkey[BLE_GAP_PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
  933. uint8_t match_request : 1; /**< If 1 requires the application to report the match using @ref sd_ble_gap_auth_key_reply
  934. with either @ref BLE_GAP_AUTH_KEY_TYPE_NONE if there is no match or
  935. @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY if there is a match. */
  936. } ble_gap_evt_passkey_display_t;
  937. /**@brief Event structure for @ref BLE_GAP_EVT_KEY_PRESSED. */
  938. typedef struct
  939. {
  940. uint8_t kp_not; /**< Keypress notification type, see @ref BLE_GAP_KP_NOT_TYPES. */
  941. } ble_gap_evt_key_pressed_t;
  942. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_KEY_REQUEST. */
  943. typedef struct
  944. {
  945. uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */
  946. } ble_gap_evt_auth_key_request_t;
  947. /**@brief Event structure for @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST. */
  948. typedef struct
  949. {
  950. 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
  951. inside the keyset during the call to @ref sd_ble_gap_sec_params_reply. */
  952. 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. */
  953. } ble_gap_evt_lesc_dhkey_request_t;
  954. /**@brief Security levels supported.
  955. * @note See Bluetooth Specification Version 4.2 Volume 3, Part C, Chapter 10, Section 10.2.1.
  956. */
  957. typedef struct
  958. {
  959. uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */
  960. uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */
  961. uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */
  962. uint8_t lv4 : 1; /**< If 1: Level 4 is supported. */
  963. } ble_gap_sec_levels_t;
  964. /**@brief Encryption Key. */
  965. typedef struct
  966. {
  967. ble_gap_enc_info_t enc_info; /**< Encryption Information. */
  968. ble_gap_master_id_t master_id; /**< Master Identification. */
  969. } ble_gap_enc_key_t;
  970. /**@brief Identity Key. */
  971. typedef struct
  972. {
  973. ble_gap_irk_t id_info; /**< Identity Resolving Key. */
  974. ble_gap_addr_t id_addr_info; /**< Identity Address. */
  975. } ble_gap_id_key_t;
  976. /**@brief Security Keys. */
  977. typedef struct
  978. {
  979. ble_gap_enc_key_t *p_enc_key; /**< Encryption Key, or NULL. */
  980. ble_gap_id_key_t *p_id_key; /**< Identity Key, or NULL. */
  981. ble_gap_sign_info_t *p_sign_key; /**< Signing Key, or NULL. */
  982. 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
  983. in the Core Bluetooth Specification v4.2 Vol.3, Part H, Section 2.3.5.6.1 */
  984. } ble_gap_sec_keys_t;
  985. /**@brief Security key set for both local and peer keys. */
  986. typedef struct
  987. {
  988. 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. */
  989. ble_gap_sec_keys_t keys_peer; /**< Keys distributed by the remote device. For LE Secure Connections, p_enc_key must always be NULL. */
  990. } ble_gap_sec_keyset_t;
  991. /**@brief Data Length Update Procedure parameters. */
  992. typedef struct
  993. {
  994. uint16_t max_tx_octets; /**< Maximum number of payload octets that a Controller supports for transmission of a single Link Layer Data Channel PDU. */
  995. uint16_t max_rx_octets; /**< Maximum number of payload octets that a Controller supports for reception of a single Link Layer Data Channel PDU. */
  996. uint16_t max_tx_time_us; /**< Maximum time, in microseconds, that a Controller supports for transmission of a single Link Layer Data Channel PDU. */
  997. uint16_t max_rx_time_us; /**< Maximum time, in microseconds, that a Controller supports for reception of a single Link Layer Data Channel PDU. */
  998. } ble_gap_data_length_params_t;
  999. /**@brief Data Length Update Procedure local limitation. */
  1000. typedef struct
  1001. {
  1002. uint16_t tx_payload_limited_octets; /**< If > 0, the requested TX packet length is too long by this many octets. */
  1003. uint16_t rx_payload_limited_octets; /**< If > 0, the requested RX packet length is too long by this many octets. */
  1004. uint16_t tx_rx_time_limited_us; /**< If > 0, the requested combination of TX and RX packet lengths is too long by this many microseconds. */
  1005. } ble_gap_data_length_limitation_t;
  1006. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_STATUS. */
  1007. typedef struct
  1008. {
  1009. uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */
  1010. uint8_t error_src : 2; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */
  1011. uint8_t bonded : 1; /**< Procedure resulted in a bond. */
  1012. uint8_t lesc : 1; /**< Procedure resulted in a LE Secure Connection. */
  1013. ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */
  1014. ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */
  1015. 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. */
  1016. 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. */
  1017. } ble_gap_evt_auth_status_t;
  1018. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_SEC_UPDATE. */
  1019. typedef struct
  1020. {
  1021. ble_gap_conn_sec_t conn_sec; /**< Connection security level. */
  1022. } ble_gap_evt_conn_sec_update_t;
  1023. /**@brief Event structure for @ref BLE_GAP_EVT_TIMEOUT. */
  1024. typedef struct
  1025. {
  1026. uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */
  1027. union
  1028. {
  1029. ble_data_t adv_report_buffer; /**< If source is set to @ref BLE_GAP_TIMEOUT_SRC_SCAN, the released
  1030. scan buffer is contained in this field. */
  1031. } params; /**< Event Parameters. */
  1032. } ble_gap_evt_timeout_t;
  1033. /**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */
  1034. typedef struct
  1035. {
  1036. int8_t rssi; /**< Received Signal Strength Indication in dBm.
  1037. @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement. */
  1038. uint8_t ch_index; /**< Data Channel Index on which the Signal Strength is measured (0-36). */
  1039. } ble_gap_evt_rssi_changed_t;
  1040. /**@brief Event structure for @ref BLE_GAP_EVT_ADV_SET_TERMINATED */
  1041. typedef struct
  1042. {
  1043. uint8_t reason; /**< Reason for why the advertising set terminated. See
  1044. @ref BLE_GAP_EVT_ADV_SET_TERMINATED_REASON. */
  1045. uint8_t adv_handle; /**< Advertising handle in which advertising has ended. */
  1046. uint8_t num_completed_adv_events; /**< If @ref ble_gap_adv_params_t::max_adv_evts was not set to 0,
  1047. this field indicates the number of completed advertising events. */
  1048. ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated
  1049. advertising set. The advertising buffers provided in
  1050. @ref sd_ble_gap_adv_set_configure are now released. */
  1051. } ble_gap_evt_adv_set_terminated_t;
  1052. /**@brief Event structure for @ref BLE_GAP_EVT_ADV_REPORT.
  1053. *
  1054. * @note If @ref ble_gap_adv_report_type_t::status is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA,
  1055. * not all fields in the advertising report may be available.
  1056. *
  1057. * @note When ble_gap_adv_report_type_t::status is not set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA,
  1058. * scanning will be paused. To continue scanning, call @ref sd_ble_gap_scan_start.
  1059. */
  1060. typedef struct
  1061. {
  1062. ble_gap_adv_report_type_t type; /**< Advertising report type. See @ref ble_gap_adv_report_type_t. */
  1063. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr is resolved:
  1064. @ref ble_gap_addr_t::addr_id_peer is set to 1 and the address is the
  1065. peer's identity address. */
  1066. ble_gap_addr_t direct_addr; /**< Contains the target address of the advertising event if
  1067. @ref ble_gap_adv_report_type_t::directed is set to 1. If the
  1068. SoftDevice was able to resolve the address,
  1069. @ref ble_gap_addr_t::addr_id_peer is set to 1 and the direct_addr
  1070. contains the local identity address. If the target address of the
  1071. advertising event is @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE,
  1072. and the SoftDevice was unable to resolve it, the application may try
  1073. to resolve this address to find out if the advertising event was
  1074. directed to us. */
  1075. uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising packet was received.
  1076. See @ref BLE_GAP_PHYS. */
  1077. uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising packet was received.
  1078. See @ref BLE_GAP_PHYS. This field is set to @ref BLE_GAP_PHY_NOT_SET if no packets
  1079. were received on a secondary advertising channel. */
  1080. int8_t tx_power; /**< TX Power reported by the advertiser in the last packet header received.
  1081. This field is set to @ref BLE_GAP_POWER_LEVEL_INVALID if the
  1082. last received packet did not contain the Tx Power field.
  1083. @note TX Power is only included in extended advertising packets. */
  1084. int8_t rssi; /**< Received Signal Strength Indication in dBm of the last packet received.
  1085. @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement. */
  1086. uint8_t ch_index; /**< Channel Index on which the last advertising packet is received (0-39). */
  1087. uint8_t set_id; /**< Set ID of the received advertising data. Set ID is not present
  1088. if set to @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */
  1089. uint16_t data_id:12; /**< The advertising data ID of the received advertising data. Data ID
  1090. is not present if @ref ble_gap_evt_adv_report_t::set_id is set to
  1091. @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */
  1092. ble_data_t data; /**< Received advertising or scan response data. If
  1093. @ref ble_gap_adv_report_type_t::status is not set to
  1094. @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the data buffer provided
  1095. in @ref sd_ble_gap_scan_start is now released. */
  1096. ble_gap_aux_pointer_t aux_pointer; /**< The offset and PHY of the next advertising packet in this extended advertising
  1097. event. @note This field is only set if @ref ble_gap_adv_report_type_t::status
  1098. is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. */
  1099. } ble_gap_evt_adv_report_t;
  1100. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_REQUEST. */
  1101. typedef struct
  1102. {
  1103. uint8_t bond : 1; /**< Perform bonding. */
  1104. uint8_t mitm : 1; /**< Man In The Middle protection requested. */
  1105. uint8_t lesc : 1; /**< LE Secure Connections requested. */
  1106. uint8_t keypress : 1; /**< Generation of keypress notifications requested. */
  1107. } ble_gap_evt_sec_request_t;
  1108. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST. */
  1109. typedef struct
  1110. {
  1111. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  1112. } ble_gap_evt_conn_param_update_request_t;
  1113. /**@brief Event structure for @ref BLE_GAP_EVT_SCAN_REQ_REPORT. */
  1114. typedef struct
  1115. {
  1116. uint8_t adv_handle; /**< Advertising handle for the advertising set which received the Scan Request */
  1117. int8_t rssi; /**< Received Signal Strength Indication in dBm.
  1118. @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement. */
  1119. 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
  1120. and the address is the device's identity address. */
  1121. } ble_gap_evt_scan_req_report_t;
  1122. /**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST. */
  1123. typedef struct
  1124. {
  1125. ble_gap_data_length_params_t peer_params; /**< Peer data length parameters. */
  1126. } ble_gap_evt_data_length_update_request_t;
  1127. /**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE. */
  1128. typedef struct
  1129. {
  1130. ble_gap_data_length_params_t effective_params; /**< The effective data length parameters. */
  1131. } ble_gap_evt_data_length_update_t;
  1132. /**@brief Event structure for @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT. */
  1133. typedef struct
  1134. {
  1135. int8_t channel_energy[BLE_GAP_CHANNEL_COUNT]; /**< The measured energy on the Bluetooth Low Energy
  1136. channels, in dBm, indexed by Channel Index.
  1137. If no measurement is available for the given channel, channel_energy is set to
  1138. @ref BLE_GAP_POWER_LEVEL_INVALID. */
  1139. } ble_gap_evt_qos_channel_survey_report_t;
  1140. /**@brief GAP event structure. */
  1141. typedef struct
  1142. {
  1143. uint16_t conn_handle; /**< Connection Handle on which event occurred. */
  1144. union /**< union alternative identified by evt_id in enclosing struct. */
  1145. {
  1146. ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */
  1147. ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */
  1148. ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */
  1149. ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */
  1150. ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */
  1151. ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */
  1152. ble_gap_evt_key_pressed_t key_pressed; /**< Key Pressed Event Parameters. */
  1153. ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */
  1154. ble_gap_evt_lesc_dhkey_request_t lesc_dhkey_request; /**< LE Secure Connections DHKey calculation request. */
  1155. ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */
  1156. ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */
  1157. ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */
  1158. ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event Parameters. */
  1159. ble_gap_evt_adv_report_t adv_report; /**< Advertising Report Event Parameters. */
  1160. ble_gap_evt_adv_set_terminated_t adv_set_terminated; /**< Advertising Set Terminated Event Parameters. */
  1161. ble_gap_evt_sec_request_t sec_request; /**< Security Request Event Parameters. */
  1162. ble_gap_evt_conn_param_update_request_t conn_param_update_request; /**< Connection Parameter Update Parameters. */
  1163. ble_gap_evt_scan_req_report_t scan_req_report; /**< Scan Request Report Parameters. */
  1164. ble_gap_evt_phy_update_request_t phy_update_request; /**< PHY Update Request Event Parameters. */
  1165. ble_gap_evt_phy_update_t phy_update; /**< PHY Update Parameters. */
  1166. ble_gap_evt_data_length_update_request_t data_length_update_request; /**< Data Length Update Request Event Parameters. */
  1167. ble_gap_evt_data_length_update_t data_length_update; /**< Data Length Update Event Parameters. */
  1168. ble_gap_evt_qos_channel_survey_report_t qos_channel_survey_report; /**< Quality of Service (QoS) Channel Survey Report Parameters. */
  1169. } params; /**< Event Parameters. */
  1170. } ble_gap_evt_t;
  1171. /**
  1172. * @brief BLE GAP connection configuration parameters, set with @ref sd_ble_cfg_set.
  1173. *
  1174. * @retval ::NRF_ERROR_CONN_COUNT The connection count for the connection configurations is zero.
  1175. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  1176. * - The sum of conn_count for all connection configurations combined exceeds UINT8_MAX.
  1177. * - The event length is smaller than @ref BLE_GAP_EVENT_LENGTH_MIN.
  1178. */
  1179. typedef struct
  1180. {
  1181. uint8_t conn_count; /**< The number of concurrent connections the application can create with this configuration.
  1182. The default and minimum value is @ref BLE_GAP_CONN_COUNT_DEFAULT. */
  1183. uint16_t event_length; /**< The time set aside for this connection on every connection interval in 1.25 ms units.
  1184. The default value is @ref BLE_GAP_EVENT_LENGTH_DEFAULT, the minimum value is @ref BLE_GAP_EVENT_LENGTH_MIN.
  1185. The event length and the connection interval are the primary parameters
  1186. for setting the throughput of a connection.
  1187. See the SoftDevice Specification for details on throughput. */
  1188. } ble_gap_conn_cfg_t;
  1189. /**
  1190. * @brief Configuration of maximum concurrent connections in the different connected roles, set with
  1191. * @ref sd_ble_cfg_set.
  1192. *
  1193. * @retval ::NRF_ERROR_CONN_COUNT The sum of periph_role_count and central_role_count is too
  1194. * large. The maximum supported sum of concurrent connections is
  1195. * @ref BLE_GAP_ROLE_COUNT_COMBINED_MAX.
  1196. * @retval ::NRF_ERROR_INVALID_PARAM central_sec_count is larger than central_role_count.
  1197. * @retval ::NRF_ERROR_RESOURCES The adv_set_count is too large. The maximum
  1198. * supported advertising handles is
  1199. * @ref BLE_GAP_ADV_SET_COUNT_MAX.
  1200. */
  1201. typedef struct
  1202. {
  1203. uint8_t adv_set_count; /**< Maximum number of advertising sets. Default value is @ref BLE_GAP_ADV_SET_COUNT_DEFAULT. */
  1204. uint8_t periph_role_count; /**< Maximum number of connections concurrently acting as a peripheral. Default value is @ref BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT. */
  1205. uint8_t central_role_count; /**< Maximum number of connections concurrently acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT. */
  1206. uint8_t central_sec_count; /**< Number of SMP instances shared between all connections acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_SEC_DEFAULT. */
  1207. uint8_t qos_channel_survey_role_available:1; /**< If set, the Quality of Service (QoS) channel survey module is available to the
  1208. application using @ref sd_ble_gap_qos_channel_survey_start. */
  1209. } ble_gap_cfg_role_count_t;
  1210. /**
  1211. * @brief Device name and its properties, set with @ref sd_ble_cfg_set.
  1212. *
  1213. * @note If the device name is not configured, the default device name will be
  1214. * @ref BLE_GAP_DEVNAME_DEFAULT, the maximum device name length will be
  1215. * @ref BLE_GAP_DEVNAME_DEFAULT_LEN, vloc will be set to @ref BLE_GATTS_VLOC_STACK and the device name
  1216. * will have no write access.
  1217. *
  1218. * @note If @ref max_len is more than @ref BLE_GAP_DEVNAME_DEFAULT_LEN and vloc is set to @ref BLE_GATTS_VLOC_STACK,
  1219. * the attribute table size must be increased to have room for the longer device name (see
  1220. * @ref sd_ble_cfg_set and @ref ble_gatts_cfg_attr_tab_size_t).
  1221. *
  1222. * @note If vloc is @ref BLE_GATTS_VLOC_STACK :
  1223. * - p_value must point to non-volatile memory (flash) or be NULL.
  1224. * - If p_value is NULL, the device name will initially be empty.
  1225. *
  1226. * @note If vloc is @ref BLE_GATTS_VLOC_USER :
  1227. * - p_value cannot be NULL.
  1228. * - If the device name is writable, p_value must point to volatile memory (RAM).
  1229. *
  1230. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  1231. * - Invalid device name location (vloc).
  1232. * - Invalid device name security mode.
  1233. * @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true:
  1234. * - The device name length is invalid (must be between 0 and @ref BLE_GAP_DEVNAME_MAX_LEN).
  1235. * - The device name length is too long for the given Attribute Table.
  1236. * @retval ::NRF_ERROR_NOT_SUPPORTED Device name security mode is not supported.
  1237. */
  1238. typedef struct
  1239. {
  1240. ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
  1241. uint8_t vloc:2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
  1242. uint8_t *p_value; /**< Pointer to where the value (device name) is stored or will be stored. */
  1243. uint16_t current_len; /**< Current length in bytes of the memory pointed to by p_value.*/
  1244. uint16_t max_len; /**< Maximum length in bytes of the memory pointed to by p_value.*/
  1245. } ble_gap_cfg_device_name_t;
  1246. /**@brief Configuration structure for GAP configurations. */
  1247. typedef union
  1248. {
  1249. ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */
  1250. ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */
  1251. } ble_gap_cfg_t;
  1252. /**@brief Channel Map option.
  1253. *
  1254. * @details Used with @ref sd_ble_opt_get to get the current channel map
  1255. * or @ref sd_ble_opt_set to set a new channel map. When setting the
  1256. * channel map, it applies to all current and future connections. When getting the
  1257. * current channel map, it applies to a single connection and the connection handle
  1258. * must be supplied.
  1259. *
  1260. * @note Setting the channel map may take some time, depending on connection parameters.
  1261. * The time taken may be different for each connection and the get operation will
  1262. * return the previous channel map until the new one has taken effect.
  1263. *
  1264. * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed.
  1265. * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46.
  1266. *
  1267. * @retval ::NRF_SUCCESS Get or set successful.
  1268. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  1269. * - Less then two bits in @ref ch_map are set.
  1270. * - Bits for primary advertising channels (37-39) are set.
  1271. * @retval ::NRF_ERROR_BUSY Channel map was set again before enough time had passed.
  1272. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied for get.
  1273. *
  1274. */
  1275. typedef struct
  1276. {
  1277. uint16_t conn_handle; /**< Connection Handle (only applicable for get) */
  1278. uint8_t ch_map[5]; /**< Channel Map (37-bit). */
  1279. } ble_gap_opt_ch_map_t;
  1280. /**@brief Local connection latency option.
  1281. *
  1282. * @details Local connection latency is a feature which enables the slave to improve
  1283. * current consumption by ignoring the slave latency set by the peer. The
  1284. * local connection latency can only be set to a multiple of the slave latency,
  1285. * and cannot be longer than half of the supervision timeout.
  1286. *
  1287. * @details Used with @ref sd_ble_opt_set to set the local connection latency. The
  1288. * @ref sd_ble_opt_get is not supported for this option, but the actual
  1289. * local connection latency (unless set to NULL) is set as a return parameter
  1290. * when setting the option.
  1291. *
  1292. * @note The latency set will be truncated down to the closest slave latency event
  1293. * multiple, or the nearest multiple before half of the supervision timeout.
  1294. *
  1295. * @note The local connection latency is disabled by default, and needs to be enabled for new
  1296. * connections and whenever the connection is updated.
  1297. *
  1298. * @retval ::NRF_SUCCESS Set successfully.
  1299. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
  1300. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1301. */
  1302. typedef struct
  1303. {
  1304. uint16_t conn_handle; /**< Connection Handle */
  1305. uint16_t requested_latency; /**< Requested local connection latency. */
  1306. uint16_t * p_actual_latency; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
  1307. } ble_gap_opt_local_conn_latency_t;
  1308. /**@brief Disable slave latency
  1309. *
  1310. * @details Used with @ref sd_ble_opt_set to temporarily disable slave latency of a peripheral connection
  1311. * (see @ref ble_gap_conn_params_t::slave_latency). And to re-enable it again. When disabled, the
  1312. * peripheral will ignore the slave_latency set by the central.
  1313. *
  1314. * @note Shall only be called on peripheral links.
  1315. *
  1316. * @retval ::NRF_SUCCESS Set successfully.
  1317. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
  1318. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1319. */
  1320. typedef struct
  1321. {
  1322. uint16_t conn_handle; /**< Connection Handle */
  1323. uint8_t disable : 1; /**< Set to 1 to disable slave latency. Set to 0 enable it again.*/
  1324. } ble_gap_opt_slave_latency_disable_t;
  1325. /**@brief Passkey Option.
  1326. *
  1327. * @details Structure containing the passkey to be used during pairing. This can be used with @ref
  1328. * sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication
  1329. * instead of generating a random one.
  1330. *
  1331. * @note Repeated pairing attempts using the same preprogrammed passkey makes pairing vulnerable to MITM attacks.
  1332. *
  1333. * @note @ref sd_ble_opt_get is not supported for this option.
  1334. *
  1335. */
  1336. typedef struct
  1337. {
  1338. 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.*/
  1339. } ble_gap_opt_passkey_t;
  1340. /**@brief Compatibility mode 1 option.
  1341. *
  1342. * @details This can be used with @ref sd_ble_opt_set to enable and disable
  1343. * compatibility mode 1. Compatibility mode 1 is disabled by default.
  1344. *
  1345. * @note Compatibility mode 1 enables interoperability with devices that do not support a value of
  1346. * 0 for the WinOffset parameter in the Link Layer CONNECT_IND packet. This applies to a
  1347. * limited set of legacy peripheral devices from another vendor. Enabling this compatibility
  1348. * mode will only have an effect if the local device will act as a central device and
  1349. * initiate a connection to a peripheral device. In that case it may lead to the connection
  1350. * creation taking up to one connection interval longer to complete for all connections.
  1351. *
  1352. * @retval ::NRF_SUCCESS Set successfully.
  1353. * @retval ::NRF_ERROR_INVALID_STATE When connection creation is ongoing while mode 1 is set.
  1354. */
  1355. typedef struct
  1356. {
  1357. uint8_t enable : 1; /**< Enable compatibility mode 1.*/
  1358. } ble_gap_opt_compat_mode_1_t;
  1359. /**@brief Authenticated payload timeout option.
  1360. *
  1361. * @details This can be used with @ref sd_ble_opt_set to change the Authenticated payload timeout to a value other
  1362. * than the default of @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX.
  1363. *
  1364. * @note The authenticated payload timeout event ::BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD will be generated
  1365. * if auth_payload_timeout time has elapsed without receiving a packet with a valid MIC on an encrypted
  1366. * link.
  1367. *
  1368. * @note The LE ping procedure will be initiated before the timer expires to give the peer a chance
  1369. * to reset the timer. In addition the stack will try to prioritize running of LE ping over other
  1370. * activities to increase chances of finishing LE ping before timer expires. To avoid side-effects
  1371. * on other activities, it is recommended to use high timeout values.
  1372. * Recommended timeout > 2*(connInterval * (6 + connSlaveLatency)).
  1373. *
  1374. * @retval ::NRF_SUCCESS Set successfully.
  1375. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. auth_payload_timeout was outside of allowed range.
  1376. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1377. */
  1378. typedef struct
  1379. {
  1380. uint16_t conn_handle; /**< Connection Handle */
  1381. uint16_t auth_payload_timeout; /**< Requested timeout in 10 ms unit, see @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT. */
  1382. } ble_gap_opt_auth_payload_timeout_t;
  1383. /**@brief Option structure for GAP options. */
  1384. typedef union
  1385. {
  1386. ble_gap_opt_ch_map_t ch_map; /**< Parameters for the Channel Map option. */
  1387. ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Parameters for the Local connection latency option */
  1388. ble_gap_opt_passkey_t passkey; /**< Parameters for the Passkey option.*/
  1389. ble_gap_opt_compat_mode_1_t compat_mode_1; /**< Parameters for the compatibility mode 1 option.*/
  1390. ble_gap_opt_auth_payload_timeout_t auth_payload_timeout; /**< Parameters for the authenticated payload timeout option.*/
  1391. ble_gap_opt_slave_latency_disable_t slave_latency_disable; /**< Parameters for the Disable slave latency option */
  1392. } ble_gap_opt_t;
  1393. /**@} */
  1394. /**@addtogroup BLE_GAP_FUNCTIONS Functions
  1395. * @{ */
  1396. /**@brief Set the local Bluetooth identity address.
  1397. *
  1398. * The local Bluetooth identity address is the address that identifies this device to other peers.
  1399. * The address type must be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC.
  1400. *
  1401. * @note The identity address cannot be changed while advertising, scanning or creating a connection.
  1402. *
  1403. * @note This address will be distributed to the peer during bonding.
  1404. * If the address changes, the address stored in the peer device will not be valid and the ability to
  1405. * reconnect using the old address will be lost.
  1406. *
  1407. * @note By default the SoftDevice will set an address of type @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC upon being
  1408. * enabled. The address is a random number populated during the IC manufacturing process and remains unchanged
  1409. * for the lifetime of each IC.
  1410. *
  1411. * @mscs
  1412. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1413. * @endmscs
  1414. *
  1415. * @param[in] p_addr Pointer to address structure.
  1416. *
  1417. * @retval ::NRF_SUCCESS Address successfully set.
  1418. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1419. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address.
  1420. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1421. * @retval ::NRF_ERROR_INVALID_STATE The identity address cannot be changed while advertising,
  1422. * scanning or creating a connection.
  1423. */
  1424. SVCALL(SD_BLE_GAP_ADDR_SET, uint32_t, sd_ble_gap_addr_set(ble_gap_addr_t const *p_addr));
  1425. /**@brief Get local Bluetooth identity address.
  1426. *
  1427. * @note This will always return the identity address irrespective of the privacy settings,
  1428. * i.e. the address type will always be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC.
  1429. *
  1430. * @param[out] p_addr Pointer to address structure to be filled in.
  1431. *
  1432. * @retval ::NRF_SUCCESS Address successfully retrieved.
  1433. * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
  1434. */
  1435. SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr));
  1436. /**@brief Get the Bluetooth device address used by the advertiser.
  1437. *
  1438. * @note This function will return the local Bluetooth address used in advertising PDUs. When
  1439. * using privacy, the SoftDevice will generate a new private address every
  1440. * @ref ble_gap_privacy_params_t::private_addr_cycle_s configured using
  1441. * @ref sd_ble_gap_privacy_set. Hence depending on when the application calls this API, the
  1442. * address returned may not be the latest address that is used in the advertising PDUs.
  1443. *
  1444. * @param[in] adv_handle The advertising handle to get the address from.
  1445. * @param[out] p_addr Pointer to address structure to be filled in.
  1446. *
  1447. * @retval ::NRF_SUCCESS Address successfully retrieved.
  1448. * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
  1449. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found.
  1450. * @retval ::NRF_ERROR_INVALID_STATE The advertising set is currently not advertising.
  1451. */
  1452. 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));
  1453. /**@brief Set the active whitelist in the SoftDevice.
  1454. *
  1455. * @note Only one whitelist can be used at a time and the whitelist is shared between the BLE roles.
  1456. * The whitelist cannot be set if a BLE role is using the whitelist.
  1457. *
  1458. * @note If an address is resolved using the information in the device identity list, then the whitelist
  1459. * filter policy applies to the peer identity address and not the resolvable address sent on air.
  1460. *
  1461. * @mscs
  1462. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1463. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC}
  1464. * @endmscs
  1465. *
  1466. * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses, if NULL the whitelist will be cleared.
  1467. * @param[in] len Length of the whitelist, maximum @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT.
  1468. *
  1469. * @retval ::NRF_SUCCESS The whitelist is successfully set/cleared.
  1470. * @retval ::NRF_ERROR_INVALID_ADDR The whitelist (or one of its entries) provided is invalid.
  1471. * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE The whitelist is in use by a BLE role and cannot be set or cleared.
  1472. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1473. * @retval ::NRF_ERROR_DATA_SIZE The given whitelist size is invalid (zero or too large); this can only return when
  1474. * pp_wl_addrs is not NULL.
  1475. */
  1476. 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));
  1477. /**@brief Set device identity list.
  1478. *
  1479. * @note Only one device identity list can be used at a time and the list is shared between the BLE roles.
  1480. * The device identity list cannot be set if a BLE role is using the list.
  1481. *
  1482. * @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.
  1483. * @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.
  1484. * To fill in the list with the currently set device IRK for all peers, set to NULL.
  1485. * @param[in] len Length of the device identity list, maximum @ref BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT.
  1486. *
  1487. * @mscs
  1488. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC}
  1489. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC}
  1490. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC}
  1491. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1492. * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC}
  1493. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC}
  1494. * @endmscs
  1495. *
  1496. * @retval ::NRF_SUCCESS The device identity list successfully set/cleared.
  1497. * @retval ::NRF_ERROR_INVALID_ADDR The device identity list (or one of its entries) provided is invalid.
  1498. * This code may be returned if the local IRK list also has an invalid entry.
  1499. * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE The device identity list is in use and cannot be set or cleared.
  1500. * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE The device identity list contains multiple entries with the same identity address.
  1501. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1502. * @retval ::NRF_ERROR_DATA_SIZE The given device identity list size invalid (zero or too large); this can
  1503. * only return when pp_id_keys is not NULL.
  1504. */
  1505. 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));
  1506. /**@brief Set privacy settings.
  1507. *
  1508. * @note Privacy settings cannot be changed while advertising, scanning or creating a connection.
  1509. *
  1510. * @param[in] p_privacy_params Privacy settings.
  1511. *
  1512. * @mscs
  1513. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC}
  1514. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC}
  1515. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1516. * @endmscs
  1517. *
  1518. * @retval ::NRF_SUCCESS Set successfully.
  1519. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1520. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1521. * @retval ::NRF_ERROR_INVALID_ADDR The pointer to privacy settings is NULL or invalid.
  1522. * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
  1523. * @retval ::NRF_ERROR_INVALID_PARAM Out of range parameters are provided.
  1524. * @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising, scanning
  1525. * or creating a connection.
  1526. */
  1527. SVCALL(SD_BLE_GAP_PRIVACY_SET, uint32_t, sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params));
  1528. /**@brief Get privacy settings.
  1529. *
  1530. * @note ::ble_gap_privacy_params_t::p_device_irk must be initialized to NULL or a valid address before this function is called.
  1531. * If it is initialized to a valid address, the address pointed to will contain the current device IRK on return.
  1532. *
  1533. * @param[in,out] p_privacy_params Privacy settings.
  1534. *
  1535. * @retval ::NRF_SUCCESS Privacy settings read.
  1536. * @retval ::NRF_ERROR_INVALID_ADDR The pointer given for returning the privacy settings may be NULL or invalid.
  1537. * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
  1538. */
  1539. SVCALL(SD_BLE_GAP_PRIVACY_GET, uint32_t, sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params));
  1540. /**@brief Configure an advertising set. Set, clear or update advertising and scan response data.
  1541. *
  1542. * @note The format of the advertising data will be checked by this call to ensure interoperability.
  1543. * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
  1544. * duplicating the local name in the advertising data and scan response data.
  1545. *
  1546. * @note In order to update advertising data while advertising, new advertising buffers must be provided.
  1547. *
  1548. * @mscs
  1549. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1550. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1551. * @endmscs
  1552. *
  1553. * @param[in,out] p_adv_handle Provide a pointer to a handle containing @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to configure
  1554. * a new advertising set. On success, a new handle is then returned through the pointer.
  1555. * Provide a pointer to an existing advertising handle to configure an existing advertising set.
  1556. * @param[in] p_adv_data Advertising data. If set to NULL, no advertising data will be used. See @ref ble_gap_adv_data_t.
  1557. * @param[in] p_adv_params Advertising parameters. When this function is used to update advertising data while advertising,
  1558. * this parameter must be NULL. See @ref ble_gap_adv_params_t.
  1559. *
  1560. * @retval ::NRF_SUCCESS Advertising set successfully configured.
  1561. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied:
  1562. * - Invalid advertising data configuration specified. See @ref ble_gap_adv_data_t.
  1563. * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t.
  1564. * - Use of whitelist requested but whitelist has not been set,
  1565. * see @ref sd_ble_gap_whitelist_set.
  1566. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR ble_gap_adv_params_t::p_peer_addr is invalid.
  1567. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1568. * - It is invalid to provide non-NULL advertising set parameters while advertising.
  1569. * - It is invalid to provide the same data buffers while advertising. To update
  1570. * advertising data, provide new advertising buffers.
  1571. * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible.
  1572. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. Use @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to
  1573. * configure a new advertising handle.
  1574. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1575. * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied.
  1576. * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied. Check the advertising data format specification
  1577. * given in Bluetooth Specification Version 5.0, Volume 3, Part C, Chapter 11.
  1578. * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied.
  1579. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data length or advertising parameter configuration.
  1580. * @retval ::NRF_ERROR_NO_MEM Not enough memory to configure a new advertising handle. Update an
  1581. * existing advertising handle instead.
  1582. * @retval ::BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied.
  1583. */
  1584. 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));
  1585. /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  1586. *
  1587. * @note Only one advertiser may be active at any time.
  1588. *
  1589. * @events
  1590. * @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.}
  1591. * @event{@ref BLE_GAP_EVT_ADV_SET_TERMINATED, Advertising set has terminated.}
  1592. * @event{@ref BLE_GAP_EVT_SCAN_REQ_REPORT, A scan request was received.}
  1593. * @endevents
  1594. *
  1595. * @mscs
  1596. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1597. * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC}
  1598. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1599. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1600. * @endmscs
  1601. *
  1602. * @param[in] adv_handle Advertising handle to advertise on, received from @ref sd_ble_gap_adv_set_configure.
  1603. * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or
  1604. * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. For non-connectable
  1605. * advertising, this is ignored.
  1606. *
  1607. * @retval ::NRF_SUCCESS The BLE stack has started advertising.
  1608. * @retval ::NRF_ERROR_INVALID_STATE adv_handle is not configured or already advertising.
  1609. * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached; connectable advertiser cannot be started.
  1610. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. Configure a new adveriting handle with @ref sd_ble_gap_adv_set_configure.
  1611. * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found.
  1612. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied:
  1613. * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t.
  1614. * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set.
  1615. * @retval ::NRF_ERROR_RESOURCES Either:
  1616. * - adv_handle is configured with connectable advertising, but the event_length parameter
  1617. * associated with conn_cfg_tag is too small to be able to establish a connection on
  1618. * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length.
  1619. * - Not enough BLE role slots available.
  1620. Stop one or more currently active roles (Central, Peripheral, Broadcaster or Observer) and try again.
  1621. * - p_adv_params is configured with connectable advertising, but the event_length parameter
  1622. * associated with conn_cfg_tag is too small to be able to establish a connection on
  1623. * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length.
  1624. */
  1625. SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag));
  1626. /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  1627. *
  1628. * @mscs
  1629. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1630. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1631. * @endmscs
  1632. *
  1633. * @param[in] adv_handle The advertising handle that should stop advertising.
  1634. *
  1635. * @retval ::NRF_SUCCESS The BLE stack has stopped advertising.
  1636. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Invalid advertising handle.
  1637. * @retval ::NRF_ERROR_INVALID_STATE The advertising handle is not advertising.
  1638. */
  1639. SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle));
  1640. /**@brief Update connection parameters.
  1641. *
  1642. * @details In the central role this will initiate a Link Layer connection parameter update procedure,
  1643. * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for
  1644. * the central to perform the procedure. In both cases, and regardless of success or failure, the application
  1645. * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event.
  1646. *
  1647. * @details This function can be used as a central both to reply to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST or to start the procedure unrequested.
  1648. *
  1649. * @events
  1650. * @event{@ref BLE_GAP_EVT_CONN_PARAM_UPDATE, Result of the connection parameter update procedure.}
  1651. * @endevents
  1652. *
  1653. * @mscs
  1654. * @mmsc{@ref BLE_GAP_CPU_MSC}
  1655. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  1656. * @mmsc{@ref BLE_GAP_MULTILINK_CPU_MSC}
  1657. * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC}
  1658. * @mmsc{@ref BLE_GAP_CENTRAL_CPU_MSC}
  1659. * @endmscs
  1660. *
  1661. * @param[in] conn_handle Connection handle.
  1662. * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role,
  1663. * the parameters in the PPCP characteristic of the GAP service will be used instead.
  1664. * If NULL is provided on a central role and in response to a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST, the peripheral request will be rejected
  1665. *
  1666. * @retval ::NRF_SUCCESS The Connection Update procedure has been started successfully.
  1667. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1668. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
  1669. * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established.
  1670. * @retval ::NRF_ERROR_BUSY Procedure already in progress, wait for pending procedures to complete and retry.
  1671. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1672. * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
  1673. */
  1674. 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));
  1675. /**@brief Disconnect (GAP Link Termination).
  1676. *
  1677. * @details This call initiates the disconnection procedure, and its completion will be communicated to the application
  1678. * with a @ref BLE_GAP_EVT_DISCONNECTED event.
  1679. *
  1680. * @events
  1681. * @event{@ref BLE_GAP_EVT_DISCONNECTED, Generated when disconnection procedure is complete.}
  1682. * @endevents
  1683. *
  1684. * @mscs
  1685. * @mmsc{@ref BLE_GAP_CONN_MSC}
  1686. * @endmscs
  1687. *
  1688. * @param[in] conn_handle Connection handle.
  1689. * @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).
  1690. *
  1691. * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully.
  1692. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1693. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1694. * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established.
  1695. */
  1696. SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
  1697. /**@brief Set the radio's transmit power.
  1698. *
  1699. * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for
  1700. * possible roles.
  1701. * @param[in] handle The handle parameter is interpreted depending on role:
  1702. * - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle.
  1703. * - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle,
  1704. * will use the specified transmit power, and include it in the advertising packet headers if
  1705. * @ref ble_gap_adv_properties_t::include_tx_power set.
  1706. * - For all other roles handle is ignored.
  1707. * @param[in] tx_power Radio transmit power in dBm (see note for accepted values).
  1708. *
  1709. * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +2dBm, +3dBm, +4dBm, +5dBm, +6dBm, +7dBm and +8dBm.
  1710. * @note The initiator will have the same transmit power as the scanner.
  1711. * @note When a connection is created it will inherit the transmit power from the initiator or
  1712. * advertiser leading to the connection.
  1713. *
  1714. * @retval ::NRF_SUCCESS Successfully changed the transmit power.
  1715. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1716. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found.
  1717. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1718. */
  1719. 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));
  1720. /**@brief Set GAP Appearance value.
  1721. *
  1722. * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
  1723. *
  1724. * @retval ::NRF_SUCCESS Appearance value set successfully.
  1725. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1726. */
  1727. SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance));
  1728. /**@brief Get GAP Appearance value.
  1729. *
  1730. * @param[out] p_appearance Pointer to appearance (16-bit) to be filled in, see @ref BLE_APPEARANCES.
  1731. *
  1732. * @retval ::NRF_SUCCESS Appearance value retrieved successfully.
  1733. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1734. */
  1735. SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t *p_appearance));
  1736. /**@brief Set GAP Peripheral Preferred Connection Parameters.
  1737. *
  1738. * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters.
  1739. *
  1740. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully.
  1741. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1742. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1743. */
  1744. SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params));
  1745. /**@brief Get GAP Peripheral Preferred Connection Parameters.
  1746. *
  1747. * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored.
  1748. *
  1749. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully.
  1750. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1751. */
  1752. SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params));
  1753. /**@brief Set GAP device name.
  1754. *
  1755. * @note If the device name is located in application flash memory (see @ref ble_gap_cfg_device_name_t),
  1756. * it cannot be changed. Then @ref NRF_ERROR_FORBIDDEN will be returned.
  1757. *
  1758. * @param[in] p_write_perm Write permissions for the Device Name characteristic, see @ref ble_gap_conn_sec_mode_t.
  1759. * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string.
  1760. * @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).
  1761. *
  1762. * @retval ::NRF_SUCCESS GAP device name and permissions set successfully.
  1763. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1764. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1765. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1766. * @retval ::NRF_ERROR_FORBIDDEN Device name is not writable.
  1767. */
  1768. 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));
  1769. /**@brief Get GAP device name.
  1770. *
  1771. * @note If the device name is longer than the size of the supplied buffer,
  1772. * p_len will return the complete device name length,
  1773. * and not the number of bytes actually returned in p_dev_name.
  1774. * The application may use this information to allocate a suitable buffer size.
  1775. *
  1776. * @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.
  1777. * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output.
  1778. *
  1779. * @retval ::NRF_SUCCESS GAP device name retrieved successfully.
  1780. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1781. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1782. */
  1783. SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t *p_dev_name, uint16_t *p_len));
  1784. /**@brief Initiate the GAP Authentication procedure.
  1785. *
  1786. * @details In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected),
  1787. * otherwise in the peripheral role, an SMP Security Request will be sent.
  1788. *
  1789. * @events
  1790. * @event{Depending on the security parameters set and the packet exchanges with the peer\, the following events may be generated:}
  1791. * @event{@ref BLE_GAP_EVT_SEC_PARAMS_REQUEST}
  1792. * @event{@ref BLE_GAP_EVT_SEC_INFO_REQUEST}
  1793. * @event{@ref BLE_GAP_EVT_PASSKEY_DISPLAY}
  1794. * @event{@ref BLE_GAP_EVT_KEY_PRESSED}
  1795. * @event{@ref BLE_GAP_EVT_AUTH_KEY_REQUEST}
  1796. * @event{@ref BLE_GAP_EVT_LESC_DHKEY_REQUEST}
  1797. * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE}
  1798. * @event{@ref BLE_GAP_EVT_AUTH_STATUS}
  1799. * @event{@ref BLE_GAP_EVT_TIMEOUT}
  1800. * @endevents
  1801. *
  1802. * @mscs
  1803. * @mmsc{@ref BLE_GAP_PERIPH_SEC_REQ_MSC}
  1804. * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC}
  1805. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  1806. * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC}
  1807. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC}
  1808. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC}
  1809. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1810. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1811. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1812. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1813. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1814. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1815. * @endmscs
  1816. *
  1817. * @param[in] conn_handle Connection handle.
  1818. * @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.
  1819. * In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used.
  1820. * In the central role, this pointer may be NULL to reject a Security Request.
  1821. *
  1822. * @retval ::NRF_SUCCESS Successfully initiated authentication procedure.
  1823. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1824. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1825. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1826. * - No link has been established.
  1827. * - An encryption is already executing or queued.
  1828. * @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached.
  1829. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1830. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
  1831. * @retval ::NRF_ERROR_TIMEOUT A SMP timeout has occurred, and further SMP operations on this link is prohibited.
  1832. */
  1833. SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params));
  1834. /**@brief Reply with GAP security parameters.
  1835. *
  1836. * @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.
  1837. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1838. *
  1839. * @events
  1840. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1841. * @endevents
  1842. *
  1843. * @mscs
  1844. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_JW_MSC}
  1845. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_JW_MSC}
  1846. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_PERIPH_MSC}
  1847. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1848. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
  1849. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_CONFIRM_FAIL_MSC}
  1850. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1851. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1852. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1853. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1854. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1855. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_KS_TOO_SMALL_MSC}
  1856. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_APP_ERROR_MSC}
  1857. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_REMOTE_PAIRING_FAIL_MSC}
  1858. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_TIMEOUT_MSC}
  1859. * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC}
  1860. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC}
  1861. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC}
  1862. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1863. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1864. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1865. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1866. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1867. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1868. * @endmscs
  1869. *
  1870. * @param[in] conn_handle Connection handle.
  1871. * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS.
  1872. * @param[in] p_sec_params Pointer to a @ref ble_gap_sec_params_t security parameters structure. In the central role this must be set to NULL, as the parameters have
  1873. * already been provided during a previous call to @ref sd_ble_gap_authenticate.
  1874. * @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
  1875. * will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application
  1876. * upon reception of a @ref BLE_GAP_EVT_AUTH_STATUS event.
  1877. * Note that the SoftDevice expects the application to provide memory for storing the
  1878. * peer's keys. So it must be ensured that the relevant pointers inside this structure are not NULL. The pointers to the local key
  1879. * can, however, be NULL, in which case, the local key data will not be available to the application upon reception of the
  1880. * @ref BLE_GAP_EVT_AUTH_STATUS event.
  1881. *
  1882. * @retval ::NRF_SUCCESS Successfully accepted security parameter from the application.
  1883. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1884. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1885. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1886. * @retval ::NRF_ERROR_INVALID_STATE Security parameters has not been requested.
  1887. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1888. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
  1889. */
  1890. 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));
  1891. /**@brief Reply with an authentication key.
  1892. *
  1893. * @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.
  1894. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1895. *
  1896. * @events
  1897. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1898. * @endevents
  1899. *
  1900. * @mscs
  1901. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1902. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1903. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1904. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1905. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1906. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1907. * @endmscs
  1908. *
  1909. * @param[in] conn_handle Connection handle.
  1910. * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES.
  1911. * @param[in] p_key If key type is @ref BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL.
  1912. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination)
  1913. * or NULL when confirming LE Secure Connections Numeric Comparison.
  1914. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in little-endian format.
  1915. *
  1916. * @retval ::NRF_SUCCESS Authentication key successfully set.
  1917. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1918. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1919. * @retval ::NRF_ERROR_INVALID_STATE Authentication key has not been requested.
  1920. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1921. */
  1922. 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));
  1923. /**@brief Reply with an LE Secure connections DHKey.
  1924. *
  1925. * @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.
  1926. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1927. *
  1928. * @events
  1929. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1930. * @endevents
  1931. *
  1932. * @mscs
  1933. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1934. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1935. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1936. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1937. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1938. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1939. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1940. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1941. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1942. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1943. * @endmscs
  1944. *
  1945. * @param[in] conn_handle Connection handle.
  1946. * @param[in] p_dhkey LE Secure Connections DHKey.
  1947. *
  1948. * @retval ::NRF_SUCCESS DHKey successfully set.
  1949. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1950. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1951. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1952. * - The peer is not authenticated.
  1953. * - The application has not pulled a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event.
  1954. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1955. */
  1956. 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));
  1957. /**@brief Notify the peer of a local keypress.
  1958. *
  1959. * @mscs
  1960. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1961. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1962. * @endmscs
  1963. *
  1964. * @param[in] conn_handle Connection handle.
  1965. * @param[in] kp_not See @ref BLE_GAP_KP_NOT_TYPES.
  1966. *
  1967. * @retval ::NRF_SUCCESS Keypress notification successfully queued for transmission.
  1968. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1969. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1970. * - Authentication key not requested.
  1971. * - Passkey has not been entered.
  1972. * - Keypresses have not been enabled by both peers.
  1973. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1974. * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
  1975. */
  1976. SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not));
  1977. /**@brief Generate a set of OOB data to send to a peer out of band.
  1978. *
  1979. * @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,
  1980. * the one used during connection setup). The application may manually overwrite it with an updated value.
  1981. *
  1982. * @mscs
  1983. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1984. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1985. * @endmscs
  1986. *
  1987. * @param[in] conn_handle Connection handle. Can be @ref BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet.
  1988. * @param[in] p_pk_own LE Secure Connections local P-256 Public Key.
  1989. * @param[out] p_oobd_own The OOB data to be sent out of band to a peer.
  1990. *
  1991. * @retval ::NRF_SUCCESS OOB data successfully generated.
  1992. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1993. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1994. */
  1995. 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));
  1996. /**@brief Provide the OOB data sent/received out of band.
  1997. *
  1998. * @note An authentication procedure with OOB selected as an algorithm must be in progress when calling this function.
  1999. * @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.
  2000. *
  2001. * @events
  2002. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  2003. * @endevents
  2004. *
  2005. * @mscs
  2006. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  2007. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  2008. * @endmscs
  2009. *
  2010. * @param[in] conn_handle Connection handle.
  2011. * @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.
  2012. * Must correspond to @ref ble_gap_sec_params_t::oob flag in @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST.
  2013. * @param[in] p_oobd_peer The OOB data received out of band from a peer or NULL if none received.
  2014. * Must correspond to @ref ble_gap_sec_params_t::oob flag
  2015. * in @ref sd_ble_gap_authenticate in the central role or
  2016. * in @ref sd_ble_gap_sec_params_reply in the peripheral role.
  2017. *
  2018. * @retval ::NRF_SUCCESS OOB data accepted.
  2019. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2020. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  2021. * - Authentication key not requested
  2022. * - Not expecting LESC OOB data
  2023. * - Have not actually exchanged passkeys.
  2024. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2025. */
  2026. 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));
  2027. /**@brief Initiate GAP Encryption procedure.
  2028. *
  2029. * @details In the central role, this function will initiate the encryption procedure using the encryption information provided.
  2030. *
  2031. * @events
  2032. * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE, The connection security has been updated.}
  2033. * @endevents
  2034. *
  2035. * @mscs
  2036. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  2037. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_MSC}
  2038. * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC}
  2039. * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC}
  2040. * @endmscs
  2041. *
  2042. * @param[in] conn_handle Connection handle.
  2043. * @param[in] p_master_id Pointer to a @ref ble_gap_master_id_t master identification structure.
  2044. * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure.
  2045. *
  2046. * @retval ::NRF_SUCCESS Successfully initiated authentication procedure.
  2047. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2048. * @retval ::NRF_ERROR_INVALID_STATE No link has been established.
  2049. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2050. * @retval ::BLE_ERROR_INVALID_ROLE Operation is not supported in the Peripheral role.
  2051. * @retval ::NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, wait for pending procedures to complete and retry.
  2052. */
  2053. SVCALL(SD_BLE_GAP_ENCRYPT, uint32_t, sd_ble_gap_encrypt(uint16_t conn_handle, ble_gap_master_id_t const *p_master_id, ble_gap_enc_info_t const *p_enc_info));
  2054. /**@brief Reply with GAP security information.
  2055. *
  2056. * @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.
  2057. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  2058. * @note Data signing is not yet supported, and p_sign_info must therefore be NULL.
  2059. *
  2060. * @mscs
  2061. * @mmsc{@ref BLE_GAP_PERIPH_ENC_MSC}
  2062. * @endmscs
  2063. *
  2064. * @param[in] conn_handle Connection handle.
  2065. * @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.
  2066. * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t identity information structure. May be NULL to signal none is available.
  2067. * @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.
  2068. *
  2069. * @retval ::NRF_SUCCESS Successfully accepted security information.
  2070. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  2071. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  2072. * - No link has been established.
  2073. * - No @ref BLE_GAP_EVT_SEC_REQUEST pending.
  2074. * - LE long term key requested command not allowed.
  2075. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2076. */
  2077. 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));
  2078. /**@brief Get the current connection security.
  2079. *
  2080. * @param[in] conn_handle Connection handle.
  2081. * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in.
  2082. *
  2083. * @retval ::NRF_SUCCESS Current connection security successfully retrieved.
  2084. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2085. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2086. */
  2087. 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));
  2088. /**@brief Start reporting the received signal strength to the application.
  2089. *
  2090. * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
  2091. *
  2092. * @events
  2093. * @event{@ref BLE_GAP_EVT_RSSI_CHANGED, New RSSI data available. How often the event is generated is
  2094. * dependent on the settings of the <code>threshold_dbm</code>
  2095. * and <code>skip_count</code> input parameters.}
  2096. * @endevents
  2097. *
  2098. * @mscs
  2099. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  2100. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  2101. * @endmscs
  2102. *
  2103. * @param[in] conn_handle Connection handle.
  2104. * @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.
  2105. * @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.
  2106. *
  2107. * @retval ::NRF_SUCCESS Successfully activated RSSI reporting.
  2108. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is already ongoing.
  2109. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2110. */
  2111. 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));
  2112. /**@brief Stop reporting the received signal strength.
  2113. *
  2114. * @note An RSSI change detected before the call but not yet received by the application
  2115. * may be reported after @ref sd_ble_gap_rssi_stop has been called.
  2116. *
  2117. * @mscs
  2118. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  2119. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  2120. * @endmscs
  2121. *
  2122. * @param[in] conn_handle Connection handle.
  2123. *
  2124. * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting.
  2125. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
  2126. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2127. */
  2128. SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle));
  2129. /**@brief Get the received signal strength for the last connection event.
  2130. *
  2131. * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND
  2132. * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start.
  2133. * @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement.
  2134. * @mscs
  2135. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  2136. * @endmscs
  2137. *
  2138. * @param[in] conn_handle Connection handle.
  2139. * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored.
  2140. * @param[out] p_ch_index Pointer to the location where Channel Index for the RSSI measurement shall be stored.
  2141. *
  2142. * @retval ::NRF_SUCCESS Successfully read the RSSI.
  2143. * @retval ::NRF_ERROR_NOT_FOUND No sample is available.
  2144. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2145. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2146. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
  2147. */
  2148. 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));
  2149. /**@brief Start or continue scanning (GAP Discovery procedure, Observer Procedure).
  2150. *
  2151. * @note A call to this function will require the application to keep the memory pointed by
  2152. * p_adv_report_buffer alive until the buffer is released. The buffer is released when the scanner is stopped
  2153. * or when this function is called with another buffer.
  2154. *
  2155. * @note The scanner will automatically stop in the following cases:
  2156. * - @ref sd_ble_gap_scan_stop is called.
  2157. * - @ref sd_ble_gap_connect is called.
  2158. * - A @ref BLE_GAP_EVT_TIMEOUT with source set to @ref BLE_GAP_TIMEOUT_SRC_SCAN is received.
  2159. * - When a @ref BLE_GAP_EVT_ADV_REPORT event is received and @ref ble_gap_adv_report_type_t::status is not set to
  2160. * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. In this case scanning is only paused to let the application
  2161. * access received data. The application must call this function to continue scanning, or call @ref sd_ble_gap_scan_stop
  2162. * to stop scanning.
  2163. *
  2164. * @note If a @ref BLE_GAP_EVT_ADV_REPORT event is received with @ref ble_gap_adv_report_type_t::status set to
  2165. * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the scanner will continue scanning, and the application will
  2166. * receive more reports from this advertising event. The following reports will include the old and new received data.
  2167. *
  2168. * @events
  2169. * @event{@ref BLE_GAP_EVT_ADV_REPORT, An advertising or scan response packet has been received.}
  2170. * @event{@ref BLE_GAP_EVT_TIMEOUT, Scanner has timed out.}
  2171. * @endevents
  2172. *
  2173. * @mscs
  2174. * @mmsc{@ref BLE_GAP_SCAN_MSC}
  2175. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  2176. * @endmscs
  2177. *
  2178. * @param[in] p_scan_params Pointer to scan parameters structure. When this function is used to continue
  2179. * scanning, this parameter must be NULL.
  2180. * @param[in] p_adv_report_buffer Pointer to buffer used to store incoming advertising data.
  2181. * The memory pointed to should be kept alive until the scanning is stopped.
  2182. * See @ref BLE_GAP_SCAN_BUFFER_SIZE for minimum and maximum buffer size.
  2183. * If the scanner receives advertising data larger than can be stored in the buffer,
  2184. * a @ref BLE_GAP_EVT_ADV_REPORT will be raised with @ref ble_gap_adv_report_type_t::status
  2185. * set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_TRUNCATED.
  2186. *
  2187. * @retval ::NRF_SUCCESS Successfully initiated scanning procedure.
  2188. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2189. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  2190. * - Scanning is already ongoing and p_scan_params was not NULL
  2191. * - Scanning is not running and p_scan_params was NULL.
  2192. * - The scanner has timed out when this function is called to continue scanning.
  2193. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. See @ref ble_gap_scan_params_t.
  2194. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported parameters supplied. See @ref ble_gap_scan_params_t.
  2195. * @retval ::NRF_ERROR_INVALID_LENGTH The provided buffer length is invalid. See @ref BLE_GAP_SCAN_BUFFER_MIN.
  2196. * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available.
  2197. * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again
  2198. */
  2199. SVCALL(SD_BLE_GAP_SCAN_START, uint32_t, sd_ble_gap_scan_start(ble_gap_scan_params_t const *p_scan_params, ble_data_t const * p_adv_report_buffer));
  2200. /**@brief Stop scanning (GAP Discovery procedure, Observer Procedure).
  2201. *
  2202. * @note The buffer provided in @ref sd_ble_gap_scan_start is released.
  2203. *
  2204. * @mscs
  2205. * @mmsc{@ref BLE_GAP_SCAN_MSC}
  2206. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  2207. * @endmscs
  2208. *
  2209. * @retval ::NRF_SUCCESS Successfully stopped scanning procedure.
  2210. * @retval ::NRF_ERROR_INVALID_STATE Not in the scanning state.
  2211. */
  2212. SVCALL(SD_BLE_GAP_SCAN_STOP, uint32_t, sd_ble_gap_scan_stop(void));
  2213. /**@brief Create a connection (GAP Link Establishment).
  2214. *
  2215. * @note If a scanning procedure is currently in progress it will be automatically stopped when calling this function.
  2216. * The scanning procedure will be stopped even if the function returns an error.
  2217. *
  2218. * @events
  2219. * @event{@ref BLE_GAP_EVT_CONNECTED, A connection was established.}
  2220. * @event{@ref BLE_GAP_EVT_TIMEOUT, Failed to establish a connection.}
  2221. * @endevents
  2222. *
  2223. * @mscs
  2224. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  2225. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC}
  2226. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC}
  2227. * @endmscs
  2228. *
  2229. * @param[in] p_peer_addr Pointer to peer identity address. If @ref ble_gap_scan_params_t::filter_policy is set to use
  2230. * whitelist, then p_peer_addr is ignored.
  2231. * @param[in] p_scan_params Pointer to scan parameters structure.
  2232. * @param[in] p_conn_params Pointer to desired connection parameters.
  2233. * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or
  2234. * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration.
  2235. *
  2236. * @retval ::NRF_SUCCESS Successfully initiated connection procedure.
  2237. * @retval ::NRF_ERROR_INVALID_ADDR Invalid parameter(s) pointer supplied.
  2238. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  2239. * - Invalid parameter(s) in p_scan_params or p_conn_params.
  2240. * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set.
  2241. * - Peer address was not present in the device identity list, see @ref sd_ble_gap_device_identities_set.
  2242. * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found.
  2243. * @retval ::NRF_ERROR_INVALID_STATE The SoftDevice is in an invalid state to perform this operation. This may be due to an
  2244. * existing locally initiated connect procedure, which must complete before initiating again.
  2245. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Peer address.
  2246. * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached.
  2247. * @retval ::NRF_ERROR_RESOURCES Either:
  2248. * - Not enough BLE role slots available.
  2249. * Stop one or more currently active roles (Central, Peripheral or Observer) and try again.
  2250. * - The event_length parameter associated with conn_cfg_tag is too small to be able to
  2251. * establish a connection on the selected @ref ble_gap_scan_params_t::scan_phys.
  2252. * Use @ref sd_ble_cfg_set to increase the event length.
  2253. */
  2254. SVCALL(SD_BLE_GAP_CONNECT, uint32_t, sd_ble_gap_connect(ble_gap_addr_t const *p_peer_addr, ble_gap_scan_params_t const *p_scan_params, ble_gap_conn_params_t const *p_conn_params, uint8_t conn_cfg_tag));
  2255. /**@brief Cancel a connection establishment.
  2256. *
  2257. * @mscs
  2258. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC}
  2259. * @endmscs
  2260. *
  2261. * @retval ::NRF_SUCCESS Successfully canceled an ongoing connection procedure.
  2262. * @retval ::NRF_ERROR_INVALID_STATE No locally initiated connect procedure started or connection
  2263. * completed occurred.
  2264. */
  2265. SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void));
  2266. /**@brief Initiate or respond to a PHY Update Procedure
  2267. *
  2268. * @details This function is used to initiate or respond to a PHY Update Procedure. It will always
  2269. * generate a @ref BLE_GAP_EVT_PHY_UPDATE event if successfully executed.
  2270. * If this function is used to initiate a PHY Update procedure and the only option
  2271. * provided in @ref ble_gap_phys_t::tx_phys and @ref ble_gap_phys_t::rx_phys is the
  2272. * currently active PHYs in the respective directions, the SoftDevice will generate a
  2273. * @ref BLE_GAP_EVT_PHY_UPDATE with the current PHYs set and will not initiate the
  2274. * procedure in the Link Layer.
  2275. *
  2276. * If @ref ble_gap_phys_t::tx_phys or @ref ble_gap_phys_t::rx_phys is @ref BLE_GAP_PHY_AUTO,
  2277. * then the stack will select PHYs based on the peer's PHY preferences and the local link
  2278. * configuration. The PHY Update procedure will for this case result in a PHY combination
  2279. * that respects the time constraints configured with @ref sd_ble_cfg_set and the current
  2280. * link layer data length.
  2281. *
  2282. * When acting as a central, the SoftDevice will select the fastest common PHY in each direction.
  2283. *
  2284. * If the peer does not support the PHY Update Procedure, then the resulting
  2285. * @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to
  2286. * @ref BLE_HCI_UNSUPPORTED_REMOTE_FEATURE.
  2287. *
  2288. * If the PHY procedure was rejected by the peer due to a procedure collision, the status
  2289. * will be @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or
  2290. * @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION.
  2291. * If the peer responds to the PHY Update procedure with invalid parameters, the status
  2292. * will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS.
  2293. * If the PHY procedure was rejected by the peer for a different reason, the status will
  2294. * contain the reason as specified by the peer.
  2295. *
  2296. * @events
  2297. * @event{@ref BLE_GAP_EVT_PHY_UPDATE, Result of the PHY Update Procedure.}
  2298. * @endevents
  2299. *
  2300. * @mscs
  2301. * @mmsc{@ref BLE_GAP_CENTRAL_PHY_UPDATE}
  2302. * @mmsc{@ref BLE_GAP_PERIPHERAL_PHY_UPDATE}
  2303. * @endmscs
  2304. *
  2305. * @param[in] conn_handle Connection handle to indicate the connection for which the PHY Update is requested.
  2306. * @param[in] p_gap_phys Pointer to PHY structure.
  2307. *
  2308. * @retval ::NRF_SUCCESS Successfully requested a PHY Update.
  2309. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2310. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2311. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  2312. * @retval ::NRF_ERROR_INVALID_STATE No link has been established.
  2313. * @retval ::NRF_ERROR_RESOURCES The connection event length configured for this link is not sufficient for the combination of
  2314. * @ref ble_gap_phys_t::tx_phys, @ref ble_gap_phys_t::rx_phys, and @ref ble_gap_data_length_params_t.
  2315. * The connection event length is configured with @ref BLE_CONN_CFG_GAP using @ref sd_ble_cfg_set.
  2316. * @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.
  2317. *
  2318. */
  2319. 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));
  2320. /**@brief Initiate or respond to a Data Length Update Procedure.
  2321. *
  2322. * @note If the application uses @ref BLE_GAP_DATA_LENGTH_AUTO for one or more members of
  2323. * p_dl_params, the SoftDevice will choose the highest value supported in current
  2324. * configuration and connection parameters.
  2325. * @note If the link PHY is Coded, the SoftDevice will ensure that the MaxTxTime and/or MaxRxTime
  2326. * used in the Data Length Update procedure is at least 2704 us. Otherwise, MaxTxTime and
  2327. * MaxRxTime will be limited to maximum 2120 us.
  2328. *
  2329. * @param[in] conn_handle Connection handle.
  2330. * @param[in] p_dl_params Pointer to local parameters to be used in Data Length Update
  2331. * Procedure. Set any member to @ref BLE_GAP_DATA_LENGTH_AUTO to let
  2332. * the SoftDevice automatically decide the value for that member.
  2333. * Set to NULL to use automatic values for all members.
  2334. * @param[out] p_dl_limitation Pointer to limitation to be written when local device does not
  2335. * have enough resources or does not support the requested Data Length
  2336. * Update parameters. Ignored if NULL.
  2337. *
  2338. * @mscs
  2339. * @mmsc{@ref BLE_GAP_DATA_LENGTH_UPDATE_PROCEDURE_MSC}
  2340. * @endmscs
  2341. *
  2342. * @retval ::NRF_SUCCESS Successfully set Data Length Extension initiation/response parameters.
  2343. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2344. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied.
  2345. * @retval ::NRF_ERROR_INVALID_STATE No link has been established.
  2346. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied.
  2347. * @retval ::NRF_ERROR_NOT_SUPPORTED The requested parameters are not supported by the SoftDevice. Inspect
  2348. * p_dl_limitation to see which parameter is not supported.
  2349. * @retval ::NRF_ERROR_RESOURCES The connection event length configured for this link is not sufficient for the requested parameters.
  2350. * Use @ref sd_ble_cfg_set with @ref BLE_CONN_CFG_GAP to increase the connection event length.
  2351. * Inspect p_dl_limitation to see where the limitation is.
  2352. * @retval ::NRF_ERROR_BUSY Peer has already initiated a Data Length Update Procedure. Process the
  2353. * pending @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST event to respond.
  2354. */
  2355. SVCALL(SD_BLE_GAP_DATA_LENGTH_UPDATE, uint32_t, sd_ble_gap_data_length_update(uint16_t conn_handle, ble_gap_data_length_params_t const *p_dl_params, ble_gap_data_length_limitation_t *p_dl_limitation));
  2356. /**@brief Start the Quality of Service (QoS) channel survey module.
  2357. *
  2358. * @details The channel survey module provides measurements of the energy levels on
  2359. * the Bluetooth Low Energy channels. When the module is enabled, @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT
  2360. * events will periodically report the measured energy levels for each channel.
  2361. *
  2362. * @note The measurements are scheduled with lower priority than other Bluetooth Low Energy roles,
  2363. * Radio Timeslot API events and Flash API events.
  2364. *
  2365. * @note The channel survey module will attempt to do measurements so that the average interval
  2366. * between measurements will be interval_us. However due to the channel survey module
  2367. * having the lowest priority of all roles and modules, this may not be possible. In that
  2368. * case fewer than expected channel survey reports may be given.
  2369. *
  2370. * @note In order to use the channel survey module, @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available
  2371. * must be set. This is done using @ref sd_ble_cfg_set.
  2372. *
  2373. * @param[in] interval_us Requested average interval for the measurements and reports. See
  2374. * @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVALS for valid ranges. If set
  2375. * to @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_CONTINUOUS, the channel
  2376. * survey role will be scheduled at every available opportunity.
  2377. *
  2378. * @retval ::NRF_SUCCESS The module is successfully started.
  2379. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter supplied. interval_us is out of the
  2380. * allowed range.
  2381. * @retval ::NRF_ERROR_INVALID_STATE Trying to start the module when already running.
  2382. * @retval ::NRF_ERROR_RESOURCES The channel survey module is not available to the application.
  2383. * Set @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available using
  2384. * @ref sd_ble_cfg_set.
  2385. */
  2386. SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START, uint32_t, sd_ble_gap_qos_channel_survey_start(uint32_t interval_us));
  2387. /**@brief Stop the Quality of Service (QoS) channel survey module.
  2388. *
  2389. * @retval ::NRF_SUCCESS The module is successfully stopped.
  2390. * @retval ::NRF_ERROR_INVALID_STATE Trying to stop the module when it is not running.
  2391. */
  2392. SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP, uint32_t, sd_ble_gap_qos_channel_survey_stop(void));
  2393. /** @} */
  2394. #ifdef __cplusplus
  2395. }
  2396. #endif
  2397. #endif // BLE_GAP_H__
  2398. /**
  2399. @}
  2400. */