bt_pan.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright (C) 2012 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef ANDROID_INCLUDE_BT_PAN_H
  17. #define ANDROID_INCLUDE_BT_PAN_H
  18. __BEGIN_DECLS
  19. #define BTPAN_ROLE_NONE 0
  20. #define BTPAN_ROLE_PANNAP 1
  21. #define BTPAN_ROLE_PANU 2
  22. typedef enum {
  23. BTPAN_STATE_CONNECTED = 0,
  24. BTPAN_STATE_CONNECTING = 1,
  25. BTPAN_STATE_DISCONNECTED = 2,
  26. BTPAN_STATE_DISCONNECTING = 3
  27. } btpan_connection_state_t;
  28. typedef enum {
  29. BTPAN_STATE_ENABLED = 0,
  30. BTPAN_STATE_DISABLED = 1
  31. } btpan_control_state_t;
  32. /**
  33. * Callback for pan connection state
  34. */
  35. typedef void (*btpan_connection_state_callback)(btpan_connection_state_t state,
  36. bt_status_t error,
  37. const RawAddress* bd_addr,
  38. int local_role,
  39. int remote_role);
  40. typedef void (*btpan_control_state_callback)(btpan_control_state_t state,
  41. int local_role, bt_status_t error,
  42. const char* ifname);
  43. typedef struct {
  44. size_t size;
  45. btpan_control_state_callback control_state_cb;
  46. btpan_connection_state_callback connection_state_cb;
  47. } btpan_callbacks_t;
  48. typedef struct {
  49. /** set to size of this struct*/
  50. size_t size;
  51. /**
  52. * Initialize the pan interface and register the btpan callbacks
  53. */
  54. bt_status_t (*init)(const btpan_callbacks_t* callbacks);
  55. /*
  56. * enable the pan service by specified role. The result state of
  57. * enabl will be returned by btpan_control_state_callback. when pan-nap is
  58. * enabled, the state of connecting panu device will be notified by
  59. * btpan_connection_state_callback
  60. */
  61. bt_status_t (*enable)(int local_role);
  62. /*
  63. * get current pan local role
  64. */
  65. int (*get_local_role)(void);
  66. /**
  67. * start bluetooth pan connection to the remote device by specified pan role.
  68. * The result state will be returned by btpan_connection_state_callback
  69. */
  70. bt_status_t (*connect)(const RawAddress* bd_addr, int local_role,
  71. int remote_role);
  72. /**
  73. * stop bluetooth pan connection. The result state will be returned by
  74. * btpan_connection_state_callback
  75. */
  76. bt_status_t (*disconnect)(const RawAddress* bd_addr);
  77. /**
  78. * Cleanup the pan interface
  79. */
  80. void (*cleanup)(void);
  81. } btpan_interface_t;
  82. __END_DECLS
  83. #endif /* ANDROID_INCLUDE_BT_PAN_H */