ble_ots_l2cap.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /**
  2. * Copyright (c) 2017 - 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. /**@file
  41. *
  42. * @defgroup ble_sdk_srv_ots_l2cap Object Transfer Service, l2cap channel handling
  43. * @{
  44. * @ingroup ble_ots
  45. * @brief Object Transfer Service module
  46. *
  47. * @details This module is responsible for handling the l2cap connection oriented channels.
  48. */
  49. #ifndef BLE_OTS_L2CAP_H__
  50. #define BLE_OTS_L2CAP_H__
  51. #include <stdint.h>
  52. #include "ble_ots.h"
  53. /**@brief Function for initializing the Object Transfer Service l2cap module.
  54. *
  55. * @param[out] p_ots_l2cap Object Transfer Service l2cap structure. This structure will have to be
  56. * supplied by the application. It will be initialized by this function,
  57. * and will later be used to identify this particular instance.
  58. * @param[in] p_ots_l2cap_init Information needed to initialize the module.
  59. *
  60. * @return NRF_SUCCESS on successful initialization, otherwise an error code.
  61. */
  62. uint32_t ble_ots_l2cap_init(ble_ots_l2cap_t * p_ots_l2cap, ble_ots_l2cap_init_t * p_ots_l2cap_init);
  63. /**@brief Function for handling the Application's BLE Stack events.
  64. *
  65. * @details Handles all events from the BLE stack of interest to the l2cap module.
  66. *
  67. * @param[in] p_ots_l2cap Object transfer service l2cap module structure.
  68. * @param[in] p_ble_evt Event received from the BLE stack.
  69. */
  70. void ble_ots_l2cap_on_ble_evt(ble_ots_l2cap_t * p_ots_l2cap, ble_evt_t const * p_ble_evt);
  71. /**@brief Function starting to send the data in the transfer buffer.
  72. *
  73. * @param[in] p_ots_l2cap Object transfer service l2cap module structure.
  74. * @param[in] p_data Pointer to the data to be sent.
  75. * @param[in] data_len The length of the data to be sent.
  76. *
  77. * @return NRF_SUCCESS If the transmission was started.
  78. * @return NRF_ERROR_INVALID_STATE When in an invalid state. Otherwise an other error code.
  79. */
  80. uint32_t ble_ots_l2cap_obj_send(ble_ots_l2cap_t * p_ots_l2cap, uint8_t * p_data, uint16_t data_len);
  81. /**@brief Function starting to receive data to the transfer buffer.
  82. *
  83. * @param[in] p_ots_l2cap Object transfer service l2cap module structure.
  84. * @param[in] len The length of the data to be received.
  85. *
  86. * @return NRF_SUCCESS If the transmission was started.
  87. * @return NRF_ERROR_INVALID_STATE When in an invalid state. Otherwise an other error code.
  88. */
  89. uint32_t ble_ots_l2cap_start_recv(ble_ots_l2cap_t * p_ots_l2cap, uint16_t len);
  90. /**@brief Function that checks if the channel is available for transmission.
  91. *
  92. * @param[in] p_ots_l2cap Object transfer service l2cap module structure.
  93. *
  94. * @return true if the channel is available.
  95. */
  96. bool ble_ots_l2cap_is_channel_available(ble_ots_l2cap_t * p_ots_l2cap);
  97. /**@brief Function starting to abort the current transmission.
  98. *
  99. * @param[in] p_ots_l2cap Object transfer service l2cap module structure.
  100. *
  101. * @return NRF_SUCCESS If the transmission was aborted.
  102. * @return NRF_ERROR_INVALID_STATE When in an invalid state. Otherwise an other error code.
  103. */
  104. uint32_t ble_ots_l2cap_abort_transmission(ble_ots_l2cap_t * p_ots_l2cap);
  105. #endif // BLE_OTS_L2CAP_H__
  106. /** @} */ // End tag for the file.