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