bt_app_core.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. This example code is in the Public Domain (or CC0 licensed, at your option.)
  3. Unless required by applicable law or agreed to in writing, this
  4. software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  5. CONDITIONS OF ANY KIND, either express or implied.
  6. */
  7. #ifndef __BT_APP_CORE_H__
  8. #define __BT_APP_CORE_H__
  9. #include "esp_log.h"
  10. #include "time.h"
  11. #include <stdint.h>
  12. #include <stdbool.h>
  13. #include <stdio.h>
  14. #define BT_APP_CORE_TAG "BT_APP_CORE"
  15. #define BT_APP_SIG_WORK_DISPATCH (0x01)
  16. enum {
  17. BT_APP_EVT_STACK_UP = 0,
  18. };
  19. /* A2DP global state */
  20. enum {
  21. APP_AV_STATE_IDLE,
  22. APP_AV_STATE_DISCOVERING,
  23. APP_AV_STATE_DISCOVERED,
  24. APP_AV_STATE_UNCONNECTED,
  25. APP_AV_STATE_CONNECTING,
  26. APP_AV_STATE_CONNECTED,
  27. APP_AV_STATE_DISCONNECTING,
  28. };
  29. /* sub states of APP_AV_STATE_CONNECTED */
  30. enum {
  31. APP_AV_MEDIA_STATE_IDLE,
  32. APP_AV_MEDIA_STATE_STARTING,
  33. APP_AV_MEDIA_STATE_STARTED,
  34. APP_AV_MEDIA_STATE_STOPPING,
  35. APP_AV_MEDIA_STATE_WAIT_DISCONNECT
  36. };
  37. extern int bt_app_source_get_a2d_state();
  38. extern int bt_app_source_get_media_state();
  39. /**
  40. * @brief handler for the dispatched work
  41. */
  42. typedef void (* bt_app_cb_t) (uint16_t event, void *param);
  43. /* message to be sent */
  44. typedef struct {
  45. uint16_t sig; /*!< signal to bt_app_task */
  46. uint16_t event; /*!< message event id */
  47. bt_app_cb_t cb; /*!< context switch callback */
  48. void *param; /*!< parameter area needs to be last */
  49. } bt_app_msg_t;
  50. /**
  51. * @brief parameter deep-copy function to be customized
  52. */
  53. typedef void (* bt_app_copy_cb_t) (bt_app_msg_t *msg, void *p_dest, void *p_src);
  54. /**
  55. * @brief callback for startup event
  56. */
  57. typedef void bt_av_hdl_stack_evt_t(uint16_t event, void *p_param);
  58. /**
  59. * @brief work dispatcher for the application task
  60. */
  61. bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback);
  62. void bt_app_task_start_up(bt_av_hdl_stack_evt_t* handler);
  63. void bt_app_task_shut_down(void);
  64. #endif /* __BT_APP_CORE_H__ */