ble_gattc_evt_app.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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_GATTC_EVT_APP_H__
  41. #define BLE_GATTC_EVT_APP_H__
  42. /**@file
  43. *
  44. * @defgroup ble_gattc_evt_app GATTC Application event decoders
  45. * @{
  46. * @ingroup ser_app_s130_codecs
  47. *
  48. * @brief GATTC Application event decoders.
  49. */
  50. #include "ble.h"
  51. #ifdef __cplusplus
  52. extern "C" {
  53. #endif
  54. /**
  55. * @brief Decodes ble_gattc_evt_char_disc_rsp 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_gattc_evt_char_disc_rsp_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_gattc_evt_char_val_by_uuid_read_rsp 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_gattc_evt_char_val_by_uuid_read_rsp_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_gattc_evt_char_vals_read_rsp 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_gattc_evt_char_vals_read_rsp_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_gattc_evt_desc_disc_rsp 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_gattc_evt_desc_disc_rsp_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_gattc_evt_hvx 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_gattc_evt_hvx_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_gattc_evt_prim_srvc_disc_rsp 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_gattc_evt_prim_srvc_disc_rsp_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_gattc_evt_read_rsp 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_gattc_evt_read_rsp_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_gattc_evt_rel_disc_rsp_dec 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_gattc_evt_rel_disc_rsp_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_gattc_evt_timeout 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_gattc_evt_timeout_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_gattc_evt_write_rsp 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_gattc_evt_write_rsp_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_gattc_evt_attr_info_disc_rsp 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_gattc_evt_attr_info_disc_rsp_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_gattc_evt_exchange_mtu_rsp 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_gattc_evt_exchange_mtu_rsp_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. #if NRF_SD_BLE_API_VERSION >= 4
  319. /**
  320. * @brief Decodes ble_gattc_evt_write_cmd_tx_complete event.
  321. *
  322. * If \p p_event is null, the required length of \p p_event is returned in \p p_event_len.
  323. *
  324. * @param[in] p_buf Pointer to the beginning of an event packet.
  325. * @param[in] packet_len Length (in bytes) of the event packet.
  326. * @param[in,out] p_event Pointer to a \ref ble_evt_t buffer where the decoded event will be
  327. * stored. If NULL, required length will be returned in \p p_event_len.
  328. * @param[in,out] p_event_len \c in: Size (in bytes) of \p p_event buffer.
  329. * \c out: Length of decoded contents of \p p_event.
  330. *
  331. * @retval NRF_SUCCESS Decoding success.
  332. * @retval NRF_ERROR_NULL Decoding failure. NULL pointer supplied.
  333. * @retval NRF_ERROR_INVALID_LENGTH Decoding failure. Incorrect buffer length.
  334. * @retval NRF_ERROR_DATA_SIZE Decoding failure. Length of \p p_event is too small to
  335. * hold decoded event.
  336. */
  337. uint32_t ble_gattc_evt_write_cmd_tx_complete_dec(uint8_t const * const p_buf,
  338. uint32_t packet_len,
  339. ble_evt_t * const p_event,
  340. uint32_t * const p_event_len);
  341. #endif
  342. /** @} */
  343. #ifdef __cplusplus
  344. }
  345. #endif
  346. #endif