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_WRITE_EVT      24 /* the result for BTA_JvL2capWrite*/
144 #define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */
145 
146 /* events received by tBTA_JV_RFCOMM_CBACK */
147 #define BTA_JV_RFCOMM_OPEN_EVT      26 /* open status of RFCOMM Client connection */
148 #define BTA_JV_RFCOMM_CLOSE_EVT     27 /* RFCOMM connection closed */
149 #define BTA_JV_RFCOMM_START_EVT     28 /* RFCOMM server started */
150 #define BTA_JV_RFCOMM_CL_INIT_EVT   29 /* RFCOMM client initiated a connection */
151 #define BTA_JV_RFCOMM_DATA_IND_EVT  30 /* RFCOMM connection received data */
152 #define BTA_JV_RFCOMM_CONG_EVT      31 /* RFCOMM connection congestion status changed */
153 #define BTA_JV_RFCOMM_WRITE_EVT     33 /* the result for BTA_JvRfcommWrite*/
154 #define BTA_JV_RFCOMM_SRV_OPEN_EVT  34 /* open status of Server RFCOMM connection */
155 #define BTA_JV_MAX_EVT              35 /* max number of JV events */
156 
157 typedef UINT16 tBTA_JV_EVT;
158 
159 /* data associated with BTA_JV_SET_DISCOVER_EVT */
160 typedef struct
161 {
162     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
163     tBTA_JV_DISC    disc_mode;  /* The current discoverable mode */
164 } tBTA_JV_SET_DISCOVER;
165 
166 /* data associated with BTA_JV_DISCOVERY_COMP_EVT_ */
167 typedef struct
168 {
169     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
170     int scn;                    /* channel # */
171 } tBTA_JV_DISCOVERY_COMP;
172 
173 /* data associated with BTA_JV_CREATE_RECORD_EVT */
174 typedef struct
175 {
176    tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
177 } tBTA_JV_CREATE_RECORD;
178 
179 /* data associated with BTA_JV_L2CAP_OPEN_EVT */
180 typedef struct
181 {
182     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
183     UINT32          handle;     /* The connection handle */
184     BD_ADDR         rem_bda;    /* The peer address */
185     INT32           tx_mtu;     /* The transmit MTU */
186 } tBTA_JV_L2CAP_OPEN;
187 
188 /* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
189 typedef struct
190 {
191     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
192     UINT32          handle;     /* The connection handle */
193     BD_ADDR         rem_bda;    /* The peer address */
194     INT32           tx_mtu;     /* The transmit MTU */
195     void          **p_p_cback;  /* set them for new socket */
196     void          **p_user_data;/* set them for new socket */
197 
198 } tBTA_JV_L2CAP_LE_OPEN;
199 
200 
201 /* data associated with BTA_JV_L2CAP_CLOSE_EVT */
202 typedef struct
203 {
204     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
205     UINT32          handle;     /* The connection handle */
206     BOOLEAN         async;      /* FALSE, if local initiates disconnect */
207 } tBTA_JV_L2CAP_CLOSE;
208 
209 /* data associated with BTA_JV_L2CAP_START_EVT */
210 typedef struct
211 {
212     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
213     UINT32          handle;     /* The connection handle */
214     UINT8           sec_id;     /* security ID used by this server */
215 } tBTA_JV_L2CAP_START;
216 
217 /* data associated with BTA_JV_L2CAP_CL_INIT_EVT */
218 typedef struct
219 {
220     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
221     UINT32          handle;     /* The connection handle */
222     UINT8           sec_id;     /* security ID used by this client */
223 } tBTA_JV_L2CAP_CL_INIT;
224 
225 /* data associated with BTA_JV_L2CAP_CONG_EVT */
226 typedef struct
227 {
228     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
229     UINT32          handle;     /* The connection handle */
230     BOOLEAN         cong;       /* TRUE, congested. FALSE, uncongested */
231 } tBTA_JV_L2CAP_CONG;
232 
233 /* data associated with BTA_JV_L2CAP_READ_EVT */
234 typedef struct
235 {
236     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
237     UINT32          handle;     /* The connection handle */
238     UINT32          req_id;     /* The req_id in the associated BTA_JvL2capRead() */
239     UINT8           *p_data;    /* This points the same location as the p_data
240                                  * parameter in BTA_JvL2capRead () */
241     UINT16          len;        /* The length of the data read. */
242 } tBTA_JV_L2CAP_READ;
243 
244 /* data associated with BTA_JV_L2CAP_WRITE_EVT */
245 typedef struct
246 {
247     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
248     UINT32          handle;     /* The connection handle */
249     UINT32          req_id;     /* The req_id in the associated BTA_JvL2capWrite() */
250     UINT16          len;        /* The length of the data written. */
251     BOOLEAN         cong;       /* congestion status */
252 } tBTA_JV_L2CAP_WRITE;
253 
254 
255 /* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */
256 typedef struct
257 {
258     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
259     UINT16          channel;    /* The connection channel */
260     BD_ADDR         addr;       /* The peer address */
261     UINT32          req_id;     /* The req_id in the associated BTA_JvL2capWrite() */
262     UINT16          len;        /* The length of the data written. */
263     BOOLEAN         cong;       /* congestion status */
264 } tBTA_JV_L2CAP_WRITE_FIXED;
265 
266 /* data associated with BTA_JV_RFCOMM_OPEN_EVT */
267 typedef struct
268 {
269     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
270     UINT32          handle;     /* The connection handle */
271     BD_ADDR         rem_bda;    /* The peer address */
272 } tBTA_JV_RFCOMM_OPEN;
273 /* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
274 typedef struct
275 {
276     tBTA_JV_STATUS  status;             /* Whether the operation succeeded or failed. */
277     UINT32          handle;             /* The connection handle */
278     UINT32          new_listen_handle;  /* The new listen handle */
279     BD_ADDR         rem_bda;            /* The peer address */
280 } tBTA_JV_RFCOMM_SRV_OPEN;
281 
282 
283 /* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
284 typedef struct
285 {
286     tBTA_JV_STATUS  status;      /* Whether the operation succeeded or failed. */
287     UINT32          port_status; /* PORT status */
288     UINT32          handle;      /* The connection handle */
289     BOOLEAN         async;       /* FALSE, if local initiates disconnect */
290 } tBTA_JV_RFCOMM_CLOSE;
291 
292 /* data associated with BTA_JV_RFCOMM_START_EVT */
293 typedef struct
294 {
295     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
296     UINT32          handle;     /* The connection handle */
297     UINT8           sec_id;     /* security ID used by this server */
298     BOOLEAN         use_co;     /* TRUE to use co_rfc_data */
299 } tBTA_JV_RFCOMM_START;
300 
301 /* data associated with BTA_JV_RFCOMM_CL_INIT_EVT */
302 typedef struct
303 {
304     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
305     UINT32          handle;     /* The connection handle */
306     UINT8           sec_id;     /* security ID used by this client */
307     BOOLEAN         use_co;     /* TRUE to use co_rfc_data */
308 } tBTA_JV_RFCOMM_CL_INIT;
309 /*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */
310 typedef struct
311 {
312     UINT32          handle;     /* The connection handle */
313 } tBTA_JV_DATA_IND;
314 
315 /*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
316 typedef struct
317 {
318     UINT32          handle;     /* The connection handle */
319     BT_HDR         *p_buf;      /* The incoming data */
320 } tBTA_JV_LE_DATA_IND;
321 
322 
323 /* data associated with BTA_JV_RFCOMM_CONG_EVT */
324 typedef struct
325 {
326     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
327     UINT32          handle;     /* The connection handle */
328     BOOLEAN         cong;       /* TRUE, congested. FALSE, uncongested */
329 } tBTA_JV_RFCOMM_CONG;
330 
331 /* data associated with BTA_JV_RFCOMM_WRITE_EVT */
332 typedef struct
333 {
334     tBTA_JV_STATUS  status;     /* Whether the operation succeeded or failed. */
335     UINT32          handle;     /* The connection handle */
336     UINT32          req_id;     /* The req_id in the associated BTA_JvRfcommWrite() */
337     int             len;        /* The length of the data written. */
338     BOOLEAN         cong;       /* congestion status */
339 } tBTA_JV_RFCOMM_WRITE;
340 
341 /* data associated with BTA_JV_API_SET_PM_PROFILE_EVT */
342 typedef struct
343 {
344     tBTA_JV_STATUS  status;     /* Status of the operation */
345     UINT32          handle;     /* Connection handle */
346     tBTA_JV_PM_ID   app_id;      /* JV app ID */
347 } tBTA_JV_SET_PM_PROFILE;
348 
349 /* data associated with BTA_JV_API_NOTIFY_PM_STATE_CHANGE_EVT */
350 typedef struct
351 {
352     UINT32          handle;     /* Connection handle */
353     tBTA_JV_CONN_STATE  state;  /* JV connection stata */
354 } tBTA_JV_NOTIFY_PM_STATE_CHANGE;
355 
356 
357 /* union of data associated with JV callback */
358 typedef union
359 {
360     tBTA_JV_STATUS          status;         /* BTA_JV_ENABLE_EVT */
361     tBTA_JV_DISCOVERY_COMP  disc_comp;      /* BTA_JV_DISCOVERY_COMP_EVT */
362     tBTA_JV_SET_DISCOVER    set_discover;   /* BTA_JV_SET_DISCOVER_EVT */
363     UINT8                   scn;            /* BTA_JV_GET_SCN_EVT */
364     UINT16                  psm;            /* BTA_JV_GET_PSM_EVT */
365     tBTA_JV_CREATE_RECORD   create_rec;     /* BTA_JV_CREATE_RECORD_EVT */
366     tBTA_JV_L2CAP_OPEN      l2c_open;       /* BTA_JV_L2CAP_OPEN_EVT */
367     tBTA_JV_L2CAP_CLOSE     l2c_close;      /* BTA_JV_L2CAP_CLOSE_EVT */
368     tBTA_JV_L2CAP_START     l2c_start;      /* BTA_JV_L2CAP_START_EVT */
369     tBTA_JV_L2CAP_CL_INIT   l2c_cl_init;    /* BTA_JV_L2CAP_CL_INIT_EVT */
370     tBTA_JV_L2CAP_CONG      l2c_cong;       /* BTA_JV_L2CAP_CONG_EVT */
371     tBTA_JV_L2CAP_READ      l2c_read;       /* BTA_JV_L2CAP_READ_EVT */
372     tBTA_JV_L2CAP_WRITE     l2c_write;      /* BTA_JV_L2CAP_WRITE_EVT */
373     tBTA_JV_RFCOMM_OPEN     rfc_open;       /* BTA_JV_RFCOMM_OPEN_EVT */
374     tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open;   /* BTA_JV_RFCOMM_SRV_OPEN_EVT */
375     tBTA_JV_RFCOMM_CLOSE    rfc_close;      /* BTA_JV_RFCOMM_CLOSE_EVT */
376     tBTA_JV_RFCOMM_START    rfc_start;      /* BTA_JV_RFCOMM_START_EVT */
377     tBTA_JV_RFCOMM_CL_INIT  rfc_cl_init;    /* BTA_JV_RFCOMM_CL_INIT_EVT */
378     tBTA_JV_RFCOMM_CONG     rfc_cong;       /* BTA_JV_RFCOMM_CONG_EVT */
379     tBTA_JV_RFCOMM_WRITE    rfc_write;      /* BTA_JV_RFCOMM_WRITE_EVT */
380     tBTA_JV_DATA_IND        data_ind;       /* BTA_JV_L2CAP_DATA_IND_EVT
381                                                BTA_JV_RFCOMM_DATA_IND_EVT */
382     tBTA_JV_LE_DATA_IND      le_data_ind;   /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
383     tBTA_JV_L2CAP_LE_OPEN      l2c_le_open;       /* BTA_JV_L2CAP_OPEN_EVT */
384     tBTA_JV_L2CAP_WRITE_FIXED  l2c_write_fixed;      /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
385 } tBTA_JV;
386 
387 /* JAVA DM Interface callback */
388 typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void * user_data);
389 
390 /* JAVA RFCOMM interface callback */
391 typedef void* (tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
392 
393 /* JAVA L2CAP interface callback */
394 typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data);
395 
396 /* JV configuration structure */
397 typedef struct
398 {
399     UINT16  sdp_raw_size;           /* The size of p_sdp_raw_data */
400     UINT16  sdp_db_size;            /* The size of p_sdp_db */
401     UINT8   *p_sdp_raw_data;        /* The data buffer to keep raw data */
402     tSDP_DISCOVERY_DB   *p_sdp_db;  /* The data buffer to keep SDP database */
403 } tBTA_JV_CFG;
404 
405 /*******************************************************************************
406 **
407 ** Function         BTA_JvEnable
408 **
409 ** Description      Enable the Java I/F service. When the enable
410 **                  operation is complete the callback function will be
411 **                  called with a BTA_JV_ENABLE_EVT. This function must
412 **                  be called before other functions in the JV API are
413 **                  called.
414 **
415 ** Returns          BTA_JV_SUCCESS if successful.
416 **                  BTA_JV_FAIL if internal failure.
417 **
418 *******************************************************************************/
419 tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback);
420 
421 /*******************************************************************************
422 **
423 ** Function         BTA_JvDisable
424 **
425 ** Description      Disable the Java I/F
426 **
427 ** Returns          void
428 **
429 *******************************************************************************/
430 void BTA_JvDisable(void);
431 
432 /*******************************************************************************
433 **
434 ** Function         BTA_JvIsEncrypted
435 **
436 ** Description      This function checks if the link to peer device is encrypted
437 **
438 ** Returns          TRUE if encrypted.
439 **                  FALSE if not.
440 **
441 *******************************************************************************/
442 BOOLEAN BTA_JvIsEncrypted(BD_ADDR bd_addr);
443 
444 /*******************************************************************************
445 **
446 ** Function         BTA_JvGetChannelId
447 **
448 ** Description      This function reserves a SCN/PSM for applications running
449 **                  over RFCOMM or L2CAP. It is primarily called by
450 **                  server profiles/applications to register their SCN/PSM into the
451 **                  SDP database. The SCN is reported by the tBTA_JV_DM_CBACK
452 **                  callback with a BTA_JV_GET_SCN_EVT.
453 **                  If the SCN/PSM reported is 0, that means all SCN resources are
454 **                  exhausted.
455 **                  The channel parameter can be used to request a specific
456 **                  channel. If the request on the specific channel fails, the
457 **                  SCN/PSM returned in the EVT will be 0 - no attempt to request
458 **                  a new channel will be made. set channel to <= 0 to automatically
459 **                  assign an channel ID.
460 **
461 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
462 **                  BTA_JV_FAILURE, otherwise.
463 **
464 *******************************************************************************/
465 tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void* user_data,
466                                                  INT32 channel);
467 
468 /*******************************************************************************
469 **
470 ** Function         BTA_JvFreeChannel
471 **
472 ** Description      This function frees a SCN/PSM that was used
473 **                  by an application running over RFCOMM or L2CAP.
474 **
475 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
476 **                  BTA_JV_FAILURE, otherwise.
477 **
478 *******************************************************************************/
479 tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type);
480 
481 /*******************************************************************************
482 **
483 ** Function         BTA_JvStartDiscovery
484 **
485 ** Description      This function performs service discovery for the services
486 **                  provided by the given peer device. When the operation is
487 **                  complete the tBTA_JV_DM_CBACK callback function will be
488 **                  called with a BTA_JV_DISCOVERY_COMP_EVT.
489 **
490 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
491 **                  BTA_JV_FAILURE, otherwise.
492 **
493 *******************************************************************************/
494 tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, UINT16 num_uuid,
495                                            tSDP_UUID *p_uuid_list, void* user_data);
496 
497 /*******************************************************************************
498 **
499 ** Function         BTA_JvCreateRecordByUser
500 **
501 ** Description      Create a service record in the local SDP database by user in
502 **                  tBTA_JV_DM_CBACK callback with a BTA_JV_CREATE_RECORD_EVT.
503 **
504 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
505 **                  BTA_JV_FAILURE, otherwise.
506 **
507 *******************************************************************************/
508 tBTA_JV_STATUS BTA_JvCreateRecordByUser(void* user_data);
509 
510 /*******************************************************************************
511 **
512 ** Function         BTA_JvDeleteRecord
513 **
514 ** Description      Delete a service record in the local SDP database.
515 **
516 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
517 **                  BTA_JV_FAILURE, otherwise.
518 **
519 *******************************************************************************/
520 tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle);
521 
522 /*******************************************************************************
523 **
524 ** Function         BTA_JvL2capConnectLE
525 **
526 ** Description      Initiate a connection as an LE L2CAP client to the given BD
527 **                  Address.
528 **                  When the connection is initiated or failed to initiate,
529 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
530 **                  When the connection is established or failed,
531 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
532 **
533 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
534 **                  BTA_JV_FAILURE, otherwise.
535 **
536 *******************************************************************************/
537 tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
538                            const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_chan,
539                            UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
540                            BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
541 
542 /*******************************************************************************
543 **
544 ** Function         BTA_JvL2capConnect
545 **
546 ** Description      Initiate a connection as a L2CAP client to the given BD
547 **                  Address.
548 **                  When the connection is initiated or failed to initiate,
549 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT
550 **                  When the connection is established or failed,
551 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT
552 **
553 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
554 **                  BTA_JV_FAILURE, otherwise.
555 **
556 *******************************************************************************/
557 tBTA_JV_STATUS BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
558                            const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_psm,
559                            UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
560                            BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
561 
562 /*******************************************************************************
563 **
564 ** Function         BTA_JvL2capClose
565 **
566 ** Description      This function closes an L2CAP client connection
567 **
568 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
569 **                  BTA_JV_FAILURE, otherwise.
570 **
571 *******************************************************************************/
572 tBTA_JV_STATUS BTA_JvL2capClose(UINT32 handle);
573 
574 /*******************************************************************************
575 **
576 ** Function         BTA_JvL2capCloseLE
577 **
578 ** Description      This function closes an L2CAP client connection for Fixed Channels
579 **                  Function is idempotent and no callbacks are called!
580 **
581 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
582 **                  BTA_JV_FAILURE, otherwise.
583 **
584 *******************************************************************************/
585 tBTA_JV_STATUS BTA_JvL2capCloseLE(UINT32 handle);
586 
587 /*******************************************************************************
588 **
589 ** Function         BTA_JvL2capStartServer
590 **
591 ** Description      This function starts an L2CAP server and listens for an L2CAP
592 **                  connection from a remote Bluetooth device.  When the server
593 **                  is started successfully, tBTA_JV_L2CAP_CBACK is called with
594 **                  BTA_JV_L2CAP_START_EVT.  When the connection is established,
595 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT.
596 **
597 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
598 **                  BTA_JV_FAILURE, otherwise.
599 **
600 *******************************************************************************/
601 tBTA_JV_STATUS BTA_JvL2capStartServer(int conn_type, tBTA_SEC sec_mask, tBTA_JV_ROLE role,
602                            const tL2CAP_ERTM_INFO *ertm_info,
603                            UINT16 local_psm, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
604                            tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
605 
606 /*******************************************************************************
607 **
608 ** Function         BTA_JvL2capStartServerLE
609 **
610 ** Description      This function starts an LE L2CAP server and listens for an L2CAP
611 **                  connection from a remote Bluetooth device on a fixed channel
612 **                  over an LE link.  When the server
613 **                  is started successfully, tBTA_JV_L2CAP_CBACK is called with
614 **                  BTA_JV_L2CAP_START_EVT.  When the connection is established,
615 **                  tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT.
616 **
617 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
618 **                  BTA_JV_FAILURE, otherwise.
619 **
620 *******************************************************************************/
621 tBTA_JV_STATUS BTA_JvL2capStartServerLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
622                            const tL2CAP_ERTM_INFO *ertm_info,
623                            UINT16 local_chan, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg,
624                            tBTA_JV_L2CAP_CBACK *p_cback, void *user_data);
625 
626 /*******************************************************************************
627 **
628 ** Function         BTA_JvL2capStopServerLE
629 **
630 ** Description      This function stops the LE L2CAP server. If the server has an
631 **                  active connection, it would be closed.
632 **
633 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
634 **                  BTA_JV_FAILURE, otherwise.
635 **
636 *******************************************************************************/
637 tBTA_JV_STATUS BTA_JvL2capStopServerLE(UINT16 local_chan, void *user_data);
638 
639 /*******************************************************************************
640 **
641 ** Function         BTA_JvL2capStopServerLE
642 **
643 ** Description      This function stops the LE L2CAP server. If the server has an
644 **                  active connection, it would be closed.
645 **
646 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
647 **                  BTA_JV_FAILURE, otherwise.
648 **
649 *******************************************************************************/
650 tBTA_JV_STATUS BTA_JvL2capStopServer(UINT16 local_psm, void *user_data);
651 
652 /*******************************************************************************
653 **
654 ** Function         BTA_JvL2capRead
655 **
656 ** Description      This function reads data from an L2CAP connection
657 **                  When the operation is complete, tBTA_JV_L2CAP_CBACK is
658 **                  called with BTA_JV_L2CAP_READ_EVT.
659 **
660 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
661 **                  BTA_JV_FAILURE, otherwise.
662 **
663 *******************************************************************************/
664 tBTA_JV_STATUS BTA_JvL2capRead(UINT32 handle, UINT32 req_id,
665                                               UINT8 *p_data, UINT16 len);
666 
667 /*******************************************************************************
668 **
669 ** Function         BTA_JvL2capReady
670 **
671 ** Description      This function determined if there is data to read from
672 **                  an L2CAP connection
673 **
674 ** Returns          BTA_JV_SUCCESS, if data queue size is in *p_data_size.
675 **                  BTA_JV_FAILURE, if error.
676 **
677 *******************************************************************************/
678 tBTA_JV_STATUS BTA_JvL2capReady(UINT32 handle, UINT32 *p_data_size);
679 
680 /*******************************************************************************
681 **
682 ** Function         BTA_JvL2capWrite
683 **
684 ** Description      This function writes data to an L2CAP connection
685 **                  When the operation is complete, tBTA_JV_L2CAP_CBACK is
686 **                  called with BTA_JV_L2CAP_WRITE_EVT. Works for
687 **                  PSM-based connections
688 **
689 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
690 **                  BTA_JV_FAILURE, otherwise.
691 **
692 *******************************************************************************/
693 tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id,
694                                                UINT8 *p_data, UINT16 len, void *user_data);
695 
696 
697 /*******************************************************************************
698 **
699 ** Function         BTA_JvL2capWriteFixed
700 **
701 ** Description      This function writes data to an L2CAP connection
702 **                  When the operation is complete, tBTA_JV_L2CAP_CBACK is
703 **                  called with BTA_JV_L2CAP_WRITE_FIXED_EVT. Works for
704 **                  fixed-channel connections
705 **
706 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
707 **                  BTA_JV_FAILURE, otherwise.
708 **
709 *******************************************************************************/
710 tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id,
711                                                tBTA_JV_L2CAP_CBACK *p_cback,
712                                                UINT8 *p_data, UINT16 len, void *user_data);
713 
714 /*******************************************************************************
715 **
716 ** Function         BTA_JvRfcommConnect
717 **
718 ** Description      This function makes an RFCOMM conection to a remote BD
719 **                  Address.
720 **                  When the connection is initiated or failed to initiate,
721 **                  tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT
722 **                  When the connection is established or failed,
723 **                  tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT
724 **
725 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
726 **                  BTA_JV_FAILURE, otherwise.
727 **
728 *******************************************************************************/
729 tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
730                                           tBTA_JV_ROLE role, UINT8 remote_scn, BD_ADDR peer_bd_addr,
731                                           tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
732 
733 /*******************************************************************************
734 **
735 ** Function         BTA_JvRfcommClose
736 **
737 ** Description      This function closes an RFCOMM connection
738 **
739 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
740 **                  BTA_JV_FAILURE, otherwise.
741 **
742 *******************************************************************************/
743 tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void* user_data);
744 
745 /*******************************************************************************
746 **
747 ** Function         BTA_JvRfcommStartServer
748 **
749 ** Description      This function starts listening for an RFCOMM connection
750 **                  request from a remote Bluetooth device.  When the server is
751 **                  started successfully, tBTA_JV_RFCOMM_CBACK is called
752 **                  with BTA_JV_RFCOMM_START_EVT.
753 **                  When the connection is established, tBTA_JV_RFCOMM_CBACK
754 **                  is called with BTA_JV_RFCOMM_OPEN_EVT.
755 **
756 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
757 **                  BTA_JV_FAILURE, otherwise.
758 **
759 *******************************************************************************/
760 tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask,
761                                               tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session,
762                                               tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
763 
764 /*******************************************************************************
765 **
766 ** Function         BTA_JvRfcommStopServer
767 **
768 ** Description      This function stops the RFCOMM server. If the server has an
769 **                  active connection, it would be closed.
770 **
771 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
772 **                  BTA_JV_FAILURE, otherwise.
773 **
774 *******************************************************************************/
775 tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void* user_data);
776 
777 /*******************************************************************************
778 **
779 ** Function         BTA_JvRfcommWrite
780 **
781 ** Description      This function writes data to an RFCOMM connection
782 **                  When the operation is complete, tBTA_JV_RFCOMM_CBACK is
783 **                  called with BTA_JV_RFCOMM_WRITE_EVT.
784 **
785 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
786 **                  BTA_JV_FAILURE, otherwise.
787 **
788 *******************************************************************************/
789 tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id);
790 
791 /*******************************************************************************
792  **
793  ** Function    BTA_JVSetPmProfile
794  **
795  ** Description This function set or free power mode profile for different JV application
796  **
797  ** Parameters:  handle,  JV handle from RFCOMM or L2CAP
798  **              app_id:  app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details
799  **              BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and
800  **              BTA_JV_CONN_CLOSE is called implicitely
801  **              init_st:  state after calling this API. typically it should be BTA_JV_CONN_OPEN
802  **
803  ** Returns      BTA_JV_SUCCESS, if the request is being processed.
804  **              BTA_JV_FAILURE, otherwise.
805  **
806  ** NOTE:        BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm calls automatically
807  **              BTA_JV_CONN_CLOSE to remove in case of connection close!
808  **
809  *******************************************************************************/
810 tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id,
811                                          tBTA_JV_CONN_STATE init_st);
812 
813 /*******************************************************************************
814 **
815 ** Function         BTA_JvRfcommGetPortHdl
816 **
817 ** Description    This function fetches the rfcomm port handle
818 **
819 ** Returns          BTA_JV_SUCCESS, if the request is being processed.
820 **                  BTA_JV_FAILURE, otherwise.
821 **
822 *******************************************************************************/
823 UINT16 BTA_JvRfcommGetPortHdl(UINT32 handle);
824 
825 #endif /* BTA_JV_API_H */
826