conn_mw_ble_gatts.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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 _CONN_MW_BLE_GATTS_H
  41. #define _CONN_MW_BLE_GATTS_H
  42. #include <stdint.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @addtogroup sercon_mw_s132_ble_gatts GATTS Middleware command handlers
  48. * @{
  49. * @ingroup sercon_mw_s132
  50. */
  51. /**@brief Handles @ref sd_ble_gatts_service_add command and prepares response.
  52. *
  53. * @param[in] p_rx_buf Pointer to input buffer.
  54. * @param[in] rx_buf_len Size of @p p_rx_buf.
  55. * @param[out] p_tx_buf Pointer to output buffer.
  56. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  57. * \c out: Length of valid data in \p p_tx_buf.
  58. *
  59. * @retval NRF_SUCCESS Handler success.
  60. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  61. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  62. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  63. */
  64. uint32_t conn_mw_ble_gatts_service_add (uint8_t const * const p_rx_buf,
  65. uint32_t rx_buf_len,
  66. uint8_t * const p_tx_buf,
  67. uint32_t * const p_tx_buf_len);
  68. /**@brief Handles @ref sd_ble_gatts_characteristic_add command and prepares response.
  69. *
  70. * @param[in] p_rx_buf Pointer to input buffer.
  71. * @param[in] rx_buf_len Size of @p p_rx_buf.
  72. * @param[out] p_tx_buf Pointer to output buffer.
  73. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  74. * \c out: Length of valid data in \p p_tx_buf.
  75. *
  76. * @retval NRF_SUCCESS Handler success.
  77. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  78. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  79. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  80. */
  81. uint32_t conn_mw_ble_gatts_characteristic_add(uint8_t const * const p_rx_buf,
  82. uint32_t rx_buf_len,
  83. uint8_t * const p_tx_buf,
  84. uint32_t * const p_tx_buf_len);
  85. /**@brief Handles @ref conn_mw_ble_gatts_include_add command and prepares response.
  86. *
  87. * @param[in] p_rx_buf Pointer to input buffer.
  88. * @param[in] rx_buf_len Size of @p p_rx_buf.
  89. * @param[out] p_tx_buf Pointer to output buffer.
  90. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  91. * \c out: Length of valid data in \p p_tx_buf.
  92. *
  93. * @retval NRF_SUCCESS Handler success.
  94. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  95. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  96. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  97. */
  98. uint32_t conn_mw_ble_gatts_include_add (uint8_t const * const p_rx_buf,
  99. uint32_t rx_buf_len,
  100. uint8_t * const p_tx_buf,
  101. uint32_t * const p_tx_buf_len);
  102. /**@brief Handles @ref conn_mw_ble_gatts_descriptor_add command and prepares response.
  103. *
  104. * @param[in] p_rx_buf Pointer to input buffer.
  105. * @param[in] rx_buf_len Size of @p p_rx_buf.
  106. * @param[out] p_tx_buf Pointer to output buffer.
  107. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  108. * \c out: Length of valid data in \p p_tx_buf.
  109. *
  110. * @retval NRF_SUCCESS Handler success.
  111. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  112. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  113. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  114. */
  115. uint32_t conn_mw_ble_gatts_descriptor_add(uint8_t const * const p_rx_buf,
  116. uint32_t rx_buf_len,
  117. uint8_t * const p_tx_buf,
  118. uint32_t * const p_tx_buf_len);
  119. /**@brief Handles @ref conn_mw_ble_gatts_value_set command and prepares response.
  120. *
  121. * @param[in] p_rx_buf Pointer to input buffer.
  122. * @param[in] rx_buf_len Size of @p p_rx_buf.
  123. * @param[out] p_tx_buf Pointer to output buffer.
  124. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  125. * \c out: Length of valid data in \p p_tx_buf.
  126. *
  127. * @retval NRF_SUCCESS Handler success.
  128. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  129. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  130. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  131. */
  132. uint32_t conn_mw_ble_gatts_value_set(uint8_t const * const p_rx_buf,
  133. uint32_t rx_buf_len,
  134. uint8_t * const p_tx_buf,
  135. uint32_t * const p_tx_buf_len);
  136. /**@brief Handles @ref conn_mw_ble_gatts_value_get command and prepares response.
  137. *
  138. * @param[in] p_rx_buf Pointer to input buffer.
  139. * @param[in] rx_buf_len Size of @p p_rx_buf.
  140. * @param[out] p_tx_buf Pointer to output buffer.
  141. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  142. * \c out: Length of valid data in \p p_tx_buf.
  143. *
  144. * @retval NRF_SUCCESS Handler success.
  145. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  146. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  147. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  148. */
  149. uint32_t conn_mw_ble_gatts_value_get(uint8_t const * const p_rx_buf,
  150. uint32_t rx_buf_len,
  151. uint8_t * const p_tx_buf,
  152. uint32_t * const p_tx_buf_len);
  153. /**@brief Handles @ref conn_mw_ble_gatts_hvx command and prepares response.
  154. *
  155. * @param[in] p_rx_buf Pointer to input buffer.
  156. * @param[in] rx_buf_len Size of @p p_rx_buf.
  157. * @param[out] p_tx_buf Pointer to output buffer.
  158. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  159. * \c out: Length of valid data in \p p_tx_buf.
  160. *
  161. * @retval NRF_SUCCESS Handler success.
  162. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  163. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  164. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  165. */
  166. uint32_t conn_mw_ble_gatts_hvx(uint8_t const * const p_rx_buf,
  167. uint32_t rx_buf_len,
  168. uint8_t * const p_tx_buf,
  169. uint32_t * const p_tx_buf_len);
  170. /**@brief Handles @ref conn_mw_ble_gatts_service_changed command and prepares response.
  171. *
  172. * @param[in] p_rx_buf Pointer to input buffer.
  173. * @param[in] rx_buf_len Size of @p p_rx_buf.
  174. * @param[out] p_tx_buf Pointer to output buffer.
  175. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  176. * \c out: Length of valid data in \p p_tx_buf.
  177. *
  178. * @retval NRF_SUCCESS Handler success.
  179. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  180. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  181. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  182. */
  183. uint32_t conn_mw_ble_gatts_service_changed(uint8_t const * const p_rx_buf,
  184. uint32_t rx_buf_len,
  185. uint8_t * const p_tx_buf,
  186. uint32_t * const p_tx_buf_len);
  187. /**@brief Handles @ref conn_mw_ble_gatts_rw_authorize_reply command and prepares response.
  188. *
  189. * @param[in] p_rx_buf Pointer to input buffer.
  190. * @param[in] rx_buf_len Size of @p p_rx_buf.
  191. * @param[out] p_tx_buf Pointer to output buffer.
  192. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  193. * \c out: Length of valid data in \p p_tx_buf.
  194. *
  195. * @retval NRF_SUCCESS Handler success.
  196. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  197. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  198. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  199. */
  200. uint32_t conn_mw_ble_gatts_rw_authorize_reply(uint8_t const * const p_rx_buf,
  201. uint32_t rx_buf_len,
  202. uint8_t * const p_tx_buf,
  203. uint32_t * const p_tx_buf_len);
  204. /**@brief Handles @ref conn_mw_ble_gatts_sys_attr_set command and prepares response.
  205. *
  206. * @param[in] p_rx_buf Pointer to input buffer.
  207. * @param[in] rx_buf_len Size of @p p_rx_buf.
  208. * @param[out] p_tx_buf Pointer to output buffer.
  209. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  210. * \c out: Length of valid data in \p p_tx_buf.
  211. *
  212. * @retval NRF_SUCCESS Handler success.
  213. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  214. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  215. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  216. */
  217. uint32_t conn_mw_ble_gatts_sys_attr_set(uint8_t const * const p_rx_buf,
  218. uint32_t rx_buf_len,
  219. uint8_t * const p_tx_buf,
  220. uint32_t * const p_tx_buf_len);
  221. /**@brief Handles @ref conn_mw_ble_gatts_sys_attr_get command and prepares response.
  222. *
  223. * @param[in] p_rx_buf Pointer to input buffer.
  224. * @param[in] rx_buf_len Size of @p p_rx_buf.
  225. * @param[out] p_tx_buf Pointer to output buffer.
  226. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  227. * \c out: Length of valid data in \p p_tx_buf.
  228. *
  229. * @retval NRF_SUCCESS Handler success.
  230. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  231. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  232. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  233. */
  234. uint32_t conn_mw_ble_gatts_sys_attr_get(uint8_t const * const p_rx_buf,
  235. uint32_t rx_buf_len,
  236. uint8_t * const p_tx_buf,
  237. uint32_t * const p_tx_buf_len);
  238. /**@brief Handles @ref conn_mw_ble_gatts_attr_get command and prepares response.
  239. *
  240. * @param[in] p_rx_buf Pointer to input buffer.
  241. * @param[in] rx_buf_len Size of @p p_rx_buf.
  242. * @param[out] p_tx_buf Pointer to output buffer.
  243. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  244. * \c out: Length of valid data in \p p_tx_buf.
  245. *
  246. * @retval NRF_SUCCESS Handler success.
  247. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  248. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  249. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  250. */
  251. uint32_t conn_mw_ble_gatts_attr_get(uint8_t const * const p_rx_buf,
  252. uint32_t rx_buf_len,
  253. uint8_t * const p_tx_buf,
  254. uint32_t * const p_tx_buf_len);
  255. /**@brief Handles @ref conn_mw_ble_gatts_initial_user_handle_get command and prepares response.
  256. *
  257. * @param[in] p_rx_buf Pointer to input buffer.
  258. * @param[in] rx_buf_len Size of @p p_rx_buf.
  259. * @param[out] p_tx_buf Pointer to output buffer.
  260. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  261. * \c out: Length of valid data in \p p_tx_buf.
  262. *
  263. * @retval NRF_SUCCESS Handler success.
  264. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  265. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  266. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  267. */
  268. uint32_t conn_mw_ble_gatts_initial_user_handle_get(uint8_t const * const p_rx_buf,
  269. uint32_t rx_buf_len,
  270. uint8_t * const p_tx_buf,
  271. uint32_t * const p_tx_buf_len);
  272. /**@brief Handles @ref conn_mw_ble_gatts_exchange_mtu_reply command and prepares response.
  273. *
  274. * @param[in] p_rx_buf Pointer to input buffer.
  275. * @param[in] rx_buf_len Size of @p p_rx_buf.
  276. * @param[out] p_tx_buf Pointer to output buffer.
  277. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  278. * \c out: Length of valid data in \p p_tx_buf.
  279. *
  280. * @retval NRF_SUCCESS Handler success.
  281. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  282. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  283. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  284. */
  285. uint32_t conn_mw_ble_gatts_exchange_mtu_reply(uint8_t const * const p_rx_buf,
  286. uint32_t rx_buf_len,
  287. uint8_t * const p_tx_buf,
  288. uint32_t * const p_tx_buf_len);
  289. /** @} */
  290. #ifdef __cplusplus
  291. }
  292. #endif
  293. #endif //_CONN_MW_BLE_GATTS_H