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