1 /******************************************************************************
2  *
3  *  Copyright (C) 2006-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 the BTA Java I/F
22  *
23  ******************************************************************************/
24 #ifndef BTA_JV_API_H
25 #define BTA_JV_API_H
26 
27 #include "bt_target.h"
28 #include "bt_types.h"
29 #include "bta_api.h"
30 #include "btm_api.h"
31 #include "l2c_api.h"
32 
33 /*****************************************************************************
34 **  Constants and data types
35 *****************************************************************************/
36 /* status values */
37 #define BTA_JV_SUCCESS             0            /* Successful operation. */
38 #define BTA_JV_FAILURE             1            /* Generic failure. */
39 #define BTA_JV_BUSY                2            /* Temporarily can not handle this request. */
40 #define BTA_JV_NO_DATA             3            /* no data. */
41 #define BTA_JV_NO_RESOURCE         4            /* No more set pm control block */
42 
43 typedef UINT8 tBTA_JV_STATUS;
44 #define BTA_JV_INTERNAL_ERR        (-1) /* internal error. */
45 
46 #define BTA_JV_MAX_UUIDS        SDP_MAX_UUID_FILTERS
47 #define BTA_JV_MAX_ATTRS        SDP_MAX_ATTR_FILTERS
48 #define BTA_JV_MAX_SDP_REC      SDP_MAX_RECORDS
49 #define BTA_JV_MAX_L2C_CONN     GAP_MAX_CONNECTIONS /* GAP handle is used as index, hence do not change this value */
50 #define BTA_JV_MAX_SCN          PORT_MAX_RFC_PORTS /* same as BTM_MAX_SCN (in btm_int.h) */
51 #define BTA_JV_MAX_RFC_CONN     MAX_RFC_PORTS
52 
53 #ifndef BTA_JV_DEF_RFC_MTU
54 #define BTA_JV_DEF_RFC_MTU      (3*330)
55 #endif
56 
57 #ifndef BTA_JV_MAX_RFC_SR_SESSION
58 #define BTA_JV_MAX_RFC_SR_SESSION   MAX_BD_CONNECTIONS
59 #endif
60 
61 /* BTA_JV_MAX_RFC_SR_SESSION can not be bigger than MAX_BD_CONNECTIONS */
62 #if (BTA_JV_MAX_RFC_SR_SESSION > MAX_BD_CONNECTIONS)
63 #undef BTA_JV_MAX_RFC_SR_SESSION
64 #define BTA_JV_MAX_RFC_SR_SESSION   MAX_BD_CONNECTIONS
65 #endif
66 
67 #define BTA_JV_FIRST_SERVICE_ID BTA_FIRST_JV_SERVICE_ID
68 #define BTA_JV_LAST_SERVICE_ID  BTA_LAST_JV_SERVICE_ID
69 #define BTA_JV_NUM_SERVICE_ID   (BTA_LAST_JV_SERVICE_ID - BTA_FIRST_JV_SERVICE_ID + 1)
70 
71 /* Discoverable modes */
72 enum
73 {
74     BTA_JV_DISC_NONE,
75     BTA_JV_DISC_LIMITED,
76     BTA_JV_DISC_GENERAL
77 };
78 typedef UINT16 tBTA_JV_DISC;
79 
80 #define BTA_JV_ROLE_SLAVE       BTM_ROLE_SLAVE
81 #define BTA_JV_ROLE_MASTER      BTM_ROLE_MASTER
82 typedef UINT32 tBTA_JV_ROLE;
83 
84 #define BTA_JV_SERVICE_LMTD_DISCOVER    BTM_COD_SERVICE_LMTD_DISCOVER   /* 0x0020 */
85 #define BTA_JV_SERVICE_POSITIONING      BTM_COD_SERVICE_POSITIONING     /* 0x0100 */
86 #define BTA_JV_SERVICE_NETWORKING       BTM_COD_SERVICE_NETWORKING      /* 0x0200 */
87 #define BTA_JV_SERVICE_RENDERING        BTM_COD_SERVICE_RENDERING       /* 0x0400 */
88 #define BTA_JV_SERVICE_CAPTURING        BTM_COD_SERVICE_CAPTURING       /* 0x0800 */
89 #define BTA_JV_SERVICE_OBJ_TRANSFER     BTM_COD_SERVICE_OBJ_TRANSFER    /* 0x1000 */
90 #define BTA_JV_SERVICE_AUDIO            BTM_COD_SERVICE_AUDIO           /* 0x2000 */
91 #define BTA_JV_SERVICE_TELEPHONY        BTM_COD_SERVICE_TELEPHONY       /* 0x4000 */
92 #define BTA_JV_SERVICE_INFORMATION      BTM_COD_SERVICE_INFORMATION     /* 0x8000 */
93 
94 /* JV ID type */
95 #define BTA_JV_PM_ID_1             1    /* PM example profile 1 */
96 #define BTA_JV_PM_ID_2             2    /* PM example profile 2 */
97 #define BTA_JV_PM_ID_CLEAR         0    /* Special JV ID used to clear PM profile */
98 #define BTA_JV_PM_ALL              0xFF /* Generic match all id, see bta_dm_cfg.c */
99 typedef UINT8 tBTA_JV_PM_ID;
100 
101 #define BTA_JV_PM_HANDLE_CLEAR     0xFF /* Special JV ID used to clear PM profile  */
102 
103 /* define maximum number of registered PM entities. should be in sync with bta pm! */
104 #ifndef BTA_JV_PM_MAX_NUM
105 #define BTA_JV_PM_MAX_NUM 5
106 #endif
107 
108 /* JV pm connection states */
109 enum
110 {
111     BTA_JV_CONN_OPEN = 0,   /* Connection opened state */
112     BTA_JV_CONN_CLOSE,      /* Connection closed state */
113     BTA_JV_APP_OPEN,        /* JV Application opened state */
114     BTA_JV_APP_CLOSE,       /* JV Application closed state */
115     BTA_JV_SCO_OPEN,        /* SCO connection opened state */
116     BTA_JV_SCO_CLOSE,       /* SCO connection opened state */
117     BTA_JV_CONN_IDLE,       /* Connection idle state */
118     BTA_JV_CONN_BUSY,       /* Connection busy state */
119     BTA_JV_MAX_CONN_STATE   /* Max number of connection state */
120 };
121 typedef UINT8 tBTA_JV_CONN_STATE;
122 
123 /* JV Connection types */
124 #define BTA_JV_CONN_TYPE_RFCOMM    0
125 #define BTA_JV_CONN_TYPE_L2CAP     1
126 #define BTA_JV_CONN_TYPE_L2CAP_LE  2
127 
128 /* Java I/F callback events */
129 /* events received by tBTA_JV_DM_CBACK */
130 #define BTA_JV_ENABLE_EVT           0  /* JV enabled */
131 #define BTA_JV_GET_SCN_EVT          6  /* Reserved an SCN */
132 #define BTA_JV_GET_PSM_EVT          7  /* Reserved a PSM */
133 #define BTA_JV_DISCOVERY_COMP_EVT   8  /* SDP discovery complete */
134 #define BTA_JV_CREATE_RECORD_EVT    11 /* the result for BTA_JvCreateRecord */
135 /* events received by tBTA_JV_L2CAP_CBACK */
136 #define BTA_JV_L2CAP_OPEN_EVT       16 /* open status of L2CAP connection */
137 #define BTA_JV_L2CAP_CLOSE_EVT      17 /* L2CAP connection closed */
138 #define BTA_JV_L2CAP_START_EVT      18 /* L2CAP server started */
139 #define BTA_JV_L2CAP_CL_INIT_EVT    19 /* L2CAP client initiated a connection */
140 #define BTA_JV_L2CAP_DATA_IND_EVT   20 /* L2CAP connection received data */
141 #define BTA_JV_L2CAP_CONG_EVT       21 /* L2CAP connection congestion status changed */
142 #define BTA_JV_L2CAP_READ_EVT       22 /* the result for BTA_JvL2capRead */
143 #define BTA_JV_L2CAP_RECEIVE_EVT    23 /* the result for BTA_JvL2capReceive*/
144 #define BTA_JV_L2CAP_WRITE_EVT      24 /* the result for BTA_JvL2capWrite*/
145 #define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */
146 
147 /* events received by tBTA_JV_RFCOMM_CBACK */
148 #define BTA_JV_RFCOMM_OPEN_EVT      26 /* open status of RFCOMM Client connection */
149 #define BTA_JV_RFCOMM_CLOSE_EVT     27 /* RFCOMM connection closed */
150 #define BTA_JV_RFCOMM_START_EVT     28 /* RFCOMM server started */
151 #define BTA_JV_RFCOMM_CL_INIT_EVT   29 /* RFCOMM client initiated a connection */
152 #define BTA_JV_RFCOMM_DATA_IND_EVT  30 /* RFCOMM connection received data */
153 #define BTA_JV_RFCOMM_CONG_EVT      31 /* RFCOMM connection congestion status changed */
154 #define BTA_JV_RFCOMM_READ_EVT      32 /* the result for BTA_JvRfcommRead */
155 #define BTA_JV_RFCOMM_WRITE_EVT     33 /* the result for BTA_JvRfcommWrite*/
156 #define BTA_JV_RFCOMM_SRV_OPEN_EVT  34 /* open status of Server RFCOMM connection */
157 #define BTA_JV_MAX_EVT              35 /* max number of JV events */
158 
159 typedef UINT16 tBTA_JV_EVT;
160 
161 /* data associated with BTA_JV_SET_DISCOVER_EVT */
162 typedef struct
163 {
164     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
165     tBTA_JV_DISC    disc_mode;  /* The current discoverable mode */
166 } tBTA_JV_SET_DISCOVER;
167 
168 /* data associated with BTA_JV_DISCOVERY_COMP_EVT_ */
169 typedef struct
170 {
171     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
172     int scn;                    /* channel # */
173 } tBTA_JV_DISCOVERY_COMP;
174 
175 /* data associated with BTA_JV_CREATE_RECORD_EVT */
176 typedef struct
177 {
178    tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
179 } tBTA_JV_CREATE_RECORD;
180 
181 /* data associated with BTA_JV_L2CAP_OPEN_EVT */
182 typedef struct
183 {
184     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
185     UINT32          handle;     /* The connection handle */
186     BD_ADDR         rem_bda;    /* The peer address */
187     INT32           tx_mtu;     /* The transmit MTU */
188 } tBTA_JV_L2CAP_OPEN;
189 
190 /* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
191 typedef struct
192 {
193     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
194     UINT32          handle;     /* The connection handle */
195     BD_ADDR         rem_bda;    /* The peer address */
196     INT32           tx_mtu;     /* The transmit MTU */
197     void          **p_p_cback;  /* set them for new socket */
198     void          **p_user_data;/* set them for new socket */
199 
200 } tBTA_JV_L2CAP_LE_OPEN;
201 
202 
203 /* data associated with BTA_JV_L2CAP_CLOSE_EVT */
204 typedef struct
205 {
206     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
207     UINT32          handle;     /* The connection handle */
208     BOOLEAN         async;      /* FALSE, if local initiates disconnect */
209 } tBTA_JV_L2CAP_CLOSE;
210 
211 /* data associated with BTA_JV_L2CAP_START_EVT */
212 typedef struct
213 {
214     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
215     UINT32          handle;     /* The connection handle */
216     UINT8           sec_id;     /* security ID used by this server */
217 } tBTA_JV_L2CAP_START;
218 
219 /* data associated with BTA_JV_L2CAP_CL_INIT_EVT */
220 typedef struct
221 {
222     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
223     UINT32          handle;     /* The connection handle */
224     UINT8           sec_id;     /* security ID used by this client */
225 } tBTA_JV_L2CAP_CL_INIT;
226 
227 /* data associated with BTA_JV_L2CAP_CONG_EVT */
228 typedef struct
229 {
230     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
231     UINT32          handle;     /* The connection handle */
232     BOOLEAN         cong;       /* TRUE, congested. FALSE, uncongested */
233 } tBTA_JV_L2CAP_CONG;
234 
235 /* data associated with BTA_JV_L2CAP_READ_EVT */
236 typedef struct
237 {
238     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
239     UINT32          handle;     /* The connection handle */
240     UINT32          req_id;     /* The req_id in the associated BTA_JvL2capRead() */
241     UINT8           *p_data;    /* This points the same location as the p_data
242                                  * parameter in BTA_JvL2capRead () */
243     UINT16          len;        /* The length of the data read. */
244 } tBTA_JV_L2CAP_READ;
245 
246 /* data associated with BTA_JV_L2CAP_RECEIVE_EVT */
247 typedef struct
248 {
249     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
250     UINT32          handle;     /* The connection handle */
251     UINT32          req_id;     /* The req_id in the associated BTA_JvL2capReceive() */
252     UINT8           *p_data;    /* This points the same location as the p_data
253                                  * parameter in BTA_JvL2capReceive () */
254     UINT16          len;        /* The length of the data read. */
255 } tBTA_JV_L2CAP_RECEIVE;
256 
257 /* data associated with BTA_JV_L2CAP_WRITE_EVT */
258 typedef struct
259 {
260     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
261     UINT32          handle;     /* The connection handle */
262     UINT32          req_id;     /* The req_id in the associated BTA_JvL2capWrite() */
263     UINT16          len;        /* The length of the data written. */
264     BOOLEAN         cong;       /* congestion status */
265 } tBTA_JV_L2CAP_WRITE;
266 
267 
268 /* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */
269 typedef struct
270 {
271     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
272     UINT16          channel;    /* The connection channel */
273     BD_ADDR         addr;       /* The peer address */
274     UINT32          req_id;     /* The req_id in the associated BTA_JvL2capWrite() */
275     UINT16          len;        /* The length of the data written. */
276     BOOLEAN         cong;       /* congestion status */
277 } tBTA_JV_L2CAP_WRITE_FIXED;
278 
279 /* data associated with BTA_JV_RFCOMM_OPEN_EVT */
280 typedef struct
281 {
282     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
283     UINT32          handle;     /* The connection handle */
284     BD_ADDR         rem_bda;    /* The peer address */
285 } tBTA_JV_RFCOMM_OPEN;
286 /* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
287 typedef struct
288 {
289     tBTA_JV_STATUS  status;             /* Whether the operation succeeded or failed. */
290     UINT32          handle;             /* The connection handle */
291     UINT32          new_listen_handle;  /* The new listen handle */
292     BD_ADDR         rem_bda;            /* The peer address */
293 } tBTA_JV_RFCOMM_SRV_OPEN;
294 
295 
296 /* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
297 typedef struct
298 {
299     tBTA_JV_STATUS  status;      /* Whether the operation succeeded or failed. */
300     UINT32          port_status; /* PORT status */
301     UINT32          handle;      /* The connection handle */
302     BOOLEAN         async;       /* FALSE, if local initiates disconnect */
303 } tBTA_JV_RFCOMM_CLOSE;
304 
305 /* data associated with BTA_JV_RFCOMM_START_EVT */
306 typedef struct
307 {
308     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
309     UINT32          handle;     /* The connection handle */
310     UINT8           sec_id;     /* security ID used by this server */
311     BOOLEAN         use_co;     /* TRUE to use co_rfc_data */
312 } tBTA_JV_RFCOMM_START;
313 
314 /* data associated with BTA_JV_RFCOMM_CL_INIT_EVT */
315 typedef struct
316 {
317     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
318     UINT32          handle;     /* The connection handle */
319     UINT8           sec_id;     /* security ID used by this client */
320     BOOLEAN         use_co;     /* TRUE to use co_rfc_data */
321 } tBTA_JV_RFCOMM_CL_INIT;
322 /*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */
323 typedef struct
324 {
325     UINT32          handle;     /* The connection handle */
326 } tBTA_JV_DATA_IND;
327 
328 /*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
329 typedef struct
330 {
331     UINT32          handle;     /* The connection handle */
332     BT_HDR         *p_buf;      /* The incoming data */
333 } tBTA_JV_LE_DATA_IND;
334 
335 
336 /* data associated with BTA_JV_RFCOMM_CONG_EVT */
337 typedef struct
338 {
339     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
340     UINT32          handle;     /* The connection handle */
341     BOOLEAN         cong;       /* TRUE, congested. FALSE, uncongested */
342 } tBTA_JV_RFCOMM_CONG;
343 
344 /* data associated with BTA_JV_RFCOMM_READ_EVT */
345 typedef struct
346 {
347     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
348     UINT32          handle;     /* The connection handle */
349     UINT32          req_id;     /* The req_id in the associated BTA_JvRfcommRead() */
350     UINT8           *p_data;    /* This points the same location as the p_data
351                                  * parameter in BTA_JvRfcommRead () */
352     UINT16          len;        /* The length of the data read. */
353 } tBTA_JV_RFCOMM_READ;
354 
355 /* data associated with BTA_JV_RFCOMM_WRITE_EVT */
356 typedef struct
357 {
358     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
359     UINT32          handle;     /* The connection handle */
360     UINT32          req_id;     /* The req_id in the associated BTA_JvRfcommWrite() */
361     int             len;        /* The length of the data written. */
362     BOOLEAN         cong;       /* congestion status */
363 } tBTA_JV_RFCOMM_WRITE;
364 
365 /* data associated with BTA_JV_API_SET_PM_PROFILE_EVT */
366 typedef struct
367 {
368     tBTA_JV_STATUS  status;     /* Status of the operation */
369     UINT32          handle;     /* Connection handle */
370     tBTA_JV_PM_ID   app_id;      /* JV app ID */
371 } tBTA_JV_SET_PM_PROFILE;
372 
373 /* data associated with BTA_JV_API_NOTIFY_PM_STATE_CHANGE_EVT */
374 typedef struct
375 {
376     UINT32          handle;     /* Connection handle */
377     tBTA_JV_CONN_STATE  state;  /* JV connection stata */
378 } tBTA_JV_NOTIFY_PM_STATE_CHANGE;
379 
380 
381 /* union of data associated with JV callback */
382 typedef union
383 {
384     tBTA_JV_STATUS          status;         /* BTA_JV_ENABLE_EVT */
385     tBTA_JV_DISCOVERY_COMP  disc_comp;      /* BTA_JV_DISCOVERY_COMP_EVT */
386     tBTA_JV_SET_DISCOVER    set_discover;   /* BTA_JV_SET_DISCOVER_EVT */
387     UINT8                   scn;            /* BTA_JV_GET_SCN_EVT */
388     UINT16                  psm;            /* BTA_JV_GET_PSM_EVT */
389     tBTA_JV_CREATE_RECORD   create_rec;     /* BTA_JV_CREATE_RECORD_EVT */
390     tBTA_JV_L2CAP_OPEN      l2c_open;       /* BTA_JV_L2CAP_OPEN_EVT */
391     tBTA_JV_L2CAP_CLOSE     l2c_close;      /* BTA_JV_L2CAP_CLOSE_EVT */
392     tBTA_JV_L2CAP_START     l2c_start;      /* BTA_JV_L2CAP_START_EVT */
393     tBTA_JV_L2CAP_CL_INIT   l2c_cl_init;    /* BTA_JV_L2CAP_CL_INIT_EVT */
394     tBTA_JV_L2CAP_CONG      l2c_cong;       /* BTA_JV_L2CAP_CONG_EVT */
395     tBTA_JV_L2CAP_READ      l2c_read;       /* BTA_JV_L2CAP_READ_EVT */
396     tBTA_JV_L2CAP_WRITE     l2c_write;      /* BTA_JV_L2CAP_WRITE_EVT */
397     tBTA_JV_RFCOMM_OPEN     rfc_open;       /* BTA_JV_RFCOMM_OPEN_EVT */
398     tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open;   /* BTA_JV_RFCOMM_SRV_OPEN_EVT */
399     tBTA_JV_RFCOMM_CLOSE    rfc_close;      /* BTA_JV_RFCOMM_CLOSE_EVT */
400     tBTA_JV_RFCOMM_START    rfc_start;      /* BTA_JV_RFCOMM_START_EVT */
401     tBTA_JV_RFCOMM_CL_INIT  rfc_cl_init;    /* BTA_JV_RFCOMM_CL_INIT_EVT */
402     tBTA_JV_RFCOMM_CONG     rfc_cong;       /* BTA_JV_RFCOMM_CONG_EVT */
403     tBTA_JV_RFCOMM_READ     rfc_read;       /* BTA_JV_RFCOMM_READ_EVT */
404     tBTA_JV_RFCOMM_WRITE    rfc_write;      /* BTA_JV_RFCOMM_WRITE_EVT */
405     tBTA_JV_DATA_IND        data_ind;       /* BTA_JV_L2CAP_DATA_IND_EVT
406                                                BTA_JV_RFCOMM_DATA_IND_EVT */
407     tBTA_JV_LE_DATA_IND      le_data_ind;   /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
408     tBTA_JV_L2CAP_LE_OPEN      l2c_le_open;       /* BTA_JV_L2CAP_OPEN_EVT */
409     tBTA_JV_L2CAP_WRITE_FIXED  l2c_write_fixed;      /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
410 } tBTA_JV;
411 
412 /* JAVA DM Interface callback */
413 typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void * user_data);
414 
415 /* JAVA RFCOMM interface callback */
416 typedef void* (tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
417 
418 /* JAVA L2CAP interface callback */
419 typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data);
420 
421 /* JV configuration structure */
422 typedef struct
423 {
424     UINT16  sdp_raw_size;           /* The size of p_sdp_raw_data */
425     UINT16  sdp_db_size;            /* The size of p_sdp_db */
426     UINT8   *p_sdp_raw_data;        /* The data buffer to keep raw data */
427     tSDP_DISCOVERY_DB   *p_sdp_db;  /* The data buffer to keep SDP database */
428 } tBTA_JV_CFG;
429 
430 /*******************************************************************************
431 **
432 ** Function         BTA_JvEnable
433 **
434 ** Description      Enable the Java I/F service. When the enable
435 **                  operation is complete the callback function will be
436 **                  called with a BTA_JV_ENABLE_EVT. This function must
437 **                  be called before other functions in the JV API are
438 **                  called.
439 **
440 ** Returns          BTA_JV_SUCCESS if successful.
441 **                  BTA_JV_FAIL if internal failure.
442 **
443 *******************************************************************************/
444 extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback);
445 
446 /*******************************************************************************
447 **
448 ** Function         BTA_JvDisable
449 **
450 ** Description      Disable the Java I/F
451 **
452 ** Returns          void
453 **
454 *******************************************************************************/
455 extern void BTA_JvDisable(void);
456 
457 /*******************************************************************************
458 **
459 ** Function         BTA_JvIsEnable
460 **
461 ** Description      Get the JV registration status.
462 **
463 ** Returns          TRUE, if registered
464 **
465 *******************************************************************************/
466 extern BOOLEAN BTA_JvIsEnable(void);
467 
468 /*******************************************************************************
469 **
470 ** Function         BTA_JvIsEncrypted
471 **
472 ** Description      This function checks if the link to peer device is encrypted
473 **
474 ** Returns          TRUE if encrypted.
475 **                  FALSE if not.
476 **
477 *******************************************************************************/
478 extern BOOLEAN BTA_JvIsEncrypted(BD_ADDR bd_addr);
479 
480 /*******************************************************************************
481 **
482 ** Function         BTA_JvGetChannelId
483 **
484 ** Description      This function reserves a SCN/PSM for applications running
485 **                  over RFCOMM or L2CAP. It is primarily called by
486 **                  server profiles/applications to register their SCN/PSM into the
487 **                  SDP database. The SCN is reported by the tBTA_JV_DM_CBACK
488 **                  callback with a BTA_JV_GET_SCN_EVT.
489 **                  If the SCN/PSM reported is 0, that means all SCN resources are
490 **                  exhausted.
491 **                  The channel parameter can be used to request a specific
492 **                  channel. If the request on the specific channel fails, the
493 **                  SCN/PSM returned in the EVT will be 0 - no attempt to request
494 **                  a new channel will be made. set channel to <= 0 to automatically
495 **                  assign an channel ID.
496 **
497 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
498 **                  BTA_JV_FAILURE, otherwise.
499 **
500 *******************************************************************************/
501 extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void* user_data,
502                                                  INT32 channel);
503 
504 /*******************************************************************************
505 **
506 ** Function         BTA_JvFreeChannel
507 **
508 ** Description      This function frees a SCN/PSM that was used
509 **                  by an application running over RFCOMM or L2CAP.
510 **
511 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
512 **                  BTA_JV_FAILURE, otherwise.
513 **
514 *******************************************************************************/
515 extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type);
516 
517 /*******************************************************************************
518 **
519 ** Function         BTA_JvStartDiscovery
520 **
521 ** Description      This function performs service discovery for the services
522 **                  provided by the given peer device. When the operation is
523 **                  complete the tBTA_JV_DM_CBACK callback function will be
524 **                  called with a BTA_JV_DISCOVERY_COMP_EVT.
525 **
526 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
527 **                  BTA_JV_FAILURE, otherwise.
528 **
529 *******************************************************************************/
530 extern tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, UINT16 num_uuid,
531                                            tSDP_UUID *p_uuid_list, void* user_data);
532 
533 /*******************************************************************************
534 **
535 ** Function         BTA_JvCreateRecord
536 **
537 ** Description      Create a service record in the local SDP database by user in
538 **                  tBTA_JV_DM_CBACK callback with a BTA_JV_CREATE_RECORD_EVT.
539 **
540 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
541 **                  BTA_JV_FAILURE, otherwise.
542 **
543 *******************************************************************************/
544 extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(void* user_data);
545 
546 /*******************************************************************************
547 **
548 ** Function         BTA_JvDeleteRecord
549 **
550 ** Description      Delete a service record in the local SDP database.
551 **
552 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
553 **                  BTA_JV_FAILURE, otherwise.
554 **
555 *******************************************************************************/
556 extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle);
557 
558 /*******************************************************************************
559 **
560 ** Function         BTA_JvL2capConnectLE
561 **
562 ** Description      Initiate a connection as an LE L2CAP client to the given BD
563 **                  Address.
564 **                  When the connection is initiated or failed to initiate,
565 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
566 **                  When the connection is established or failed,
567 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
568 **
569 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
570 **                  BTA_JV_FAILURE, otherwise.
571 **
572 *******************************************************************************/
573 extern tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
574                            const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_chan,
575                            UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
576                            BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
577 
578 /*******************************************************************************
579 **
580 ** Function         BTA_JvL2capConnect
581 **
582 ** Description      Initiate a connection as a L2CAP client to the given BD
583 **                  Address.
584 **                  When the connection is initiated or failed to initiate,
585 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
586 **                  When the connection is established or failed,
587 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
588 **
589 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
590 **                  BTA_JV_FAILURE, otherwise.
591 **
592 *******************************************************************************/
593 extern tBTA_JV_STATUS BTA_JvL2capConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
594                            const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_psm,
595                            UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
596                            BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
597 
598 /*******************************************************************************
599 **
600 ** Function         BTA_JvL2capClose
601 **
602 ** Description      This function closes an L2CAP client connection
603 **
604 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
605 **                  BTA_JV_FAILURE, otherwise.
606 **
607 *******************************************************************************/
608 extern tBTA_JV_STATUS BTA_JvL2capClose(UINT32 handle);
609 
610 /*******************************************************************************
611 **
612 ** Function         BTA_JvL2capCloseLE
613 **
614 ** Description      This function closes an L2CAP client connection for Fixed Channels
615 **                  Function is idempotent and no callbacks are called!
616 **
617 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
618 **                  BTA_JV_FAILURE, otherwise.
619 **
620 *******************************************************************************/
621 extern tBTA_JV_STATUS BTA_JvL2capCloseLE(UINT32 handle);
622 
623 /*******************************************************************************
624 **
625 ** Function         BTA_JvL2capStartServer
626 **
627 ** Description      This function starts an L2CAP server and listens for an L2CAP
628 **                  connection from a remote Bluetooth device.  When the server
629 **                  is started successfully, tBTA_JV_L2CAP_CBACK is called with
630 **                  BTA_JV_L2CAP_START_EVT.  When the connection is established,
631 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT.
632 **
633 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
634 **                  BTA_JV_FAILURE, otherwise.
635 **
636 *******************************************************************************/
637 extern tBTA_JV_STATUS BTA_JvL2capStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
638                            const tL2CAP_ERTM_INFO *ertm_info,
639                            UINT16 local_psm, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
640                            tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
641 
642 /*******************************************************************************
643 **
644 ** Function         BTA_JvL2capStartServerLE
645 **
646 ** Description      This function starts an LE L2CAP server and listens for an L2CAP
647 **                  connection from a remote Bluetooth device on a fixed channel
648 **                  over an LE link.  When the server
649 **                  is started successfully, tBTA_JV_L2CAP_CBACK is called with
650 **                  BTA_JV_L2CAP_START_EVT.  When the connection is established,
651 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT.
652 **
653 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
654 **                  BTA_JV_FAILURE, otherwise.
655 **
656 *******************************************************************************/
657 extern tBTA_JV_STATUS BTA_JvL2capStartServerLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
658                            const tL2CAP_ERTM_INFO *ertm_info,
659                            UINT16 local_chan, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
660                            tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
661 
662 /*******************************************************************************
663 **
664 ** Function         BTA_JvL2capStopServerLE
665 **
666 ** Description      This function stops the LE L2CAP server. If the server has an
667 **                  active connection, it would be closed.
668 **
669 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
670 **                  BTA_JV_FAILURE, otherwise.
671 **
672 *******************************************************************************/
673 extern tBTA_JV_STATUS BTA_JvL2capStopServerLE(UINT16 local_chan, void *user_data);
674 
675 /*******************************************************************************
676 **
677 ** Function         BTA_JvL2capStopServerLE
678 **
679 ** Description      This function stops the LE L2CAP server. If the server has an
680 **                  active connection, it would be closed.
681 **
682 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
683 **                  BTA_JV_FAILURE, otherwise.
684 **
685 *******************************************************************************/
686 extern tBTA_JV_STATUS BTA_JvL2capStopServer(UINT16 local_psm, void *user_data);
687 
688 /*******************************************************************************
689 **
690 ** Function         BTA_JvL2capRead
691 **
692 ** Description      This function reads data from an L2CAP connection
693 **                  When the operation is complete, tBTA_JV_L2CAP_CBACK is
694 **                  called with BTA_JV_L2CAP_READ_EVT.
695 **
696 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
697 **                  BTA_JV_FAILURE, otherwise.
698 **
699 *******************************************************************************/
700 extern tBTA_JV_STATUS BTA_JvL2capRead(UINT32 handle, UINT32 req_id,
701                                               UINT8 *p_data, UINT16 len);
702 
703 /*******************************************************************************
704 **
705 ** Function         BTA_JvL2capReceive
706 **
707 ** Description      This function reads data from an L2CAP connection
708 **                  When the operation is complete, tBTA_JV_L2CAP_CBACK is
709 **                  called with BTA_JV_L2CAP_RECEIVE_EVT.
710 **                  If there are more data queued in L2CAP than len, the extra data will be discarded.
711 **
712 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
713 **                  BTA_JV_FAILURE, otherwise.
714 **
715 *******************************************************************************/
716 extern tBTA_JV_STATUS BTA_JvL2capReceive(UINT32 handle, UINT32 req_id,
717                                               UINT8 *p_data, UINT16 len);
718 
719 /*******************************************************************************
720 **
721 ** Function         BTA_JvL2capReady
722 **
723 ** Description      This function determined if there is data to read from
724 **                  an L2CAP connection
725 **
726 ** Returns          BTA_JV_SUCCESS, if data queue size is in *p_data_size.
727 **                  BTA_JV_FAILURE, if error.
728 **
729 *******************************************************************************/
730 extern tBTA_JV_STATUS BTA_JvL2capReady(UINT32 handle, UINT32 *p_data_size);
731 
732 /*******************************************************************************
733 **
734 ** Function         BTA_JvL2capWrite
735 **
736 ** Description      This function writes data to an L2CAP connection
737 **                  When the operation is complete, tBTA_JV_L2CAP_CBACK is
738 **                  called with BTA_JV_L2CAP_WRITE_EVT. Works for
739 **                  PSM-based connections
740 **
741 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
742 **                  BTA_JV_FAILURE, otherwise.
743 **
744 *******************************************************************************/
745 extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id,
746                                                UINT8 *p_data, UINT16 len, void *user_data);
747 
748 
749 /*******************************************************************************
750 **
751 ** Function         BTA_JvL2capWriteFixed
752 **
753 ** Description      This function writes data to an L2CAP connection
754 **                  When the operation is complete, tBTA_JV_L2CAP_CBACK is
755 **                  called with BTA_JV_L2CAP_WRITE_FIXED_EVT. Works for
756 **                  fixed-channel connections
757 **
758 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
759 **                  BTA_JV_FAILURE, otherwise.
760 **
761 *******************************************************************************/
762 extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id,
763                                                tBTA_JV_L2CAP_CBACK *p_cback,
764                                                UINT8 *p_data, UINT16 len, void *user_data);
765 
766 /*******************************************************************************
767 **
768 ** Function         BTA_JvRfcommConnect
769 **
770 ** Description      This function makes an RFCOMM conection to a remote BD
771 **                  Address.
772 **                  When the connection is initiated or failed to initiate,
773 **                  tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT
774 **                  When the connection is established or failed,
775 **                  tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT
776 **
777 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
778 **                  BTA_JV_FAILURE, otherwise.
779 **
780 *******************************************************************************/
781 extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
782                                           tBTA_JV_ROLE role, UINT8 remote_scn, BD_ADDR peer_bd_addr,
783                                           tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
784 
785 /*******************************************************************************
786 **
787 ** Function         BTA_JvRfcommClose
788 **
789 ** Description      This function closes an RFCOMM connection
790 **
791 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
792 **                  BTA_JV_FAILURE, otherwise.
793 **
794 *******************************************************************************/
795 extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void* user_data);
796 
797 /*******************************************************************************
798 **
799 ** Function         BTA_JvRfcommStartServer
800 **
801 ** Description      This function starts listening for an RFCOMM connection
802 **                  request from a remote Bluetooth device.  When the server is
803 **                  started successfully, tBTA_JV_RFCOMM_CBACK is called
804 **                  with BTA_JV_RFCOMM_START_EVT.
805 **                  When the connection is established, tBTA_JV_RFCOMM_CBACK
806 **                  is called with BTA_JV_RFCOMM_OPEN_EVT.
807 **
808 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
809 **                  BTA_JV_FAILURE, otherwise.
810 **
811 *******************************************************************************/
812 extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask,
813                                               tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session,
814                                               tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
815 
816 /*******************************************************************************
817 **
818 ** Function         BTA_JvRfcommStopServer
819 **
820 ** Description      This function stops the RFCOMM server. If the server has an
821 **                  active connection, it would be closed.
822 **
823 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
824 **                  BTA_JV_FAILURE, otherwise.
825 **
826 *******************************************************************************/
827 extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void* user_data);
828 
829 /*******************************************************************************
830 **
831 ** Function         BTA_JvRfcommRead
832 **
833 ** Description      This function reads data from an RFCOMM connection
834 **                  When the operation is complete, tBTA_JV_RFCOMM_CBACK is
835 **                  called with BTA_JV_RFCOMM_READ_EVT.
836 **
837 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
838 **                  BTA_JV_FAILURE, otherwise.
839 **
840 *******************************************************************************/
841 extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id,
842                                        UINT8 *p_data, UINT16 len);
843 
844 /*******************************************************************************
845 **
846 ** Function         BTA_JvRfcommReady
847 **
848 ** Description      This function determined if there is data to read from
849 **                  an RFCOMM connection
850 **
851 ** Returns          BTA_JV_SUCCESS, if data queue size is in *p_data_size.
852 **                  BTA_JV_FAILURE, if error.
853 **
854 *******************************************************************************/
855 extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size);
856 
857 /*******************************************************************************
858 **
859 ** Function         BTA_JvRfcommWrite
860 **
861 ** Description      This function writes data to an RFCOMM connection
862 **                  When the operation is complete, tBTA_JV_RFCOMM_CBACK is
863 **                  called with BTA_JV_RFCOMM_WRITE_EVT.
864 **
865 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
866 **                  BTA_JV_FAILURE, otherwise.
867 **
868 *******************************************************************************/
869 extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id);
870 
871 /*******************************************************************************
872  **
873  ** Function    BTA_JVSetPmProfile
874  **
875  ** Description This function set or free power mode profile for different JV application
876  **
877  ** Parameters:  handle,  JV handle from RFCOMM or L2CAP
878  **              app_id:  app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details
879  **              BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and
880  **              BTA_JV_CONN_CLOSE is called implicitely
881  **              init_st:  state after calling this API. typically it should be BTA_JV_CONN_OPEN
882  **
883  ** Returns      BTA_JV_SUCCESS, if the request is being processed.
884  **              BTA_JV_FAILURE, otherwise.
885  **
886  ** NOTE:        BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm calls automatically
887  **              BTA_JV_CONN_CLOSE to remove in case of connection close!
888  **
889  *******************************************************************************/
890 extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id,
891                                          tBTA_JV_CONN_STATE init_st);
892 
893 /*******************************************************************************
894 **
895 ** Function         BTA_JvRfcommGetPortHdl
896 **
897 ** Description    This function fetches the rfcomm port handle
898 **
899 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
900 **                  BTA_JV_FAILURE, otherwise.
901 **
902 *******************************************************************************/
903 UINT16 BTA_JvRfcommGetPortHdl(UINT32 handle);
904 
905 #endif /* BTA_JV_API_H */
906