ble_gatts_conn.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  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_GATTS_CONN_H__
  41. #define BLE_GATTS_CONN_H__
  42. /**@file
  43. *
  44. * @defgroup ble_gatts_conn GATTS Connectivity command request decoders and command response encoders
  45. * @{
  46. * @ingroup ser_conn_s130_codecs
  47. *
  48. * @brief GATTS Connectivity command request decoders and command response encoders.
  49. */
  50. #include "ble_gatts.h"
  51. #include "ble.h"
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /**@brief Decodes @ref sd_ble_gatts_value_get command request.
  56. *
  57. * @sa @ref ble_gatts_value_get_rsp_enc for response encoding.
  58. *
  59. * @param[in] p_buf Pointer to beginning of command request packet.
  60. * @param[in] packet_len Length (in bytes) of request packet.
  61. * @param[out] p_conn_handle Pointer to the connection_handle.
  62. * @param[out] p_handle Pointer to the attribute_handle.
  63. * @param[out] pp_value Pointer to pointer to the Attribute Value structure.
  64. *
  65. * @retval NRF_SUCCESS Decoding success.
  66. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  67. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  68. */
  69. uint32_t ble_gatts_value_get_req_dec(uint8_t const * const p_buf,
  70. uint16_t packet_len,
  71. uint16_t * const p_conn_handle,
  72. uint16_t * const p_handle,
  73. ble_gatts_value_t * * const pp_value);
  74. /**@brief Encodes @ref sd_ble_gatts_value_get command response.
  75. *
  76. * @sa @ref ble_gatts_value_get_req_dec for request decoding.
  77. *
  78. * @param[in] return_code Return code indicating if command was successful or not.
  79. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  80. * returned.
  81. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  82. * \c out: Length of encoded command response packet.
  83. * @param[in] p_value Pointer to Attribute Value structure.
  84. *
  85. * @retval NRF_SUCCESS Encoding success.
  86. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  87. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  88. */
  89. uint32_t ble_gatts_value_get_rsp_enc(uint32_t return_code,
  90. uint8_t * const p_buf,
  91. uint32_t * const p_buf_len,
  92. ble_gatts_value_t * const p_value);
  93. /**@brief Decodes @ref sd_ble_gatts_characteristic_add command request.
  94. *
  95. * @sa @ref ble_gatts_characteristic_add_rsp_enc for response encoding.
  96. *
  97. * @param[in] p_buf Pointer to beginning of command request packet.
  98. * @param[in] packet_len Length (in bytes) of request packet.
  99. * @param[out] p_service_handle Pointer to the service_handle.
  100. * @param[out] constpp_char_md Pointer to pointer to the location where Characteristic metadata
  101. * will be decoded.
  102. * @param[out] pp_attr_char_value Pointer to pointer to the location where GATT Attribute will be
  103. * decoded.
  104. * @param[out] pp_handles Pointer to pointer to the location where Characteristic definition
  105. * handles will be decoded.
  106. *
  107. * @retval NRF_SUCCESS Decoding success.
  108. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  109. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  110. */
  111. uint32_t ble_gatts_characteristic_add_req_dec(uint8_t const * const p_buf,
  112. uint32_t packet_len,
  113. uint16_t * p_service_handle,
  114. ble_gatts_char_md_t * * constpp_char_md,
  115. ble_gatts_attr_t * * const pp_attr_char_value,
  116. ble_gatts_char_handles_t * * const pp_handles);
  117. /**@brief Encodes @ref ble_gatts_sys_attr_get_rsp_enc command response.
  118. *
  119. * @sa @ref ble_gatts_sys_attr_get_req_dec for request decoding.
  120. *
  121. * @param[in] return_code Return code indicating if command was successful or not.
  122. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  123. * returned.
  124. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  125. * \c out: Length of encoded command response packet.
  126. * @param[in] p_handles Pointer to handle struct to be encoded.
  127. *
  128. * @retval NRF_SUCCESS Encoding success.
  129. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  130. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  131. */
  132. uint32_t ble_gatts_characteristic_add_rsp_enc(uint32_t return_code,
  133. uint8_t * const p_buf,
  134. uint32_t * const p_buf_len,
  135. ble_gatts_char_handles_t const * const p_handles);
  136. /**@brief Decodes @ref sd_ble_gatts_include_add command request.
  137. *
  138. * @sa @ref ble_gatts_include_add_rsp_enc for response encoding.
  139. *
  140. * @param[in] p_buf Pointer to beginning of command request packet.
  141. * @param[in] packet_len Length (in bytes) of request packet.
  142. * @param[out] p_service_handle Pointer to the service_handle.
  143. * @param[out] p_inc_srvc_handle Pointer to the handle of the included service.
  144. * @param[out] pp_include_handle Pointer to Pointer to 16-bit word where the assigned handle will be stored.
  145. *
  146. * @retval NRF_SUCCESS Decoding success.
  147. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  148. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  149. */
  150. uint32_t ble_gatts_include_add_req_dec(uint8_t const * const p_buf,
  151. uint16_t packet_len,
  152. uint16_t * const p_service_handle,
  153. uint16_t * const p_inc_srvc_handle,
  154. uint16_t * * const pp_include_handle);
  155. /**@brief Encodes @ref ble_gatts_include_add_rsp_enc command response.
  156. *
  157. * @param[in] return_code Return code indicating if command was successful or not.
  158. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  159. * returned.
  160. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  161. * \c out: Length of encoded command response packet.
  162. * @param[in] p_include_handle Pointer to a 16-bit word where the assigned handle was stored.
  163. *
  164. * @retval NRF_SUCCESS Encoding success.
  165. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  166. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  167. */
  168. uint32_t ble_gatts_include_add_rsp_enc(uint32_t return_code,
  169. uint8_t * const p_buf,
  170. uint32_t * const p_buf_len,
  171. uint16_t const * const p_include_handle);
  172. /**@brief Decodes @ref sd_ble_gatts_service_add command request.
  173. *
  174. * @sa @ref ble_gatts_service_add_rsp_enc for response encoding.
  175. *
  176. * @param[in] p_buf Pointer to beginning of command request packet.
  177. * @param[in] packet_len Length (in bytes) of request packet.
  178. * @param[out] p_type Pointer to the service type.
  179. * @param[out] pp_uuid Pointer to pointer to service UUID.
  180. * @param[out] pp_handle Pointer to pointer to a 16-bit word where the assigned handle will be stored.
  181. *
  182. * @retval NRF_SUCCESS Decoding success.
  183. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  184. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  185. */
  186. uint32_t ble_gatts_service_add_req_dec(uint8_t const * const p_buf,
  187. uint32_t packet_len,
  188. uint8_t * const p_type,
  189. ble_uuid_t * * const pp_uuid,
  190. uint16_t * * const pp_handle);
  191. /**@brief Encodes @ref ble_gatts_service_add_rsp_enc command response.
  192. *
  193. * @param[in] return_code Return code indicating if command was successful or not.
  194. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  195. * returned.
  196. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  197. * \c out: Length of encoded command response packet.
  198. * @param[in] p_handle Pointer to a 16-bit word where the assigned handle was stored.
  199. *
  200. * @retval NRF_SUCCESS Encoding success.
  201. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  202. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  203. */
  204. uint32_t ble_gatts_service_add_rsp_enc(uint32_t return_code,
  205. uint8_t * const p_buf,
  206. uint32_t * const p_buf_len,
  207. uint16_t const * const p_handle);
  208. /**@brief Decodes @ref ble_gatts_sys_attr_get_req_dec command request.
  209. *
  210. * @sa @ref ble_gatts_sys_attr_get_rsp_enc for response encoding.
  211. *
  212. * @param[in] p_buf Pointer to beginning of command request packet.
  213. * @param[in] packet_len Length (in bytes) of response packet.
  214. * @param[out] p_conn_handle Pointer to connectiton handle.
  215. * @param[out] pp_sys_attr_data Pointer to pointer to buffer where system attributes data will be filled in.
  216. * @param[out] pp_sys_attr_data_len Pointer to pointer to variable which contains size of buffer for system attributes.
  217. * @param[out] p_flags Pointer to additional optional flags.
  218. *
  219. * @retval NRF_SUCCESS Decoding success.
  220. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  221. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  222. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  223. */
  224. uint32_t ble_gatts_sys_attr_get_req_dec(uint8_t const * const p_buf,
  225. uint32_t packet_len,
  226. uint16_t * const p_conn_handle,
  227. uint8_t * * const pp_sys_attr_data,
  228. uint16_t * * const pp_sys_attr_data_len,
  229. uint32_t * const p_flags);
  230. /**@brief Encodes @ref ble_gatts_sys_attr_get_rsp_enc command response.
  231. *
  232. * @sa @ref ble_gatts_sys_attr_get_req_dec for request decoding.
  233. *
  234. * @param[in] return_code Return code indicating if command was successful or not.
  235. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  236. * returned.
  237. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  238. * \c out: Length of encoded command response packet.
  239. * @param[in] p_sys_attr_data Pointer to buffer where system attributes data are stored.
  240. * @param[in] p_sys_attr_data_len Pointer to variable which contains size of buffer for system attributes.
  241. *
  242. * @retval NRF_SUCCESS Encoding success.
  243. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  244. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  245. */
  246. uint32_t ble_gatts_sys_attr_get_rsp_enc(uint32_t return_code,
  247. uint8_t * const p_buf,
  248. uint32_t * const p_buf_len,
  249. uint8_t const * const p_sys_attr_data,
  250. uint16_t const * const p_sys_attr_data_len);
  251. /**@brief Decodes @ref sd_ble_gatts_value_set command request.
  252. *
  253. * @sa @ref ble_gatts_value_set_rsp_enc for response encoding.
  254. *
  255. * @param[in] p_buf Pointer to beginning of command request packet.
  256. * @param[in] packet_len Length (in bytes) of response packet.
  257. * @param[out] p_conn_handle Pointer to connection handle.
  258. * @param[out] p_handle Pointer to attribute handle.
  259. * @param[out] pp_value Pointer to pointer to attribute value structure.
  260. *
  261. * @retval NRF_SUCCESS Decoding success.
  262. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  263. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  264. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  265. */
  266. uint32_t ble_gatts_value_set_req_dec(uint8_t const * const p_buf,
  267. uint16_t packet_len,
  268. uint16_t * p_conn_handle,
  269. uint16_t * p_handle,
  270. ble_gatts_value_t * * const pp_value);
  271. /**@brief Encodes @ref sd_ble_gatts_value_set command response.
  272. *
  273. * @param[in] return_code Return code indicating if command was successful or not.
  274. * @param[in] p_buf Pointer to buffer where encoded data command response will be
  275. * returned.
  276. * @param[in, out] p_buf_len \c in: size of \p p_buf buffer.
  277. * \c out: Length of encoded command response packet.
  278. * @param[in] p_value \c in: size of value returned when value was written with success
  279. *
  280. * @retval NRF_SUCCESS Encoding success.
  281. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  282. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  283. */
  284. uint32_t ble_gatts_value_set_rsp_enc(uint32_t return_code,
  285. uint8_t * const p_buf,
  286. uint32_t * const p_buf_len,
  287. ble_gatts_value_t * p_value);
  288. /**@brief Decodes @ref sd_ble_gatts_sys_attr_set command request.
  289. *
  290. * @sa @ref ble_gatts_sys_attr_set_rsp_enc for response encoding.
  291. *
  292. * @param[in] p_buf Pointer to beginning of command request packet.
  293. * @param[in] packet_len Length (in bytes) of request packet.
  294. * @param[out] p_conn_handle Pointer to the buffer raw data to be placed in advertisement packet.
  295. * @param[out] pp_sys_attr_data Pointer to pointer to system attribute data.
  296. * @param[out] p_sys_attr_data_len Pointer to data length for system attribute data.
  297. * @param[out] p_flags Pointer to additional optional flags.
  298. *
  299. * @retval NRF_SUCCESS Decoding success.
  300. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  301. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  302. */
  303. uint32_t ble_gatts_sys_attr_set_req_dec(uint8_t const * const p_buf,
  304. uint32_t packet_len,
  305. uint16_t * const p_conn_handle,
  306. uint8_t * * const pp_sys_attr_data,
  307. uint16_t * const p_sys_attr_data_len,
  308. uint32_t * const p_flags);
  309. /**@brief Encodes @ref sd_ble_gatts_sys_attr_set command response.
  310. *
  311. * @sa @ref ble_gatts_sys_attr_set_req_dec for request decoding.
  312. *
  313. * @param[in] return_code Return code indicating if command was successful or not.
  314. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  315. * returned.
  316. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  317. * \c out: Length of encoded command response packet.
  318. *
  319. * @retval NRF_SUCCESS Encoding success.
  320. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  321. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  322. */
  323. uint32_t ble_gatts_sys_attr_set_rsp_enc(uint32_t return_code,
  324. uint8_t * const p_buf,
  325. uint32_t * const p_buf_len);
  326. /**@brief Decodes @ref ble_gatts_hvx_req_dec command request.
  327. *
  328. * @sa @ref ble_gatts_hvx_rsp_enc for response encoding.
  329. *
  330. * @param[in] p_buf Pointer to beginning of command request packet.
  331. * @param[in] packet_len Length (in bytes) of request packet.
  332. * @param[out] p_conn_handle Pointer to the buffer raw data to be placed in advertisement packet.
  333. * @param[out] pp_hvx_params Pointer to an HVx parameters structure.
  334. *
  335. * @retval NRF_SUCCESS Decoding success.
  336. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  337. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  338. */
  339. uint32_t ble_gatts_hvx_req_dec(uint8_t const * const p_buf,
  340. uint32_t packet_len,
  341. uint16_t * const p_conn_handle,
  342. ble_gatts_hvx_params_t * * const pp_hvx_params);
  343. /**@brief Encodes @ref ble_gatts_hvx_rsp_enc command response.
  344. *
  345. * @sa @ref ble_gatts_hvx_req_dec for request decoding.
  346. *
  347. * @param[in] return_code Return code indicating if command was successful or not.
  348. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  349. * returned.
  350. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  351. * \c out: Length of encoded command response packet.
  352. * @param[in] p_bytes_written Pointer to number of bytes written.
  353. *
  354. * @retval NRF_SUCCESS Encoding success.
  355. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  356. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  357. */
  358. uint32_t ble_gatts_hvx_rsp_enc(uint32_t return_code,
  359. uint8_t * const p_buf,
  360. uint32_t * const p_buf_len,
  361. uint16_t const * const p_bytes_written);
  362. /**@brief Decodes @ref sd_ble_gatts_descriptor_add command request.
  363. *
  364. * @sa @ref ble_gatts_descriptor_add_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 request packet.
  368. * @param[out] p_char_handle Pointer to buffer where characteristic handle will be.
  369. returned.
  370. * @param[out] pp_attr Pointer to pointer to an attribute structure.
  371. * @param[out] pp_handle Pointer to pointer to descriptor handle.
  372. *
  373. * @retval NRF_SUCCESS Decoding success.
  374. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  375. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  376. */
  377. uint32_t ble_gatts_descriptor_add_req_dec(uint8_t const * const p_buf,
  378. uint32_t packet_len,
  379. uint16_t * const p_char_handle,
  380. ble_gatts_attr_t * * const pp_attr,
  381. uint16_t * * const pp_handle);
  382. /**@brief Encodes @ref sd_ble_gatts_descriptor_add command response.
  383. *
  384. * @sa @ref ble_gatts_descriptor_add_req_dec for request decoding.
  385. *
  386. * @param[in] return_code Return code indicating if command was successful or not.
  387. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  388. * returned.
  389. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  390. * \c out: Length of encoded command response packet.
  391. * @param[in] p_handle Pointer to descriptor handle value.
  392. *
  393. * @retval NRF_SUCCESS Encoding success.
  394. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  395. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  396. */
  397. uint32_t ble_gatts_descriptor_add_rsp_enc(uint32_t return_code,
  398. uint8_t * const p_buf,
  399. uint32_t * const p_buf_len,
  400. uint16_t * p_handle);
  401. /**@brief Decodes @ref sd_ble_gatts_rw_authorize_reply command request.
  402. *
  403. * @sa @ref ble_gatts_rw_authorize_reply_rsp_enc for response encoding.
  404. *
  405. * @param[in] p_buf Pointer to beginning of command request packet.
  406. * @param[in] packet_len Length (in bytes) of response packet.
  407. * @param[out] p_conn_handle Pointer to connection handle.
  408. * @param[out] pp_reply_params Pointer to pointer to \ref ble_gatts_rw_authorize_reply_params_t .
  409. *
  410. * @retval NRF_SUCCESS Decoding success.
  411. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  412. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  413. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  414. */
  415. uint32_t ble_gatts_rw_authorize_reply_req_dec(
  416. uint8_t const * const p_buf,
  417. uint32_t
  418. packet_len,
  419. uint16_t *
  420. p_conn_handle,
  421. ble_gatts_rw_authorize_reply_params_t * * const
  422. pp_reply_params);
  423. /**@brief Encodes @ref sd_ble_gatts_rw_authorize_reply command response.
  424. *
  425. * @sa @ref ble_gatts_rw_authorize_reply_req_dec for request decoding.
  426. *
  427. * @param[in] return_code Return code indicating if command was successful or not.
  428. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  429. * returned.
  430. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  431. * \c out: Length of encoded command response packet.
  432. *
  433. * @retval NRF_SUCCESS Encoding success.
  434. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  435. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  436. */
  437. uint32_t ble_gatts_rw_authorize_reply_rsp_enc(uint32_t return_code,
  438. uint8_t * const p_buf,
  439. uint32_t * const p_buf_len);
  440. /**@brief Decodes @ref sd_ble_gatts_service_changed command request.
  441. *
  442. * @sa @ref ble_gatts_service_changed_rsp_enc for response encoding.
  443. *
  444. * @param[in] p_buf Pointer to beginning of command request packet.
  445. * @param[in] packet_len Length (in bytes) of response packet.
  446. * @param[out] p_conn_handle Pointer to connection handle.
  447. * @param[out] p_start_handle Pointer to start handle.
  448. * @param[out] p_end_handle Pointer to end handle.
  449. *
  450. * @retval NRF_SUCCESS Decoding success.
  451. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  452. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  453. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  454. */
  455. uint32_t ble_gatts_service_changed_req_dec(uint8_t const * const p_buf,
  456. uint32_t packet_len,
  457. uint16_t * p_conn_handle,
  458. uint16_t * p_start_handle,
  459. uint16_t * p_end_handle);
  460. /**@brief Encodes @ref sd_ble_gatts_service_changed command response.
  461. *
  462. * @sa @ref ble_gatts_service_changed_req_dec for request decoding.
  463. *
  464. * @param[in] return_code Return code indicating if command was successful or not.
  465. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  466. * returned.
  467. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  468. * \c out: Length of encoded command response packet.
  469. *
  470. * @retval NRF_SUCCESS Encoding success.
  471. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  472. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  473. */
  474. uint32_t ble_gatts_service_changed_rsp_enc(uint32_t return_code,
  475. uint8_t * const p_buf,
  476. uint32_t * const p_buf_len);
  477. /**@brief Decodes @ref ble_gatts_attr_get_req_dec command request.
  478. *
  479. * @sa @ref ble_gatts_attr_get_rsp_enc for response encoding.
  480. *
  481. * @param[in] p_buf Pointer to beginning of command request packet.
  482. * @param[in] packet_len Length (in bytes) of response packet.
  483. * @param[out] p_handle Pointer to handle.
  484. * @param[out] pp_uuid Pointer to pointer to location for decoded uuid structure.
  485. * @param[out] pp_md Pointer to pointer to location for md structure.
  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_INVALID_PARAM Decoding failure. Invalid operation type.
  491. */
  492. uint32_t ble_gatts_attr_get_req_dec(uint8_t const * const p_buf,
  493. uint32_t packet_len,
  494. uint16_t * p_handle,
  495. ble_uuid_t * * pp_uuid,
  496. ble_gatts_attr_md_t * * pp_md);
  497. /**@brief Encodes @ref ble_gatts_attr_get_rsp_enc command response.
  498. *
  499. * @sa @ref ble_gatts_attr_get_req_dec for request decoding.
  500. *
  501. * @param[in] return_code Return code indicating if command was successful or not.
  502. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  503. * returned.
  504. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  505. * \c out: Length of encoded command response packet.
  506. * @param[in] p_uuid Pointer to structure to be encoded.
  507. * @param[in] p_md Pointer to structure to be encoded.
  508. *
  509. * @retval NRF_SUCCESS Encoding success.
  510. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  511. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  512. */
  513. uint32_t ble_gatts_attr_get_rsp_enc(uint32_t return_code,
  514. uint8_t * const p_buf,
  515. uint32_t * const p_buf_len,
  516. ble_uuid_t * p_uuid,
  517. ble_gatts_attr_md_t * p_md);
  518. /**@brief Decodes @ref ble_gatts_initial_user_handle_get_req_dec command request.
  519. *
  520. * @sa @ref ble_gatts_initial_user_handle_get_rsp_enc for response encoding.
  521. *
  522. * @param[in] p_buf Pointer to beginning of command request packet.
  523. * @param[in] packet_len Length (in bytes) of response packet.
  524. * @param[out] pp_handle Pointer to pointer to handle.
  525. *
  526. * @retval NRF_SUCCESS Decoding success.
  527. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  528. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  529. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  530. */
  531. uint32_t ble_gatts_initial_user_handle_get_req_dec(uint8_t const * const p_buf,
  532. uint32_t packet_len,
  533. uint16_t * * pp_handle);
  534. /**@brief Encodes @ref ble_gatts_initial_user_handle_get_rsp_enc command response.
  535. *
  536. * @sa @ref ble_gatts_initial_user_handle_get_req_dec for request decoding.
  537. *
  538. * @param[in] return_code Return code indicating if command was successful or not.
  539. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  540. * returned.
  541. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  542. * \c out: Length of encoded command response packet.
  543. * @param[in] p_handle Pointer to handle to be encoded.
  544. *
  545. * @retval NRF_SUCCESS Encoding success.
  546. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  547. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  548. */
  549. uint32_t ble_gatts_initial_user_handle_get_rsp_enc(uint32_t return_code,
  550. uint8_t * const p_buf,
  551. uint32_t * const p_buf_len,
  552. uint16_t * p_handle);
  553. /**@brief Decodes @ref sd_ble_gatts_rw_authorize_reply command request.
  554. *
  555. * @ref ble_gatts_exchange_mtu_reply_rsp_enc for response encoding.
  556. *
  557. * @param[in] p_buf Pointer to beginning of command request packet.
  558. * @param[in] packet_len Length (in bytes) of response packet.
  559. * @param[out] p_conn_handle Pointer to connection handle.
  560. * @param[out] p_server_rx_mtu Pointer to Server RX MTU size.
  561. *
  562. * @retval NRF_SUCCESS Decoding success.
  563. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  564. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  565. * @retval NRF_ERROR_INVALID_PARAM Decoding failure. Invalid operation type.
  566. */
  567. uint32_t ble_gatts_exchange_mtu_reply_req_dec(uint8_t const * const p_buf,
  568. uint16_t packet_len,
  569. uint16_t * const p_conn_handle,
  570. uint16_t * const p_server_rx_mtu);
  571. /**@brief Encodes @ref sd_ble_gatts_rw_authorize_reply command response.
  572. *
  573. * @ref ble_gatts_exchange_mtu_reply_req_dec for request decoding.
  574. *
  575. * @param[in] return_code Return code indicating if command was successful or not.
  576. * @param[out] p_buf Pointer to buffer where encoded data command response will be
  577. * returned.
  578. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  579. * \c out: Length of encoded command response packet.
  580. *
  581. * @retval NRF_SUCCESS Encoding success.
  582. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  583. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  584. */
  585. uint32_t ble_gatts_exchange_mtu_reply_rsp_enc(uint32_t return_code,
  586. uint8_t * const p_buf,
  587. uint32_t * const p_buf_len);
  588. /** @} */
  589. #ifdef __cplusplus
  590. }
  591. #endif
  592. #endif //BLE_GATTS_CONN_H__