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