ble_conn.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  1. /**
  2. * Copyright (c) 2013 - 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_CONN_H__
  41. #define BLE_CONN_H__
  42. /**
  43. * @addtogroup ser_conn_s130_codecs Connectivity codecs for S132 and S140
  44. * @ingroup ser_codecs_conn
  45. */
  46. /**@file
  47. *
  48. * @defgroup ble_conn Connectivity command request decoders and command response encoders
  49. * @{
  50. * @ingroup ser_conn_s130_codecs
  51. *
  52. * @brief Connectivity command request decoders and command response encoders.
  53. */
  54. #include "ble.h"
  55. #ifdef __cplusplus
  56. extern "C" {
  57. #endif
  58. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  59. /**@brief Decodes @ref sd_ble_tx_packet_count_get command request.
  60. *
  61. * @sa @ref ble_tx_packet_count_get_rsp_enc for response encoding.
  62. *
  63. * @param[in] p_buf Pointer to beginning of command request packet.
  64. * @param[in] packet_len Length (in bytes) of response packet.
  65. * @param[out] p_conn_handle Pointer to connection handle.
  66. * @param[out] pp_count Pointer to pointer to location for count.
  67. *
  68. * @retval NRF_SUCCESS Decoding success.
  69. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  70. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  71. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  72. */
  73. uint32_t ble_tx_packet_count_get_req_dec(uint8_t const * const p_buf,
  74. uint16_t packet_len,
  75. uint16_t * const p_conn_handle,
  76. uint8_t * * const pp_count);
  77. /**@brief Encodes @ref sd_ble_tx_packet_count_get command response.
  78. *
  79. * @sa @ref ble_tx_packet_count_get_req_dec for request decoding.
  80. *
  81. * @param[in] return_code Return code indicating if command was successful or not.
  82. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  83. * returned.
  84. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  85. * \c out: Length of encoded command response packet.
  86. * @param[in] p_count Pointer to count value.
  87. *
  88. * @retval NRF_SUCCESS Encoding success.
  89. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  90. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  91. */
  92. uint32_t ble_tx_packet_count_get_rsp_enc(uint32_t return_code,
  93. uint8_t * const p_buf,
  94. uint32_t * const p_buf_len,
  95. uint8_t const * const p_count);
  96. #endif
  97. /**@brief Event encoding dispatcher.
  98. *
  99. * The event encoding dispatcher will route the event packet to the correct encoder which in turn
  100. * encodes the contents of the event and updates the \p p_buf buffer.
  101. *
  102. * @param[in] p_event Pointer to the \ref ble_evt_t buffer that shall be encoded.
  103. * @param[in] event_len Size (in bytes) of \p p_event buffer.
  104. * @param[out] p_buf Pointer to the beginning of a buffer for encoded event packet.
  105. * @param[in,out] p_buf_len \c in: Size (in bytes) of \p p_buf buffer.
  106. * \c out: Length of encoded contents in \p p_buf.
  107. *
  108. * @retval NRF_SUCCESS Encoding success.
  109. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  110. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  111. * @retval NRF_ERROR_NOT_SUPPORTED Event encoder is not implemented.
  112. */
  113. uint32_t ble_event_enc(ble_evt_t const * const p_event,
  114. uint32_t event_len,
  115. uint8_t * const p_buf,
  116. uint32_t * const p_buf_len);
  117. /**@brief Decodes @ref sd_ble_version_get command request.
  118. *
  119. * @sa @ref ble_version_get_rsp_enc for response encoding.
  120. *
  121. * @param[in] p_buf Pointer to beginning of command request packet.
  122. * @param[in] packet_len Length (in bytes) of response packet.
  123. * @param[out] pp_version Pointer to pointer to @ref ble_version_t address.
  124. *
  125. * @retval NRF_SUCCESS Decoding success.
  126. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  127. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  128. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  129. */
  130. uint32_t ble_version_get_req_dec(uint8_t const * const p_buf,
  131. uint16_t packet_len,
  132. ble_version_t * * const pp_version);
  133. /**@brief Encodes @ref sd_ble_version_get command response.
  134. *
  135. * @sa @ref ble_version_get_req_dec for request decoding.
  136. *
  137. * @param[in] return_code Return code indicating if command was successful or not.
  138. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  139. * returned.
  140. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  141. * \c out: Length of encoded command response packet.
  142. * @param[in] p_version Pointer to @ref ble_version_t address.
  143. *
  144. * @retval NRF_SUCCESS Encoding success.
  145. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  146. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  147. */
  148. uint32_t ble_version_get_rsp_enc(uint32_t return_code,
  149. uint8_t * const p_buf,
  150. uint32_t * const p_buf_len,
  151. ble_version_t const * const p_version);
  152. /**@brief Decodes @ref sd_ble_opt_get command request.
  153. *
  154. * @sa @ref ble_opt_get_rsp_enc for response encoding.
  155. *
  156. * @param[in] p_buf Pointer to beginning of command request packet.
  157. * @param[in] packet_len Length (in bytes) of response packet.
  158. * @param[out] p_opt_id Pointer to pointer to @ref ble_version_t address.
  159. * @param[out] pp_opt Pointer to pointer to @ref ble_opt_t address.
  160. *
  161. * @retval NRF_SUCCESS Decoding success.
  162. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  163. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  164. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  165. */
  166. uint32_t ble_opt_get_req_dec(uint8_t const * const p_buf,
  167. uint16_t packet_len,
  168. uint32_t * const p_opt_id,
  169. ble_opt_t **const pp_opt );
  170. /**@brief Encodes @ref sd_ble_opt_get command response.
  171. *
  172. * @sa @ref ble_opt_get_req_dec for request decoding.
  173. *
  174. * @param[in] return_code Return code indicating if command was successful or not.
  175. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  176. * returned.
  177. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  178. * \c out: Length of encoded command response packet.
  179. * @param[in] opt_id identifies type of ble_opt_t union
  180. * @param[in] p_opt Pointer to @ref ble_opt_t union.
  181. *
  182. * @retval NRF_SUCCESS Encoding success.
  183. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  184. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  185. */
  186. uint32_t ble_opt_get_rsp_enc(uint32_t return_code,
  187. uint8_t * const p_buf,
  188. uint32_t * const p_buf_len,
  189. uint32_t opt_id,
  190. ble_opt_t const * const p_opt);
  191. /**@brief Decodes @ref sd_ble_opt_set command request.
  192. *
  193. * @sa @ref ble_opt_set_rsp_enc for response encoding.
  194. *
  195. * @param[in] p_buf Pointer to beginning of command request packet.
  196. * @param[in] packet_len Length (in bytes) of response packet.
  197. * @param[out] p_opt_id Pointer to @ref ble_opt_t union type identifier.
  198. * @param[out] pp_opt Pointer to pointer to @ref ble_opt_t union.
  199. *
  200. * @retval NRF_SUCCESS Decoding success.
  201. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  202. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  203. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  204. */
  205. uint32_t ble_opt_set_req_dec(uint8_t const * const p_buf,
  206. uint16_t packet_len,
  207. uint32_t * const p_opt_id,
  208. ble_opt_t **const pp_opt );
  209. /**@brief Encodes @ref sd_ble_opt_set command response.
  210. *
  211. * @sa @ref ble_opt_set_req_dec for request decoding.
  212. *
  213. * @param[in] return_code Return code indicating if command was successful or not.
  214. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  215. * returned.
  216. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  217. * \c out: Length of encoded command response packet.
  218. *
  219. * @retval NRF_SUCCESS Encoding success.
  220. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  221. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  222. */
  223. uint32_t ble_opt_set_rsp_enc(uint32_t return_code,
  224. uint8_t * const p_buf,
  225. uint32_t * const p_buf_len);
  226. /**@brief Decodes @ref sd_ble_uuid_encode command request.
  227. *
  228. * @sa @ref ble_uuid_encode_rsp_enc for response encoding.
  229. *
  230. * @param[in] p_buf Pointer to beginning of command request packet.
  231. * @param[in] packet_len Length (in bytes) of response packet.
  232. * @param[out] pp_uuid Pointer to pointer to @ref ble_uuid_t structure.
  233. * @param[out] pp_uuid_le_len Pointer to pointer to the length of encoded UUID.
  234. * @param[out] pp_uuid_le Pointer to pointer to buffer where encoded UUID will be stored.
  235. *
  236. * @retval NRF_SUCCESS Decoding success.
  237. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  238. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  239. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  240. */
  241. uint32_t ble_uuid_encode_req_dec(uint8_t const * const p_buf,
  242. uint16_t packet_len,
  243. ble_uuid_t * * const pp_uuid,
  244. uint8_t * * const pp_uuid_le_len,
  245. uint8_t * * const pp_uuid_le);
  246. /**@brief Encodes @ref sd_ble_uuid_encode command response.
  247. *
  248. * @sa @ref ble_uuid_encode_req_dec for request decoding.
  249. *
  250. * @param[in] return_code Return code indicating if command was successful or not.
  251. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  252. * returned.
  253. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  254. * \c out: Length of encoded command response packet.
  255. * @param[in] uuid_le_len Length of the encoded UUID.
  256. * @param[in] p_uuid_le Pointer to the buffer with encoded UUID.
  257. *
  258. * @retval NRF_SUCCESS Encoding success.
  259. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  260. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  261. */
  262. uint32_t ble_uuid_encode_rsp_enc(uint32_t return_code,
  263. uint8_t * const p_buf,
  264. uint32_t * const p_buf_len,
  265. uint8_t uuid_le_len,
  266. uint8_t const * const p_uuid_le);
  267. /**@brief Decodes @ref sd_ble_uuid_decode command request.
  268. *
  269. * @sa @ref ble_uuid_decode_rsp_enc for response encoding.
  270. *
  271. * @param[in] p_buf Pointer to beginning of command request packet.
  272. * @param[in] packet_len Length (in bytes) of response packet.
  273. * @param[out] p_uuid_le_len Pointer to the length of encoded UUID.
  274. * @param[out] pp_uuid_le Pointer to pointer to buffer where encoded UUID will be stored.
  275. * @param[out] pp_uuid Pointer to pointer to @ref ble_uuid_t structure.
  276. * \c It will be set to NULL if p_uuid is not present in the packet.
  277. *
  278. * @retval NRF_SUCCESS Decoding success.
  279. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  280. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  281. */
  282. uint32_t ble_uuid_decode_req_dec(uint8_t const * const p_buf,
  283. uint32_t const packet_len,
  284. uint8_t * p_uuid_le_len,
  285. uint8_t * * const pp_uuid_le,
  286. ble_uuid_t * * const pp_uuid);
  287. /**@brief Encodes @ref sd_ble_uuid_decode command response.
  288. *
  289. * @sa @ref ble_uuid_decode_req_dec for request decoding.
  290. *
  291. * @param[in] return_code Return code indicating if command was successful or not.
  292. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  293. * returned.
  294. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  295. * \c out: Length of encoded command response packet.
  296. * @param[in] p_uuid Pointer to the buffer with encoded UUID.
  297. *
  298. * @retval NRF_SUCCESS Encoding success.
  299. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  300. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  301. */
  302. uint32_t ble_uuid_decode_rsp_enc(uint32_t return_code,
  303. uint8_t * const p_buf,
  304. uint32_t * const p_buf_len,
  305. ble_uuid_t const * const p_uuid);
  306. /**@brief Decodes @ref sd_ble_uuid_vs_add command request.
  307. *
  308. * @sa @ref ble_uuid_vs_add_rsp_enc for response encoding.
  309. *
  310. * @param[in] p_buf Pointer to beginning of command request packet.
  311. * @param[in] packet_len Length (in bytes) of response packet.
  312. * @param[out] pp_uuid Pointer to pointer to UUID.
  313. * \c It will be set to NULL if p_uuid is not present in the packet.
  314. * @param[out] pp_uuid_type Pointer to pointer to UUID type.
  315. * \c It will be set to NULL if p_uuid_type is not present in the packet.
  316. *
  317. * @retval NRF_SUCCESS Decoding success.
  318. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  319. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  320. */
  321. uint32_t ble_uuid_vs_add_req_dec(uint8_t const * const p_buf,
  322. uint16_t packet_len,
  323. ble_uuid128_t * * const pp_uuid,
  324. uint8_t * * const pp_uuid_type);
  325. /**@brief Encodes @ref sd_ble_uuid_vs_add command response.
  326. *
  327. * @sa @ref ble_uuid_vs_add_req_dec for request decoding.
  328. *
  329. * @param[in] return_code Return code indicating if command was successful or not.
  330. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  331. * returned.
  332. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  333. * \c out: Length of encoded command response packet.
  334. * @param[in] p_uuid_type Pointer to the UUID type.
  335. *
  336. * @retval NRF_SUCCESS Encoding success.
  337. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  338. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  339. */
  340. uint32_t ble_uuid_vs_add_rsp_enc(uint32_t return_code,
  341. uint8_t * const p_buf,
  342. uint32_t * const p_buf_len,
  343. uint8_t const * const p_uuid_type);
  344. #if defined(NRF_SD_BLE_API_VERSION) && NRF_SD_BLE_API_VERSION < 4
  345. /**@brief Decodes @ref sd_ble_enable command request.
  346. *
  347. * @sa @ref ble_enable_rsp_enc for response encoding.
  348. *
  349. * @param[in] p_buf Pointer to beginning of command request packet.
  350. * @param[in] packet_len Length (in bytes) of response packet.
  351. * @param[out] pp_ble_enable_params Pointer to pointer to ble_enable_params_t.
  352. * \c It will be set to NULL if p_ble_enable_params is not present in the packet.
  353. *
  354. * @retval NRF_SUCCESS Decoding success.
  355. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  356. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  357. */
  358. uint32_t ble_enable_req_dec(uint8_t const * const p_buf,
  359. uint32_t packet_len,
  360. ble_enable_params_t * * const pp_ble_enable_params);
  361. #else
  362. /**@brief Decodes @ref sd_ble_enable command request.
  363. *
  364. * @sa @ref ble_enable_rsp_enc for response encoding.
  365. *
  366. * @param[in] p_buf Pointer to beginning of command request packet.
  367. * @param[in] packet_len Length (in bytes) of response packet.
  368. *
  369. * @retval NRF_SUCCESS Decoding success.
  370. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  371. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  372. */
  373. uint32_t ble_enable_req_dec(uint8_t const * const p_buf,
  374. uint32_t packet_len);
  375. #endif
  376. /**@brief Encodes @ref sd_ble_enable command response.
  377. *
  378. * @sa @ref ble_enable_req_dec for request decoding.
  379. *
  380. * @param[in] return_code Return code indicating if command was successful or not.
  381. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  382. * returned.
  383. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  384. * \c out: Length of encoded command response packet.
  385. *
  386. * @retval NRF_SUCCESS Encoding success.
  387. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  388. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  389. */
  390. uint32_t ble_enable_rsp_enc(uint32_t return_code,
  391. uint8_t * const p_buf,
  392. uint32_t * const p_buf_len);
  393. /**@brief Pre-decodes opt_id of @ref ble_opt_t for middleware.
  394. *
  395. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  396. * returned.
  397. * @param[in,out] packet_len \c in: size of \p p_buf buffer.
  398. * \c out: Length of encoded command response packet.
  399. * @param[in,out] p_opt_id Pointer to opt_id which identifies type of @ref ble_opt_t union.
  400. *
  401. * @retval NRF_SUCCESS Encoding success.
  402. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  403. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  404. */
  405. uint32_t ble_opt_id_pre_dec(uint8_t const * const p_buf,
  406. uint16_t packet_len,
  407. uint32_t * const p_opt_id);
  408. /**@brief Decodes @ref sd_ble_user_mem_reply command request.
  409. *
  410. * @sa @ref ble_user_mem_reply_rsp_enc for response encoding.
  411. *
  412. * @param[in] p_buf Pointer to beginning of command request packet.
  413. * @param[in] packet_len Length (in bytes) of response packet.
  414. * @param[in] p_conn_handle Pointer to Connection Handle.
  415. * @param[in,out] pp_block Pointer to pointer to ble_user_mem_block_t.
  416. * \c It will be set to NULL if p_block is not present in the packet.
  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. */
  422. uint32_t ble_user_mem_reply_req_dec(uint8_t const * const p_buf,
  423. uint32_t packet_len,
  424. uint16_t * const p_conn_handle,
  425. ble_user_mem_block_t * * const pp_block);
  426. /**@brief Encodes @ref sd_ble_user_mem_reply command response.
  427. *
  428. * @sa @ref ble_user_mem_reply_req_dec for request decoding.
  429. *
  430. * @param[in] return_code Return code indicating if command was successful or not.
  431. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  432. * returned.
  433. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  434. * \c out: Length of encoded command response packet.
  435. *
  436. * @retval NRF_SUCCESS Encoding success.
  437. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  438. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  439. */
  440. uint32_t ble_user_mem_reply_rsp_enc(uint32_t return_code,
  441. uint8_t * const p_buf,
  442. uint32_t * const p_buf_len);
  443. #if NRF_SD_BLE_API_VERSION >= 4
  444. /**@brief Decodes @ref sd_ble_cfg_set command request.
  445. *
  446. * @sa @ref ble_cfg_set_rsp_enc for response encoding.
  447. *
  448. * @param[in] p_buf Pointer to beginning of command request packet.
  449. * @param[in] packet_len Length (in bytes) of response packet.
  450. * @param[in] p_cfg_id Pointer to ConfigurationId.
  451. * @param[in,out] pp_cfg Pointer to pointer to configuration struct.
  452. * \c It will be set to NULL if p_block is not present in the packet.
  453. *
  454. * @retval NRF_SUCCESS Decoding success.
  455. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  456. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  457. */
  458. uint32_t ble_cfg_set_req_dec(uint8_t const * const p_buf,
  459. uint32_t packet_len,
  460. uint32_t * p_cfg_id,
  461. ble_cfg_t * * const pp_cfg);
  462. /**@brief Encodes @ref sd_ble_cfg_set command response.
  463. *
  464. * @sa @ref ble_cfg_set_req_dec for request decoding.
  465. *
  466. * @param[in] return_code Return code indicating if command was successful or not.
  467. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  468. * returned.
  469. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  470. * \c out: Length of encoded command response packet.
  471. *
  472. * @retval NRF_SUCCESS Encoding success.
  473. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  474. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  475. */
  476. uint32_t ble_cfg_set_rsp_enc(uint32_t return_code,
  477. uint8_t * const p_buf,
  478. uint32_t * const p_buf_len);
  479. #endif
  480. /** @} */
  481. #ifdef __cplusplus
  482. }
  483. #endif
  484. #endif