conn_mw_ble.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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_H
  41. #define _CONN_MW_BLE_H
  42. #include <stdint.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @addtogroup sercon_mw_s132_ble Middleware command handlers
  48. * @{
  49. * @ingroup sercon_mw_s132
  50. */
  51. /**@brief Handles sd_ble_tx_packet_count_get 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_tx_packet_count_get(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_uuid_vs_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_uuid_vs_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 sd_ble_uuid_decode 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_uuid_decode(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 sd_ble_uuid_encode 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_uuid_encode(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 sd_ble_version_get 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_version_get(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 sd_ble_opt_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_opt_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 sd_ble_opt_set 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_opt_set(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 sd_ble_enable 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_enable(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 sd_ble_user_mem_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_user_mem_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. #if NRF_SD_BLE_API_VERSION >= 4
  205. /**@brief Handles @ref sd_ble_cfg_set command and prepares response.
  206. *
  207. * @param[in] p_rx_buf Pointer to input buffer.
  208. * @param[in] rx_buf_len Size of @p p_rx_buf.
  209. * @param[out] p_tx_buf Pointer to output buffer.
  210. * @param[in,out] p_tx_buf_len \c in: Size of \p p_tx_buf buffer.
  211. * \c out: Length of valid data in \p p_tx_buf.
  212. *
  213. * @retval NRF_SUCCESS Handler success.
  214. * @retval NRF_ERROR_NULL Handler failure. NULL pointer supplied.
  215. * @retval NRF_ERROR_INVALID_LENGTH Handler failure. Incorrect buffer length.
  216. * @retval NRF_ERROR_INVALID_PARAM Handler failure. Invalid operation type.
  217. */
  218. uint32_t conn_mw_ble_cfg_set(uint8_t const * const p_rx_buf,
  219. uint32_t rx_buf_len,
  220. uint8_t * const p_tx_buf,
  221. uint32_t * const p_tx_buf_len);
  222. #endif
  223. #ifdef __cplusplus
  224. }
  225. #endif
  226. /** @} */
  227. #endif //_CONN_MW_BLE_H