wm_bt.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. /**
  2. * @file wm_bt.h
  3. *
  4. * @brief Bluetooth API
  5. *
  6. * @author WinnerMicro
  7. *
  8. * Copyright (c) 2020 Winner Microelectronics Co., Ltd.
  9. */
  10. #ifndef WM_BT_H
  11. #define WM_BT_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 BT_Host_APIs BT Host APIs
  23. * @brief BT Host APIs
  24. */
  25. /**
  26. * @addtogroup BT_Host_APIs
  27. * @{
  28. */
  29. /**
  30. * @brief reply the pin request
  31. *
  32. * @param[in] *bd_addr remote device address
  33. * @param[in] accept
  34. * @param[in] pin_len
  35. * @param[in] *pin_code
  36. *
  37. * @return @ref tls_bt_status_t
  38. *
  39. * @note None
  40. */
  41. tls_bt_status_t tls_bt_pin_reply(const tls_bt_addr_t *bd_addr, uint8_t accept,
  42. uint8_t pin_len, tls_bt_pin_code_t *pin_code);
  43. /**
  44. * @brief reply the ssp request
  45. *
  46. * @param[in] *bd_addr remote device address
  47. * @param[in] variant @ref tls_bt_ssp_variant_t
  48. * @param[in] accept
  49. * @param[in] passkey
  50. *
  51. * @return @ref tls_bt_status_t
  52. *
  53. * @note None
  54. */
  55. tls_bt_status_t tls_bt_ssp_reply(const tls_bt_addr_t *bd_addr, tls_bt_ssp_variant_t variant,
  56. uint8_t accept, uint32_t passkey);
  57. /**
  58. * @brief set the adapter property
  59. *
  60. * @param[in] *property remote device address
  61. * @param[in] update_to_flash save the property to flash or not
  62. *
  63. * @return @ref tls_bt_status_t
  64. *
  65. * @note None
  66. */
  67. tls_bt_status_t tls_bt_set_adapter_property(const tls_bt_property_t *property, uint8_t update_to_flash);
  68. /**
  69. * @brief get the adapter property
  70. *
  71. * @param[in] type @ref tls_bt_property_type_t
  72. *
  73. * @return @ref tls_bt_status_t
  74. *
  75. * @note None
  76. */
  77. tls_bt_status_t tls_bt_get_adapter_property(tls_bt_property_type_t type);
  78. /**
  79. * @brief
  80. *
  81. * @param None
  82. *
  83. * @return @ref tls_bt_status_t
  84. *
  85. * @note None
  86. */
  87. tls_bt_status_t tls_bt_start_discovery(void);
  88. /**
  89. * @brief
  90. *
  91. * @param None
  92. *
  93. * @return @ref tls_bt_status_t
  94. *
  95. * @note None
  96. */
  97. tls_bt_status_t tls_bt_cancel_discovery(void);
  98. /**
  99. * @brief
  100. *
  101. * @param[in] *bd_addr
  102. * @param[in] transport
  103. *
  104. * @return @ref tls_bt_status_t
  105. *
  106. * @note None
  107. */
  108. tls_bt_status_t tls_bt_create_bond(const tls_bt_addr_t *bd_addr, int transport);
  109. /**
  110. * @brief
  111. *
  112. * @param[in] *bd_addr
  113. *
  114. * @return @ref tls_bt_status_t
  115. *
  116. * @note None
  117. */
  118. tls_bt_status_t tls_bt_cancel_bond(const tls_bt_addr_t *bd_addr);
  119. /**
  120. * @brief
  121. *
  122. * @param[in] *bd_addr
  123. *
  124. * @return @ref tls_bt_status_t
  125. *
  126. * @note None
  127. */
  128. tls_bt_status_t tls_bt_remove_bond(const tls_bt_addr_t *bd_addr);
  129. /**
  130. * @brief
  131. *
  132. * @param None
  133. *
  134. * @return @ref tls_bt_status_t
  135. *
  136. * @note None
  137. */
  138. tls_bt_status_t tls_bt_host_cleanup(void);
  139. /**
  140. * @brief
  141. *
  142. * @param[in] callback
  143. * @param[in] *p_hci_if
  144. * @param[in] log_level
  145. *
  146. * @return @ref tls_bt_status_t
  147. *
  148. * @note None
  149. */
  150. tls_bt_status_t tls_bt_enable(tls_bt_host_callback_t callback, tls_bt_hci_if_t *p_hci_if, tls_bt_log_level_t log_level);
  151. /**
  152. * @brief
  153. *
  154. * @param None
  155. *
  156. * @return @ref tls_bt_status_t
  157. *
  158. * @note None
  159. */
  160. tls_bt_status_t tls_bt_disable();
  161. /**
  162. * @}
  163. */
  164. /**
  165. * @defgroup BT_Controller_APIs BT Controller APIs
  166. * @brief BT Controller APIs
  167. */
  168. /**
  169. * @addtogroup BT_Controller_APIs
  170. * @{
  171. */
  172. /**
  173. * @brief enable the bluetooth controller stack
  174. *
  175. * @param[in] *p_hci_if pointer on uart property
  176. * @param[in] log_level @ref tls_bt_log_level_t
  177. *
  178. * @retval @ref tls_bt_status_t
  179. *
  180. * @note None
  181. */
  182. tls_bt_status_t tls_bt_ctrl_enable(tls_bt_hci_if_t *p_hci_if, tls_bt_log_level_t log_level);
  183. /**
  184. * @brief disable the bluetooth controller stack
  185. *
  186. * @param None
  187. *
  188. * @return @ref tls_bt_status_t
  189. *
  190. * @note None
  191. */
  192. tls_bt_status_t tls_bt_ctrl_disable(void);
  193. /**
  194. * @brief configure the ble emit power of different ble handle type
  195. *
  196. * @param[in] power_type @ref tls_ble_power_type_t
  197. * @param[in] power_level_index [1,2,3,4,5] map to[1,4,7,10,13]dBm
  198. *
  199. * @retval @ref tls_bt_status_t
  200. *
  201. * @note power_type, supports TLS_BLE_PWR_TYPE_DEFAULT only.
  202. */
  203. tls_bt_status_t tls_ble_set_tx_power(tls_ble_power_type_t power_type, int8_t power_level_index);
  204. /**
  205. * @brief get the ble emit power of different ble handle type
  206. *
  207. * @param[in] power_type @ref tls_ble_power_type_t
  208. *
  209. * @retval power value db
  210. *
  211. * @note power_type, supports TLS_BLE_PWR_TYPE_DEFAULT only.
  212. */
  213. int8_t tls_ble_get_tx_power(tls_ble_power_type_t power_type);
  214. /**
  215. * @brief configure the classic/enhanced bluetooth transmit power
  216. *
  217. * @param[in] min_power_level power level[1,13]dBm
  218. * @param[in] max_power_level power level[1,13]dBm
  219. *
  220. * @retval @ref tls_bt_status_t
  221. *
  222. * @note None
  223. */
  224. tls_bt_status_t tls_bredr_set_tx_power(int8_t min_power_level,int8_t max_power_level);
  225. /**
  226. * @brief get the classic/enhanced bluetooth transmit power level
  227. *
  228. * @param[in] *min_power_level pointer on min_power_level
  229. * @param[in] *max_power_level pointer on max_power_level
  230. *
  231. * @retval @ref tls_bt_status_t
  232. *
  233. * @note None
  234. */
  235. tls_bt_status_t tls_bredr_get_tx_power(int8_t* min_power_level, int8_t* max_power_level);
  236. /**
  237. * @brief configure the voice output path
  238. *
  239. * @param[in] data_path @ref tls_sco_data_path_t
  240. *
  241. * @retval @ref tls_bt_status_t
  242. *
  243. * @note None
  244. */
  245. tls_bt_status_t tls_bredr_sco_datapath_set(tls_sco_data_path_t data_path);
  246. /**
  247. * @brief get controller stack status
  248. *
  249. * @param None
  250. *
  251. * @retval @ref tls_bt_ctrl_status_t
  252. *
  253. * @note None
  254. */
  255. tls_bt_ctrl_status_t tls_bt_controller_get_status(void);
  256. /**
  257. * @brief this function receive the hci message from host hci_h4 inteface
  258. *
  259. * @param[in] *data hci formated message
  260. * @param[in] len command length
  261. *
  262. * @retval @ref tls_bt_ctrl_status_t
  263. *
  264. * @note None
  265. */
  266. tls_bt_status_t tls_bt_vuart_host_send_packet( uint8_t *data, uint16_t len);
  267. /**
  268. * @brief this function register the host stack receive message function
  269. * and indication the controller receive hci command avaiable
  270. *
  271. * @param[in] *p_host_if @ref tls_bt_host_if_t
  272. *
  273. * @retval @ref tls_bt_ctrl_status_t
  274. *
  275. * @note None
  276. */
  277. tls_bt_status_t tls_bt_ctrl_if_register(const tls_bt_host_if_t *p_host_if);
  278. /**
  279. * @brief this function unregister the host stack receive message function
  280. * and indication the controller receive hci command avaiable
  281. *
  282. * @param None
  283. *
  284. * @retval @ref tls_bt_ctrl_status_t
  285. *
  286. * @note None
  287. */
  288. tls_bt_status_t tls_bt_ctrl_if_unregister();
  289. /**
  290. * @brief this function configure the controller enter into sleep mode when controller
  291. * is in idle mode
  292. *
  293. * @param[in] enable TRUE: enable
  294. * FALSE: didsable
  295. *
  296. * @retval @ref tls_bt_ctrl_status_t
  297. *
  298. * @note None
  299. */
  300. tls_bt_status_t tls_bt_ctrl_sleep(bool enable);
  301. /**
  302. * @brief this function look up the controller is in sleep mode or not
  303. *
  304. * @param None
  305. *
  306. * @retval TRUE: sleep mode
  307. * FALSE: not sleep mode
  308. *
  309. * @note None
  310. */
  311. bool tls_bt_ctrl_is_sleep(void);
  312. /**
  313. * @brief this function wake up the controller, in other words exit sleep mode
  314. *
  315. * @param None
  316. *
  317. * @retval @ref tls_bt_ctrl_status_t
  318. *
  319. * @note None
  320. */
  321. tls_bt_status_t tls_bt_ctrl_wakeup(void);
  322. /**
  323. * @brief this function check controller can handle hci commands yes or no
  324. *
  325. * @param None
  326. *
  327. * @retval @ref bool TRUE or FALSE
  328. *
  329. * @note None
  330. */
  331. bool tls_bt_vuart_host_check_send_available();
  332. /**
  333. * @brief this function exit bluetooth test mode
  334. *
  335. * @param None
  336. *
  337. * @retval @ref tls_bt_ctrl_status_t
  338. *
  339. * @note None
  340. */
  341. tls_bt_status_t exit_bt_test_mode();
  342. /**
  343. * @brief this function enable bluetooth test mode
  344. *
  345. * @param[in] p_hci_if, specific the uart port property
  346. *
  347. * @retval @ref tls_bt_ctrl_status_t
  348. *
  349. * @note None
  350. */
  351. tls_bt_status_t enable_bt_test_mode(tls_bt_hci_if_t *p_hci_if);
  352. /**
  353. * @brief this function enable rf to bluetooth mode
  354. *
  355. * @param[in] 1, bluetooth mode, 0 wifi/bluetooth mode
  356. *
  357. * @retval None
  358. *
  359. * @note None
  360. */
  361. void tls_rf_bt_mode(uint8_t enable);
  362. /**
  363. * @}
  364. */
  365. /**
  366. * @}
  367. */
  368. #endif /* WM_BT_H */