es_gatts.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /**
  2. * Copyright (c) 2016 - 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 ES_GATTS_H__
  41. #define ES_GATTS_H__
  42. #include <stdint.h>
  43. #include "nrf_ble_escs.h"
  44. /**
  45. * @file
  46. * @defgroup eddystone_gatts GATTS
  47. * @brief Functions for handling GATTS write and read requests.
  48. * @ingroup eddystone
  49. * @{
  50. */
  51. ret_code_t es_gatts_init(nrf_ble_escs_t * p_ble_escs);
  52. /**@brief Function for handling all write requests from the Central.
  53. *
  54. * @param[in] p_escs Pointer to the Eddystone Configuration Service.
  55. * @param[in] uuid The UUID of the characteristic that is being written to.
  56. * @param[in] val_handle Value handle field of the characteristic handle of the characteristic that is being written to.
  57. * @param[in] p_data Pointer to the data to be written.
  58. * @param[in] length Length of the data to be written.
  59. *
  60. */
  61. void es_gatts_handle_write(nrf_ble_escs_t * p_escs,
  62. uint16_t uuid,
  63. uint16_t val_handle,
  64. uint8_t const * p_data,
  65. uint16_t length);
  66. /**@brief Function for handling all read requests from the Central.
  67. *
  68. * @param[in] p_escs Pointer to the Eddystone Configuration Service.
  69. * @param[in] uuid The UUID of the characteristic that is being read from.
  70. * @param[in] val_handle Value handle field of the characteristic handle of the characteristic that is being read from.
  71. *
  72. */
  73. void es_gatts_handle_read(nrf_ble_escs_t * p_escs, uint16_t uuid, uint16_t val_handle);
  74. /**@brief Function for sending an RW-authorization reply.
  75. *
  76. * @param[in] p_escs Pointer to the Eddystone Configuration Service.
  77. * @param[in] p_reply Pointer to the reply to send.
  78. *
  79. * @retval NRF_SUCCESS If the reply was successfully issued to the SoftDevice.
  80. * @retval NRF_ERROR_NULL If either of the pointers @p p_escs or @p p_reply is NULL.
  81. * @retval NRF_ERROR_INVALID_STATE If the connection handle of @p p_escs is invalid.
  82. * @return Otherwise, an error code from sd_ble_gatts_rw_authorize_reply() is returned.
  83. */
  84. ret_code_t es_gatts_send_reply(nrf_ble_escs_t * p_escs, ble_gatts_rw_authorize_reply_params_t * p_reply);
  85. /**@brief Function for sending an RW-authorization reply with status 'Operation not permitted'.
  86. *
  87. * @param[in] p_escs Pointer to the Eddystone Configuration Service.
  88. * @param[in] op_is_read Flag that specifies if the operation being responded to is a 'read' operation.
  89. If false, a 'write' operation is assumed.
  90. *
  91. * @retval NRF_ERROR_NULL If @p p_escs is NULL.
  92. * @return Otherwise, the error code from es_gatts_send_reply() is returned.
  93. */
  94. ret_code_t es_gatts_send_op_not_permitted(nrf_ble_escs_t * p_escs, bool op_is_read);
  95. /**
  96. * @}
  97. */
  98. #endif // ES_GATTS_H__