ble_gap.h 175 KB

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