ble_gatts_app.h 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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_APP_H__
  41. #define BLE_GATTS_APP_H__
  42. /**@file
  43. *
  44. * @defgroup ble_gatts_app GATTS Application command request encoders and command response decoders
  45. * @{
  46. * @ingroup ser_app_s130_codecs
  47. *
  48. * @brief GATTS Application command request encoders and command response decoders.
  49. */
  50. #include "ble_gatts.h"
  51. #include "ble.h"
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. /**@brief Encodes @ref sd_ble_gatts_value_get command request.
  56. *
  57. * @sa @ref ble_gatts_value_get_rsp_dec for command response decoder.
  58. *
  59. * @param[in] conn_handle Connection handle.
  60. * @param[in] handle Attribute handle.
  61. * @param[in] p_value Pointer to attribute value information.
  62. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  63. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  64. * \c out: Length of encoded command packet.
  65. *
  66. * @note \p p_data_len and \p p_data will not be updated by the command
  67. * request encoder. Updated values are set by @ref ble_gatts_value_get_rsp_dec.
  68. *
  69. * @retval NRF_SUCCESS Encoding success.
  70. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  71. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  72. */
  73. uint32_t ble_gatts_value_get_req_enc(uint16_t conn_handle,
  74. uint16_t handle,
  75. ble_gatts_value_t const * const p_value,
  76. uint8_t * const p_buf,
  77. uint32_t * const p_buf_len);
  78. /**@brief Decodes response to @ref sd_ble_gatts_value_get command.
  79. *
  80. * @sa @ref ble_gatts_value_get_req_enc for command request encoder.
  81. *
  82. * @param[in] p_buf Pointer to beginning of command response packet.
  83. * @param[in] packet_len Length (in bytes) of response packet.
  84. * @param[out] p_value Pointer to structure where the attribute value will be stored.
  85. * @param[out] p_result_code Command result code.
  86. *
  87. * @retval NRF_SUCCESS Decoding success.
  88. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  89. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  90. * @retval NRF_ERROR_DATA_SIZE Length of \p p_value is too small to hold decoded
  91. * value from response.
  92. */
  93. uint32_t ble_gatts_value_get_rsp_dec(uint8_t const * const p_buf,
  94. uint32_t packet_len,
  95. ble_gatts_value_t * const p_value,
  96. uint32_t * const p_result_code);
  97. /**@brief Encodes @ref sd_ble_gatts_hvx command request.
  98. *
  99. * @sa @ref ble_gatts_hvx_rsp_dec for command response decoder.
  100. *
  101. * @param[in] conn_handle Connection handle.
  102. * @param[in] p_hvx_params Pointer to an HVx parameters structure to be encoded.
  103. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  104. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  105. * \c out: Length of encoded command packet.
  106. *
  107. * @note \p p_hvx_params will not be updated by the command
  108. * request encoder. Updated values are set by @ref ble_gatts_hvx_rsp_dec.
  109. *
  110. * @retval NRF_SUCCESS Encoding success.
  111. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  112. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  113. */
  114. uint32_t ble_gatts_hvx_req_enc(uint16_t conn_handle,
  115. ble_gatts_hvx_params_t const * const p_hvx_params,
  116. uint8_t * const p_buf,
  117. uint32_t * const p_buf_len);
  118. /**@brief Decodes response to @ref sd_ble_gatts_hvx command.
  119. *
  120. * @sa @ref ble_gatts_hvx_req_enc for command request encoder.
  121. *
  122. * @param[in] p_buf Pointer to beginning of command response packet.
  123. * @param[in] packet_len Length (in bytes) of response packet.
  124. * @param[out] p_result_code Command result code.
  125. * @param[out] pp_bytes_written Pointer to pointer to location where number of bytes is written.
  126. *
  127. * @retval NRF_SUCCESS Decoding success.
  128. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  129. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  130. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  131. * expected operation code.
  132. */
  133. uint32_t ble_gatts_hvx_rsp_dec(uint8_t const * const p_buf,
  134. uint32_t packet_len,
  135. uint32_t * const p_result_code,
  136. uint16_t * * const pp_bytes_written);
  137. /**@brief Encodes @ref sd_ble_gatts_characteristic_add command request.
  138. *
  139. * @sa @ref ble_gatts_characteristic_add_rsp_dec for command response decoder.
  140. *
  141. * @param[in] service_handle Handle of the service where the characteristic is to be placed.
  142. * If @ref BLE_GATT_HANDLE_INVALID is used, it will be placed
  143. * sequentially.
  144. * @param[in] p_char_md Pointer to a @ref ble_gatts_char_md_t structure, characteristic
  145. * metadata.
  146. * @param[in] p_attr_char_value Pointer to a @ref ble_gatts_attr_t structure, corresponding to
  147. * the characteristic value.
  148. * @param[in] p_handles Pointer to a @ref ble_gatts_char_handles_t structure, where the
  149. * assigned handles will be stored.
  150. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  151. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  152. * \c out: Length of encoded command packet.
  153. *
  154. * @note \p p_handles will not be updated by the command
  155. * request encoder. Updated values are set by @ref ble_gatts_characteristic_add_rsp_dec.
  156. *
  157. * @retval NRF_SUCCESS Encoding success.
  158. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  159. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  160. */
  161. uint32_t ble_gatts_characteristic_add_req_enc
  162. (uint16_t service_handle,
  163. ble_gatts_char_md_t const * const p_char_md,
  164. ble_gatts_attr_t const * const p_attr_char_value,
  165. ble_gatts_char_handles_t const * const p_handles,
  166. uint8_t * const p_buf,
  167. uint32_t * const p_buf_len);
  168. /**@brief Decodes response to @ref sd_ble_gatts_characteristic_add command.
  169. *
  170. * @sa @ref ble_gatts_characteristic_add_req_enc for command request encoder.
  171. *
  172. * @param[in] p_buf Pointer to beginning of command response packet.
  173. * @param[in] packet_len Length (in bytes) of response packet.
  174. * @param[out] pp_handles Pointer to pointer to location where handles should be decoded.
  175. * @param[out] p_result_code Pointer to command result code decode location.
  176. *
  177. * @retval NRF_SUCCESS Decoding success.
  178. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  179. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  180. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  181. * expected operation code.
  182. */
  183. uint32_t ble_gatts_characteristic_add_rsp_dec(uint8_t const * const p_buf,
  184. uint32_t packet_len,
  185. uint16_t * * const pp_handles,
  186. uint32_t * const p_result_code);
  187. /**@brief Encodes @ref sd_ble_gatts_service_add command request.
  188. *
  189. * @sa @ref ble_gatts_service_add_rsp_dec for command response decoder.
  190. *
  191. * @param[in] type Toggles between primary and secondary services,
  192. * see @ref BLE_GATTS_SRVC_TYPES.
  193. * @param[in] p_uuid Pointer to service UUID.
  194. * @param[in] p_conn_handle Pointer to a 16-bit word where the assigned handle will be stored.
  195. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  196. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  197. * \c out: Length of encoded command packet.
  198. *
  199. * @note \p p_conn_handle will not be updated by the command
  200. * request encoder. Updated values are set by @ref ble_gatts_service_add_rsp_dec.
  201. *
  202. * @retval NRF_SUCCESS Encoding success.
  203. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  204. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  205. */
  206. uint32_t ble_gatts_service_add_req_enc(uint8_t type,
  207. ble_uuid_t const * const p_uuid,
  208. uint16_t const * const p_conn_handle,
  209. uint8_t * const p_buf,
  210. uint32_t * const p_buf_len);
  211. /**@brief Decodes response to @ref sd_ble_gatts_service_add command.
  212. *
  213. * @sa @ref ble_gatts_service_add_req_enc for command request encoder.
  214. *
  215. * @param[in] p_buf Pointer to beginning of command response packet.
  216. * @param[in] packet_len Length (in bytes) of response packet.
  217. * @param[out] p_conn_handle Connection handle.
  218. * @param[out] p_result_code Command result code.
  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_INVALID_DATA Decoding failure. Decoded operation code does not match
  224. * expected operation code.
  225. */
  226. uint32_t ble_gatts_service_add_rsp_dec(uint8_t const * const p_buf,
  227. uint32_t packet_len,
  228. uint16_t * const p_conn_handle,
  229. uint32_t * const p_result_code);
  230. /**@brief Encodes @ref sd_ble_gatts_sys_attr_set command request.
  231. *
  232. * @sa @ref ble_gatts_sys_attr_set_rsp_dec for command response decoder.
  233. *
  234. * @param[in] conn_handle Connection handle.
  235. * @param[in] p_sys_attr_data Pointer to a buffer (at least \p sys_attr_data_len bytes long)
  236. * containing the attribute value to write.
  237. * @param[in] sys_attr_data_len Length (in bytes) of \p p_sys_attr_data.
  238. * @param[in] flags Optional additional flags.
  239. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  240. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  241. * \c out: Length of encoded command packet.
  242. *
  243. * @retval NRF_SUCCESS Encoding success.
  244. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  245. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  246. */
  247. uint32_t ble_gatts_sys_attr_set_req_enc(uint16_t conn_handle,
  248. uint8_t const * const p_sys_attr_data,
  249. uint16_t sys_attr_data_len,
  250. uint32_t flags,
  251. uint8_t * const p_buf,
  252. uint32_t * const p_buf_len);
  253. /**@brief Decodes response to @ref sd_ble_gatts_sys_attr_set command.
  254. *
  255. * @sa @ref ble_gatts_sys_attr_set_req_enc for command request encoder.
  256. *
  257. * @param[in] p_buf Pointer to beginning of command response packet.
  258. * @param[in] packet_len Length (in bytes) of response packet.
  259. * @param[out] p_result_code Command result code.
  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_DATA Decoding failure. Decoded operation code does not match
  265. * expected operation code.
  266. */
  267. uint32_t ble_gatts_sys_attr_set_rsp_dec(uint8_t const * const p_buf,
  268. uint32_t packet_len,
  269. uint32_t * const p_result_code);
  270. /**@brief Encodes @ref sd_ble_gatts_value_set command request.
  271. *
  272. * @sa @ref ble_gatts_value_set_rsp_dec for command response decoder.
  273. *
  274. * @param[in] conn_handle Connection handle.
  275. * @param[in] handle Attribute handle.
  276. * @param[in] p_value Pointer to attribute value information.
  277. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  278. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  279. * \c out: Length of encoded command packet.
  280. *
  281. * @retval NRF_SUCCESS Encoding success.
  282. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  283. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  284. */
  285. uint32_t ble_gatts_value_set_req_enc(uint16_t conn_handle,
  286. uint16_t handle,
  287. ble_gatts_value_t * p_value,
  288. uint8_t * const p_buf,
  289. uint32_t * const p_buf_len);
  290. /**@brief Decodes response to @ref sd_ble_gatts_value_set command.
  291. *
  292. * @sa @ref ble_gatts_value_set_req_enc for command request encoder.
  293. *
  294. * @param[in] p_buf Pointer to beginning of command response packet.
  295. * @param[in] packet_len Length (in bytes) of response packet.
  296. * @param[out] p_value Pointer to attribute value information.
  297. * @param[out] p_result_code Command result code.
  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. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  303. * expected operation code.
  304. */
  305. uint32_t ble_gatts_value_set_rsp_dec(uint8_t const * const p_buf,
  306. uint32_t packet_len,
  307. ble_gatts_value_t * const p_value,
  308. uint32_t * const p_result_code);
  309. /**@brief Encodes @ref sd_ble_gatts_sys_attr_get command request.
  310. *
  311. * @sa @ref ble_gatts_sys_attr_get_rsp_dec for command response decoder.
  312. *
  313. * @param[in] conn_handle Connection handle of the connection.
  314. * @param[in] p_sys_attr_data Pointer to buffer where updated information about system
  315. * attributes will be stored. Can be NULL to calculate required
  316. * size.
  317. * @param[in] p_sys_attr_data_len Size of p_sys_attr_data buffer if \p p_sys_attr_data is
  318. * not NULL.
  319. * @param[in] flags Additional optional flags.
  320. * @param[in,out] p_buf Pointer to buffer where encoded data command will
  321. * be returned.
  322. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  323. * \c out: Length of encoded command packet.
  324. *
  325. * @note \p p_sys_attr_data and \p p_sys_attr_data_len will not be updated by the command
  326. * request encoder. Updated values are set by @ref ble_gatts_sys_attr_get_rsp_dec.
  327. *
  328. * @retval NRF_SUCCESS Encoding success.
  329. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  330. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  331. */
  332. uint32_t ble_gatts_sys_attr_get_req_enc(uint16_t conn_handle,
  333. uint8_t const * const p_sys_attr_data,
  334. uint16_t const * const p_sys_attr_data_len,
  335. uint32_t flags,
  336. uint8_t * const p_buf,
  337. uint32_t * p_buf_len);
  338. /**@brief Decodes response to @ref sd_ble_gatts_sys_attr_get command.
  339. *
  340. * @sa @ref ble_gatts_sys_attr_get_req_enc for command request encoder.
  341. *
  342. * @param[in] p_buf Pointer to beginning of command response packet.
  343. * @param[in] packet_len Length (in bytes) of response packet.
  344. * @param[out] pp_sys_attr_data Pointer to a buffer where updated information about system
  345. * attributes will be stored.
  346. * @param[in,out] pp_sys_attr_data_len \c in: Size (in bytes) of \p p_sys_attr_data buffer.
  347. * \c out: Length of decoded contents of \p p_sys_attr_data.
  348. * @param[out] p_result_code Command result code.
  349. *
  350. * @retval NRF_SUCCESS Decoding success.
  351. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  352. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  353. * @retval NRF_ERROR_DATA_SIZE Length of \p p_sys_attr_data is too small to hold decoded
  354. * value from response.
  355. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  356. * expected operation code.
  357. */
  358. uint32_t ble_gatts_sys_attr_get_rsp_dec(uint8_t const * const p_buf,
  359. uint32_t packet_len,
  360. uint8_t * * const pp_sys_attr_data,
  361. uint16_t * * const pp_sys_attr_data_len,
  362. uint32_t * const p_result_code);
  363. /**@brief Encodes @ref sd_ble_gatts_descriptor_add command request.
  364. *
  365. * @sa @ref ble_gatts_descriptor_add_rsp_dec for command response decoder.
  366. *
  367. * @param[in] char_handle Handle of the characteristic where the description is to be placed.
  368. * If @ref BLE_GATT_HANDLE_INVALID is used, it will be placed
  369. * sequentially.
  370. * @param[in] p_attr Pointer to a @ref ble_gatts_attr_t structure, characteristic
  371. * metadata.
  372. * @param[in] p_handle Pointer to a @ref ble_gatts_char_handles_t structure, where the
  373. * assigned handles will be stored.
  374. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  375. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  376. * \c out: Length of encoded command packet.
  377. *
  378. * @retval NRF_SUCCESS Encoding success.
  379. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  380. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  381. */
  382. uint32_t ble_gatts_descriptor_add_req_enc(uint16_t char_handle,
  383. ble_gatts_attr_t const * const p_attr,
  384. uint16_t * const p_handle,
  385. uint8_t * const p_buf,
  386. uint32_t * const p_buf_len);
  387. /**@brief Decodes response to @ref sd_ble_gatts_descriptor_add command.
  388. *
  389. * @sa @ref ble_gatts_descriptor_add_req_enc for command request encoder.
  390. *
  391. * @param[in] p_buf Pointer to beginning of command response packet.
  392. * @param[in] packet_len Length (in bytes) of response packet.
  393. * @param[out] p_handle Pointer to bufer where descriptor handle will be
  394. returned.
  395. * @param[out] p_result_code Pointer to command result code decode location.
  396. *
  397. * @retval NRF_SUCCESS Decoding success.
  398. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  399. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  400. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  401. * expected operation code.
  402. */
  403. uint32_t ble_gatts_descriptor_add_rsp_dec(uint8_t const * const p_buf,
  404. uint32_t packet_len,
  405. uint16_t * const p_handle,
  406. uint32_t * const p_result_code);
  407. /**@brief Encodes @ref sd_ble_gatts_include_add command request.
  408. *
  409. * @sa @ref ble_gatts_include_add_rsp_dec for command response decoder.
  410. *
  411. * @param[in] service_handle Handle of the service where the included service is to be placed.
  412. * @param[in] inc_srvc_handle Handle of the included service
  413. * @param[in] p_include_handle Pointer to Pointer to a 16-bit word where the assigned handle will be stored.
  414. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  415. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  416. * \c out: Length of encoded command packet.
  417. *
  418. * @retval NRF_SUCCESS Encoding success.
  419. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  420. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  421. */
  422. uint32_t ble_gatts_include_add_req_enc(uint16_t service_handle,
  423. uint16_t inc_srvc_handle,
  424. uint16_t * const p_include_handle,
  425. uint8_t * const p_buf,
  426. uint32_t * const p_buf_len);
  427. /**@brief Decodes response to @ref sd_ble_gatts_include_add command.
  428. *
  429. * @sa @ref ble_gatts_include_add_req_enc for command request encoder.
  430. *
  431. * @param[in] p_buf Pointer to beginning of command response packet.
  432. * @param[in] packet_len Length (in bytes) of response packet.
  433. * @param[out] p_include_handle Pointer to a 16-bit word where the assigned handle will be stored.
  434. * @param[out] p_result_code Pointer to command result code decode location.
  435. *
  436. * @retval NRF_SUCCESS Decoding success.
  437. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  438. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  439. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  440. * expected operation code.
  441. */
  442. uint32_t ble_gatts_include_add_rsp_dec(uint8_t const * const p_buf,
  443. uint32_t packet_len,
  444. uint16_t * const p_include_handle,
  445. uint32_t * const p_result_code);
  446. /**@brief Encodes @ref sd_ble_gatts_rw_authorize_reply command request.
  447. *
  448. * @sa @ref ble_gatts_rw_authorize_reply_rsp_dec for command response decoder.
  449. *
  450. * @param[in] conn_handle Connection handle.
  451. * @param[in] p_reply_params Pointer to \ref ble_gatts_rw_authorize_reply_params_t
  452. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  453. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  454. * \c out: Length of encoded command packet.
  455. *
  456. * @retval NRF_SUCCESS Encoding success.
  457. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  458. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  459. * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Invalid param provided in p_reply_params.
  460. */
  461. uint32_t ble_gatts_rw_authorize_reply_req_enc(
  462. uint16_t conn_handle,
  463. ble_gatts_rw_authorize_reply_params_t const * const
  464. p_reply_params,
  465. uint8_t * const
  466. p_buf,
  467. uint32_t * const
  468. p_buf_len);
  469. /**@brief Decodes response to @ref sd_ble_gatts_rw_authorize_reply command.
  470. *
  471. * @sa @ref ble_gatts_rw_authorize_reply_req_enc for command request encoder.
  472. *
  473. * @param[in] p_buf Pointer to beginning of command response packet.
  474. * @param[in] packet_len Length (in bytes) of response packet.
  475. * @param[out] p_result_code Command result code.
  476. *
  477. * @retval NRF_SUCCESS Decoding success.
  478. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  479. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  480. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  481. * expected operation code.
  482. */
  483. uint32_t ble_gatts_rw_authorize_reply_rsp_dec(uint8_t const * const p_buf,
  484. uint32_t packet_len,
  485. uint32_t * const p_result_code);
  486. /**@brief Encodes @ref sd_ble_gatts_service_changed command request.
  487. *
  488. * @sa @ref ble_gatts_service_changed_rsp_dec for command response decoder.
  489. *
  490. * @param[in] conn_handle Connection handle.
  491. * @param[in] start_handle Start of affected attribute handle range.
  492. * @param[in] end_handle End of affected attribute handle range.
  493. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  494. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  495. * \c out: Length of encoded command packet.
  496. *
  497. * @retval NRF_SUCCESS Encoding success.
  498. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  499. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  500. * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Invalid param provided in p_reply_params.
  501. */
  502. uint32_t ble_gatts_service_changed_req_enc(uint16_t conn_handle,
  503. uint16_t start_handle,
  504. uint16_t end_handle,
  505. uint8_t * const p_buf,
  506. uint32_t * const p_buf_len);
  507. /**@brief Decodes response to @ref sd_ble_gatts_service_changed command.
  508. *
  509. * @sa @ref ble_gatts_service_changed_req_enc for command request encoder.
  510. *
  511. * @param[in] p_buf Pointer to beginning of command response packet.
  512. * @param[in] packet_len Length (in bytes) of response packet.
  513. * @param[out] p_result_code Command result code.
  514. *
  515. * @retval NRF_SUCCESS Decoding success.
  516. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  517. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  518. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  519. * expected operation code.
  520. */
  521. uint32_t ble_gatts_service_changed_rsp_dec(uint8_t const * const p_buf,
  522. uint32_t packet_len,
  523. uint32_t * const p_result_code);
  524. /**@brief Encodes @ref sd_ble_gatts_attr_get command request.
  525. *
  526. * @sa @ref ble_gatts_attr_get_rsp_dec for command response decoder.
  527. *
  528. * @param[in] handle See @ref sd_ble_gatts_attr_get.
  529. * @param[in] p_uuid See @ref sd_ble_gatts_attr_get.
  530. * @param[out] p_md See @ref sd_ble_gatts_attr_get.
  531. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  532. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  533. * \c out: Length of encoded command packet.
  534. *
  535. * @retval NRF_SUCCESS Encoding success.
  536. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  537. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  538. */
  539. uint32_t ble_gatts_attr_get_req_enc(uint16_t handle,
  540. ble_uuid_t * p_uuid,
  541. ble_gatts_attr_md_t * p_md,
  542. uint8_t * const p_buf,
  543. uint32_t * p_buf_len);
  544. /**@brief Decodes response to @ref sd_ble_gatts_attr_get command.
  545. *
  546. * @sa @ref ble_gatts_attr_get_req_enc for command request encoder.
  547. *
  548. * @param[in] p_buf Pointer to beginning of command response packet.
  549. * @param[in] packet_len Length (in bytes) of response packet.
  550. * @param[out] pp_uuid Pointer to address where to put output data.
  551. * @param[out] pp_md Pointer to address where to put output data.
  552. * @param[out] p_result_code Command result code.
  553. *
  554. * @retval NRF_SUCCESS Decoding success.
  555. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  556. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  557. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  558. * expected operation code.
  559. */
  560. uint32_t ble_gatts_attr_get_rsp_dec(uint8_t const * const p_buf,
  561. uint32_t packet_len,
  562. ble_uuid_t ** pp_uuid,
  563. ble_gatts_attr_md_t ** pp_md,
  564. uint32_t * const p_result_code);
  565. /**@brief Encodes @ref sd_ble_gatts_initial_user_handle_get command request.
  566. *
  567. * @sa @ref ble_gatts_initial_user_handle_get_rsp_dec for command response decoder.
  568. *
  569. * @param[out] p_handle See @ref sd_ble_gatts_initial_user_handle_get.
  570. * @param[in,out] p_buf Pointer to buffer where encoded data command will be returned.
  571. * @param[in,out] p_buf_len \c in: size of \p p_buf buffer.
  572. * \c out: Length of encoded command packet.
  573. *
  574. * @retval NRF_SUCCESS Encoding success.
  575. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  576. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  577. */
  578. uint32_t ble_gatts_initial_user_handle_get_req_enc(uint16_t * p_handle,
  579. uint8_t * const p_buf,
  580. uint32_t * p_buf_len);
  581. /**@brief Decodes response to @ref sd_ble_gatts_initial_user_handle_get command.
  582. *
  583. * @sa @ref ble_gatts_initial_user_handle_get_req_enc for command request encoder.
  584. *
  585. * @param[in] p_buf Pointer to beginning of command response packet.
  586. * @param[in] packet_len Length (in bytes) of response packet.
  587. * @param[out] pp_handle Pointer to address where to put output data.
  588. * @param[out] p_result_code Command result code.
  589. *
  590. * @retval NRF_SUCCESS Decoding success.
  591. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  592. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  593. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  594. * expected operation code.
  595. */
  596. uint32_t ble_gatts_initial_user_handle_get_rsp_dec(uint8_t const * const p_buf,
  597. uint32_t packet_len,
  598. uint16_t ** pp_handle,
  599. uint32_t * const p_result_code);
  600. /**@brief Encodes @ref sd_ble_gatts_exchange_mtu_reply command request.
  601. *
  602. * @sa @ref ble_gatts_exchange_mtu_reply_rsp_dec for command response decoder.
  603. *
  604. * @param[in] conn_handle Connection handle.
  605. * @param[in] server_rx_mtu Server MTU Size.
  606. * @param[in] p_buf Pointer to buffer where encoded data command will be returned.
  607. * @param[in,out] p_buf_len \c in: Size of \p p_buf buffer.
  608. * \c out: Length of encoded command packet.
  609. *
  610. * @retval NRF_SUCCESS Encoding success.
  611. * @retval NRF_ERROR_NULL Encoding failure. NULL pointer supplied.
  612. * @retval NRF_ERROR_INVALID_LENGTH Encoding failure. Incorrect buffer length.
  613. * @retval NRF_ERROR_INVALID_PARAM Encoding failure. Invalid param provided in p_reply_params.
  614. */
  615. uint32_t ble_gatts_exchange_mtu_reply_req_enc(uint16_t conn_handle,
  616. uint16_t server_rx_mtu,
  617. uint8_t * const p_buf,
  618. uint32_t * const p_buf_len);
  619. /**@brief Decodes response to @ref sd_ble_gatts_exchange_mtu_reply command.
  620. *
  621. * @sa @ref ble_gatts_exchange_mtu_reply_req_enc for command request encoder.
  622. *
  623. * @param[in] p_buf Pointer to beginning of command response packet.
  624. * @param[in] packet_len Length (in bytes) of response packet.
  625. * @param[out] p_result_code Command result code.
  626. *
  627. * @retval NRF_SUCCESS Decoding success.
  628. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  629. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  630. * @retval NRF_ERROR_INVALID_DATA Decoding failure. Decoded operation code does not match
  631. * expected operation code.
  632. */
  633. uint32_t ble_gatts_exchange_mtu_reply_rsp_dec(uint8_t const * const p_buf,
  634. uint32_t packet_len,
  635. uint32_t * const p_result_code);
  636. /** @} */
  637. #ifdef __cplusplus
  638. }
  639. #endif
  640. #endif //BLE_GATTS_APP_H__