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