wm_ble.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /**
  2. * @file wm_ble.h
  3. *
  4. * @brief Bluetooth API
  5. *
  6. * @author WinnerMicro
  7. *
  8. * Copyright (c) 2020 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_BLE_H
  11. #define WM_BLE_H
  12. #include "wm_bt_def.h"
  13. /**
  14. * @defgroup BT_APIs Bluetooth APIs
  15. * @brief Bluetooth related APIs
  16. */
  17. /**
  18. * @addtogroup BT_APIs
  19. * @{
  20. */
  21. /**
  22. * @defgroup BLE_APIs BLE APIs
  23. * @brief BLE APIs
  24. */
  25. /**
  26. * @addtogroup BLE_APIs
  27. * @{
  28. */
  29. /**
  30. * @brief initialize the application callback function
  31. *
  32. * @param[in] *p_callback pointer on callback function
  33. *
  34. * @return @ref tls_bt_status_t
  35. *
  36. * @note None
  37. */
  38. tls_bt_status_t tls_ble_dm_init(tls_ble_dm_callback_t callback);
  39. /**
  40. * @brief start/stop ble advertisement
  41. *
  42. * @param[in] start 1 connectable and discoverable; 2 disconnectable and discoverable; 0 stop
  43. *
  44. * @return @ref tls_bt_status_t
  45. *
  46. * @note None
  47. */
  48. tls_bt_status_t tls_ble_adv(uint8_t adv_state);
  49. /**
  50. * @brief configure the advertisment content
  51. *
  52. * @param[in] *data @ref btif_dm_adv_data_t
  53. *
  54. * @retval @ref tls_bt_status_t
  55. *
  56. * @note if pure_data equals to true, the filed of manufacturer equals to all fileds of advetisement data.
  57. * otherwise, the filed manufacturer will be advertised in 0xFF filed.
  58. *
  59. */
  60. tls_bt_status_t tls_ble_set_adv_data(tls_ble_dm_adv_data_t *data);
  61. /**
  62. * @brief configure the advertisment parameters
  63. *
  64. * @param[in] *param @ref btif_dm_adv_param_t
  65. *
  66. * @retval @ref tls_bt_status_t
  67. *
  68. * @note None
  69. */
  70. tls_bt_status_t tls_ble_set_adv_param(tls_ble_dm_adv_param_t *param);
  71. /**
  72. * @brief configure the advertisment extented parameters
  73. *
  74. * @param[in] *param @ref tls_ble_dm_adv_ext_param_t
  75. *
  76. * @retval @ref tls_bt_status_t
  77. *
  78. * @note if you know how to config all the parameters, you can use this function; otherwise, tls_ble_set_adv_param will be recommanded strongly;
  79. */
  80. tls_bt_status_t tls_ble_set_adv_ext_param(tls_ble_dm_adv_ext_param_t *param);
  81. /**
  82. * @brief start/stop ble scan
  83. *
  84. * @param[in] start TRUE enable; FALSE disable
  85. *
  86. * @retval @ref tls_bt_status_t
  87. *
  88. * @note None
  89. */
  90. tls_bt_status_t tls_ble_scan(bool start);
  91. /**
  92. * @brief configure the scan parameters
  93. *
  94. * @param[in] window scan window size
  95. * @param[in] interval scan interval length
  96. * @param[in] scan mode 0 passive scan; 1 active scan;
  97. *
  98. * @retval @ref tls_bt_status_t
  99. *
  100. * @note interval should greater or equals to windows,
  101. * both range should be within (0x0004, 0x4000)
  102. */
  103. tls_bt_status_t tls_ble_set_scan_param(int window, int interval, uint8_t scan_mode);
  104. /**
  105. * @brief enable a async process evt
  106. *
  107. * @param[in] id user specific definition
  108. * @param[in] *p_callback callback function
  109. *
  110. * @return @ref tls_bt_status_t
  111. *
  112. * @note None
  113. */
  114. tls_bt_status_t tls_dm_evt_triger(int id, tls_ble_dm_triger_callback_t callback);
  115. /**
  116. * @brief configure the max transmit unit
  117. *
  118. * @param[in] *bd_addr the remote device address
  119. * @param[in] length range [27 - 251]
  120. *
  121. * @return @ref tls_bt_status_t
  122. *
  123. * @note None
  124. */
  125. tls_bt_status_t tls_dm_set_data_length(tls_bt_addr_t *bd_addr, uint16_t length);
  126. /**
  127. * @brief configure the ble privacy
  128. *
  129. * @param[in] enable TRUE: using rpa/random address, updated every 15 mins
  130. ** FALSE: public address
  131. *
  132. * @return @ref tls_bt_status_t
  133. *
  134. * @note None
  135. */
  136. tls_bt_status_t tls_dm_set_privacy(uint8_t enable);
  137. /**
  138. * @brief update the connection parameters
  139. *
  140. * @param[in] *bd_addr remote device address
  141. * @param[in] min_interval
  142. * @param[in] max_interval
  143. * @param[in] latency
  144. * @param[in] timeout
  145. *
  146. * @return @ref tls_bt_status_t
  147. *
  148. * @note None
  149. */
  150. tls_bt_status_t tls_ble_conn_parameter_update(const tls_bt_addr_t *bd_addr,
  151. int min_interval,
  152. int max_interval,
  153. int latency,
  154. int timeout);
  155. /**
  156. * @brief read the remote device signal strength connected
  157. *
  158. * @param[in] *bd_addr remote device address
  159. *
  160. * @return @ref tls_bt_status_t
  161. *
  162. * @note None
  163. */
  164. tls_bt_status_t tls_dm_read_remote_rssi(const tls_bt_addr_t *bd_addr);
  165. /**
  166. * @brief config the io capabilities of local device
  167. *
  168. * @param[in] io_cap
  169. *
  170. * @return @ref tls_bt_status_t
  171. *
  172. * @note None
  173. */
  174. tls_bt_status_t tls_ble_set_sec_io_cap(uint8_t io_cap);
  175. /**
  176. * @brief config the auth requirement of local device
  177. *
  178. * @param[in] auth_req
  179. *
  180. * @return @ref tls_bt_status_t
  181. *
  182. * @note None
  183. */
  184. tls_bt_status_t tls_ble_set_sec_auth_req(uint8_t auth_req);
  185. /**
  186. * @brief This function is called to ensure that connection is
  187. * encrypted. Should be called only on an open connection.
  188. * Typically only needed for connections that first want to
  189. * bring up unencrypted links, then later encrypt them.
  190. * @param[in]sec_act - This is the security action to indicate
  191. * what knid of BLE security level is required for
  192. * the BLE link if the BLE is supported
  193. * @param[in]bd_addr - Address of the peer device
  194. * @ref tls_bt_status_t
  195. *
  196. * @note None
  197. */
  198. tls_bt_status_t tls_ble_set_sec(const tls_bt_addr_t *bd_addr, uint8_t sec_act);
  199. /**
  200. * @brief only used to start/stop ble advertisement
  201. *
  202. * @param[in] start 1 start advertisement; 0 stop advertisement;
  203. * @param[in] duration valid for start advertisement. 0 for forever, otherwise the last seconds of advertisement
  204. *
  205. * @return @ref tls_bt_status_t
  206. *
  207. * @note None
  208. */
  209. tls_bt_status_t tls_ble_gap_adv(uint8_t start, int duration);
  210. /**
  211. * @}
  212. */
  213. /**
  214. * @}
  215. */
  216. #endif /* WM_BLE_H */