bt_pan.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* SPDX-License-Identifier: Apache-2.0 */
  2. /*
  3. * Copyright (C) 2012 The Android Open Source Project
  4. *
  5. */
  6. #ifndef ANDROID_INCLUDE_BT_PAN_H
  7. #define ANDROID_INCLUDE_BT_PAN_H
  8. __BEGIN_DECLS
  9. #define BTPAN_ROLE_NONE 0
  10. #define BTPAN_ROLE_PANNAP 1
  11. #define BTPAN_ROLE_PANU 2
  12. typedef enum {
  13. BTPAN_STATE_CONNECTED = 0,
  14. BTPAN_STATE_CONNECTING = 1,
  15. BTPAN_STATE_DISCONNECTED = 2,
  16. BTPAN_STATE_DISCONNECTING = 3
  17. } btpan_connection_state_t;
  18. typedef enum {
  19. BTPAN_STATE_ENABLED = 0,
  20. BTPAN_STATE_DISABLED = 1
  21. } btpan_control_state_t;
  22. /**
  23. * Callback for pan connection state
  24. */
  25. typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state, bt_status_t error,
  26. const bt_bdaddr_t *bd_addr, int local_role, int remote_role);
  27. typedef void (*btpan_control_state_callback)(btpan_control_state_t state, int local_role,
  28. bt_status_t error, const char* ifname);
  29. typedef struct {
  30. size_t size;
  31. btpan_control_state_callback control_state_cb;
  32. btpan_connection_state_callback connection_state_cb;
  33. } btpan_callbacks_t;
  34. typedef struct {
  35. /** set to size of this struct*/
  36. size_t size;
  37. /**
  38. * Initialize the pan interface and register the btpan callbacks
  39. */
  40. bt_status_t (*init)(const btpan_callbacks_t* callbacks);
  41. /*
  42. * enable the pan service by specified role. The result state of
  43. * enabl will be returned by btpan_control_state_callback. when pan-nap is enabled,
  44. * the state of connecting panu device will be notified by btpan_connection_state_callback
  45. */
  46. bt_status_t (*enable)(int local_role);
  47. /*
  48. * get current pan local role
  49. */
  50. int (*get_local_role)(void);
  51. /**
  52. * start bluetooth pan connection to the remote device by specified pan role. The result state will be
  53. * returned by btpan_connection_state_callback
  54. */
  55. bt_status_t (*connect)(const bt_bdaddr_t *bd_addr, int local_role, int remote_role);
  56. /**
  57. * stop bluetooth pan connection. The result state will be returned by btpan_connection_state_callback
  58. */
  59. bt_status_t (*disconnect)(const bt_bdaddr_t *bd_addr);
  60. /**
  61. * Cleanup the pan interface
  62. */
  63. void (*cleanup)(void);
  64. } btpan_interface_t;
  65. __END_DECLS
  66. #endif /* ANDROID_INCLUDE_BT_PAN_H */