• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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  *
21  *  This is the public interface file for the Personal Area Networking (PAN)
22  *  subsystem of BTA, Broadcom's Bluetooth application layer for mobile
23  *  phones.
24  *
25  ******************************************************************************/
26 #ifndef BTA_PAN_API_H
27 #define BTA_PAN_API_H
28 
29 #include <cstdint>
30 
31 #include "types/raw_address.h"
32 
33 /*****************************************************************************
34  *  Constants and data types
35  ****************************************************************************/
36 #define BTA_PAN_SUCCESS 0
37 #define BTA_PAN_FAIL 1
38 
39 typedef uint8_t tBTA_PAN_STATUS;
40 
41 /* PAN Callback events */
42 #define BTA_PAN_ENABLE_EVT 0   /* PAN service is enabled. */
43 #define BTA_PAN_SET_ROLE_EVT 1 /* PAN roles registered */
44 #define BTA_PAN_OPENING_EVT 2  /* Connection is being opened. */
45 #define BTA_PAN_OPEN_EVT 3     /* Connection has been opened. */
46 #define BTA_PAN_CLOSE_EVT 4    /* Connection has been closed. */
47 
48 typedef uint8_t tBTA_PAN_EVT;
49 
50 /* pan roles */
51 #define BTA_PAN_ROLE_PANU PAN_ROLE_CLIENT
52 #define BTA_PAN_ROLE_NAP PAN_ROLE_NAP_SERVER
53 
54 typedef uint8_t tBTA_PAN_ROLE;
55 
56 /*  information regarding PAN roles */
57 typedef struct {
58   const char* p_srv_name; /* service name for the PAN role */
59   uint8_t app_id;         /* application id */
60 } tBTA_PAN_ROLE_INFO;
61 
62 /* Event associated with BTA_PAN_SET_ROLE_EVT */
63 typedef struct {
64   tBTA_PAN_STATUS status; /* status of set role event */
65   tBTA_PAN_ROLE role;     /* PAN roles successfully registered */
66 } tBTA_PAN_SET_ROLE;
67 
68 /* Event associated with BTA_PAN_OPENING_EVT */
69 typedef struct {
70   RawAddress bd_addr; /* BD address of peer device. */
71   uint16_t handle; /* Handle associated with this connection. */
72 
73 } tBTA_PAN_OPENING;
74 
75 /* Event associated with BTA_PAN_OPEN_EVT */
76 typedef struct {
77   RawAddress bd_addr;       /* BD address of peer device. */
78   uint16_t handle;          /* Handle associated with this connection. */
79   tBTA_PAN_STATUS status;   /* status of open event */
80   tBTA_PAN_ROLE local_role; /* Local device PAN role for the connection */
81   tBTA_PAN_ROLE peer_role;  /* Peer device PAN role for the connection */
82 
83 } tBTA_PAN_OPEN;
84 
85 /* Event associated with BTA_PAN_CLOSE_EVT */
86 typedef struct {
87   uint16_t handle; /* Handle associated with the connection. */
88 } tBTA_PAN_CLOSE;
89 
90 /* Union of all PAN callback structures */
91 typedef union {
92   tBTA_PAN_SET_ROLE set_role; /* set_role event */
93   tBTA_PAN_OPEN open;         /* Connection has been opened. */
94   tBTA_PAN_OPENING opening;   /* Connection being opened */
95   tBTA_PAN_CLOSE close;       /* Connection has been closed. */
96 } tBTA_PAN;
97 
98 /* Number of PAN connections */
99 #ifndef BTA_PAN_NUM_CONN
100 #define BTA_PAN_NUM_CONN 4
101 #endif
102 
103 /* PAN callback */
104 typedef void(tBTA_PAN_CBACK)(tBTA_PAN_EVT event, tBTA_PAN* p_data);
105 
106 /*****************************************************************************
107  *  External Function Declarations
108  ****************************************************************************/
109 
110 /*******************************************************************************
111  *
112  * Function         BTA_PanEnable
113  *
114  * Description      Enable PAN service.  This function must be
115  *                  called before any other functions in the PAN API are called.
116  *                  When the enable operation is complete the callback function
117  *                  will be called with a BTA_PAN_ENABLE_EVT.
118  *
119  * Returns          void
120  *
121  ******************************************************************************/
122 extern void BTA_PanEnable(tBTA_PAN_CBACK p_cback);
123 
124 /*******************************************************************************
125  *
126  * Function         BTA_PanDisable
127  *
128  * Description      Disable PAN service.
129  *
130  * Returns          void
131  *
132  ******************************************************************************/
133 extern void BTA_PanDisable(void);
134 
135 /*******************************************************************************
136  *
137  * Function         BTA_PanSetRole
138  *
139  * Description      Sets PAN roles. When the enable operation is complete
140  *                  the callback function will be called with a
141  *                  BTA_PAN_SET_ROLE_EVT.
142  *
143  * Returns          void
144  *
145  ******************************************************************************/
146 void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO* p_user_info,
147                     tBTA_PAN_ROLE_INFO* p_nap_info);
148 
149 /*******************************************************************************
150  *
151  * Function         BTA_PanOpen
152  *
153  * Description      Opens a connection to a peer device.
154  *                  When connection is open callback function is called
155  *                  with a BTA_PAN_OPEN_EVT.
156  *
157  *
158  * Returns          void
159  *
160  ******************************************************************************/
161 void BTA_PanOpen(const RawAddress& bd_addr, tBTA_PAN_ROLE local_role,
162                  tBTA_PAN_ROLE peer_role);
163 
164 /*******************************************************************************
165  *
166  * Function         BTA_PanClose
167  *
168  * Description      Close a PAN  connection to a peer device.
169  *
170  *
171  * Returns          void
172  *
173  ******************************************************************************/
174 extern void BTA_PanClose(uint16_t handle);
175 
176 #endif /* BTA_PAN_API_H */
177