ble_gap_evt_app.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597
  1. /**
  2. * Copyright (c) 2014 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef BLE_GAP_EVT_APP_H__
  41. #define BLE_GAP_EVT_APP_H__
  42. /**@file
  43. *
  44. * @defgroup ble_gap_evt_app GAP Application event decoders
  45. * @{
  46. * @ingroup ser_app_s130_codecs
  47. *
  48. * @brief GAP Application event decoders.
  49. */
  50. #include "ble.h"
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. /**
  55. * @brief Decodes ble_gap_evt_auth_key_request event.
  56. *
  57. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  58. *
  59. * @param[in] p_buf Pointer to the beginning of an event packet.
  60. * @param[in] packet_len Length (in bytes) of the event packet.
  61. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  62. * stored. If NULL, required length will be returned in \p p_event_len.
  63. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  64. * \c out: Length of decoded contents of \p p_event.
  65. *
  66. * @retval NRF_SUCCESS Decoding success.
  67. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  68. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  69. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  70. * hold decoded event.
  71. */
  72. uint32_t ble_gap_evt_auth_key_request_dec(uint8_t const * const p_buf,
  73. uint32_t packet_len,
  74. ble_evt_t * const p_event,
  75. uint32_t * const p_event_len);
  76. /**
  77. * @brief Decodes ble_gap_evt_auth_status event.
  78. *
  79. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  80. *
  81. * @param[in] p_buf Pointer to the beginning of an event packet.
  82. * @param[in] packet_len Length (in bytes) of the event packet.
  83. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  84. * stored. If NULL, required length will be returned in \p p_event_len.
  85. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  86. * \c out: Length of decoded contents of \p p_event.
  87. *
  88. * @retval NRF_SUCCESS Decoding success.
  89. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  90. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  91. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  92. * hold decoded event.
  93. */
  94. uint32_t ble_gap_evt_auth_status_dec(uint8_t const * const p_buf,
  95. uint32_t packet_len,
  96. ble_evt_t * const p_event,
  97. uint32_t * const p_event_len);
  98. /**
  99. * @brief Decodes ble_gap_evt_conn_param_update event.
  100. *
  101. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  102. *
  103. * @param[in] p_buf Pointer to the beginning of an event packet.
  104. * @param[in] packet_len Length (in bytes) of the event packet.
  105. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  106. * stored. If NULL, required length will be returned in \p p_event_len.
  107. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  108. * \c out: Length of decoded contents of \p p_event.
  109. *
  110. * @retval NRF_SUCCESS Decoding success.
  111. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  112. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  113. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  114. * hold decoded event.
  115. */
  116. uint32_t ble_gap_evt_conn_param_update_dec(uint8_t const * const p_buf,
  117. uint32_t packet_len,
  118. ble_evt_t * const p_event,
  119. uint32_t * const p_event_len);
  120. /**
  121. * @brief Decodes ble_gap_evt_conn_sec_update event.
  122. *
  123. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  124. *
  125. * @param[in] p_buf Pointer to the beginning of an event packet.
  126. * @param[in] packet_len Length (in bytes) of the event packet.
  127. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  128. * stored. If NULL, required length will be returned in \p p_event_len.
  129. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  130. * \c out: Length of decoded contents of \p p_event.
  131. *
  132. * @retval NRF_SUCCESS Decoding success.
  133. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  134. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  135. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  136. * hold decoded event.
  137. */
  138. uint32_t ble_gap_evt_conn_sec_update_dec(uint8_t const * const p_buf,
  139. uint32_t packet_len,
  140. ble_evt_t * const p_event,
  141. uint32_t * const p_event_len);
  142. /**
  143. * @brief Decodes ble_gap_evt_connected event.
  144. *
  145. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  146. *
  147. * @param[in] p_buf Pointer to the beginning of an event packet.
  148. * @param[in] packet_len Length (in bytes) of the event packet.
  149. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  150. * stored. If NULL, required length will be returned in \p p_event_len.
  151. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  152. * \c out: Length of decoded contents of \p p_event.
  153. *
  154. * @retval NRF_SUCCESS Decoding success.
  155. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  156. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  157. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  158. * hold decoded event.
  159. */
  160. uint32_t ble_gap_evt_connected_dec(uint8_t const * const p_buf,
  161. uint32_t packet_len,
  162. ble_evt_t * const p_event,
  163. uint32_t * const p_event_len);
  164. /**
  165. * @brief Decodes ble_gap_evt_disconnected event.
  166. *
  167. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  168. *
  169. * @param[in] p_buf Pointer to the beginning of an event packet.
  170. * @param[in] packet_len Length (in bytes) of the event packet.
  171. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  172. * stored. If NULL, required length will be returned in \p p_event_len.
  173. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  174. * \c out: Length of decoded contents of \p p_event.
  175. *
  176. * @retval NRF_SUCCESS Decoding success.
  177. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  178. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  179. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  180. * hold decoded event.
  181. */
  182. uint32_t ble_gap_evt_disconnected_dec(uint8_t const * const p_buf,
  183. uint32_t packet_len,
  184. ble_evt_t * const p_event,
  185. uint32_t * const p_event_len);
  186. /**
  187. * @brief Decodes ble_gap_evt_passkey_display event.
  188. *
  189. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  190. *
  191. * @param[in] p_buf Pointer to the beginning of an event packet.
  192. * @param[in] packet_len Length (in bytes) of the event packet.
  193. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  194. * stored. If NULL, required length will be returned in \p p_event_len.
  195. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  196. * \c out: Length of decoded contents of \p p_event.
  197. *
  198. * @retval NRF_SUCCESS Decoding success.
  199. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  200. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  201. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  202. * hold decoded event.
  203. */
  204. uint32_t ble_gap_evt_passkey_display_dec(uint8_t const * const p_buf,
  205. uint32_t packet_len,
  206. ble_evt_t * const p_event,
  207. uint32_t * const p_event_len);
  208. /**
  209. * @brief Decodes ble_gap_evt_rssi_changed event.
  210. *
  211. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  212. *
  213. * @param[in] p_buf Pointer to the beginning of an event packet.
  214. * @param[in] packet_len Length (in bytes) of the event packet.
  215. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  216. * stored. If NULL, required length will be returned in \p p_event_len.
  217. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  218. * \c out: Length of decoded contents of \p p_event.
  219. *
  220. * @retval NRF_SUCCESS Decoding success.
  221. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  222. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  223. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  224. * hold decoded event.
  225. */
  226. uint32_t ble_gap_evt_rssi_changed_dec(uint8_t const * const p_buf,
  227. uint32_t packet_len,
  228. ble_evt_t * const p_event,
  229. uint32_t * const p_event_len);
  230. /**
  231. * @brief Decodes ble_gap_evt_sec_info_request event.
  232. *
  233. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  234. *
  235. * @param[in] p_buf Pointer to the beginning of an event packet.
  236. * @param[in] packet_len Length (in bytes) of the event packet.
  237. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  238. * stored. If NULL, required length will be returned in \p p_event_len.
  239. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  240. * \c out: Length of decoded contents of \p p_event.
  241. *
  242. * @retval NRF_SUCCESS Decoding success.
  243. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  244. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  245. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  246. * hold decoded event.
  247. */
  248. uint32_t ble_gap_evt_sec_info_request_dec(uint8_t const * const p_buf,
  249. uint32_t packet_len,
  250. ble_evt_t * const p_event,
  251. uint32_t * const p_event_len);
  252. /**
  253. * @brief Decodes ble_gap_evt_sec_params_request event.
  254. *
  255. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  256. *
  257. * @param[in] p_buf Pointer to the beginning of an event packet.
  258. * @param[in] packet_len Length (in bytes) of the event packet.
  259. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  260. * stored. If NULL, required length will be returned in \p p_event_len.
  261. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  262. * \c out: Length of decoded contents of \p p_event.
  263. *
  264. * @retval NRF_SUCCESS Decoding success.
  265. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  266. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  267. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  268. * hold decoded event.
  269. */
  270. uint32_t ble_gap_evt_sec_params_request_dec(uint8_t const * const p_buf,
  271. uint32_t packet_len,
  272. ble_evt_t * const p_event,
  273. uint32_t * const p_event_len);
  274. /**
  275. * @brief Decodes ble_gap_evt_timeout event.
  276. *
  277. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  278. *
  279. * @param[in] p_buf Pointer to the beginning of an event packet.
  280. * @param[in] packet_len Length (in bytes) of the event packet.
  281. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  282. * stored. If NULL, required length will be returned in \p p_event_len.
  283. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  284. * \c out: Length of decoded contents of \p p_event.
  285. *
  286. * @retval NRF_SUCCESS Decoding success.
  287. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  288. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  289. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  290. * hold decoded event.
  291. */
  292. uint32_t ble_gap_evt_timeout_dec(uint8_t const * const p_buf,
  293. uint32_t packet_len,
  294. ble_evt_t * const p_event,
  295. uint32_t * const p_event_len);
  296. /**
  297. * @brief Decodes ble_gap_evt_sec_request event.
  298. *
  299. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  300. *
  301. * @param[in] p_buf Pointer to the beginning of an event packet.
  302. * @param[in] packet_len Length (in bytes) of the event packet.
  303. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  304. * stored. If NULL, required length will be returned in \p p_event_len.
  305. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  306. * \c out: Length of decoded contents of \p p_event.
  307. *
  308. * @retval NRF_SUCCESS Decoding success.
  309. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  310. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  311. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  312. * hold decoded event.
  313. */
  314. uint32_t ble_gap_evt_sec_request_dec(uint8_t const * const p_buf,
  315. uint32_t packet_len,
  316. ble_evt_t * const p_event,
  317. uint32_t * const p_event_len);
  318. /**
  319. * @brief Decodes ble_gap_evt_conn_param_update_request event.
  320. *
  321. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  322. *
  323. * @param[in] p_buf Pointer to the beginning of an event packet.
  324. * @param[in] packet_len Length (in bytes) of the event packet.
  325. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  326. * stored. If NULL, required length will be returned in \p p_event_len.
  327. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  328. * \c out: Length of decoded contents of \p p_event.
  329. *
  330. * @retval NRF_SUCCESS Decoding success.
  331. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  332. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  333. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  334. * hold decoded event.
  335. */
  336. uint32_t ble_gap_evt_conn_param_update_request_dec(uint8_t const * const p_buf,
  337. uint32_t packet_len,
  338. ble_evt_t * const p_event,
  339. uint32_t * const p_event_len);
  340. /**
  341. * @brief Decodes ble_gap_evt_adv_report event.
  342. *
  343. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  344. *
  345. * @param[in] p_buf Pointer to the beginning of an event packet.
  346. * @param[in] packet_len Length (in bytes) of the event packet.
  347. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  348. * stored. If NULL, required length will be returned in \p p_event_len.
  349. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  350. * \c out: Length of decoded contents of \p p_event.
  351. *
  352. * @retval NRF_SUCCESS Decoding success.
  353. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  354. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  355. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  356. * hold decoded event.
  357. */
  358. uint32_t ble_gap_evt_adv_report_dec(uint8_t const * const p_buf,
  359. uint32_t packet_len,
  360. ble_evt_t * const p_event,
  361. uint32_t * const p_event_len);
  362. /**
  363. * @brief Decodes ble_gap_evt_scan_req_report event.
  364. *
  365. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  366. *
  367. * @param[in] p_buf Pointer to the beginning of an event packet.
  368. * @param[in] packet_len Length (in bytes) of the event packet.
  369. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  370. * stored. If NULL, required length will be returned in \p p_event_len.
  371. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  372. * \c out: Length of decoded contents of \p p_event.
  373. *
  374. * @retval NRF_SUCCESS Decoding success.
  375. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  376. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  377. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  378. * hold decoded event.
  379. */
  380. uint32_t ble_gap_evt_scan_req_report_dec(uint8_t const * const p_buf,
  381. uint32_t packet_len,
  382. ble_evt_t * const p_event,
  383. uint32_t * const p_event_len);
  384. /**
  385. * @brief Decodes ble_gap_evt_key_pressed event.
  386. *
  387. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  388. *
  389. * @param[in] p_buf Pointer to the beginning of an event packet.
  390. * @param[in] packet_len Length (in bytes) of the event packet.
  391. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  392. * stored. If NULL, required length will be returned in \p p_event_len.
  393. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  394. * \c out: Length of decoded contents of \p p_event.
  395. *
  396. * @retval NRF_SUCCESS Decoding success.
  397. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  398. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  399. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  400. * hold decoded event.
  401. */
  402. uint32_t ble_gap_evt_key_pressed_dec(uint8_t const * const p_buf,
  403. uint32_t packet_len,
  404. ble_evt_t * const p_event,
  405. uint32_t * const p_event_len);
  406. /**
  407. * @brief Decodes ble_gap_evt_lesc_dhkey_request event.
  408. *
  409. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  410. *
  411. * @param[in] p_buf Pointer to the beginning of an event packet.
  412. * @param[in] packet_len Length (in bytes) of the event packet.
  413. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  414. * stored. If NULL, required length will be returned in \p p_event_len.
  415. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  416. * \c out: Length of decoded contents of \p p_event.
  417. *
  418. * @retval NRF_SUCCESS Decoding success.
  419. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  420. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  421. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  422. * hold decoded event.
  423. */
  424. uint32_t ble_gap_evt_lesc_dhkey_request_dec(uint8_t const * const p_buf,
  425. uint32_t packet_len,
  426. ble_evt_t * const p_event,
  427. uint32_t * const p_event_len);
  428. #if NRF_SD_BLE_API_VERSION >= 5
  429. /**
  430. * @brief Decodes ble_gap_evt_phy_update event.
  431. *
  432. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  433. *
  434. * @param[in] p_buf Pointer to the beginning of an event packet.
  435. * @param[in] packet_len Length (in bytes) of the event packet.
  436. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  437. * stored. If NULL, required length will be returned in \p p_event_len.
  438. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  439. * \c out: Length of decoded contents of \p p_event.
  440. *
  441. * @retval NRF_SUCCESS Decoding success.
  442. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  443. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  444. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  445. * hold decoded event.
  446. */
  447. uint32_t ble_gap_evt_phy_update_dec(uint8_t const * const p_buf,
  448. uint32_t packet_len,
  449. ble_evt_t * const p_event,
  450. uint32_t * const p_event_len);
  451. /**
  452. * @brief Decodes ble_gap_evt_phy_update_request event.
  453. *
  454. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  455. *
  456. * @param[in] p_buf Pointer to the beginning of an event packet.
  457. * @param[in] packet_len Length (in bytes) of the event packet.
  458. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  459. * stored. If NULL, required length will be returned in \p p_event_len.
  460. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  461. * \c out: Length of decoded contents of \p p_event.
  462. *
  463. * @retval NRF_SUCCESS Decoding success.
  464. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  465. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  466. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  467. * hold decoded event.
  468. */
  469. uint32_t ble_gap_evt_phy_update_request_dec(uint8_t const * const p_buf,
  470. uint32_t packet_len,
  471. ble_evt_t * const p_event,
  472. uint32_t * const p_event_len);
  473. #endif
  474. #if NRF_SD_BLE_API_VERSION >= 4
  475. /**
  476. * @brief Decodes ble_gap_evt_data_length_update_request event.
  477. *
  478. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  479. *
  480. * @param[in] p_buf Pointer to the beginning of an event packet.
  481. * @param[in] packet_len Length (in bytes) of the event packet.
  482. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  483. * stored. If NULL, required length will be returned in \p p_event_len.
  484. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  485. * \c out: Length of decoded contents of \p p_event.
  486. *
  487. * @retval NRF_SUCCESS Decoding success.
  488. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  489. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  490. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  491. * hold decoded event.
  492. */
  493. uint32_t ble_gap_evt_data_length_update_request_dec(uint8_t const * const p_buf,
  494. uint32_t packet_len,
  495. ble_evt_t * const p_event,
  496. uint32_t * const p_event_len);
  497. /**
  498. * @brief Decodes ble_gap_evt_data_length_update event.
  499. *
  500. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  501. *
  502. * @param[in] p_buf Pointer to the beginning of an event packet.
  503. * @param[in] packet_len Length (in bytes) of the event packet.
  504. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  505. * stored. If NULL, required length will be returned in \p p_event_len.
  506. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  507. * \c out: Length of decoded contents of \p p_event.
  508. *
  509. * @retval NRF_SUCCESS Decoding success.
  510. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  511. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  512. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  513. * hold decoded event.
  514. */
  515. uint32_t ble_gap_evt_data_length_update_dec(uint8_t const * const p_buf,
  516. uint32_t packet_len,
  517. ble_evt_t * const p_event,
  518. uint32_t * const p_event_len);
  519. #endif //NRF_SD_BLE_API_VERSION >= 4
  520. #if NRF_SD_BLE_API_VERSION >= 6
  521. #ifndef S112
  522. /**
  523. * @brief Decodes ble_gap_evt_qos_channel_survey_report event.
  524. *
  525. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  526. *
  527. * @param[in] p_buf Pointer to the beginning of an event packet.
  528. * @param[in] packet_len Length (in bytes) of the event packet.
  529. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  530. * stored. If NULL, required length will be returned in \p p_event_len.
  531. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  532. * \c out: Length of decoded contents of \p p_event.
  533. *
  534. * @retval NRF_SUCCESS Decoding success.
  535. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  536. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  537. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  538. * hold decoded event.
  539. */
  540. uint32_t ble_gap_evt_qos_channel_survey_report_dec(uint8_t const * const p_buf,
  541. uint32_t packet_len,
  542. ble_evt_t * const p_event,
  543. uint32_t * const p_event_len);
  544. #endif
  545. /**
  546. * @brief Decodes ble_gap_evt_adv_set_terminated event.
  547. *
  548. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  549. *
  550. * @param[in] p_buf Pointer to the beginning of an event packet.
  551. * @param[in] packet_len Length (in bytes) of the event packet.
  552. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  553. * stored. If NULL, required length will be returned in \p p_event_len.
  554. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  555. * \c out: Length of decoded contents of \p p_event.
  556. *
  557. * @retval NRF_SUCCESS Decoding success.
  558. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  559. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  560. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  561. * hold decoded event.
  562. */
  563. uint32_t ble_gap_evt_adv_set_terminated_dec(uint8_t const * const p_buf,
  564. uint32_t packet_len,
  565. ble_evt_t * const p_event,
  566. uint32_t * const p_event_len);
  567. #endif
  568. /** @} */
  569. #ifdef __cplusplus
  570. }
  571. #endif
  572. #endif