bt_hl.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /* SPDX-License-Identifier: Apache-2.0 */
  2. /*
  3. * Copyright (C) 2012 The Android Open Source Project
  4. *
  5. */
  6. #ifndef ANDROID_INCLUDE_BT_HL_H
  7. #define ANDROID_INCLUDE_BT_HL_H
  8. __BEGIN_DECLS
  9. /* HL connection states */
  10. typedef enum
  11. {
  12. BTHL_MDEP_ROLE_SOURCE,
  13. BTHL_MDEP_ROLE_SINK
  14. } bthl_mdep_role_t;
  15. typedef enum {
  16. BTHL_APP_REG_STATE_REG_SUCCESS,
  17. BTHL_APP_REG_STATE_REG_FAILED,
  18. BTHL_APP_REG_STATE_DEREG_SUCCESS,
  19. BTHL_APP_REG_STATE_DEREG_FAILED
  20. } bthl_app_reg_state_t;
  21. typedef enum
  22. {
  23. BTHL_CHANNEL_TYPE_RELIABLE,
  24. BTHL_CHANNEL_TYPE_STREAMING,
  25. BTHL_CHANNEL_TYPE_ANY
  26. } bthl_channel_type_t;
  27. /* HL connection states */
  28. typedef enum {
  29. BTHL_CONN_STATE_CONNECTING,
  30. BTHL_CONN_STATE_CONNECTED,
  31. BTHL_CONN_STATE_DISCONNECTING,
  32. BTHL_CONN_STATE_DISCONNECTED,
  33. BTHL_CONN_STATE_DESTROYED
  34. } bthl_channel_state_t;
  35. typedef struct
  36. {
  37. bthl_mdep_role_t mdep_role;
  38. int data_type;
  39. bthl_channel_type_t channel_type;
  40. const char *mdep_description; /* MDEP description to be used in the SDP (optional); null terminated */
  41. } bthl_mdep_cfg_t;
  42. typedef struct
  43. {
  44. const char *application_name;
  45. const char *provider_name; /* provider name to be used in the SDP (optional); null terminated */
  46. const char *srv_name; /* service name to be used in the SDP (optional); null terminated*/
  47. const char *srv_desp; /* service description to be used in the SDP (optional); null terminated */
  48. int number_of_mdeps;
  49. bthl_mdep_cfg_t *mdep_cfg; /* Dynamic array */
  50. } bthl_reg_param_t;
  51. /** Callback for application registration status.
  52. * state will have one of the values from bthl_app_reg_state_t
  53. */
  54. typedef void (* bthl_app_reg_state_callback)(int app_id, bthl_app_reg_state_t state);
  55. /** Callback for channel connection state change.
  56. * state will have one of the values from
  57. * bthl_connection_state_t and fd (file descriptor)
  58. */
  59. typedef void (* bthl_channel_state_callback)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int channel_id, bthl_channel_state_t state, int fd);
  60. /** BT-HL callback structure. */
  61. typedef struct {
  62. /** set to sizeof(bthl_callbacks_t) */
  63. size_t size;
  64. bthl_app_reg_state_callback app_reg_state_cb;
  65. bthl_channel_state_callback channel_state_cb;
  66. } bthl_callbacks_t;
  67. /** Represents the standard BT-HL interface. */
  68. typedef struct {
  69. /** set to sizeof(bthl_interface_t) */
  70. size_t size;
  71. /**
  72. * Register the Bthl callbacks
  73. */
  74. bt_status_t (*init)( bthl_callbacks_t* callbacks );
  75. /** Register HL application */
  76. bt_status_t (*register_application) ( bthl_reg_param_t *p_reg_param, int *app_id);
  77. /** Unregister HL application */
  78. bt_status_t (*unregister_application) (int app_id);
  79. /** connect channel */
  80. bt_status_t (*connect_channel)(int app_id, bt_bdaddr_t *bd_addr, int mdep_cfg_index, int *channel_id);
  81. /** destroy channel */
  82. bt_status_t (*destroy_channel)(int channel_id);
  83. /** Close the Bthl callback **/
  84. void (*cleanup)(void);
  85. } bthl_interface_t;
  86. __END_DECLS
  87. #endif /* ANDROID_INCLUDE_BT_HL_H */