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