ble_gap.h 117 KB

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