1 /****************************************************************************** 2 * 3 * Copyright (C) 2006-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This is the public interface file the BTA Java I/F 22 * 23 ******************************************************************************/ 24 #ifndef BTA_JV_API_H 25 #define BTA_JV_API_H 26 27 #include "bt_target.h" 28 #include "bt_types.h" 29 #include "bta_api.h" 30 #include "btm_api.h" 31 #include "l2c_api.h" 32 33 /***************************************************************************** 34 * Constants and data types 35 ****************************************************************************/ 36 /* status values */ 37 #define BTA_JV_SUCCESS 0 /* Successful operation. */ 38 #define BTA_JV_FAILURE 1 /* Generic failure. */ 39 #define BTA_JV_BUSY 2 /* Temporarily can not handle this request. */ 40 #define BTA_JV_NO_DATA 3 /* no data. */ 41 #define BTA_JV_NO_RESOURCE 4 /* No more set pm control block */ 42 43 typedef uint8_t tBTA_JV_STATUS; 44 #define BTA_JV_INTERNAL_ERR (-1) /* internal error. */ 45 46 #define BTA_JV_MAX_UUIDS SDP_MAX_UUID_FILTERS 47 #define BTA_JV_MAX_ATTRS SDP_MAX_ATTR_FILTERS 48 #define BTA_JV_MAX_SDP_REC SDP_MAX_RECORDS 49 #define BTA_JV_MAX_L2C_CONN \ 50 GAP_MAX_CONNECTIONS /* GAP handle is used as index, hence do not change this \ 51 value */ 52 #define BTA_JV_MAX_SCN \ 53 PORT_MAX_RFC_PORTS /* same as BTM_MAX_SCN (in btm_int.h) */ 54 #define BTA_JV_MAX_RFC_CONN MAX_RFC_PORTS 55 56 #ifndef BTA_JV_DEF_RFC_MTU 57 #define BTA_JV_DEF_RFC_MTU (3 * 330) 58 #endif 59 60 #ifndef BTA_JV_MAX_RFC_SR_SESSION 61 #define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS 62 #endif 63 64 /* BTA_JV_MAX_RFC_SR_SESSION can not be bigger than MAX_BD_CONNECTIONS */ 65 #if (BTA_JV_MAX_RFC_SR_SESSION > MAX_BD_CONNECTIONS) 66 #undef BTA_JV_MAX_RFC_SR_SESSION 67 #define BTA_JV_MAX_RFC_SR_SESSION MAX_BD_CONNECTIONS 68 #endif 69 70 #define BTA_JV_FIRST_SERVICE_ID BTA_FIRST_JV_SERVICE_ID 71 #define BTA_JV_LAST_SERVICE_ID BTA_LAST_JV_SERVICE_ID 72 #define BTA_JV_NUM_SERVICE_ID \ 73 (BTA_LAST_JV_SERVICE_ID - BTA_FIRST_JV_SERVICE_ID + 1) 74 75 /* Discoverable modes */ 76 enum { BTA_JV_DISC_NONE, BTA_JV_DISC_LIMITED, BTA_JV_DISC_GENERAL }; 77 typedef uint16_t tBTA_JV_DISC; 78 79 #define BTA_JV_ROLE_SLAVE BTM_ROLE_SLAVE 80 #define BTA_JV_ROLE_MASTER BTM_ROLE_MASTER 81 typedef uint32_t tBTA_JV_ROLE; 82 83 #define BTA_JV_SERVICE_LMTD_DISCOVER \ 84 BTM_COD_SERVICE_LMTD_DISCOVER /* 0x0020 \ 85 */ 86 #define BTA_JV_SERVICE_POSITIONING BTM_COD_SERVICE_POSITIONING /* 0x0100 */ 87 #define BTA_JV_SERVICE_NETWORKING BTM_COD_SERVICE_NETWORKING /* 0x0200 */ 88 #define BTA_JV_SERVICE_RENDERING BTM_COD_SERVICE_RENDERING /* 0x0400 */ 89 #define BTA_JV_SERVICE_CAPTURING BTM_COD_SERVICE_CAPTURING /* 0x0800 */ 90 #define BTA_JV_SERVICE_OBJ_TRANSFER BTM_COD_SERVICE_OBJ_TRANSFER /* 0x1000 */ 91 #define BTA_JV_SERVICE_AUDIO BTM_COD_SERVICE_AUDIO /* 0x2000 */ 92 #define BTA_JV_SERVICE_TELEPHONY BTM_COD_SERVICE_TELEPHONY /* 0x4000 */ 93 #define BTA_JV_SERVICE_INFORMATION BTM_COD_SERVICE_INFORMATION /* 0x8000 */ 94 95 /* JV ID type */ 96 #define BTA_JV_PM_ID_1 1 /* PM example profile 1 */ 97 #define BTA_JV_PM_ID_2 2 /* PM example profile 2 */ 98 #define BTA_JV_PM_ID_CLEAR 0 /* Special JV ID used to clear PM profile */ 99 #define BTA_JV_PM_ALL 0xFF /* Generic match all id, see bta_dm_cfg.c */ 100 typedef uint8_t tBTA_JV_PM_ID; 101 102 #define BTA_JV_PM_HANDLE_CLEAR \ 103 0xFF /* Special JV ID used to clear PM profile */ 104 105 /* define maximum number of registered PM entities. should be in sync with bta 106 * pm! */ 107 #ifndef BTA_JV_PM_MAX_NUM 108 #define BTA_JV_PM_MAX_NUM 5 109 #endif 110 111 /* JV pm connection states */ 112 enum { 113 BTA_JV_CONN_OPEN = 0, /* Connection opened state */ 114 BTA_JV_CONN_CLOSE, /* Connection closed state */ 115 BTA_JV_APP_OPEN, /* JV Application opened state */ 116 BTA_JV_APP_CLOSE, /* JV Application closed state */ 117 BTA_JV_SCO_OPEN, /* SCO connection opened state */ 118 BTA_JV_SCO_CLOSE, /* SCO connection opened state */ 119 BTA_JV_CONN_IDLE, /* Connection idle state */ 120 BTA_JV_CONN_BUSY, /* Connection busy state */ 121 BTA_JV_MAX_CONN_STATE /* Max number of connection state */ 122 }; 123 typedef uint8_t tBTA_JV_CONN_STATE; 124 125 /* JV Connection types */ 126 #define BTA_JV_CONN_TYPE_RFCOMM 0 127 #define BTA_JV_CONN_TYPE_L2CAP 1 128 #define BTA_JV_CONN_TYPE_L2CAP_LE 2 129 130 /* Java I/F callback events */ 131 /* events received by tBTA_JV_DM_CBACK */ 132 #define BTA_JV_ENABLE_EVT 0 /* JV enabled */ 133 #define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */ 134 #define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */ 135 #define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */ 136 #define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */ 137 /* events received by tBTA_JV_L2CAP_CBACK */ 138 #define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */ 139 #define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */ 140 #define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */ 141 #define BTA_JV_L2CAP_CL_INIT_EVT 19 /* L2CAP client initiated a connection */ 142 #define BTA_JV_L2CAP_DATA_IND_EVT 20 /* L2CAP connection received data */ 143 #define BTA_JV_L2CAP_CONG_EVT \ 144 21 /* L2CAP connection congestion status changed */ 145 #define BTA_JV_L2CAP_READ_EVT 22 /* the result for BTA_JvL2capRead */ 146 #define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/ 147 #define BTA_JV_L2CAP_WRITE_FIXED_EVT \ 148 25 /* the result for BTA_JvL2capWriteFixed */ 149 150 /* events received by tBTA_JV_RFCOMM_CBACK */ 151 #define BTA_JV_RFCOMM_OPEN_EVT \ 152 26 /* open status of RFCOMM Client connection \ 153 */ 154 #define BTA_JV_RFCOMM_CLOSE_EVT 27 /* RFCOMM connection closed */ 155 #define BTA_JV_RFCOMM_START_EVT 28 /* RFCOMM server started */ 156 #define BTA_JV_RFCOMM_CL_INIT_EVT \ 157 29 /* RFCOMM client initiated a connection \ 158 */ 159 #define BTA_JV_RFCOMM_DATA_IND_EVT 30 /* RFCOMM connection received data */ 160 #define BTA_JV_RFCOMM_CONG_EVT \ 161 31 /* RFCOMM connection congestion status changed */ 162 #define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/ 163 #define BTA_JV_RFCOMM_SRV_OPEN_EVT \ 164 34 /* open status of Server RFCOMM connection */ 165 #define BTA_JV_MAX_EVT 35 /* max number of JV events */ 166 167 typedef uint16_t tBTA_JV_EVT; 168 169 /* data associated with BTA_JV_SET_DISCOVER_EVT */ 170 typedef struct { 171 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 172 tBTA_JV_DISC disc_mode; /* The current discoverable mode */ 173 } tBTA_JV_SET_DISCOVER; 174 175 /* data associated with BTA_JV_DISCOVERY_COMP_EVT_ */ 176 typedef struct { 177 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 178 int scn; /* channel # */ 179 } tBTA_JV_DISCOVERY_COMP; 180 181 /* data associated with BTA_JV_CREATE_RECORD_EVT */ 182 typedef struct { 183 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 184 } tBTA_JV_CREATE_RECORD; 185 186 /* data associated with BTA_JV_L2CAP_OPEN_EVT */ 187 typedef struct { 188 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 189 uint32_t handle; /* The connection handle */ 190 BD_ADDR rem_bda; /* The peer address */ 191 int32_t tx_mtu; /* The transmit MTU */ 192 } tBTA_JV_L2CAP_OPEN; 193 194 /* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */ 195 typedef struct { 196 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 197 uint32_t handle; /* The connection handle */ 198 BD_ADDR rem_bda; /* The peer address */ 199 int32_t tx_mtu; /* The transmit MTU */ 200 void** p_p_cback; /* set them for new socket */ 201 void** p_user_data; /* set them for new socket */ 202 203 } tBTA_JV_L2CAP_LE_OPEN; 204 205 /* data associated with BTA_JV_L2CAP_CLOSE_EVT */ 206 typedef struct { 207 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 208 uint32_t handle; /* The connection handle */ 209 bool async; /* false, if local initiates disconnect */ 210 } tBTA_JV_L2CAP_CLOSE; 211 212 /* data associated with BTA_JV_L2CAP_START_EVT */ 213 typedef struct { 214 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 215 uint32_t handle; /* The connection handle */ 216 uint8_t sec_id; /* security ID used by this server */ 217 } tBTA_JV_L2CAP_START; 218 219 /* data associated with BTA_JV_L2CAP_CL_INIT_EVT */ 220 typedef struct { 221 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 222 uint32_t handle; /* The connection handle */ 223 uint8_t sec_id; /* security ID used by this client */ 224 } tBTA_JV_L2CAP_CL_INIT; 225 226 /* data associated with BTA_JV_L2CAP_CONG_EVT */ 227 typedef struct { 228 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 229 uint32_t handle; /* The connection handle */ 230 bool cong; /* true, congested. false, uncongested */ 231 } tBTA_JV_L2CAP_CONG; 232 233 /* data associated with BTA_JV_L2CAP_READ_EVT */ 234 typedef struct { 235 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 236 uint32_t handle; /* The connection handle */ 237 uint32_t req_id; /* The req_id in the associated BTA_JvL2capRead() */ 238 uint8_t* p_data; /* This points the same location as the p_data 239 * parameter in BTA_JvL2capRead () */ 240 uint16_t len; /* The length of the data read. */ 241 } tBTA_JV_L2CAP_READ; 242 243 /* data associated with BTA_JV_L2CAP_WRITE_EVT */ 244 typedef struct { 245 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 246 uint32_t handle; /* The connection handle */ 247 uint32_t req_id; /* The req_id in the associated BTA_JvL2capWrite() */ 248 uint16_t len; /* The length of the data written. */ 249 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 */ 254 typedef struct { 255 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 256 uint16_t channel; /* The connection channel */ 257 BD_ADDR 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 */ 265 typedef struct { 266 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 267 uint32_t handle; /* The connection handle */ 268 BD_ADDR rem_bda; /* The peer address */ 269 } tBTA_JV_RFCOMM_OPEN; 270 /* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */ 271 typedef 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 BD_ADDR rem_bda; /* The peer address */ 276 } tBTA_JV_RFCOMM_SRV_OPEN; 277 278 /* data associated with BTA_JV_RFCOMM_CLOSE_EVT */ 279 typedef 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 */ 287 typedef 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 */ 295 typedef 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 */ 302 typedef 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 */ 307 typedef 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 */ 313 typedef 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 */ 320 typedef 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 */ 329 typedef 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 */ 336 typedef 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 */ 342 typedef 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 */ 371 typedef void(tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV* p_data, uint32_t id); 372 373 /* JAVA RFCOMM interface callback */ 374 typedef 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 */ 378 typedef void(tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV* p_data, 379 uint32_t l2cap_socket_id); 380 381 /* JV configuration structure */ 382 typedef 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 ******************************************************************************/ 403 tBTA_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 ******************************************************************************/ 414 void 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 ******************************************************************************/ 426 bool BTA_JvIsEncrypted(BD_ADDR 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 ******************************************************************************/ 449 tBTA_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 ******************************************************************************/ 462 tBTA_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 ******************************************************************************/ 477 tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, uint16_t num_uuid, 478 tSDP_UUID* p_uuid_list, 479 uint32_t rfcomm_slot_id); 480 481 /******************************************************************************* 482 * 483 * Function BTA_JvCreateRecordByUser 484 * 485 * Description Create a service record in the local SDP database by user in 486 * tBTA_JV_DM_CBACK callback with a BTA_JV_CREATE_RECORD_EVT. 487 * 488 * Returns BTA_JV_SUCCESS, if the request is being processed. 489 * BTA_JV_FAILURE, otherwise. 490 * 491 ******************************************************************************/ 492 tBTA_JV_STATUS BTA_JvCreateRecordByUser(uint32_t rfcomm_slot_id); 493 494 /******************************************************************************* 495 * 496 * Function BTA_JvDeleteRecord 497 * 498 * Description Delete a service record in the local SDP database. 499 * 500 * Returns BTA_JV_SUCCESS, if the request is being processed. 501 * BTA_JV_FAILURE, otherwise. 502 * 503 ******************************************************************************/ 504 tBTA_JV_STATUS BTA_JvDeleteRecord(uint32_t handle); 505 506 /******************************************************************************* 507 * 508 * Function BTA_JvL2capConnectLE 509 * 510 * Description Initiate a connection as an LE L2CAP client to the given BD 511 * Address. 512 * When the connection is initiated or failed to initiate, 513 * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT 514 * When the connection is established or failed, 515 * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT 516 * 517 * Returns BTA_JV_SUCCESS, if the request is being processed. 518 * BTA_JV_FAILURE, otherwise. 519 * 520 ******************************************************************************/ 521 tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 522 const tL2CAP_ERTM_INFO* ertm_info, 523 uint16_t remote_chan, uint16_t rx_mtu, 524 tL2CAP_CFG_INFO* cfg, BD_ADDR peer_bd_addr, 525 tBTA_JV_L2CAP_CBACK* p_cback, 526 uint32_t l2cap_socket_id); 527 528 /******************************************************************************* 529 * 530 * Function BTA_JvL2capConnect 531 * 532 * Description Initiate a connection as a L2CAP client to the given BD 533 * Address. 534 * When the connection is initiated or failed to initiate, 535 * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT 536 * When the connection is established or failed, 537 * tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT 538 * 539 * Returns BTA_JV_SUCCESS, if the request is being processed. 540 * BTA_JV_FAILURE, otherwise. 541 * 542 ******************************************************************************/ 543 tBTA_JV_STATUS BTA_JvL2capConnect(int conn_type, tBTA_SEC sec_mask, 544 tBTA_JV_ROLE role, 545 const tL2CAP_ERTM_INFO* ertm_info, 546 uint16_t remote_psm, uint16_t rx_mtu, 547 tL2CAP_CFG_INFO* cfg, BD_ADDR peer_bd_addr, 548 tBTA_JV_L2CAP_CBACK* p_cback, 549 uint32_t l2cap_socket_id); 550 551 /******************************************************************************* 552 * 553 * Function BTA_JvL2capClose 554 * 555 * Description This function closes an L2CAP client connection 556 * 557 * Returns BTA_JV_SUCCESS, if the request is being processed. 558 * BTA_JV_FAILURE, otherwise. 559 * 560 ******************************************************************************/ 561 tBTA_JV_STATUS BTA_JvL2capClose(uint32_t handle); 562 563 /******************************************************************************* 564 * 565 * Function BTA_JvL2capCloseLE 566 * 567 * Description This function closes an L2CAP client connection for Fixed 568 * Channels Function is idempotent and no callbacks are called! 569 * 570 * Returns BTA_JV_SUCCESS, if the request is being processed. 571 * BTA_JV_FAILURE, otherwise. 572 * 573 ******************************************************************************/ 574 tBTA_JV_STATUS BTA_JvL2capCloseLE(uint32_t handle); 575 576 /******************************************************************************* 577 * 578 * Function BTA_JvL2capStartServer 579 * 580 * Description This function starts an L2CAP server and listens for an 581 * L2CAP connection from a remote Bluetooth device. When the 582 * server is started successfully, tBTA_JV_L2CAP_CBACK is 583 * called with BTA_JV_L2CAP_START_EVT. When the connection is 584 * established, tBTA_JV_L2CAP_CBACK is called with 585 * BTA_JV_L2CAP_OPEN_EVT. 586 * 587 * Returns BTA_JV_SUCCESS, if the request is being processed. 588 * BTA_JV_FAILURE, otherwise. 589 * 590 ******************************************************************************/ 591 tBTA_JV_STATUS BTA_JvL2capStartServer(int conn_type, tBTA_SEC sec_mask, 592 tBTA_JV_ROLE role, 593 const tL2CAP_ERTM_INFO* ertm_info, 594 uint16_t local_psm, uint16_t rx_mtu, 595 tL2CAP_CFG_INFO* cfg, 596 tBTA_JV_L2CAP_CBACK* p_cback, 597 uint32_t l2cap_socket_id); 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 ******************************************************************************/ 614 tBTA_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 uint32_t l2cap_socket_id); 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 ******************************************************************************/ 632 tBTA_JV_STATUS BTA_JvL2capStopServerLE(uint16_t local_chan, 633 uint32_t l2cap_socket_id); 634 635 /******************************************************************************* 636 * 637 * Function BTA_JvL2capStopServer 638 * 639 * Description This function stops the L2CAP server. If the server has 640 * an active connection, it would be closed. 641 * 642 * Returns BTA_JV_SUCCESS, if the request is being processed. 643 * BTA_JV_FAILURE, otherwise. 644 * 645 ******************************************************************************/ 646 tBTA_JV_STATUS BTA_JvL2capStopServer(uint16_t local_psm, 647 uint32_t l2cap_socket_id); 648 649 /******************************************************************************* 650 * 651 * Function BTA_JvL2capRead 652 * 653 * Description This function reads data from an L2CAP connection 654 * When the operation is complete, tBTA_JV_L2CAP_CBACK is 655 * called with BTA_JV_L2CAP_READ_EVT. 656 * 657 * Returns BTA_JV_SUCCESS, if the request is being processed. 658 * BTA_JV_FAILURE, otherwise. 659 * 660 ******************************************************************************/ 661 tBTA_JV_STATUS BTA_JvL2capRead(uint32_t handle, uint32_t req_id, 662 uint8_t* p_data, uint16_t len); 663 664 /******************************************************************************* 665 * 666 * Function BTA_JvL2capReady 667 * 668 * Description This function determined if there is data to read from 669 * an L2CAP connection 670 * 671 * Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size. 672 * BTA_JV_FAILURE, if error. 673 * 674 ******************************************************************************/ 675 tBTA_JV_STATUS BTA_JvL2capReady(uint32_t handle, uint32_t* p_data_size); 676 677 /******************************************************************************* 678 * 679 * Function BTA_JvL2capWrite 680 * 681 * Description This function writes data to an L2CAP connection 682 * When the operation is complete, tBTA_JV_L2CAP_CBACK is 683 * called with BTA_JV_L2CAP_WRITE_EVT. Works for 684 * PSM-based connections 685 * 686 * Returns BTA_JV_SUCCESS, if the request is being processed. 687 * BTA_JV_FAILURE, otherwise. 688 * 689 ******************************************************************************/ 690 tBTA_JV_STATUS BTA_JvL2capWrite(uint32_t handle, uint32_t req_id, 691 uint8_t* p_data, uint16_t len, 692 uint32_t user_id); 693 694 /******************************************************************************* 695 * 696 * Function BTA_JvL2capWriteFixed 697 * 698 * Description This function writes data to an L2CAP connection 699 * When the operation is complete, tBTA_JV_L2CAP_CBACK is 700 * called with BTA_JV_L2CAP_WRITE_FIXED_EVT. Works for 701 * fixed-channel connections 702 * 703 * Returns BTA_JV_SUCCESS, if the request is being processed. 704 * BTA_JV_FAILURE, otherwise. 705 * 706 ******************************************************************************/ 707 tBTA_JV_STATUS BTA_JvL2capWriteFixed(uint16_t channel, BD_ADDR* addr, 708 uint32_t req_id, 709 tBTA_JV_L2CAP_CBACK* p_cback, 710 uint8_t* p_data, uint16_t len, 711 uint32_t user_id); 712 713 /******************************************************************************* 714 * 715 * Function BTA_JvRfcommConnect 716 * 717 * Description This function makes an RFCOMM conection to a remote BD 718 * Address. 719 * When the connection is initiated or failed to initiate, 720 * tBTA_JV_RFCOMM_CBACK is called with 721 * BTA_JV_RFCOMM_CL_INIT_EVT 722 * When the connection is established or failed, 723 * tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT 724 * 725 * Returns BTA_JV_SUCCESS, if the request is being processed. 726 * BTA_JV_FAILURE, otherwise. 727 * 728 ******************************************************************************/ 729 tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 730 uint8_t remote_scn, BD_ADDR peer_bd_addr, 731 tBTA_JV_RFCOMM_CBACK* p_cback, 732 uint32_t rfcomm_slot_id); 733 734 /******************************************************************************* 735 * 736 * Function BTA_JvRfcommClose 737 * 738 * Description This function closes an RFCOMM connection 739 * 740 * Returns BTA_JV_SUCCESS, if the request is being processed. 741 * BTA_JV_FAILURE, otherwise. 742 * 743 ******************************************************************************/ 744 tBTA_JV_STATUS BTA_JvRfcommClose(uint32_t handle, uint32_t rfcomm_slot_id); 745 746 /******************************************************************************* 747 * 748 * Function BTA_JvRfcommStartServer 749 * 750 * Description This function starts listening for an RFCOMM connection 751 * request from a remote Bluetooth device. When the server is 752 * started successfully, tBTA_JV_RFCOMM_CBACK is called 753 * with BTA_JV_RFCOMM_START_EVT. 754 * When the connection is established, tBTA_JV_RFCOMM_CBACK 755 * is called with BTA_JV_RFCOMM_OPEN_EVT. 756 * 757 * Returns BTA_JV_SUCCESS, if the request is being processed. 758 * BTA_JV_FAILURE, otherwise. 759 * 760 ******************************************************************************/ 761 tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 762 uint8_t local_scn, uint8_t max_session, 763 tBTA_JV_RFCOMM_CBACK* p_cback, 764 uint32_t rfcomm_slot_id); 765 766 /******************************************************************************* 767 * 768 * Function BTA_JvRfcommStopServer 769 * 770 * Description This function stops the RFCOMM server. If the server has an 771 * active connection, it would be closed. 772 * 773 * Returns BTA_JV_SUCCESS, if the request is being processed. 774 * BTA_JV_FAILURE, otherwise. 775 * 776 ******************************************************************************/ 777 tBTA_JV_STATUS BTA_JvRfcommStopServer(uint32_t handle, uint32_t rfcomm_slot_id); 778 779 /******************************************************************************* 780 * 781 * Function BTA_JvRfcommWrite 782 * 783 * Description This function writes data to an RFCOMM connection 784 * When the operation is complete, tBTA_JV_RFCOMM_CBACK is 785 * called with BTA_JV_RFCOMM_WRITE_EVT. 786 * 787 * Returns BTA_JV_SUCCESS, if the request is being processed. 788 * BTA_JV_FAILURE, otherwise. 789 * 790 ******************************************************************************/ 791 tBTA_JV_STATUS BTA_JvRfcommWrite(uint32_t handle, uint32_t req_id); 792 793 /******************************************************************************* 794 * 795 * Function BTA_JVSetPmProfile 796 * 797 * Description This function set or free power mode profile for different JV 798 * application 799 * 800 * Parameters: handle, JV handle from RFCOMM or L2CAP 801 * app_id: app specific pm ID, can be BTA_JV_PM_ALL, see 802 * bta_dm_cfg.c for details 803 * BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st 804 * is ignored and BTA_JV_CONN_CLOSE is called 805 * implicitly 806 * init_st: state after calling this API. typically it should be 807 * BTA_JV_CONN_OPEN 808 * 809 * Returns BTA_JV_SUCCESS, if the request is being processed. 810 * BTA_JV_FAILURE, otherwise. 811 * 812 * NOTE: BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm 813 * calls automatically 814 * BTA_JV_CONN_CLOSE to remove in case of connection close! 815 * 816 ******************************************************************************/ 817 tBTA_JV_STATUS BTA_JvSetPmProfile(uint32_t handle, tBTA_JV_PM_ID app_id, 818 tBTA_JV_CONN_STATE init_st); 819 820 /******************************************************************************* 821 * 822 * Function BTA_JvRfcommGetPortHdl 823 * 824 * Description This function fetches the rfcomm port handle 825 * 826 * Returns BTA_JV_SUCCESS, if the request is being processed. 827 * BTA_JV_FAILURE, otherwise. 828 * 829 ******************************************************************************/ 830 uint16_t BTA_JvRfcommGetPortHdl(uint32_t handle); 831 832 #endif /* BTA_JV_API_H */ 833