ble_gap.h 164 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691
  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
  758. bitfield indicates the PHYs on where a connection may be initiated.
  759. If scan_phys contains @ref BLE_GAP_PHY_1MBPS and/or @ref BLE_GAP_PHY_2MBPS,
  760. the primary scan PHY is @ref BLE_GAP_PHY_1MBPS.
  761. If scan_phys also contains @ref BLE_GAP_PHY_CODED, the primary scan
  762. PHY will also contain @ref BLE_GAP_PHY_CODED. If the only scan PHY is
  763. @ref BLE_GAP_PHY_CODED, the primary scan PHY is
  764. @ref BLE_GAP_PHY_CODED only. */
  765. uint16_t interval; /**< Scan interval in 625 us units. @sa BLE_GAP_SCAN_INTERVALS. */
  766. uint16_t window; /**< Scan window in 625 us units. @sa BLE_GAP_SCAN_WINDOW.
  767. If scan_phys contains both @ref BLE_GAP_PHY_1MBPS and
  768. @ref BLE_GAP_PHY_CODED interval shall be larger than or
  769. equal to twice the scan window. */
  770. uint16_t timeout; /**< Scan timeout in 10 ms units. @sa BLE_GAP_SCAN_TIMEOUT. */
  771. ble_gap_ch_mask_t channel_mask; /**< Channel mask for primary and secondary advertising channels.
  772. At least one of the primary channels, that is channel index 37-39, must be
  773. set to 0.
  774. Masking away secondary channels is not supported. */
  775. } ble_gap_scan_params_t;
  776. /**@brief Privacy.
  777. *
  778. * The privacy feature provides a way for the device to avoid being tracked over a period of time.
  779. * The privacy feature, when enabled, hides the local device identity and replaces it with a private address
  780. * that is automatically refreshed at a specified interval.
  781. *
  782. * If a device still wants to be recognized by other peers, it needs to share it's Identity Resolving Key (IRK).
  783. * With this key, a device can generate a random private address that can only be recognized by peers in possession of that key,
  784. * and devices can establish connections without revealing their real identities.
  785. *
  786. * Both network privacy (@ref BLE_GAP_PRIVACY_MODE_NETWORK_PRIVACY) and device privacy (@ref BLE_GAP_PRIVACY_MODE_DEVICE_PRIVACY)
  787. * are supported.
  788. *
  789. * @note If the device IRK is updated, the new IRK becomes the one to be distributed in all
  790. * bonding procedures performed after @ref sd_ble_gap_privacy_set returns.
  791. * The IRK distributed during bonding procedure is the device IRK that is active when @ref sd_ble_gap_sec_params_reply is called.
  792. */
  793. typedef struct
  794. {
  795. uint8_t privacy_mode; /**< Privacy mode, see @ref BLE_GAP_PRIVACY_MODES. Default is @ref BLE_GAP_PRIVACY_MODE_OFF. */
  796. 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. */
  797. 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. */
  798. 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.
  799. When used as output, pointer to IRK structure where the current default IRK will be written to. If NULL, this argument is ignored.
  800. By default, the default IRK is used to generate random private resolvable addresses for the local device unless instructed otherwise. */
  801. } ble_gap_privacy_params_t;
  802. /**@brief PHY preferences for TX and RX
  803. * @note tx_phys and rx_phys are bit fields. Multiple bits can be set in them to indicate multiple preferred PHYs for each direction.
  804. * @code
  805. * p_gap_phys->tx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS;
  806. * p_gap_phys->rx_phys = BLE_GAP_PHY_1MBPS | BLE_GAP_PHY_2MBPS;
  807. * @endcode
  808. *
  809. */
  810. typedef struct
  811. {
  812. uint8_t tx_phys; /**< Preferred transmit PHYs, see @ref BLE_GAP_PHYS. */
  813. uint8_t rx_phys; /**< Preferred receive PHYs, see @ref BLE_GAP_PHYS. */
  814. } ble_gap_phys_t;
  815. /** @brief Keys that can be exchanged during a bonding procedure. */
  816. typedef struct
  817. {
  818. uint8_t enc : 1; /**< Long Term Key and Master Identification. */
  819. uint8_t id : 1; /**< Identity Resolving Key and Identity Address Information. */
  820. uint8_t sign : 1; /**< Connection Signature Resolving Key. */
  821. uint8_t link : 1; /**< Derive the Link Key from the LTK. */
  822. } ble_gap_sec_kdist_t;
  823. /**@brief GAP security parameters. */
  824. typedef struct
  825. {
  826. uint8_t bond : 1; /**< Perform bonding. */
  827. uint8_t mitm : 1; /**< Enable Man In The Middle protection. */
  828. uint8_t lesc : 1; /**< Enable LE Secure Connection pairing. */
  829. uint8_t keypress : 1; /**< Enable generation of keypress notifications. */
  830. uint8_t io_caps : 3; /**< IO capabilities, see @ref BLE_GAP_IO_CAPS. */
  831. uint8_t oob : 1; /**< The OOB data flag.
  832. - In LE legacy pairing, this flag is set if a device has out of band authentication data.
  833. The OOB method is used if both of the devices have out of band authentication data.
  834. - In LE Secure Connections pairing, this flag is set if a device has the peer device's out of band authentication data.
  835. The OOB method is used if at least one device has the peer device's OOB data available. */
  836. uint8_t min_key_size; /**< Minimum encryption key size in octets between 7 and 16. If 0 then not applicable in this instance. */
  837. uint8_t max_key_size; /**< Maximum encryption key size in octets between min_key_size and 16. */
  838. ble_gap_sec_kdist_t kdist_own; /**< Key distribution bitmap: keys that the local device will distribute. */
  839. ble_gap_sec_kdist_t kdist_peer; /**< Key distribution bitmap: keys that the remote device will distribute. */
  840. } ble_gap_sec_params_t;
  841. /**@brief GAP Encryption Information. */
  842. typedef struct
  843. {
  844. uint8_t ltk[BLE_GAP_SEC_KEY_LEN]; /**< Long Term Key. */
  845. uint8_t lesc : 1; /**< Key generated using LE Secure Connections. */
  846. uint8_t auth : 1; /**< Authenticated Key. */
  847. uint8_t ltk_len : 6; /**< LTK length in octets. */
  848. } ble_gap_enc_info_t;
  849. /**@brief GAP Master Identification. */
  850. typedef struct
  851. {
  852. uint16_t ediv; /**< Encrypted Diversifier. */
  853. uint8_t rand[BLE_GAP_SEC_RAND_LEN]; /**< Random Number. */
  854. } ble_gap_master_id_t;
  855. /**@brief GAP Signing Information. */
  856. typedef struct
  857. {
  858. uint8_t csrk[BLE_GAP_SEC_KEY_LEN]; /**< Connection Signature Resolving Key. */
  859. } ble_gap_sign_info_t;
  860. /**@brief GAP LE Secure Connections P-256 Public Key. */
  861. typedef struct
  862. {
  863. 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. */
  864. } ble_gap_lesc_p256_pk_t;
  865. /**@brief GAP LE Secure Connections DHKey. */
  866. typedef struct
  867. {
  868. uint8_t key[BLE_GAP_LESC_DHKEY_LEN]; /**< LE Secure Connections Elliptic Curve Diffie-Hellman Key. Stored in little-endian. */
  869. } ble_gap_lesc_dhkey_t;
  870. /**@brief GAP LE Secure Connections OOB data. */
  871. typedef struct
  872. {
  873. ble_gap_addr_t addr; /**< Bluetooth address of the device. */
  874. uint8_t r[BLE_GAP_SEC_KEY_LEN]; /**< Random Number. */
  875. uint8_t c[BLE_GAP_SEC_KEY_LEN]; /**< Confirm Value. */
  876. } ble_gap_lesc_oob_data_t;
  877. /**@brief Event structure for @ref BLE_GAP_EVT_CONNECTED. */
  878. typedef struct
  879. {
  880. 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
  881. and the address is the device's identity address. */
  882. uint8_t role; /**< BLE role for this connection, see @ref BLE_GAP_ROLES */
  883. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  884. uint8_t adv_handle; /**< Advertising handle in which advertising has ended.
  885. This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */
  886. ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated
  887. advertising set. The advertising buffers provided in
  888. @ref sd_ble_gap_adv_set_configure are now released.
  889. This variable is only set if role is set to @ref BLE_GAP_ROLE_PERIPH. */
  890. } ble_gap_evt_connected_t;
  891. /**@brief Event structure for @ref BLE_GAP_EVT_DISCONNECTED. */
  892. typedef struct
  893. {
  894. uint8_t reason; /**< HCI error code, see @ref BLE_HCI_STATUS_CODES. */
  895. } ble_gap_evt_disconnected_t;
  896. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE. */
  897. typedef struct
  898. {
  899. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  900. } ble_gap_evt_conn_param_update_t;
  901. /**@brief Event structure for @ref BLE_GAP_EVT_PHY_UPDATE_REQUEST. */
  902. typedef struct
  903. {
  904. ble_gap_phys_t peer_preferred_phys; /**< The PHYs the peer prefers to use. */
  905. } ble_gap_evt_phy_update_request_t;
  906. /**@brief Event Structure for @ref BLE_GAP_EVT_PHY_UPDATE. */
  907. typedef struct
  908. {
  909. uint8_t status; /**< Status of the procedure, see @ref BLE_HCI_STATUS_CODES.*/
  910. uint8_t tx_phy; /**< TX PHY for this connection, see @ref BLE_GAP_PHYS. */
  911. uint8_t rx_phy; /**< RX PHY for this connection, see @ref BLE_GAP_PHYS. */
  912. } ble_gap_evt_phy_update_t;
  913. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST. */
  914. typedef struct
  915. {
  916. ble_gap_sec_params_t peer_params; /**< Initiator Security Parameters. */
  917. } ble_gap_evt_sec_params_request_t;
  918. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_INFO_REQUEST. */
  919. typedef struct
  920. {
  921. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. */
  922. ble_gap_master_id_t master_id; /**< Master Identification for LTK lookup. */
  923. uint8_t enc_info : 1; /**< If 1, Encryption Information required. */
  924. uint8_t id_info : 1; /**< If 1, Identity Information required. */
  925. uint8_t sign_info : 1; /**< If 1, Signing Information required. */
  926. } ble_gap_evt_sec_info_request_t;
  927. /**@brief Event structure for @ref BLE_GAP_EVT_PASSKEY_DISPLAY. */
  928. typedef struct
  929. {
  930. uint8_t passkey[BLE_GAP_PASSKEY_LEN]; /**< 6-digit passkey in ASCII ('0'-'9' digits only). */
  931. uint8_t match_request : 1; /**< If 1 requires the application to report the match using @ref sd_ble_gap_auth_key_reply
  932. with either @ref BLE_GAP_AUTH_KEY_TYPE_NONE if there is no match or
  933. @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY if there is a match. */
  934. } ble_gap_evt_passkey_display_t;
  935. /**@brief Event structure for @ref BLE_GAP_EVT_KEY_PRESSED. */
  936. typedef struct
  937. {
  938. uint8_t kp_not; /**< Keypress notification type, see @ref BLE_GAP_KP_NOT_TYPES. */
  939. } ble_gap_evt_key_pressed_t;
  940. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_KEY_REQUEST. */
  941. typedef struct
  942. {
  943. uint8_t key_type; /**< See @ref BLE_GAP_AUTH_KEY_TYPES. */
  944. } ble_gap_evt_auth_key_request_t;
  945. /**@brief Event structure for @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST. */
  946. typedef struct
  947. {
  948. 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
  949. inside the keyset during the call to @ref sd_ble_gap_sec_params_reply. */
  950. 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. */
  951. } ble_gap_evt_lesc_dhkey_request_t;
  952. /**@brief Security levels supported.
  953. * @note See Bluetooth Specification Version 4.2 Volume 3, Part C, Chapter 10, Section 10.2.1.
  954. */
  955. typedef struct
  956. {
  957. uint8_t lv1 : 1; /**< If 1: Level 1 is supported. */
  958. uint8_t lv2 : 1; /**< If 1: Level 2 is supported. */
  959. uint8_t lv3 : 1; /**< If 1: Level 3 is supported. */
  960. uint8_t lv4 : 1; /**< If 1: Level 4 is supported. */
  961. } ble_gap_sec_levels_t;
  962. /**@brief Encryption Key. */
  963. typedef struct
  964. {
  965. ble_gap_enc_info_t enc_info; /**< Encryption Information. */
  966. ble_gap_master_id_t master_id; /**< Master Identification. */
  967. } ble_gap_enc_key_t;
  968. /**@brief Identity Key. */
  969. typedef struct
  970. {
  971. ble_gap_irk_t id_info; /**< Identity Resolving Key. */
  972. ble_gap_addr_t id_addr_info; /**< Identity Address. */
  973. } ble_gap_id_key_t;
  974. /**@brief Security Keys. */
  975. typedef struct
  976. {
  977. ble_gap_enc_key_t *p_enc_key; /**< Encryption Key, or NULL. */
  978. ble_gap_id_key_t *p_id_key; /**< Identity Key, or NULL. */
  979. ble_gap_sign_info_t *p_sign_key; /**< Signing Key, or NULL. */
  980. 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
  981. in the Core Bluetooth Specification v4.2 Vol.3, Part H, Section 2.3.5.6.1 */
  982. } ble_gap_sec_keys_t;
  983. /**@brief Security key set for both local and peer keys. */
  984. typedef struct
  985. {
  986. 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. */
  987. ble_gap_sec_keys_t keys_peer; /**< Keys distributed by the remote device. For LE Secure Connections, p_enc_key must always be NULL. */
  988. } ble_gap_sec_keyset_t;
  989. /**@brief Data Length Update Procedure parameters. */
  990. typedef struct
  991. {
  992. uint16_t max_tx_octets; /**< Maximum number of payload octets that a Controller supports for transmission of a single Link Layer Data Channel PDU. */
  993. uint16_t max_rx_octets; /**< Maximum number of payload octets that a Controller supports for reception of a single Link Layer Data Channel PDU. */
  994. uint16_t max_tx_time_us; /**< Maximum time, in microseconds, that a Controller supports for transmission of a single Link Layer Data Channel PDU. */
  995. uint16_t max_rx_time_us; /**< Maximum time, in microseconds, that a Controller supports for reception of a single Link Layer Data Channel PDU. */
  996. } ble_gap_data_length_params_t;
  997. /**@brief Data Length Update Procedure local limitation. */
  998. typedef struct
  999. {
  1000. uint16_t tx_payload_limited_octets; /**< If > 0, the requested TX packet length is too long by this many octets. */
  1001. uint16_t rx_payload_limited_octets; /**< If > 0, the requested RX packet length is too long by this many octets. */
  1002. 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. */
  1003. } ble_gap_data_length_limitation_t;
  1004. /**@brief Event structure for @ref BLE_GAP_EVT_AUTH_STATUS. */
  1005. typedef struct
  1006. {
  1007. uint8_t auth_status; /**< Authentication status, see @ref BLE_GAP_SEC_STATUS. */
  1008. uint8_t error_src : 2; /**< On error, source that caused the failure, see @ref BLE_GAP_SEC_STATUS_SOURCES. */
  1009. uint8_t bonded : 1; /**< Procedure resulted in a bond. */
  1010. uint8_t lesc : 1; /**< Procedure resulted in a LE Secure Connection. */
  1011. ble_gap_sec_levels_t sm1_levels; /**< Levels supported in Security Mode 1. */
  1012. ble_gap_sec_levels_t sm2_levels; /**< Levels supported in Security Mode 2. */
  1013. 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. */
  1014. 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. */
  1015. } ble_gap_evt_auth_status_t;
  1016. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_SEC_UPDATE. */
  1017. typedef struct
  1018. {
  1019. ble_gap_conn_sec_t conn_sec; /**< Connection security level. */
  1020. } ble_gap_evt_conn_sec_update_t;
  1021. /**@brief Event structure for @ref BLE_GAP_EVT_TIMEOUT. */
  1022. typedef struct
  1023. {
  1024. uint8_t src; /**< Source of timeout event, see @ref BLE_GAP_TIMEOUT_SOURCES. */
  1025. union
  1026. {
  1027. ble_data_t adv_report_buffer; /**< If source is set to @ref BLE_GAP_TIMEOUT_SRC_SCAN, the released
  1028. scan buffer is contained in this field. */
  1029. } params; /**< Event Parameters. */
  1030. } ble_gap_evt_timeout_t;
  1031. /**@brief Event structure for @ref BLE_GAP_EVT_RSSI_CHANGED. */
  1032. typedef struct
  1033. {
  1034. int8_t rssi; /**< Received Signal Strength Indication in dBm.
  1035. @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement. */
  1036. uint8_t ch_index; /**< Data Channel Index on which the Signal Strength is measured (0-36). */
  1037. } ble_gap_evt_rssi_changed_t;
  1038. /**@brief Event structure for @ref BLE_GAP_EVT_ADV_SET_TERMINATED */
  1039. typedef struct
  1040. {
  1041. uint8_t reason; /**< Reason for why the advertising set terminated. See
  1042. @ref BLE_GAP_EVT_ADV_SET_TERMINATED_REASON. */
  1043. uint8_t adv_handle; /**< Advertising handle in which advertising has ended. */
  1044. uint8_t num_completed_adv_events; /**< If @ref ble_gap_adv_params_t::max_adv_evts was not set to 0,
  1045. this field indicates the number of completed advertising events. */
  1046. ble_gap_adv_data_t adv_data; /**< Advertising buffers corresponding to the terminated
  1047. advertising set. The advertising buffers provided in
  1048. @ref sd_ble_gap_adv_set_configure are now released. */
  1049. } ble_gap_evt_adv_set_terminated_t;
  1050. /**@brief Event structure for @ref BLE_GAP_EVT_ADV_REPORT.
  1051. *
  1052. * @note If @ref ble_gap_adv_report_type_t::status is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA,
  1053. * not all fields in the advertising report may be available.
  1054. *
  1055. * @note When ble_gap_adv_report_type_t::status is not set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA,
  1056. * scanning will be paused. To continue scanning, call @ref sd_ble_gap_scan_start.
  1057. */
  1058. typedef struct
  1059. {
  1060. ble_gap_adv_report_type_t type; /**< Advertising report type. See @ref ble_gap_adv_report_type_t. */
  1061. ble_gap_addr_t peer_addr; /**< Bluetooth address of the peer device. If the peer_addr is resolved:
  1062. @ref ble_gap_addr_t::addr_id_peer is set to 1 and the address is the
  1063. peer's identity address. */
  1064. ble_gap_addr_t direct_addr; /**< Contains the target address of the advertising event if
  1065. @ref ble_gap_adv_report_type_t::directed is set to 1. If the
  1066. SoftDevice was able to resolve the address,
  1067. @ref ble_gap_addr_t::addr_id_peer is set to 1 and the direct_addr
  1068. contains the local identity address. If the target address of the
  1069. advertising event is @ref BLE_GAP_ADDR_TYPE_RANDOM_PRIVATE_RESOLVABLE,
  1070. and the SoftDevice was unable to resolve it, the application may try
  1071. to resolve this address to find out if the advertising event was
  1072. directed to us. */
  1073. uint8_t primary_phy; /**< Indicates the PHY on which the primary advertising packet was received.
  1074. See @ref BLE_GAP_PHYS. */
  1075. uint8_t secondary_phy; /**< Indicates the PHY on which the secondary advertising packet was received.
  1076. See @ref BLE_GAP_PHYS. This field is set to @ref BLE_GAP_PHY_NOT_SET if no packets
  1077. were received on a secondary advertising channel. */
  1078. int8_t tx_power; /**< TX Power reported by the advertiser in the last packet header received.
  1079. This field is set to @ref BLE_GAP_POWER_LEVEL_INVALID if the
  1080. last received packet did not contain the Tx Power field.
  1081. @note TX Power is only included in extended advertising packets. */
  1082. int8_t rssi; /**< Received Signal Strength Indication in dBm of the last packet received.
  1083. @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement. */
  1084. uint8_t ch_index; /**< Channel Index on which the last advertising packet is received (0-39). */
  1085. uint8_t set_id; /**< Set ID of the received advertising data. Set ID is not present
  1086. if set to @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */
  1087. uint16_t data_id:12; /**< The advertising data ID of the received advertising data. Data ID
  1088. is not present if @ref ble_gap_evt_adv_report_t::set_id is set to
  1089. @ref BLE_GAP_ADV_REPORT_SET_ID_NOT_AVAILABLE. */
  1090. ble_data_t data; /**< Received advertising or scan response data. If
  1091. @ref ble_gap_adv_report_type_t::status is not set to
  1092. @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the data buffer provided
  1093. in @ref sd_ble_gap_scan_start is now released. */
  1094. ble_gap_aux_pointer_t aux_pointer; /**< The offset and PHY of the next advertising packet in this extended advertising
  1095. event. @note This field is only set if @ref ble_gap_adv_report_type_t::status
  1096. is set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. */
  1097. } ble_gap_evt_adv_report_t;
  1098. /**@brief Event structure for @ref BLE_GAP_EVT_SEC_REQUEST. */
  1099. typedef struct
  1100. {
  1101. uint8_t bond : 1; /**< Perform bonding. */
  1102. uint8_t mitm : 1; /**< Man In The Middle protection requested. */
  1103. uint8_t lesc : 1; /**< LE Secure Connections requested. */
  1104. uint8_t keypress : 1; /**< Generation of keypress notifications requested. */
  1105. } ble_gap_evt_sec_request_t;
  1106. /**@brief Event structure for @ref BLE_GAP_EVT_CONN_PARAM_UPDATE_REQUEST. */
  1107. typedef struct
  1108. {
  1109. ble_gap_conn_params_t conn_params; /**< GAP Connection Parameters. */
  1110. } ble_gap_evt_conn_param_update_request_t;
  1111. /**@brief Event structure for @ref BLE_GAP_EVT_SCAN_REQ_REPORT. */
  1112. typedef struct
  1113. {
  1114. uint8_t adv_handle; /**< Advertising handle for the advertising set which received the Scan Request */
  1115. int8_t rssi; /**< Received Signal Strength Indication in dBm.
  1116. @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement. */
  1117. 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
  1118. and the address is the device's identity address. */
  1119. } ble_gap_evt_scan_req_report_t;
  1120. /**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST. */
  1121. typedef struct
  1122. {
  1123. ble_gap_data_length_params_t peer_params; /**< Peer data length parameters. */
  1124. } ble_gap_evt_data_length_update_request_t;
  1125. /**@brief Event structure for @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE. */
  1126. typedef struct
  1127. {
  1128. ble_gap_data_length_params_t effective_params; /**< The effective data length parameters. */
  1129. } ble_gap_evt_data_length_update_t;
  1130. /**@brief Event structure for @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT. */
  1131. typedef struct
  1132. {
  1133. int8_t channel_energy[BLE_GAP_CHANNEL_COUNT]; /**< The measured energy on the Bluetooth Low Energy
  1134. channels, in dBm, indexed by Channel Index.
  1135. If no measurement is available for the given channel, channel_energy is set to
  1136. @ref BLE_GAP_POWER_LEVEL_INVALID. */
  1137. } ble_gap_evt_qos_channel_survey_report_t;
  1138. /**@brief GAP event structure. */
  1139. typedef struct
  1140. {
  1141. uint16_t conn_handle; /**< Connection Handle on which event occurred. */
  1142. union /**< union alternative identified by evt_id in enclosing struct. */
  1143. {
  1144. ble_gap_evt_connected_t connected; /**< Connected Event Parameters. */
  1145. ble_gap_evt_disconnected_t disconnected; /**< Disconnected Event Parameters. */
  1146. ble_gap_evt_conn_param_update_t conn_param_update; /**< Connection Parameter Update Parameters. */
  1147. ble_gap_evt_sec_params_request_t sec_params_request; /**< Security Parameters Request Event Parameters. */
  1148. ble_gap_evt_sec_info_request_t sec_info_request; /**< Security Information Request Event Parameters. */
  1149. ble_gap_evt_passkey_display_t passkey_display; /**< Passkey Display Event Parameters. */
  1150. ble_gap_evt_key_pressed_t key_pressed; /**< Key Pressed Event Parameters. */
  1151. ble_gap_evt_auth_key_request_t auth_key_request; /**< Authentication Key Request Event Parameters. */
  1152. ble_gap_evt_lesc_dhkey_request_t lesc_dhkey_request; /**< LE Secure Connections DHKey calculation request. */
  1153. ble_gap_evt_auth_status_t auth_status; /**< Authentication Status Event Parameters. */
  1154. ble_gap_evt_conn_sec_update_t conn_sec_update; /**< Connection Security Update Event Parameters. */
  1155. ble_gap_evt_timeout_t timeout; /**< Timeout Event Parameters. */
  1156. ble_gap_evt_rssi_changed_t rssi_changed; /**< RSSI Event Parameters. */
  1157. ble_gap_evt_adv_report_t adv_report; /**< Advertising Report Event Parameters. */
  1158. ble_gap_evt_adv_set_terminated_t adv_set_terminated; /**< Advertising Set Terminated Event Parameters. */
  1159. ble_gap_evt_sec_request_t sec_request; /**< Security Request Event Parameters. */
  1160. ble_gap_evt_conn_param_update_request_t conn_param_update_request; /**< Connection Parameter Update Parameters. */
  1161. ble_gap_evt_scan_req_report_t scan_req_report; /**< Scan Request Report Parameters. */
  1162. ble_gap_evt_phy_update_request_t phy_update_request; /**< PHY Update Request Event Parameters. */
  1163. ble_gap_evt_phy_update_t phy_update; /**< PHY Update Parameters. */
  1164. ble_gap_evt_data_length_update_request_t data_length_update_request; /**< Data Length Update Request Event Parameters. */
  1165. ble_gap_evt_data_length_update_t data_length_update; /**< Data Length Update Event Parameters. */
  1166. ble_gap_evt_qos_channel_survey_report_t qos_channel_survey_report; /**< Quality of Service (QoS) Channel Survey Report Parameters. */
  1167. } params; /**< Event Parameters. */
  1168. } ble_gap_evt_t;
  1169. /**
  1170. * @brief BLE GAP connection configuration parameters, set with @ref sd_ble_cfg_set.
  1171. *
  1172. * @retval ::NRF_ERROR_CONN_COUNT The connection count for the connection configurations is zero.
  1173. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  1174. * - The sum of conn_count for all connection configurations combined exceeds UINT8_MAX.
  1175. * - The event length is smaller than @ref BLE_GAP_EVENT_LENGTH_MIN.
  1176. */
  1177. typedef struct
  1178. {
  1179. uint8_t conn_count; /**< The number of concurrent connections the application can create with this configuration.
  1180. The default and minimum value is @ref BLE_GAP_CONN_COUNT_DEFAULT. */
  1181. uint16_t event_length; /**< The time set aside for this connection on every connection interval in 1.25 ms units.
  1182. The default value is @ref BLE_GAP_EVENT_LENGTH_DEFAULT, the minimum value is @ref BLE_GAP_EVENT_LENGTH_MIN.
  1183. The event length and the connection interval are the primary parameters
  1184. for setting the throughput of a connection.
  1185. See the SoftDevice Specification for details on throughput. */
  1186. } ble_gap_conn_cfg_t;
  1187. /**
  1188. * @brief Configuration of maximum concurrent connections in the different connected roles, set with
  1189. * @ref sd_ble_cfg_set.
  1190. *
  1191. * @retval ::NRF_ERROR_CONN_COUNT The sum of periph_role_count and central_role_count is too
  1192. * large. The maximum supported sum of concurrent connections is
  1193. * @ref BLE_GAP_ROLE_COUNT_COMBINED_MAX.
  1194. * @retval ::NRF_ERROR_INVALID_PARAM central_sec_count is larger than central_role_count.
  1195. * @retval ::NRF_ERROR_RESOURCES The adv_set_count is too large. The maximum
  1196. * supported advertising handles is
  1197. * @ref BLE_GAP_ADV_SET_COUNT_MAX.
  1198. */
  1199. typedef struct
  1200. {
  1201. uint8_t adv_set_count; /**< Maximum number of advertising sets. Default value is @ref BLE_GAP_ADV_SET_COUNT_DEFAULT. */
  1202. uint8_t periph_role_count; /**< Maximum number of connections concurrently acting as a peripheral. Default value is @ref BLE_GAP_ROLE_COUNT_PERIPH_DEFAULT. */
  1203. uint8_t central_role_count; /**< Maximum number of connections concurrently acting as a central. Default value is @ref BLE_GAP_ROLE_COUNT_CENTRAL_DEFAULT. */
  1204. 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. */
  1205. uint8_t qos_channel_survey_role_available:1; /**< If set, the Quality of Service (QoS) channel survey module is available to the
  1206. application using @ref sd_ble_gap_qos_channel_survey_start. */
  1207. } ble_gap_cfg_role_count_t;
  1208. /**
  1209. * @brief Device name and its properties, set with @ref sd_ble_cfg_set.
  1210. *
  1211. * @note If the device name is not configured, the default device name will be
  1212. * @ref BLE_GAP_DEVNAME_DEFAULT, the maximum device name length will be
  1213. * @ref BLE_GAP_DEVNAME_DEFAULT_LEN, vloc will be set to @ref BLE_GATTS_VLOC_STACK and the device name
  1214. * will have no write access.
  1215. *
  1216. * @note If @ref max_len is more than @ref BLE_GAP_DEVNAME_DEFAULT_LEN and vloc is set to @ref BLE_GATTS_VLOC_STACK,
  1217. * the attribute table size must be increased to have room for the longer device name (see
  1218. * @ref sd_ble_cfg_set and @ref ble_gatts_cfg_attr_tab_size_t).
  1219. *
  1220. * @note If vloc is @ref BLE_GATTS_VLOC_STACK :
  1221. * - p_value must point to non-volatile memory (flash) or be NULL.
  1222. * - If p_value is NULL, the device name will initially be empty.
  1223. *
  1224. * @note If vloc is @ref BLE_GATTS_VLOC_USER :
  1225. * - p_value cannot be NULL.
  1226. * - If the device name is writable, p_value must point to volatile memory (RAM).
  1227. *
  1228. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  1229. * - Invalid device name location (vloc).
  1230. * - Invalid device name security mode.
  1231. * @retval ::NRF_ERROR_INVALID_LENGTH One or more of the following is true:
  1232. * - The device name length is invalid (must be between 0 and @ref BLE_GAP_DEVNAME_MAX_LEN).
  1233. * - The device name length is too long for the given Attribute Table.
  1234. * @retval ::NRF_ERROR_NOT_SUPPORTED Device name security mode is not supported.
  1235. */
  1236. typedef struct
  1237. {
  1238. ble_gap_conn_sec_mode_t write_perm; /**< Write permissions. */
  1239. uint8_t vloc:2; /**< Value location, see @ref BLE_GATTS_VLOCS.*/
  1240. uint8_t *p_value; /**< Pointer to where the value (device name) is stored or will be stored. */
  1241. uint16_t current_len; /**< Current length in bytes of the memory pointed to by p_value.*/
  1242. uint16_t max_len; /**< Maximum length in bytes of the memory pointed to by p_value.*/
  1243. } ble_gap_cfg_device_name_t;
  1244. /**@brief Configuration structure for GAP configurations. */
  1245. typedef union
  1246. {
  1247. ble_gap_cfg_role_count_t role_count_cfg; /**< Role count configuration, cfg_id is @ref BLE_GAP_CFG_ROLE_COUNT. */
  1248. ble_gap_cfg_device_name_t device_name_cfg; /**< Device name configuration, cfg_id is @ref BLE_GAP_CFG_DEVICE_NAME. */
  1249. } ble_gap_cfg_t;
  1250. /**@brief Channel Map option.
  1251. *
  1252. * @details Used with @ref sd_ble_opt_get to get the current channel map
  1253. * or @ref sd_ble_opt_set to set a new channel map. When setting the
  1254. * channel map, it applies to all current and future connections. When getting the
  1255. * current channel map, it applies to a single connection and the connection handle
  1256. * must be supplied.
  1257. *
  1258. * @note Setting the channel map may take some time, depending on connection parameters.
  1259. * The time taken may be different for each connection and the get operation will
  1260. * return the previous channel map until the new one has taken effect.
  1261. *
  1262. * @note After setting the channel map, by spec it can not be set again until at least 1 s has passed.
  1263. * See Bluetooth Specification Version 4.1 Volume 2, Part E, Section 7.3.46.
  1264. *
  1265. * @retval ::NRF_SUCCESS Get or set successful.
  1266. * @retval ::NRF_ERROR_INVALID_PARAM One or more of the following is true:
  1267. * - Less then two bits in @ref ch_map are set.
  1268. * - Bits for primary advertising channels (37-39) are set.
  1269. * @retval ::NRF_ERROR_BUSY Channel map was set again before enough time had passed.
  1270. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied for get.
  1271. *
  1272. */
  1273. typedef struct
  1274. {
  1275. uint16_t conn_handle; /**< Connection Handle (only applicable for get) */
  1276. uint8_t ch_map[5]; /**< Channel Map (37-bit). */
  1277. } ble_gap_opt_ch_map_t;
  1278. /**@brief Local connection latency option.
  1279. *
  1280. * @details Local connection latency is a feature which enables the slave to improve
  1281. * current consumption by ignoring the slave latency set by the peer. The
  1282. * local connection latency can only be set to a multiple of the slave latency,
  1283. * and cannot be longer than half of the supervision timeout.
  1284. *
  1285. * @details Used with @ref sd_ble_opt_set to set the local connection latency. The
  1286. * @ref sd_ble_opt_get is not supported for this option, but the actual
  1287. * local connection latency (unless set to NULL) is set as a return parameter
  1288. * when setting the option.
  1289. *
  1290. * @note The latency set will be truncated down to the closest slave latency event
  1291. * multiple, or the nearest multiple before half of the supervision timeout.
  1292. *
  1293. * @note The local connection latency is disabled by default, and needs to be enabled for new
  1294. * connections and whenever the connection is updated.
  1295. *
  1296. * @retval ::NRF_SUCCESS Set successfully.
  1297. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
  1298. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1299. */
  1300. typedef struct
  1301. {
  1302. uint16_t conn_handle; /**< Connection Handle */
  1303. uint16_t requested_latency; /**< Requested local connection latency. */
  1304. uint16_t * p_actual_latency; /**< Pointer to storage for the actual local connection latency (can be set to NULL to skip return value). */
  1305. } ble_gap_opt_local_conn_latency_t;
  1306. /**@brief Disable slave latency
  1307. *
  1308. * @details Used with @ref sd_ble_opt_set to temporarily disable slave latency of a peripheral connection
  1309. * (see @ref ble_gap_conn_params_t::slave_latency). And to re-enable it again. When disabled, the
  1310. * peripheral will ignore the slave_latency set by the central.
  1311. *
  1312. * @note Shall only be called on peripheral links.
  1313. *
  1314. * @retval ::NRF_SUCCESS Set successfully.
  1315. * @retval ::NRF_ERROR_NOT_SUPPORTED Get is not supported.
  1316. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1317. */
  1318. typedef struct
  1319. {
  1320. uint16_t conn_handle; /**< Connection Handle */
  1321. uint8_t disable : 1; /**< Set to 1 to disable slave latency. Set to 0 enable it again.*/
  1322. } ble_gap_opt_slave_latency_disable_t;
  1323. /**@brief Passkey Option.
  1324. *
  1325. * @details Structure containing the passkey to be used during pairing. This can be used with @ref
  1326. * sd_ble_opt_set to make the SoftDevice use a preprogrammed passkey for authentication
  1327. * instead of generating a random one.
  1328. *
  1329. * @note Repeated pairing attempts using the same preprogrammed passkey makes pairing vulnerable to MITM attacks.
  1330. *
  1331. * @note @ref sd_ble_opt_get is not supported for this option.
  1332. *
  1333. */
  1334. typedef struct
  1335. {
  1336. 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.*/
  1337. } ble_gap_opt_passkey_t;
  1338. /**@brief Compatibility mode 1 option.
  1339. *
  1340. * @details This can be used with @ref sd_ble_opt_set to enable and disable
  1341. * compatibility mode 1. Compatibility mode 1 is disabled by default.
  1342. *
  1343. * @note Compatibility mode 1 enables interoperability with devices that do not support a value of
  1344. * 0 for the WinOffset parameter in the Link Layer CONNECT_IND packet. This applies to a
  1345. * limited set of legacy peripheral devices from another vendor. Enabling this compatibility
  1346. * mode will only have an effect if the local device will act as a central device and
  1347. * initiate a connection to a peripheral device. In that case it may lead to the connection
  1348. * creation taking up to one connection interval longer to complete for all connections.
  1349. *
  1350. * @retval ::NRF_SUCCESS Set successfully.
  1351. * @retval ::NRF_ERROR_INVALID_STATE When connection creation is ongoing while mode 1 is set.
  1352. */
  1353. typedef struct
  1354. {
  1355. uint8_t enable : 1; /**< Enable compatibility mode 1.*/
  1356. } ble_gap_opt_compat_mode_1_t;
  1357. /**@brief Authenticated payload timeout option.
  1358. *
  1359. * @details This can be used with @ref sd_ble_opt_set to change the Authenticated payload timeout to a value other
  1360. * than the default of @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT_MAX.
  1361. *
  1362. * @note The authenticated payload timeout event ::BLE_GAP_TIMEOUT_SRC_AUTH_PAYLOAD will be generated
  1363. * if auth_payload_timeout time has elapsed without receiving a packet with a valid MIC on an encrypted
  1364. * link.
  1365. *
  1366. * @note The LE ping procedure will be initiated before the timer expires to give the peer a chance
  1367. * to reset the timer. In addition the stack will try to prioritize running of LE ping over other
  1368. * activities to increase chances of finishing LE ping before timer expires. To avoid side-effects
  1369. * on other activities, it is recommended to use high timeout values.
  1370. * Recommended timeout > 2*(connInterval * (6 + connSlaveLatency)).
  1371. *
  1372. * @retval ::NRF_SUCCESS Set successfully.
  1373. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. auth_payload_timeout was outside of allowed range.
  1374. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter.
  1375. */
  1376. typedef struct
  1377. {
  1378. uint16_t conn_handle; /**< Connection Handle */
  1379. uint16_t auth_payload_timeout; /**< Requested timeout in 10 ms unit, see @ref BLE_GAP_AUTH_PAYLOAD_TIMEOUT. */
  1380. } ble_gap_opt_auth_payload_timeout_t;
  1381. /**@brief Option structure for GAP options. */
  1382. typedef union
  1383. {
  1384. ble_gap_opt_ch_map_t ch_map; /**< Parameters for the Channel Map option. */
  1385. ble_gap_opt_local_conn_latency_t local_conn_latency; /**< Parameters for the Local connection latency option */
  1386. ble_gap_opt_passkey_t passkey; /**< Parameters for the Passkey option.*/
  1387. ble_gap_opt_compat_mode_1_t compat_mode_1; /**< Parameters for the compatibility mode 1 option.*/
  1388. ble_gap_opt_auth_payload_timeout_t auth_payload_timeout; /**< Parameters for the authenticated payload timeout option.*/
  1389. ble_gap_opt_slave_latency_disable_t slave_latency_disable; /**< Parameters for the Disable slave latency option */
  1390. } ble_gap_opt_t;
  1391. /**@} */
  1392. /**@addtogroup BLE_GAP_FUNCTIONS Functions
  1393. * @{ */
  1394. /**@brief Set the local Bluetooth identity address.
  1395. *
  1396. * The local Bluetooth identity address is the address that identifies this device to other peers.
  1397. * The address type must be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC.
  1398. *
  1399. * @note The identity address cannot be changed while advertising, scanning or creating a connection.
  1400. *
  1401. * @note This address will be distributed to the peer during bonding.
  1402. * If the address changes, the address stored in the peer device will not be valid and the ability to
  1403. * reconnect using the old address will be lost.
  1404. *
  1405. * @note By default the SoftDevice will set an address of type @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC upon being
  1406. * enabled. The address is a random number populated during the IC manufacturing process and remains unchanged
  1407. * for the lifetime of each IC.
  1408. *
  1409. * @mscs
  1410. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1411. * @endmscs
  1412. *
  1413. * @param[in] p_addr Pointer to address structure.
  1414. *
  1415. * @retval ::NRF_SUCCESS Address successfully set.
  1416. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1417. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address.
  1418. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1419. * @retval ::NRF_ERROR_INVALID_STATE The identity address cannot be changed while advertising,
  1420. * scanning or creating a connection.
  1421. */
  1422. SVCALL(SD_BLE_GAP_ADDR_SET, uint32_t, sd_ble_gap_addr_set(ble_gap_addr_t const *p_addr));
  1423. /**@brief Get local Bluetooth identity address.
  1424. *
  1425. * @note This will always return the identity address irrespective of the privacy settings,
  1426. * i.e. the address type will always be either @ref BLE_GAP_ADDR_TYPE_PUBLIC or @ref BLE_GAP_ADDR_TYPE_RANDOM_STATIC.
  1427. *
  1428. * @param[out] p_addr Pointer to address structure to be filled in.
  1429. *
  1430. * @retval ::NRF_SUCCESS Address successfully retrieved.
  1431. * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
  1432. */
  1433. SVCALL(SD_BLE_GAP_ADDR_GET, uint32_t, sd_ble_gap_addr_get(ble_gap_addr_t *p_addr));
  1434. /**@brief Get the Bluetooth device address used by the advertiser.
  1435. *
  1436. * @note This function will return the local Bluetooth address used in advertising PDUs. When
  1437. * using privacy, the SoftDevice will generate a new private address every
  1438. * @ref ble_gap_privacy_params_t::private_addr_cycle_s configured using
  1439. * @ref sd_ble_gap_privacy_set. Hence depending on when the application calls this API, the
  1440. * address returned may not be the latest address that is used in the advertising PDUs.
  1441. *
  1442. * @param[in] adv_handle The advertising handle to get the address from.
  1443. * @param[out] p_addr Pointer to address structure to be filled in.
  1444. *
  1445. * @retval ::NRF_SUCCESS Address successfully retrieved.
  1446. * @retval ::NRF_ERROR_INVALID_ADDR Invalid or NULL pointer supplied.
  1447. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found.
  1448. * @retval ::NRF_ERROR_INVALID_STATE The advertising set is currently not advertising.
  1449. */
  1450. 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));
  1451. /**@brief Set the active whitelist in the SoftDevice.
  1452. *
  1453. * @note Only one whitelist can be used at a time and the whitelist is shared between the BLE roles.
  1454. * The whitelist cannot be set if a BLE role is using the whitelist.
  1455. *
  1456. * @note If an address is resolved using the information in the device identity list, then the whitelist
  1457. * filter policy applies to the peer identity address and not the resolvable address sent on air.
  1458. *
  1459. * @mscs
  1460. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1461. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC}
  1462. * @endmscs
  1463. *
  1464. * @param[in] pp_wl_addrs Pointer to a whitelist of peer addresses, if NULL the whitelist will be cleared.
  1465. * @param[in] len Length of the whitelist, maximum @ref BLE_GAP_WHITELIST_ADDR_MAX_COUNT.
  1466. *
  1467. * @retval ::NRF_SUCCESS The whitelist is successfully set/cleared.
  1468. * @retval ::NRF_ERROR_INVALID_ADDR The whitelist (or one of its entries) provided is invalid.
  1469. * @retval ::BLE_ERROR_GAP_WHITELIST_IN_USE The whitelist is in use by a BLE role and cannot be set or cleared.
  1470. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1471. * @retval ::NRF_ERROR_DATA_SIZE The given whitelist size is invalid (zero or too large); this can only return when
  1472. * pp_wl_addrs is not NULL.
  1473. */
  1474. 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));
  1475. /**@brief Set device identity list.
  1476. *
  1477. * @note Only one device identity list can be used at a time and the list is shared between the BLE roles.
  1478. * The device identity list cannot be set if a BLE role is using the list.
  1479. *
  1480. * @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.
  1481. * @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.
  1482. * To fill in the list with the currently set device IRK for all peers, set to NULL.
  1483. * @param[in] len Length of the device identity list, maximum @ref BLE_GAP_DEVICE_IDENTITIES_MAX_COUNT.
  1484. *
  1485. * @mscs
  1486. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC}
  1487. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC}
  1488. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_PRIVATE_SCAN_MSC}
  1489. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1490. * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC}
  1491. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC}
  1492. * @endmscs
  1493. *
  1494. * @retval ::NRF_SUCCESS The device identity list successfully set/cleared.
  1495. * @retval ::NRF_ERROR_INVALID_ADDR The device identity list (or one of its entries) provided is invalid.
  1496. * This code may be returned if the local IRK list also has an invalid entry.
  1497. * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_IN_USE The device identity list is in use and cannot be set or cleared.
  1498. * @retval ::BLE_ERROR_GAP_DEVICE_IDENTITIES_DUPLICATE The device identity list contains multiple entries with the same identity address.
  1499. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1500. * @retval ::NRF_ERROR_DATA_SIZE The given device identity list size invalid (zero or too large); this can
  1501. * only return when pp_id_keys is not NULL.
  1502. */
  1503. 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));
  1504. /**@brief Set privacy settings.
  1505. *
  1506. * @note Privacy settings cannot be changed while advertising, scanning or creating a connection.
  1507. *
  1508. * @param[in] p_privacy_params Privacy settings.
  1509. *
  1510. * @mscs
  1511. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_MSC}
  1512. * @mmsc{@ref BLE_GAP_PRIVACY_SCAN_MSC}
  1513. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1514. * @endmscs
  1515. *
  1516. * @retval ::NRF_SUCCESS Set successfully.
  1517. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1518. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid address type is supplied.
  1519. * @retval ::NRF_ERROR_INVALID_ADDR The pointer to privacy settings is NULL or invalid.
  1520. * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
  1521. * @retval ::NRF_ERROR_INVALID_PARAM Out of range parameters are provided.
  1522. * @retval ::NRF_ERROR_INVALID_STATE Privacy settings cannot be changed while advertising, scanning
  1523. * or creating a connection.
  1524. */
  1525. SVCALL(SD_BLE_GAP_PRIVACY_SET, uint32_t, sd_ble_gap_privacy_set(ble_gap_privacy_params_t const *p_privacy_params));
  1526. /**@brief Get privacy settings.
  1527. *
  1528. * @note ::ble_gap_privacy_params_t::p_device_irk must be initialized to NULL or a valid address before this function is called.
  1529. * If it is initialized to a valid address, the address pointed to will contain the current device IRK on return.
  1530. *
  1531. * @param[in,out] p_privacy_params Privacy settings.
  1532. *
  1533. * @retval ::NRF_SUCCESS Privacy settings read.
  1534. * @retval ::NRF_ERROR_INVALID_ADDR The pointer given for returning the privacy settings may be NULL or invalid.
  1535. * Otherwise, the p_device_irk pointer in privacy parameter is an invalid pointer.
  1536. */
  1537. SVCALL(SD_BLE_GAP_PRIVACY_GET, uint32_t, sd_ble_gap_privacy_get(ble_gap_privacy_params_t *p_privacy_params));
  1538. /**@brief Configure an advertising set. Set, clear or update advertising and scan response data.
  1539. *
  1540. * @note The format of the advertising data will be checked by this call to ensure interoperability.
  1541. * Limitations imposed by this API call to the data provided include having a flags data type in the scan response data and
  1542. * duplicating the local name in the advertising data and scan response data.
  1543. *
  1544. * @note In order to update advertising data while advertising, new advertising buffers must be provided.
  1545. *
  1546. * @mscs
  1547. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1548. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1549. * @endmscs
  1550. *
  1551. * @param[in,out] p_adv_handle Provide a pointer to a handle containing @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to configure
  1552. * a new advertising set. On success, a new handle is then returned through the pointer.
  1553. * Provide a pointer to an existing advertising handle to configure an existing advertising set.
  1554. * @param[in] p_adv_data Advertising data. If set to NULL, no advertising data will be used. See @ref ble_gap_adv_data_t.
  1555. * @param[in] p_adv_params Advertising parameters. When this function is used to update advertising data while advertising,
  1556. * this parameter must be NULL. See @ref ble_gap_adv_params_t.
  1557. *
  1558. * @retval ::NRF_SUCCESS Advertising set successfully configured.
  1559. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied:
  1560. * - Invalid advertising data configuration specified. See @ref ble_gap_adv_data_t.
  1561. * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t.
  1562. * - Use of whitelist requested but whitelist has not been set,
  1563. * see @ref sd_ble_gap_whitelist_set.
  1564. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR ble_gap_adv_params_t::p_peer_addr is invalid.
  1565. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1566. * - It is invalid to provide non-NULL advertising set parameters while advertising.
  1567. * - It is invalid to provide the same data buffers while advertising. To update
  1568. * advertising data, provide new advertising buffers.
  1569. * @retval ::BLE_ERROR_GAP_DISCOVERABLE_WITH_WHITELIST Discoverable mode and whitelist incompatible.
  1570. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE The provided advertising handle was not found. Use @ref BLE_GAP_ADV_SET_HANDLE_NOT_SET to
  1571. * configure a new advertising handle.
  1572. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1573. * @retval ::NRF_ERROR_INVALID_FLAGS Invalid combination of advertising flags supplied.
  1574. * @retval ::NRF_ERROR_INVALID_DATA Invalid data type(s) supplied. Check the advertising data format specification
  1575. * given in Bluetooth Specification Version 5.0, Volume 3, Part C, Chapter 11.
  1576. * @retval ::NRF_ERROR_INVALID_LENGTH Invalid data length(s) supplied.
  1577. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported data length or advertising parameter configuration.
  1578. * @retval ::NRF_ERROR_NO_MEM Not enough memory to configure a new advertising handle. Update an
  1579. * existing advertising handle instead.
  1580. * @retval ::BLE_ERROR_GAP_UUID_LIST_MISMATCH Invalid UUID list supplied.
  1581. */
  1582. 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));
  1583. /**@brief Start advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  1584. *
  1585. * @note Only one advertiser may be active at any time.
  1586. *
  1587. * @events
  1588. * @event{@ref BLE_GAP_EVT_CONNECTED, Generated after connection has been established through connectable advertising.}
  1589. * @event{@ref BLE_GAP_EVT_ADV_SET_TERMINATED, Advertising set has terminated.}
  1590. * @event{@ref BLE_GAP_EVT_SCAN_REQ_REPORT, A scan request was received.}
  1591. * @endevents
  1592. *
  1593. * @mscs
  1594. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1595. * @mmsc{@ref BLE_GAP_PERIPH_CONN_PRIV_MSC}
  1596. * @mmsc{@ref BLE_GAP_PRIVACY_ADV_DIR_PRIV_MSC}
  1597. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1598. * @endmscs
  1599. *
  1600. * @param[in] adv_handle Advertising handle to advertise on, received from @ref sd_ble_gap_adv_set_configure.
  1601. * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or
  1602. * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration. For non-connectable
  1603. * advertising, this is ignored.
  1604. *
  1605. * @retval ::NRF_SUCCESS The BLE stack has started advertising.
  1606. * @retval ::NRF_ERROR_INVALID_STATE adv_handle is not configured or already advertising.
  1607. * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached; connectable advertiser cannot be started.
  1608. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found. Configure a new adveriting handle with @ref sd_ble_gap_adv_set_configure.
  1609. * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found.
  1610. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied:
  1611. * - Invalid configuration of p_adv_params. See @ref ble_gap_adv_params_t.
  1612. * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set.
  1613. * @retval ::NRF_ERROR_RESOURCES Either:
  1614. * - adv_handle is configured with connectable advertising, but the event_length parameter
  1615. * associated with conn_cfg_tag is too small to be able to establish a connection on
  1616. * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length.
  1617. * - Not enough BLE role slots available.
  1618. Stop one or more currently active roles (Central, Peripheral, Broadcaster or Observer) and try again.
  1619. * - p_adv_params is configured with connectable advertising, but the event_length parameter
  1620. * associated with conn_cfg_tag is too small to be able to establish a connection on
  1621. * the selected advertising phys. Use @ref sd_ble_cfg_set to increase the event length.
  1622. */
  1623. SVCALL(SD_BLE_GAP_ADV_START, uint32_t, sd_ble_gap_adv_start(uint8_t adv_handle, uint8_t conn_cfg_tag));
  1624. /**@brief Stop advertising (GAP Discoverable, Connectable modes, Broadcast Procedure).
  1625. *
  1626. * @mscs
  1627. * @mmsc{@ref BLE_GAP_ADV_MSC}
  1628. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  1629. * @endmscs
  1630. *
  1631. * @param[in] adv_handle The advertising handle that should stop advertising.
  1632. *
  1633. * @retval ::NRF_SUCCESS The BLE stack has stopped advertising.
  1634. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Invalid advertising handle.
  1635. * @retval ::NRF_ERROR_INVALID_STATE The advertising handle is not advertising.
  1636. */
  1637. SVCALL(SD_BLE_GAP_ADV_STOP, uint32_t, sd_ble_gap_adv_stop(uint8_t adv_handle));
  1638. /**@brief Update connection parameters.
  1639. *
  1640. * @details In the central role this will initiate a Link Layer connection parameter update procedure,
  1641. * otherwise in the peripheral role, this will send the corresponding L2CAP request and wait for
  1642. * the central to perform the procedure. In both cases, and regardless of success or failure, the application
  1643. * will be informed of the result with a @ref BLE_GAP_EVT_CONN_PARAM_UPDATE event.
  1644. *
  1645. * @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.
  1646. *
  1647. * @events
  1648. * @event{@ref BLE_GAP_EVT_CONN_PARAM_UPDATE, Result of the connection parameter update procedure.}
  1649. * @endevents
  1650. *
  1651. * @mscs
  1652. * @mmsc{@ref BLE_GAP_CPU_MSC}
  1653. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  1654. * @mmsc{@ref BLE_GAP_MULTILINK_CPU_MSC}
  1655. * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC}
  1656. * @mmsc{@ref BLE_GAP_CENTRAL_CPU_MSC}
  1657. * @endmscs
  1658. *
  1659. * @param[in] conn_handle Connection handle.
  1660. * @param[in] p_conn_params Pointer to desired connection parameters. If NULL is provided on a peripheral role,
  1661. * the parameters in the PPCP characteristic of the GAP service will be used instead.
  1662. * 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
  1663. *
  1664. * @retval ::NRF_SUCCESS The Connection Update procedure has been started successfully.
  1665. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1666. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied, check parameter limits and constraints.
  1667. * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established.
  1668. * @retval ::NRF_ERROR_BUSY Procedure already in progress, wait for pending procedures to complete and retry.
  1669. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1670. * @retval ::NRF_ERROR_NO_MEM Not enough memory to complete operation.
  1671. */
  1672. 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));
  1673. /**@brief Disconnect (GAP Link Termination).
  1674. *
  1675. * @details This call initiates the disconnection procedure, and its completion will be communicated to the application
  1676. * with a @ref BLE_GAP_EVT_DISCONNECTED event.
  1677. *
  1678. * @events
  1679. * @event{@ref BLE_GAP_EVT_DISCONNECTED, Generated when disconnection procedure is complete.}
  1680. * @endevents
  1681. *
  1682. * @mscs
  1683. * @mmsc{@ref BLE_GAP_CONN_MSC}
  1684. * @endmscs
  1685. *
  1686. * @param[in] conn_handle Connection handle.
  1687. * @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).
  1688. *
  1689. * @retval ::NRF_SUCCESS The disconnection procedure has been started successfully.
  1690. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1691. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1692. * @retval ::NRF_ERROR_INVALID_STATE Disconnection in progress or link has not been established.
  1693. */
  1694. SVCALL(SD_BLE_GAP_DISCONNECT, uint32_t, sd_ble_gap_disconnect(uint16_t conn_handle, uint8_t hci_status_code));
  1695. /**@brief Set the radio's transmit power.
  1696. *
  1697. * @param[in] role The role to set the transmit power for, see @ref BLE_GAP_TX_POWER_ROLES for
  1698. * possible roles.
  1699. * @param[in] handle The handle parameter is interpreted depending on role:
  1700. * - If role is @ref BLE_GAP_TX_POWER_ROLE_CONN, this value is the specific connection handle.
  1701. * - If role is @ref BLE_GAP_TX_POWER_ROLE_ADV, the advertising set identified with the advertising handle,
  1702. * will use the specified transmit power, and include it in the advertising packet headers if
  1703. * @ref ble_gap_adv_properties_t::include_tx_power set.
  1704. * - For all other roles handle is ignored.
  1705. * @param[in] tx_power Radio transmit power in dBm (see note for accepted values).
  1706. *
  1707. * @note Supported tx_power values: -40dBm, -20dBm, -16dBm, -12dBm, -8dBm, -4dBm, 0dBm, +2dBm, +3dBm, +4dBm, +5dBm, +6dBm, +7dBm and +8dBm.
  1708. * @note The initiator will have the same transmit power as the scanner.
  1709. * @note When a connection is created it will inherit the transmit power from the initiator or
  1710. * advertiser leading to the connection.
  1711. *
  1712. * @retval ::NRF_SUCCESS Successfully changed the transmit power.
  1713. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1714. * @retval ::BLE_ERROR_INVALID_ADV_HANDLE Advertising handle not found.
  1715. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1716. */
  1717. 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));
  1718. /**@brief Set GAP Appearance value.
  1719. *
  1720. * @param[in] appearance Appearance (16-bit), see @ref BLE_APPEARANCES.
  1721. *
  1722. * @retval ::NRF_SUCCESS Appearance value set successfully.
  1723. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1724. */
  1725. SVCALL(SD_BLE_GAP_APPEARANCE_SET, uint32_t, sd_ble_gap_appearance_set(uint16_t appearance));
  1726. /**@brief Get GAP Appearance value.
  1727. *
  1728. * @param[out] p_appearance Pointer to appearance (16-bit) to be filled in, see @ref BLE_APPEARANCES.
  1729. *
  1730. * @retval ::NRF_SUCCESS Appearance value retrieved successfully.
  1731. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1732. */
  1733. SVCALL(SD_BLE_GAP_APPEARANCE_GET, uint32_t, sd_ble_gap_appearance_get(uint16_t *p_appearance));
  1734. /**@brief Set GAP Peripheral Preferred Connection Parameters.
  1735. *
  1736. * @param[in] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure with the desired parameters.
  1737. *
  1738. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters set successfully.
  1739. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1740. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1741. */
  1742. SVCALL(SD_BLE_GAP_PPCP_SET, uint32_t, sd_ble_gap_ppcp_set(ble_gap_conn_params_t const *p_conn_params));
  1743. /**@brief Get GAP Peripheral Preferred Connection Parameters.
  1744. *
  1745. * @param[out] p_conn_params Pointer to a @ref ble_gap_conn_params_t structure where the parameters will be stored.
  1746. *
  1747. * @retval ::NRF_SUCCESS Peripheral Preferred Connection Parameters retrieved successfully.
  1748. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1749. */
  1750. SVCALL(SD_BLE_GAP_PPCP_GET, uint32_t, sd_ble_gap_ppcp_get(ble_gap_conn_params_t *p_conn_params));
  1751. /**@brief Set GAP device name.
  1752. *
  1753. * @note If the device name is located in application flash memory (see @ref ble_gap_cfg_device_name_t),
  1754. * it cannot be changed. Then @ref NRF_ERROR_FORBIDDEN will be returned.
  1755. *
  1756. * @param[in] p_write_perm Write permissions for the Device Name characteristic, see @ref ble_gap_conn_sec_mode_t.
  1757. * @param[in] p_dev_name Pointer to a UTF-8 encoded, <b>non NULL-terminated</b> string.
  1758. * @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).
  1759. *
  1760. * @retval ::NRF_SUCCESS GAP device name and permissions set successfully.
  1761. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1762. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1763. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1764. * @retval ::NRF_ERROR_FORBIDDEN Device name is not writable.
  1765. */
  1766. 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));
  1767. /**@brief Get GAP device name.
  1768. *
  1769. * @note If the device name is longer than the size of the supplied buffer,
  1770. * p_len will return the complete device name length,
  1771. * and not the number of bytes actually returned in p_dev_name.
  1772. * The application may use this information to allocate a suitable buffer size.
  1773. *
  1774. * @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.
  1775. * @param[in,out] p_len Length of the buffer pointed by p_dev_name, complete device name length on output.
  1776. *
  1777. * @retval ::NRF_SUCCESS GAP device name retrieved successfully.
  1778. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1779. * @retval ::NRF_ERROR_DATA_SIZE Invalid data size(s) supplied.
  1780. */
  1781. SVCALL(SD_BLE_GAP_DEVICE_NAME_GET, uint32_t, sd_ble_gap_device_name_get(uint8_t *p_dev_name, uint16_t *p_len));
  1782. /**@brief Initiate the GAP Authentication procedure.
  1783. *
  1784. * @details In the central role, this function will send an SMP Pairing Request (or an SMP Pairing Failed if rejected),
  1785. * otherwise in the peripheral role, an SMP Security Request will be sent.
  1786. *
  1787. * @events
  1788. * @event{Depending on the security parameters set and the packet exchanges with the peer\, the following events may be generated:}
  1789. * @event{@ref BLE_GAP_EVT_SEC_PARAMS_REQUEST}
  1790. * @event{@ref BLE_GAP_EVT_SEC_INFO_REQUEST}
  1791. * @event{@ref BLE_GAP_EVT_PASSKEY_DISPLAY}
  1792. * @event{@ref BLE_GAP_EVT_KEY_PRESSED}
  1793. * @event{@ref BLE_GAP_EVT_AUTH_KEY_REQUEST}
  1794. * @event{@ref BLE_GAP_EVT_LESC_DHKEY_REQUEST}
  1795. * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE}
  1796. * @event{@ref BLE_GAP_EVT_AUTH_STATUS}
  1797. * @event{@ref BLE_GAP_EVT_TIMEOUT}
  1798. * @endevents
  1799. *
  1800. * @mscs
  1801. * @mmsc{@ref BLE_GAP_PERIPH_SEC_REQ_MSC}
  1802. * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC}
  1803. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  1804. * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC}
  1805. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC}
  1806. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC}
  1807. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1808. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1809. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1810. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1811. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1812. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1813. * @endmscs
  1814. *
  1815. * @param[in] conn_handle Connection handle.
  1816. * @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.
  1817. * In the peripheral role, only the bond, mitm, lesc and keypress fields of this structure are used.
  1818. * In the central role, this pointer may be NULL to reject a Security Request.
  1819. *
  1820. * @retval ::NRF_SUCCESS Successfully initiated authentication procedure.
  1821. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1822. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1823. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1824. * - No link has been established.
  1825. * - An encryption is already executing or queued.
  1826. * @retval ::NRF_ERROR_NO_MEM The maximum number of authentication procedures that can run in parallel for the given role is reached.
  1827. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1828. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
  1829. * @retval ::NRF_ERROR_TIMEOUT A SMP timeout has occurred, and further SMP operations on this link is prohibited.
  1830. */
  1831. SVCALL(SD_BLE_GAP_AUTHENTICATE, uint32_t, sd_ble_gap_authenticate(uint16_t conn_handle, ble_gap_sec_params_t const *p_sec_params));
  1832. /**@brief Reply with GAP security parameters.
  1833. *
  1834. * @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.
  1835. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1836. *
  1837. * @events
  1838. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1839. * @endevents
  1840. *
  1841. * @mscs
  1842. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_JW_MSC}
  1843. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_JW_MSC}
  1844. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_PERIPH_MSC}
  1845. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1846. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_STATIC_PK_MSC}
  1847. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_CONFIRM_FAIL_MSC}
  1848. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1849. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1850. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1851. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1852. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1853. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_KS_TOO_SMALL_MSC}
  1854. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_APP_ERROR_MSC}
  1855. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_REMOTE_PAIRING_FAIL_MSC}
  1856. * @mmsc{@ref BLE_GAP_PERIPH_PAIRING_TIMEOUT_MSC}
  1857. * @mmsc{@ref BLE_GAP_CENTRAL_PAIRING_JW_MSC}
  1858. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_JW_MSC}
  1859. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_MSC}
  1860. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1861. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1862. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1863. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1864. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1865. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1866. * @endmscs
  1867. *
  1868. * @param[in] conn_handle Connection handle.
  1869. * @param[in] sec_status Security status, see @ref BLE_GAP_SEC_STATUS.
  1870. * @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
  1871. * already been provided during a previous call to @ref sd_ble_gap_authenticate.
  1872. * @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
  1873. * will be stored into the memory referenced by the pointers inside this structure. The keys will be stored and available to the application
  1874. * upon reception of a @ref BLE_GAP_EVT_AUTH_STATUS event.
  1875. * Note that the SoftDevice expects the application to provide memory for storing the
  1876. * peer's keys. So it must be ensured that the relevant pointers inside this structure are not NULL. The pointers to the local key
  1877. * can, however, be NULL, in which case, the local key data will not be available to the application upon reception of the
  1878. * @ref BLE_GAP_EVT_AUTH_STATUS event.
  1879. *
  1880. * @retval ::NRF_SUCCESS Successfully accepted security parameter from the application.
  1881. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1882. * @retval ::NRF_ERROR_BUSY The stack is busy, process pending events and retry.
  1883. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1884. * @retval ::NRF_ERROR_INVALID_STATE Security parameters has not been requested.
  1885. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1886. * @retval ::NRF_ERROR_NOT_SUPPORTED Setting of sign or link fields in @ref ble_gap_sec_kdist_t not supported.
  1887. */
  1888. 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));
  1889. /**@brief Reply with an authentication key.
  1890. *
  1891. * @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.
  1892. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1893. *
  1894. * @events
  1895. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1896. * @endevents
  1897. *
  1898. * @mscs
  1899. * @mmsc{@ref BLE_GAP_PERIPH_BONDING_PK_CENTRAL_OOB_MSC}
  1900. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1901. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1902. * @mmsc{@ref BLE_GAP_CENTRAL_BONDING_PK_PERIPH_OOB_MSC}
  1903. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1904. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1905. * @endmscs
  1906. *
  1907. * @param[in] conn_handle Connection handle.
  1908. * @param[in] key_type See @ref BLE_GAP_AUTH_KEY_TYPES.
  1909. * @param[in] p_key If key type is @ref BLE_GAP_AUTH_KEY_TYPE_NONE, then NULL.
  1910. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_PASSKEY, then a 6-byte ASCII string (digit 0..9 only, no NULL termination)
  1911. * or NULL when confirming LE Secure Connections Numeric Comparison.
  1912. * If key type is @ref BLE_GAP_AUTH_KEY_TYPE_OOB, then a 16-byte OOB key value in little-endian format.
  1913. *
  1914. * @retval ::NRF_SUCCESS Authentication key successfully set.
  1915. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1916. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1917. * @retval ::NRF_ERROR_INVALID_STATE Authentication key has not been requested.
  1918. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1919. */
  1920. 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));
  1921. /**@brief Reply with an LE Secure connections DHKey.
  1922. *
  1923. * @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.
  1924. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  1925. *
  1926. * @events
  1927. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  1928. * @endevents
  1929. *
  1930. * @mscs
  1931. * @mmsc{@ref BLE_GAP_PERIPH_LESC_PAIRING_JW_MSC}
  1932. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_NC_MSC}
  1933. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_PD_MSC}
  1934. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1935. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1936. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_PAIRING_JW_MSC}
  1937. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_NC_MSC}
  1938. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_PD_MSC}
  1939. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1940. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1941. * @endmscs
  1942. *
  1943. * @param[in] conn_handle Connection handle.
  1944. * @param[in] p_dhkey LE Secure Connections DHKey.
  1945. *
  1946. * @retval ::NRF_SUCCESS DHKey successfully set.
  1947. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1948. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1949. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1950. * - The peer is not authenticated.
  1951. * - The application has not pulled a @ref BLE_GAP_EVT_LESC_DHKEY_REQUEST event.
  1952. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1953. */
  1954. 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));
  1955. /**@brief Notify the peer of a local keypress.
  1956. *
  1957. * @mscs
  1958. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_PKE_CD_MSC}
  1959. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_PKE_CD_MSC}
  1960. * @endmscs
  1961. *
  1962. * @param[in] conn_handle Connection handle.
  1963. * @param[in] kp_not See @ref BLE_GAP_KP_NOT_TYPES.
  1964. *
  1965. * @retval ::NRF_SUCCESS Keypress notification successfully queued for transmission.
  1966. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  1967. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  1968. * - Authentication key not requested.
  1969. * - Passkey has not been entered.
  1970. * - Keypresses have not been enabled by both peers.
  1971. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1972. * @retval ::NRF_ERROR_BUSY The BLE stack is busy. Retry at later time.
  1973. */
  1974. SVCALL(SD_BLE_GAP_KEYPRESS_NOTIFY, uint32_t, sd_ble_gap_keypress_notify(uint16_t conn_handle, uint8_t kp_not));
  1975. /**@brief Generate a set of OOB data to send to a peer out of band.
  1976. *
  1977. * @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,
  1978. * the one used during connection setup). The application may manually overwrite it with an updated value.
  1979. *
  1980. * @mscs
  1981. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  1982. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  1983. * @endmscs
  1984. *
  1985. * @param[in] conn_handle Connection handle. Can be @ref BLE_CONN_HANDLE_INVALID if a BLE connection has not been established yet.
  1986. * @param[in] p_pk_own LE Secure Connections local P-256 Public Key.
  1987. * @param[out] p_oobd_own The OOB data to be sent out of band to a peer.
  1988. *
  1989. * @retval ::NRF_SUCCESS OOB data successfully generated.
  1990. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  1991. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  1992. */
  1993. 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));
  1994. /**@brief Provide the OOB data sent/received out of band.
  1995. *
  1996. * @note An authentication procedure with OOB selected as an algorithm must be in progress when calling this function.
  1997. * @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.
  1998. *
  1999. * @events
  2000. * @event{This function is used during authentication procedures\, see the list of events in the documentation of @ref sd_ble_gap_authenticate.}
  2001. * @endevents
  2002. *
  2003. * @mscs
  2004. * @mmsc{@ref BLE_GAP_PERIPH_LESC_BONDING_OOB_MSC}
  2005. * @mmsc{@ref BLE_GAP_CENTRAL_LESC_BONDING_OOB_MSC}
  2006. * @endmscs
  2007. *
  2008. * @param[in] conn_handle Connection handle.
  2009. * @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.
  2010. * Must correspond to @ref ble_gap_sec_params_t::oob flag in @ref BLE_GAP_EVT_SEC_PARAMS_REQUEST.
  2011. * @param[in] p_oobd_peer The OOB data received out of band from a peer or NULL if none received.
  2012. * Must correspond to @ref ble_gap_sec_params_t::oob flag
  2013. * in @ref sd_ble_gap_authenticate in the central role or
  2014. * in @ref sd_ble_gap_sec_params_reply in the peripheral role.
  2015. *
  2016. * @retval ::NRF_SUCCESS OOB data accepted.
  2017. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2018. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  2019. * - Authentication key not requested
  2020. * - Not expecting LESC OOB data
  2021. * - Have not actually exchanged passkeys.
  2022. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2023. */
  2024. 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));
  2025. /**@brief Initiate GAP Encryption procedure.
  2026. *
  2027. * @details In the central role, this function will initiate the encryption procedure using the encryption information provided.
  2028. *
  2029. * @events
  2030. * @event{@ref BLE_GAP_EVT_CONN_SEC_UPDATE, The connection security has been updated.}
  2031. * @endevents
  2032. *
  2033. * @mscs
  2034. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_AUTH_MUTEX_MSC}
  2035. * @mmsc{@ref BLE_GAP_CENTRAL_ENC_MSC}
  2036. * @mmsc{@ref BLE_GAP_MULTILINK_CTRL_PROC_MSC}
  2037. * @mmsc{@ref BLE_GAP_CENTRAL_SEC_REQ_MSC}
  2038. * @endmscs
  2039. *
  2040. * @param[in] conn_handle Connection handle.
  2041. * @param[in] p_master_id Pointer to a @ref ble_gap_master_id_t master identification structure.
  2042. * @param[in] p_enc_info Pointer to a @ref ble_gap_enc_info_t encryption information structure.
  2043. *
  2044. * @retval ::NRF_SUCCESS Successfully initiated authentication procedure.
  2045. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2046. * @retval ::NRF_ERROR_INVALID_STATE No link has been established.
  2047. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2048. * @retval ::BLE_ERROR_INVALID_ROLE Operation is not supported in the Peripheral role.
  2049. * @retval ::NRF_ERROR_BUSY Procedure already in progress or not allowed at this time, wait for pending procedures to complete and retry.
  2050. */
  2051. 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));
  2052. /**@brief Reply with GAP security information.
  2053. *
  2054. * @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.
  2055. * @note If the call returns an error code, the request is still pending, and the reply call may be repeated with corrected parameters.
  2056. * @note Data signing is not yet supported, and p_sign_info must therefore be NULL.
  2057. *
  2058. * @mscs
  2059. * @mmsc{@ref BLE_GAP_PERIPH_ENC_MSC}
  2060. * @endmscs
  2061. *
  2062. * @param[in] conn_handle Connection handle.
  2063. * @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.
  2064. * @param[in] p_id_info Pointer to a @ref ble_gap_irk_t identity information structure. May be NULL to signal none is available.
  2065. * @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.
  2066. *
  2067. * @retval ::NRF_SUCCESS Successfully accepted security information.
  2068. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  2069. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  2070. * - No link has been established.
  2071. * - No @ref BLE_GAP_EVT_SEC_REQUEST pending.
  2072. * - LE long term key requested command not allowed.
  2073. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2074. */
  2075. 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));
  2076. /**@brief Get the current connection security.
  2077. *
  2078. * @param[in] conn_handle Connection handle.
  2079. * @param[out] p_conn_sec Pointer to a @ref ble_gap_conn_sec_t structure to be filled in.
  2080. *
  2081. * @retval ::NRF_SUCCESS Current connection security successfully retrieved.
  2082. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2083. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2084. */
  2085. 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));
  2086. /**@brief Start reporting the received signal strength to the application.
  2087. *
  2088. * A new event is reported whenever the RSSI value changes, until @ref sd_ble_gap_rssi_stop is called.
  2089. *
  2090. * @events
  2091. * @event{@ref BLE_GAP_EVT_RSSI_CHANGED, New RSSI data available. How often the event is generated is
  2092. * dependent on the settings of the <code>threshold_dbm</code>
  2093. * and <code>skip_count</code> input parameters.}
  2094. * @endevents
  2095. *
  2096. * @mscs
  2097. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  2098. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  2099. * @endmscs
  2100. *
  2101. * @param[in] conn_handle Connection handle.
  2102. * @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.
  2103. * @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.
  2104. *
  2105. * @retval ::NRF_SUCCESS Successfully activated RSSI reporting.
  2106. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is already ongoing.
  2107. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2108. */
  2109. 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));
  2110. /**@brief Stop reporting the received signal strength.
  2111. *
  2112. * @note An RSSI change detected before the call but not yet received by the application
  2113. * may be reported after @ref sd_ble_gap_rssi_stop has been called.
  2114. *
  2115. * @mscs
  2116. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  2117. * @mmsc{@ref BLE_GAP_RSSI_FILT_MSC}
  2118. * @endmscs
  2119. *
  2120. * @param[in] conn_handle Connection handle.
  2121. *
  2122. * @retval ::NRF_SUCCESS Successfully deactivated RSSI reporting.
  2123. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
  2124. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2125. */
  2126. SVCALL(SD_BLE_GAP_RSSI_STOP, uint32_t, sd_ble_gap_rssi_stop(uint16_t conn_handle));
  2127. /**@brief Get the received signal strength for the last connection event.
  2128. *
  2129. * @ref sd_ble_gap_rssi_start must be called to start reporting RSSI before using this function. @ref NRF_ERROR_NOT_FOUND
  2130. * will be returned until RSSI was sampled for the first time after calling @ref sd_ble_gap_rssi_start.
  2131. * @note ERRATA-153 requires the rssi sample to be compensated based on a temperature measurement.
  2132. * @mscs
  2133. * @mmsc{@ref BLE_GAP_CENTRAL_RSSI_READ_MSC}
  2134. * @endmscs
  2135. *
  2136. * @param[in] conn_handle Connection handle.
  2137. * @param[out] p_rssi Pointer to the location where the RSSI measurement shall be stored.
  2138. * @param[out] p_ch_index Pointer to the location where Channel Index for the RSSI measurement shall be stored.
  2139. *
  2140. * @retval ::NRF_SUCCESS Successfully read the RSSI.
  2141. * @retval ::NRF_ERROR_NOT_FOUND No sample is available.
  2142. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2143. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2144. * @retval ::NRF_ERROR_INVALID_STATE RSSI reporting is not ongoing.
  2145. */
  2146. 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));
  2147. /**@brief Start or continue scanning (GAP Discovery procedure, Observer Procedure).
  2148. *
  2149. * @note A call to this function will require the application to keep the memory pointed by
  2150. * p_adv_report_buffer alive until the buffer is released. The buffer is released when the scanner is stopped
  2151. * or when this function is called with another buffer.
  2152. *
  2153. * @note The scanner will automatically stop in the following cases:
  2154. * - @ref sd_ble_gap_scan_stop is called.
  2155. * - @ref sd_ble_gap_connect is called.
  2156. * - A @ref BLE_GAP_EVT_TIMEOUT with source set to @ref BLE_GAP_TIMEOUT_SRC_SCAN is received.
  2157. * - When a @ref BLE_GAP_EVT_ADV_REPORT event is received and @ref ble_gap_adv_report_type_t::status is not set to
  2158. * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA. In this case scanning is only paused to let the application
  2159. * access received data. The application must call this function to continue scanning, or call @ref sd_ble_gap_scan_stop
  2160. * to stop scanning.
  2161. *
  2162. * @note If a @ref BLE_GAP_EVT_ADV_REPORT event is received with @ref ble_gap_adv_report_type_t::status set to
  2163. * @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_MORE_DATA, the scanner will continue scanning, and the application will
  2164. * receive more reports from this advertising event. The following reports will include the old and new received data.
  2165. *
  2166. * @events
  2167. * @event{@ref BLE_GAP_EVT_ADV_REPORT, An advertising or scan response packet has been received.}
  2168. * @event{@ref BLE_GAP_EVT_TIMEOUT, Scanner has timed out.}
  2169. * @endevents
  2170. *
  2171. * @mscs
  2172. * @mmsc{@ref BLE_GAP_SCAN_MSC}
  2173. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  2174. * @endmscs
  2175. *
  2176. * @param[in] p_scan_params Pointer to scan parameters structure. When this function is used to continue
  2177. * scanning, this parameter must be NULL.
  2178. * @param[in] p_adv_report_buffer Pointer to buffer used to store incoming advertising data.
  2179. * The memory pointed to should be kept alive until the scanning is stopped.
  2180. * See @ref BLE_GAP_SCAN_BUFFER_SIZE for minimum and maximum buffer size.
  2181. * If the scanner receives advertising data larger than can be stored in the buffer,
  2182. * a @ref BLE_GAP_EVT_ADV_REPORT will be raised with @ref ble_gap_adv_report_type_t::status
  2183. * set to @ref BLE_GAP_ADV_DATA_STATUS_INCOMPLETE_TRUNCATED.
  2184. *
  2185. * @retval ::NRF_SUCCESS Successfully initiated scanning procedure.
  2186. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2187. * @retval ::NRF_ERROR_INVALID_STATE Invalid state to perform operation. Either:
  2188. * - Scanning is already ongoing and p_scan_params was not NULL
  2189. * - Scanning is not running and p_scan_params was NULL.
  2190. * - The scanner has timed out when this function is called to continue scanning.
  2191. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied. See @ref ble_gap_scan_params_t.
  2192. * @retval ::NRF_ERROR_NOT_SUPPORTED Unsupported parameters supplied. See @ref ble_gap_scan_params_t.
  2193. * @retval ::NRF_ERROR_INVALID_LENGTH The provided buffer length is invalid. See @ref BLE_GAP_SCAN_BUFFER_MIN.
  2194. * @retval ::NRF_ERROR_RESOURCES Not enough BLE role slots available.
  2195. * Stop one or more currently active roles (Central, Peripheral or Broadcaster) and try again
  2196. */
  2197. 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));
  2198. /**@brief Stop scanning (GAP Discovery procedure, Observer Procedure).
  2199. *
  2200. * @note The buffer provided in @ref sd_ble_gap_scan_start is released.
  2201. *
  2202. * @mscs
  2203. * @mmsc{@ref BLE_GAP_SCAN_MSC}
  2204. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  2205. * @endmscs
  2206. *
  2207. * @retval ::NRF_SUCCESS Successfully stopped scanning procedure.
  2208. * @retval ::NRF_ERROR_INVALID_STATE Not in the scanning state.
  2209. */
  2210. SVCALL(SD_BLE_GAP_SCAN_STOP, uint32_t, sd_ble_gap_scan_stop(void));
  2211. /**@brief Create a connection (GAP Link Establishment).
  2212. *
  2213. * @note If a scanning procedure is currently in progress it will be automatically stopped when calling this function.
  2214. * The scanning procedure will be stopped even if the function returns an error.
  2215. *
  2216. * @events
  2217. * @event{@ref BLE_GAP_EVT_CONNECTED, A connection was established.}
  2218. * @event{@ref BLE_GAP_EVT_TIMEOUT, Failed to establish a connection.}
  2219. * @endevents
  2220. *
  2221. * @mscs
  2222. * @mmsc{@ref BLE_GAP_WL_SHARE_MSC}
  2223. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_PRIV_MSC}
  2224. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC}
  2225. * @endmscs
  2226. *
  2227. * @param[in] p_peer_addr Pointer to peer identity address. If @ref ble_gap_scan_params_t::filter_policy is set to use
  2228. * whitelist, then p_peer_addr is ignored.
  2229. * @param[in] p_scan_params Pointer to scan parameters structure.
  2230. * @param[in] p_conn_params Pointer to desired connection parameters.
  2231. * @param[in] conn_cfg_tag Tag identifying a configuration set by @ref sd_ble_cfg_set or
  2232. * @ref BLE_CONN_CFG_TAG_DEFAULT to use the default connection configuration.
  2233. *
  2234. * @retval ::NRF_SUCCESS Successfully initiated connection procedure.
  2235. * @retval ::NRF_ERROR_INVALID_ADDR Invalid parameter(s) pointer supplied.
  2236. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  2237. * - Invalid parameter(s) in p_scan_params or p_conn_params.
  2238. * - Use of whitelist requested but whitelist has not been set, see @ref sd_ble_gap_whitelist_set.
  2239. * - Peer address was not present in the device identity list, see @ref sd_ble_gap_device_identities_set.
  2240. * @retval ::NRF_ERROR_NOT_FOUND conn_cfg_tag not found.
  2241. * @retval ::NRF_ERROR_INVALID_STATE The SoftDevice is in an invalid state to perform this operation. This may be due to an
  2242. * existing locally initiated connect procedure, which must complete before initiating again.
  2243. * @retval ::BLE_ERROR_GAP_INVALID_BLE_ADDR Invalid Peer address.
  2244. * @retval ::NRF_ERROR_CONN_COUNT The limit of available connections has been reached.
  2245. * @retval ::NRF_ERROR_RESOURCES Either:
  2246. * - Not enough BLE role slots available.
  2247. * Stop one or more currently active roles (Central, Peripheral or Observer) and try again.
  2248. * - The event_length parameter associated with conn_cfg_tag is too small to be able to
  2249. * establish a connection on the selected @ref ble_gap_scan_params_t::scan_phys.
  2250. * Use @ref sd_ble_cfg_set to increase the event length.
  2251. */
  2252. 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));
  2253. /**@brief Cancel a connection establishment.
  2254. *
  2255. * @mscs
  2256. * @mmsc{@ref BLE_GAP_CENTRAL_CONN_MSC}
  2257. * @endmscs
  2258. *
  2259. * @retval ::NRF_SUCCESS Successfully canceled an ongoing connection procedure.
  2260. * @retval ::NRF_ERROR_INVALID_STATE No locally initiated connect procedure started or connection
  2261. * completed occurred.
  2262. */
  2263. SVCALL(SD_BLE_GAP_CONNECT_CANCEL, uint32_t, sd_ble_gap_connect_cancel(void));
  2264. /**@brief Initiate or respond to a PHY Update Procedure
  2265. *
  2266. * @details This function is used to initiate or respond to a PHY Update Procedure. It will always
  2267. * generate a @ref BLE_GAP_EVT_PHY_UPDATE event if successfully executed.
  2268. * If this function is used to initiate a PHY Update procedure and the only option
  2269. * provided in @ref ble_gap_phys_t::tx_phys and @ref ble_gap_phys_t::rx_phys is the
  2270. * currently active PHYs in the respective directions, the SoftDevice will generate a
  2271. * @ref BLE_GAP_EVT_PHY_UPDATE with the current PHYs set and will not initiate the
  2272. * procedure in the Link Layer.
  2273. *
  2274. * If @ref ble_gap_phys_t::tx_phys or @ref ble_gap_phys_t::rx_phys is @ref BLE_GAP_PHY_AUTO,
  2275. * then the stack will select PHYs based on the peer's PHY preferences and the local link
  2276. * configuration. The PHY Update procedure will for this case result in a PHY combination
  2277. * that respects the time constraints configured with @ref sd_ble_cfg_set and the current
  2278. * link layer data length.
  2279. *
  2280. * When acting as a central, the SoftDevice will select the fastest common PHY in each direction.
  2281. *
  2282. * If the peer does not support the PHY Update Procedure, then the resulting
  2283. * @ref BLE_GAP_EVT_PHY_UPDATE event will have a status set to
  2284. * @ref BLE_HCI_UNSUPPORTED_REMOTE_FEATURE.
  2285. *
  2286. * If the PHY procedure was rejected by the peer due to a procedure collision, the status
  2287. * will be @ref BLE_HCI_STATUS_CODE_LMP_ERROR_TRANSACTION_COLLISION or
  2288. * @ref BLE_HCI_DIFFERENT_TRANSACTION_COLLISION.
  2289. * If the peer responds to the PHY Update procedure with invalid parameters, the status
  2290. * will be @ref BLE_HCI_STATUS_CODE_INVALID_LMP_PARAMETERS.
  2291. * If the PHY procedure was rejected by the peer for a different reason, the status will
  2292. * contain the reason as specified by the peer.
  2293. *
  2294. * @events
  2295. * @event{@ref BLE_GAP_EVT_PHY_UPDATE, Result of the PHY Update Procedure.}
  2296. * @endevents
  2297. *
  2298. * @mscs
  2299. * @mmsc{@ref BLE_GAP_CENTRAL_PHY_UPDATE}
  2300. * @mmsc{@ref BLE_GAP_PERIPHERAL_PHY_UPDATE}
  2301. * @endmscs
  2302. *
  2303. * @param[in] conn_handle Connection handle to indicate the connection for which the PHY Update is requested.
  2304. * @param[in] p_gap_phys Pointer to PHY structure.
  2305. *
  2306. * @retval ::NRF_SUCCESS Successfully requested a PHY Update.
  2307. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2308. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle supplied.
  2309. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter(s) supplied.
  2310. * @retval ::NRF_ERROR_INVALID_STATE No link has been established.
  2311. * @retval ::NRF_ERROR_RESOURCES The connection event length configured for this link is not sufficient for the combination of
  2312. * @ref ble_gap_phys_t::tx_phys, @ref ble_gap_phys_t::rx_phys, and @ref ble_gap_data_length_params_t.
  2313. * The connection event length is configured with @ref BLE_CONN_CFG_GAP using @ref sd_ble_cfg_set.
  2314. * @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.
  2315. *
  2316. */
  2317. 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));
  2318. /**@brief Initiate or respond to a Data Length Update Procedure.
  2319. *
  2320. * @note If the application uses @ref BLE_GAP_DATA_LENGTH_AUTO for one or more members of
  2321. * p_dl_params, the SoftDevice will choose the highest value supported in current
  2322. * configuration and connection parameters.
  2323. *
  2324. * @param[in] conn_handle Connection handle.
  2325. * @param[in] p_dl_params Pointer to local parameters to be used in Data Length Update
  2326. * Procedure. Set any member to @ref BLE_GAP_DATA_LENGTH_AUTO to let
  2327. * the SoftDevice automatically decide the value for that member.
  2328. * Set to NULL to use automatic values for all members.
  2329. * @param[out] p_dl_limitation Pointer to limitation to be written when local device does not
  2330. * have enough resources or does not support the requested Data Length
  2331. * Update parameters. Ignored if NULL.
  2332. *
  2333. * @mscs
  2334. * @mmsc{@ref BLE_GAP_DATA_LENGTH_UPDATE_PROCEDURE_MSC}
  2335. * @endmscs
  2336. *
  2337. * @retval ::NRF_SUCCESS Successfully set Data Length Extension initiation/response parameters.
  2338. * @retval ::NRF_ERROR_INVALID_ADDR Invalid pointer supplied.
  2339. * @retval ::BLE_ERROR_INVALID_CONN_HANDLE Invalid connection handle parameter supplied.
  2340. * @retval ::NRF_ERROR_INVALID_STATE No link has been established.
  2341. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameters supplied.
  2342. * @retval ::NRF_ERROR_NOT_SUPPORTED The requested parameters are not supported by the SoftDevice. Inspect
  2343. * p_dl_limitation to see which parameter is not supported.
  2344. * @retval ::NRF_ERROR_RESOURCES The connection event length configured for this link is not sufficient for the requested parameters.
  2345. * Use @ref sd_ble_cfg_set with @ref BLE_CONN_CFG_GAP to increase the connection event length.
  2346. * Inspect p_dl_limitation to see where the limitation is.
  2347. * @retval ::NRF_ERROR_BUSY Peer has already initiated a Data Length Update Procedure. Process the
  2348. * pending @ref BLE_GAP_EVT_DATA_LENGTH_UPDATE_REQUEST event to respond.
  2349. */
  2350. 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));
  2351. /**@brief Start the Quality of Service (QoS) channel survey module.
  2352. *
  2353. * @details The channel survey module provides measurements of the energy levels on
  2354. * the Bluetooth Low Energy channels. When the module is enabled, @ref BLE_GAP_EVT_QOS_CHANNEL_SURVEY_REPORT
  2355. * events will periodically report the measured energy levels for each channel.
  2356. *
  2357. * @note The measurements are scheduled with lower priority than other Bluetooth Low Energy roles,
  2358. * Radio Timeslot API events and Flash API events.
  2359. *
  2360. * @note The channel survey module will attempt to do measurements so that the average interval
  2361. * between measurements will be interval_us. However due to the channel survey module
  2362. * having the lowest priority of all roles and modules, this may not be possible. In that
  2363. * case fewer than expected channel survey reports may be given.
  2364. *
  2365. * @note In order to use the channel survey module, @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available
  2366. * must be set. This is done using @ref sd_ble_cfg_set.
  2367. *
  2368. * @param[in] interval_us Requested average interval for the measurements and reports. See
  2369. * @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVALS for valid ranges. If set
  2370. * to @ref BLE_GAP_QOS_CHANNEL_SURVEY_INTERVAL_CONTINUOUS, the channel
  2371. * survey role will be scheduled at every available opportunity.
  2372. *
  2373. * @retval ::NRF_SUCCESS The module is successfully started.
  2374. * @retval ::NRF_ERROR_INVALID_PARAM Invalid parameter supplied. interval_us is out of the
  2375. * allowed range.
  2376. * @retval ::NRF_ERROR_INVALID_STATE Trying to start the module when already running.
  2377. * @retval ::NRF_ERROR_RESOURCES The channel survey module is not available to the application.
  2378. * Set @ref ble_gap_cfg_role_count_t::qos_channel_survey_role_available using
  2379. * @ref sd_ble_cfg_set.
  2380. */
  2381. SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_START, uint32_t, sd_ble_gap_qos_channel_survey_start(uint32_t interval_us));
  2382. /**@brief Stop the Quality of Service (QoS) channel survey module.
  2383. *
  2384. * @retval ::NRF_SUCCESS The module is successfully stopped.
  2385. * @retval ::NRF_ERROR_INVALID_STATE Trying to stop the module when it is not running.
  2386. */
  2387. SVCALL(SD_BLE_GAP_QOS_CHANNEL_SURVEY_STOP, uint32_t, sd_ble_gap_qos_channel_survey_stop(void));
  2388. /** @} */
  2389. #ifdef __cplusplus
  2390. }
  2391. #endif
  2392. #endif // BLE_GAP_H__
  2393. /**
  2394. @}
  2395. */