wm_bt_spp.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /**
  2. * @file wm_bt_spp.h
  3. *
  4. * @brief Bluetooth API
  5. *
  6. * @author WinnerMicro
  7. *
  8. * Copyright (c) 2020 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef __WM_BT_SPP_H__
  11. #define __WM_BT_SPP_H__
  12. #include "wm_bt.h"
  13. /**
  14. * @defgroup BT_APIs Bluetooth APIs
  15. * @brief Bluetooth related APIs
  16. */
  17. /**
  18. * @addtogroup BT_APIs
  19. * @{
  20. */
  21. /**
  22. * @defgroup BT_SPP_APIs
  23. * @brief BT_SPP APIs
  24. */
  25. /**
  26. * @addtogroup BT_SPP_APIs
  27. * @{
  28. */
  29. /**spp realed api*/
  30. /**
  31. * @brief Initializes the SPP interface
  32. *
  33. * @param[in] callback pointer on callback function
  34. *
  35. * @retval @ref tls_bt_status_t
  36. *
  37. * @note None
  38. */
  39. tls_bt_status_t tls_bt_spp_init(tls_bt_spp_callback_t callback);
  40. /**
  41. * @brief Shuts down the SPP interface and does the cleanup
  42. *
  43. * @param None
  44. *
  45. * @retval @ref tls_bt_status_t
  46. *
  47. * @note None
  48. */
  49. tls_bt_status_t tls_bt_spp_deinit(void);
  50. /**
  51. * @brief Enable the bta jv interface
  52. *
  53. * @param[in] None
  54. *
  55. * @retval @ref tls_bt_status_t
  56. *
  57. * @note None
  58. */
  59. tls_bt_status_t tls_bt_spp_enable(void);
  60. /**
  61. * @brief Disable the bta jv interface and cleanup internal resource
  62. *
  63. * @param[in] None
  64. *
  65. * @retval @ref tls_bt_status_t
  66. *
  67. * @note None
  68. */
  69. tls_bt_status_t tls_bt_spp_disable(void);
  70. /**
  71. * @brief Discovery the spp service by the given peer device.
  72. *
  73. * @param[in] *bd_addr remote device bluetooth device address
  74. *
  75. * @retval @ref tls_bt_status_t
  76. *
  77. * @note None
  78. */
  79. tls_bt_status_t tls_bt_spp_start_discovery(tls_bt_addr_t *bd_addr, tls_bt_uuid_t *uuid);
  80. /**
  81. * @brief Create a spp connection to the remote device
  82. *
  83. * @param[in] sec_mask: Security Setting Mask
  84. * @param[in] role: Server or client
  85. * @param[in] remote_scn: Remote device bluetooth device SCN
  86. * @param[in] *bd_addr remote device bluetooth device address
  87. *
  88. * @retval @ref tls_bt_status_t
  89. *
  90. * @note None
  91. */
  92. tls_bt_status_t tls_bt_spp_connect(wm_spp_sec_t sec_mask,
  93. tls_spp_role_t role, uint8_t remote_scn, tls_bt_addr_t *bd_addr);
  94. /**
  95. * @brief Close a spp connection
  96. *
  97. * @param[in] handle: The connection handle
  98. *
  99. * @retval @ref tls_bt_status_t
  100. *
  101. * @note None
  102. */
  103. tls_bt_status_t tls_bt_spp_disconnect(uint32_t handle);
  104. /**
  105. * @brief This function create a SPP server and starts listening for an
  106. * SPP connection request from a remote Bluetooth device
  107. *
  108. * @param[in] sec_mask: Security Setting Mask .
  109. * @param[in] role: Server or client.
  110. * @param[in] local_scn: The specific channel you want to get.
  111. * If channel is 0, means get any channel.
  112. * @param[in] name: Server's name.
  113. *
  114. * @retval @ref tls_bt_status_t
  115. */
  116. tls_bt_status_t tls_bt_spp_start_server(wm_spp_sec_t sec_mask,
  117. tls_spp_role_t role, uint8_t local_scn, const char *name);
  118. /**
  119. * @brief This function is used to write data
  120. *
  121. * @param[in] handle: The connection handle.
  122. * @param[in] len: The length of the data written.
  123. * @param[in] p_data: The data written.
  124. *
  125. * @retval @ref tls_bt_status_t
  126. */
  127. tls_bt_status_t tls_bt_spp_write(uint32_t handle, uint8_t *p_data, int length);
  128. #endif