ble_gap.h 132 KB

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