bta_pan_api.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /******************************************************************************
  2. *
  3. * Copyright 2004-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * This is the public interface file for the Personal Area Networking (PAN)
  21. * subsystem of BTA, Broadcom's Bluetooth application layer for mobile
  22. * phones.
  23. *
  24. ******************************************************************************/
  25. #ifndef BTA_PAN_API_H
  26. #define BTA_PAN_API_H
  27. #include "bta_api.h"
  28. #include "pan_api.h"
  29. /*****************************************************************************
  30. * Constants and data types
  31. ****************************************************************************/
  32. #define BTA_PAN_SUCCESS 0
  33. #define BTA_PAN_FAIL 1
  34. typedef uint8_t tBTA_PAN_STATUS;
  35. /* PAN Callback events */
  36. #define BTA_PAN_ENABLE_EVT 0 /* PAN service is enabled. */
  37. #define BTA_PAN_SET_ROLE_EVT 1 /* PAN roles registered */
  38. #define BTA_PAN_OPENING_EVT 2 /* Connection is being opened. */
  39. #define BTA_PAN_OPEN_EVT 3 /* Connection has been opened. */
  40. #define BTA_PAN_CLOSE_EVT 4 /* Connection has been closed. */
  41. typedef uint8_t tBTA_PAN_EVT;
  42. /* pan roles */
  43. #define BTA_PAN_ROLE_PANU PAN_ROLE_CLIENT
  44. #define BTA_PAN_ROLE_GN PAN_ROLE_GN_SERVER
  45. #define BTA_PAN_ROLE_NAP PAN_ROLE_NAP_SERVER
  46. typedef uint8_t tBTA_PAN_ROLE;
  47. /* information regarding PAN roles */
  48. typedef struct {
  49. const char* p_srv_name; /* service name for the PAN role */
  50. uint8_t app_id; /* application id */
  51. tBTA_SEC sec_mask; /* security setting for the role */
  52. } tBTA_PAN_ROLE_INFO;
  53. /* Event associated with BTA_PAN_SET_ROLE_EVT */
  54. typedef struct {
  55. tBTA_PAN_STATUS status; /* status of set role event */
  56. tBTA_PAN_ROLE role; /* PAN roles successfully registered */
  57. } tBTA_PAN_SET_ROLE;
  58. /* Event associated with BTA_PAN_OPENING_EVT */
  59. typedef struct {
  60. RawAddress bd_addr; /* BD address of peer device. */
  61. uint16_t handle; /* Handle associated with this connection. */
  62. } tBTA_PAN_OPENING;
  63. /* Event associated with BTA_PAN_OPEN_EVT */
  64. typedef struct {
  65. RawAddress bd_addr; /* BD address of peer device. */
  66. uint16_t handle; /* Handle associated with this connection. */
  67. tBTA_PAN_STATUS status; /* status of open event */
  68. tBTA_PAN_ROLE local_role; /* Local device PAN role for the connection */
  69. tBTA_PAN_ROLE peer_role; /* Peer device PAN role for the connection */
  70. } tBTA_PAN_OPEN;
  71. /* Event associated with BTA_PAN_CLOSE_EVT */
  72. typedef struct {
  73. uint16_t handle; /* Handle associated with the connection. */
  74. } tBTA_PAN_CLOSE;
  75. /* Union of all PAN callback structures */
  76. typedef union {
  77. tBTA_PAN_SET_ROLE set_role; /* set_role event */
  78. tBTA_PAN_OPEN open; /* Connection has been opened. */
  79. tBTA_PAN_OPENING opening; /* Connection being opened */
  80. tBTA_PAN_CLOSE close; /* Connection has been closed. */
  81. } tBTA_PAN;
  82. /* Number of PAN connections */
  83. #ifndef BTA_PAN_NUM_CONN
  84. #define BTA_PAN_NUM_CONN 4
  85. #endif
  86. /* PAN callback */
  87. typedef void(tBTA_PAN_CBACK)(tBTA_PAN_EVT event, tBTA_PAN* p_data);
  88. /*****************************************************************************
  89. * External Function Declarations
  90. ****************************************************************************/
  91. /*******************************************************************************
  92. *
  93. * Function BTA_PanEnable
  94. *
  95. * Description Enable PAN service. This function must be
  96. * called before any other functions in the PAN API are called.
  97. * When the enable operation is complete the callback function
  98. * will be called with a BTA_PAN_ENABLE_EVT.
  99. *
  100. * Returns void
  101. *
  102. ******************************************************************************/
  103. extern void BTA_PanEnable(tBTA_PAN_CBACK p_cback);
  104. /*******************************************************************************
  105. *
  106. * Function BTA_PanDisable
  107. *
  108. * Description Disable PAN service.
  109. *
  110. * Returns void
  111. *
  112. ******************************************************************************/
  113. extern void BTA_PanDisable(void);
  114. /*******************************************************************************
  115. *
  116. * Function BTA_PanSetRole
  117. *
  118. * Description Sets PAN roles. When the enable operation is complete
  119. * the callback function will be called with a
  120. * BTA_PAN_SET_ROLE_EVT.
  121. *
  122. * Returns void
  123. *
  124. ******************************************************************************/
  125. void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO* p_user_info,
  126. tBTA_PAN_ROLE_INFO* p_gn_info,
  127. tBTA_PAN_ROLE_INFO* p_nap_info);
  128. /*******************************************************************************
  129. *
  130. * Function BTA_PanOpen
  131. *
  132. * Description Opens a connection to a peer device.
  133. * When connection is open callback function is called
  134. * with a BTA_PAN_OPEN_EVT.
  135. *
  136. *
  137. * Returns void
  138. *
  139. ******************************************************************************/
  140. void BTA_PanOpen(const RawAddress& bd_addr, tBTA_PAN_ROLE local_role,
  141. tBTA_PAN_ROLE peer_role);
  142. /*******************************************************************************
  143. *
  144. * Function BTA_PanClose
  145. *
  146. * Description Close a PAN connection to a peer device.
  147. *
  148. *
  149. * Returns void
  150. *
  151. ******************************************************************************/
  152. extern void BTA_PanClose(uint16_t handle);
  153. #endif /* BTA_PAN_API_H */