bt.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __BT_H__
  14. #define __BT_H__
  15. #include <stdint.h>
  16. #include <stdbool.h>
  17. #include "esp_err.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * @brief Initialize BT controller
  23. *
  24. * This function should be called only once, before any other BT functions are called.
  25. */
  26. void bt_controller_init();
  27. /** @brief: vhci_host_callback
  28. * used for vhci call host function to notify what host need to do
  29. *
  30. * notify_host_send_available: notify host can send packet to controller
  31. * notify_host_recv: notify host that controller has packet send to host
  32. */
  33. typedef struct vhci_host_callback {
  34. void (*notify_host_send_available)(void);
  35. int (*notify_host_recv)(uint8_t *data, uint16_t len);
  36. } vhci_host_callback_t;
  37. /** @brief: API_vhci_host_check_send_available
  38. * used for check actively if the host can send packet to controller or not.
  39. * return true for ready to send, false means cannot send packet
  40. */
  41. bool API_vhci_host_check_send_available(void);
  42. /** @brief: API_vhci_host_send_packet
  43. * host send packet to controller
  44. * param data is the packet point, the param len is the packet length
  45. * return void
  46. */
  47. void API_vhci_host_send_packet(uint8_t *data, uint16_t len);
  48. /** @brief: API_vhci_host_register_callback
  49. * register the vhci referece callback, the call back
  50. * struct defined by vhci_host_callback structure.
  51. * param is the vhci_host_callback type variable
  52. */
  53. void API_vhci_host_register_callback(const vhci_host_callback_t *callback);
  54. #ifdef __cplusplus
  55. }
  56. #endif
  57. #endif /* __BT_H__ */