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