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 == 1) 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; /* 0, 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; /* 1, congested. 0, 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; /* 0, if local initiates disconnect */ 302 } tBTA_JV_RFCOMM_CLOSE; 303 304 /* data associated with BTA_JV_RFCOMM_START_EVT */ 305 typedef struct { 306 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 307 UINT32 handle; /* The connection handle */ 308 UINT8 sec_id; /* security ID used by this server */ 309 UINT8 scn; /* Server channe number */ 310 BOOLEAN use_co; /* 1 to use co_rfc_data */ 311 } tBTA_JV_RFCOMM_START; 312 313 /* data associated with BTA_JV_RFCOMM_CL_INIT_EVT */ 314 typedef struct { 315 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 316 UINT32 handle; /* The connection handle */ 317 UINT8 sec_id; /* security ID used by this client */ 318 BOOLEAN use_co; /* 1 to use co_rfc_data */ 319 } tBTA_JV_RFCOMM_CL_INIT; 320 321 /*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */ 322 typedef struct { 323 UINT32 handle; /* The connection handle */ 324 BT_HDR *p_buf; /* The incoming data */ 325 } tBTA_JV_DATA_IND; 326 327 /* data associated with BTA_JV_RFCOMM_CONG_EVT */ 328 typedef struct { 329 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 330 UINT32 handle; /* The connection handle */ 331 BOOLEAN cong; /* 1, congested. 0, uncongested */ 332 } tBTA_JV_RFCOMM_CONG; 333 334 /* data associated with BTA_JV_RFCOMM_READ_EVT */ 335 typedef struct { 336 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 337 UINT32 handle; /* The connection handle */ 338 UINT32 req_id; /* The req_id in the associated BTA_JvRfcommRead() */ 339 UINT8 *p_data; /* This points the same location as the p_data 340 * parameter in BTA_JvRfcommRead () */ 341 UINT16 len; /* The length of the data read. */ 342 } tBTA_JV_RFCOMM_READ; 343 344 /* data associated with BTA_JV_RFCOMM_WRITE_EVT */ 345 typedef struct { 346 tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */ 347 UINT32 handle; /* The connection handle */ 348 UINT32 req_id; /* The req_id in the associated BTA_JvRfcommWrite() */ 349 int len; /* The length of the data written. */ 350 BOOLEAN cong; /* congestion status */ 351 BOOLEAN old_cong; /* congestion status */ 352 } tBTA_JV_RFCOMM_WRITE; 353 354 /* data associated with BTA_JV_API_SET_PM_PROFILE_EVT */ 355 typedef struct { 356 tBTA_JV_STATUS status; /* Status of the operation */ 357 UINT32 handle; /* Connection handle */ 358 tBTA_JV_PM_ID app_id; /* JV app ID */ 359 } tBTA_JV_SET_PM_PROFILE; 360 361 /* data associated with BTA_JV_API_NOTIFY_PM_STATE_CHANGE_EVT */ 362 typedef struct { 363 UINT32 handle; /* Connection handle */ 364 tBTA_JV_CONN_STATE state; /* JV connection stata */ 365 } tBTA_JV_NOTIFY_PM_STATE_CHANGE; 366 367 /* indicate server at which status */ 368 typedef enum { 369 BTA_JV_SERVER_START_FAILED, 370 BTA_JV_SERVER_RUNNING, 371 BTA_JV_SERVER_STATUS_MAX, 372 } tBTA_JV_SERVER_STATUS; 373 374 typedef struct { 375 tBTA_JV_SERVER_STATUS server_status; 376 UINT32 slot_id; 377 }tBTA_JV_FREE_SCN_USER_DATA; 378 379 /* data associated with BTA_JV_FREE_SCN_EVT */ 380 typedef struct { 381 tBTA_JV_STATUS status; /* Status of the operation */ 382 tBTA_JV_SERVER_STATUS server_status; /* Server status */ 383 UINT8 scn; /* Server channe number */ 384 } tBTA_JV_FREE_SCN; 385 386 387 /* union of data associated with JV callback */ 388 typedef union { 389 tBTA_JV_STATUS status; /* BTA_JV_ENABLE_EVT */ 390 tBTA_JV_DISCOVERY_COMP disc_comp; /* BTA_JV_DISCOVERY_COMP_EVT */ 391 tBTA_JV_SET_DISCOVER set_discover; /* BTA_JV_SET_DISCOVER_EVT */ 392 UINT8 scn; /* BTA_JV_GET_SCN_EVT */ 393 UINT16 psm; /* BTA_JV_GET_PSM_EVT */ 394 tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */ 395 #if BTA_JV_L2CAP_INCLUDED 396 tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */ 397 tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */ 398 tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */ 399 tBTA_JV_L2CAP_CL_INIT l2c_cl_init; /* BTA_JV_L2CAP_CL_INIT_EVT */ 400 tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */ 401 tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */ 402 tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */ 403 #endif /* BTA_JV_L2CAP_INCLUDED */ 404 tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */ 405 tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */ 406 tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */ 407 tBTA_JV_RFCOMM_START rfc_start; /* BTA_JV_RFCOMM_START_EVT */ 408 tBTA_JV_RFCOMM_CL_INIT rfc_cl_init; /* BTA_JV_RFCOMM_CL_INIT_EVT */ 409 tBTA_JV_RFCOMM_CONG rfc_cong; /* BTA_JV_RFCOMM_CONG_EVT */ 410 tBTA_JV_RFCOMM_READ rfc_read; /* BTA_JV_RFCOMM_READ_EVT */ 411 tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */ 412 tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT 413 BTA_JV_RFCOMM_DATA_IND_EVT */ 414 tBTA_JV_FREE_SCN free_scn; /* BTA_JV_FREE_SCN_EVT */ 415 #if BTA_JV_L2CAP_INCLUDED 416 tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */ 417 tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */ 418 tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */ 419 #endif /* BTA_JV_L2CAP_INCLUDED */ 420 } tBTA_JV; 421 422 /* JAVA DM Interface callback */ 423 typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data); 424 425 /* JAVA RFCOMM interface callback */ 426 typedef void *(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data); 427 428 #if BTA_JV_L2CAP_INCLUDED 429 /* JAVA L2CAP interface callback */ 430 typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data); 431 #endif /* BTA_JV_L2CAP_INCLUDED */ 432 433 /* JV configuration structure */ 434 typedef struct { 435 UINT16 sdp_raw_size; /* The size of p_sdp_raw_data */ 436 UINT16 sdp_db_size; /* The size of p_sdp_db */ 437 UINT8 *p_sdp_raw_data; /* The data buffer to keep raw data */ 438 tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */ 439 } tBTA_JV_CFG; 440 441 /******************************************************************************* 442 ** 443 ** Function BTA_JvEnable 444 ** 445 ** Description Enable the Java I/F service. When the enable 446 ** operation is complete the callback function will be 447 ** called with a BTA_JV_ENABLE_EVT. This function must 448 ** be called before other functions in the JV API are 449 ** called. 450 ** 451 ** Returns BTA_JV_SUCCESS if successful. 452 ** BTA_JV_FAIL if internal failure. 453 ** 454 *******************************************************************************/ 455 extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback); 456 457 /******************************************************************************* 458 ** 459 ** Function BTA_JvDisable 460 ** 461 ** Description Disable the Java I/F. When the enable 462 ** operation is complete the callback function will be 463 ** called with a BTA_JV_DISABLE_EVT. 464 ** 465 ** Returns void 466 ** 467 *******************************************************************************/ 468 extern void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback); 469 470 /******************************************************************************* 471 ** 472 ** Function BTA_JvFree 473 ** 474 ** Description Free JV configuration 475 ** 476 ** Returns void 477 ** 478 *******************************************************************************/ 479 extern void BTA_JvFree(void); 480 481 /******************************************************************************* 482 ** 483 ** Function BTA_JvIsEnable 484 ** 485 ** Description Get the JV registration status. 486 ** 487 ** Returns 1, if registered 488 ** 489 *******************************************************************************/ 490 extern BOOLEAN BTA_JvIsEnable(void); 491 492 /******************************************************************************* 493 ** 494 ** Function BTA_JvIsEncrypted 495 ** 496 ** Description This function checks if the link to peer device is encrypted 497 ** 498 ** Returns 1 if encrypted. 499 ** 0 if not. 500 ** 501 *******************************************************************************/ 502 extern BOOLEAN BTA_JvIsEncrypted(BD_ADDR bd_addr); 503 504 /******************************************************************************* 505 ** 506 ** Function BTA_JvGetChannelId 507 ** 508 ** Description This function reserves a SCN/PSM for applications running 509 ** over RFCOMM or L2CAP. It is primarily called by 510 ** server profiles/applications to register their SCN/PSM into the 511 ** SDP database. The SCN is reported by the tBTA_JV_DM_CBACK 512 ** callback with a BTA_JV_GET_SCN_EVT. 513 ** If the SCN/PSM reported is 0, that means all SCN resources are 514 ** exhausted. 515 ** The channel parameter can be used to request a specific 516 ** channel. If the request on the specific channel fails, the 517 ** SCN/PSM returned in the EVT will be 0 - no attempt to request 518 ** a new channel will be made. set channel to <= 0 to automatically 519 ** assign an channel ID. 520 ** 521 ** Returns BTA_JV_SUCCESS, if the request is being processed. 522 ** BTA_JV_FAILURE, otherwise. 523 ** 524 *******************************************************************************/ 525 extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, 526 INT32 channel); 527 528 /******************************************************************************* 529 ** 530 ** Function BTA_JvFreeChannel 531 ** 532 ** Description This function frees a SCN/PSM that was used 533 ** by an application running over RFCOMM or L2CAP. 534 ** Parameters 535 ** channel The channel to free 536 ** conn_type one of BTA_JV_CONN_TYPE_ 537 ** p_cback tBTA_JV_RFCOMM_CBACK is called with BTA_JV_FREE_SCN_EVT when server frees a SCN/PSM 538 ** user_data indicate the RFCOMM server status 539 ** 540 ** Returns BTA_JV_SUCCESS, if the request is being processed. 541 ** BTA_JV_FAILURE, otherwise. 542 ** 543 *******************************************************************************/ 544 extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); 545 546 /******************************************************************************* 547 ** 548 ** Function BTA_JvStartDiscovery 549 ** 550 ** Description This function performs service discovery for the services 551 ** provided by the given peer device. When the operation is 552 ** complete the tBTA_JV_DM_CBACK callback function will be 553 ** called with a BTA_JV_DISCOVERY_COMP_EVT. 554 ** 555 ** Returns BTA_JV_SUCCESS, if the request is being processed. 556 ** BTA_JV_FAILURE, otherwise. 557 ** 558 *******************************************************************************/ 559 extern tBTA_JV_STATUS BTA_JvStartDiscovery(BD_ADDR bd_addr, UINT16 num_uuid, 560 tSDP_UUID *p_uuid_list, void *user_data); 561 562 /******************************************************************************* 563 ** 564 ** Function BTA_JvCreateRecordByUser 565 ** 566 ** Description Create a service record in the local SDP database by user in 567 ** tBTA_JV_DM_CBACK callback with a BTA_JV_CREATE_RECORD_EVT. 568 ** 569 ** Returns BTA_JV_SUCCESS, if the request is being processed. 570 ** BTA_JV_FAILURE, otherwise. 571 ** 572 *******************************************************************************/ 573 extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel, void *user_data); 574 575 /******************************************************************************* 576 ** 577 ** Function BTA_JvDeleteRecord 578 ** 579 ** Description Delete a service record in the local SDP database. 580 ** 581 ** Returns BTA_JV_SUCCESS, if the request is being processed. 582 ** BTA_JV_FAILURE, otherwise. 583 ** 584 *******************************************************************************/ 585 extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle); 586 587 #if BTA_JV_L2CAP_INCLUDED 588 /******************************************************************************* 589 ** 590 ** Function BTA_JvL2capConnectLE 591 ** 592 ** Description Initiate a connection as an LE L2CAP client to the given BD 593 ** Address. 594 ** When the connection is initiated or failed to initiate, 595 ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT 596 ** When the connection is established or failed, 597 ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT 598 ** 599 ** Returns BTA_JV_SUCCESS, if the request is being processed. 600 ** BTA_JV_FAILURE, otherwise. 601 ** 602 *******************************************************************************/ 603 extern tBTA_JV_STATUS BTA_JvL2capConnectLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 604 const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_chan, 605 UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, 606 BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); 607 608 /******************************************************************************* 609 ** 610 ** Function BTA_JvL2capConnect 611 ** 612 ** Description Initiate a connection as a L2CAP client to the given BD 613 ** Address. 614 ** When the connection is initiated or failed to initiate, 615 ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_CL_INIT_EVT 616 ** When the connection is established or failed, 617 ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT 618 ** 619 ** Returns BTA_JV_SUCCESS, if the request is being processed. 620 ** BTA_JV_FAILURE, otherwise. 621 ** 622 *******************************************************************************/ 623 extern tBTA_JV_STATUS BTA_JvL2capConnect(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 624 const tL2CAP_ERTM_INFO *ertm_info, UINT16 remote_psm, 625 UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, 626 BD_ADDR peer_bd_addr, tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); 627 628 /******************************************************************************* 629 ** 630 ** Function BTA_JvL2capClose 631 ** 632 ** Description This function closes an L2CAP client connection 633 ** 634 ** Returns BTA_JV_SUCCESS, if the request is being processed. 635 ** BTA_JV_FAILURE, otherwise. 636 ** 637 *******************************************************************************/ 638 extern tBTA_JV_STATUS BTA_JvL2capClose(UINT32 handle); 639 640 /******************************************************************************* 641 ** 642 ** Function BTA_JvL2capCloseLE 643 ** 644 ** Description This function closes an L2CAP client connection for Fixed Channels 645 ** Function is idempotent and no callbacks are called! 646 ** 647 ** Returns BTA_JV_SUCCESS, if the request is being processed. 648 ** BTA_JV_FAILURE, otherwise. 649 ** 650 *******************************************************************************/ 651 extern tBTA_JV_STATUS BTA_JvL2capCloseLE(UINT32 handle); 652 653 /******************************************************************************* 654 ** 655 ** Function BTA_JvL2capStartServer 656 ** 657 ** Description This function starts an L2CAP server and listens for an L2CAP 658 ** connection from a remote Bluetooth device. When the server 659 ** is started successfully, tBTA_JV_L2CAP_CBACK is called with 660 ** BTA_JV_L2CAP_START_EVT. When the connection is established, 661 ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT. 662 ** 663 ** Returns BTA_JV_SUCCESS, if the request is being processed. 664 ** BTA_JV_FAILURE, otherwise. 665 ** 666 *******************************************************************************/ 667 extern tBTA_JV_STATUS BTA_JvL2capStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 668 const tL2CAP_ERTM_INFO *ertm_info, 669 UINT16 local_psm, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, 670 tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); 671 672 /******************************************************************************* 673 ** 674 ** Function BTA_JvL2capStartServerLE 675 ** 676 ** Description This function starts an LE L2CAP server and listens for an L2CAP 677 ** connection from a remote Bluetooth device on a fixed channel 678 ** over an LE link. When the server 679 ** is started successfully, tBTA_JV_L2CAP_CBACK is called with 680 ** BTA_JV_L2CAP_START_EVT. When the connection is established, 681 ** tBTA_JV_L2CAP_CBACK is called with BTA_JV_L2CAP_OPEN_EVT. 682 ** 683 ** Returns BTA_JV_SUCCESS, if the request is being processed. 684 ** BTA_JV_FAILURE, otherwise. 685 ** 686 *******************************************************************************/ 687 extern tBTA_JV_STATUS BTA_JvL2capStartServerLE(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 688 const tL2CAP_ERTM_INFO *ertm_info, 689 UINT16 local_chan, UINT16 rx_mtu, tL2CAP_CFG_INFO *cfg, 690 tBTA_JV_L2CAP_CBACK *p_cback, void *user_data); 691 692 /******************************************************************************* 693 ** 694 ** Function BTA_JvL2capStopServerLE 695 ** 696 ** Description This function stops the LE L2CAP server. If the server has an 697 ** active connection, it would be closed. 698 ** 699 ** Returns BTA_JV_SUCCESS, if the request is being processed. 700 ** BTA_JV_FAILURE, otherwise. 701 ** 702 *******************************************************************************/ 703 extern tBTA_JV_STATUS BTA_JvL2capStopServerLE(UINT16 local_chan, void *user_data); 704 705 /******************************************************************************* 706 ** 707 ** Function BTA_JvL2capStopServerLE 708 ** 709 ** Description This function stops the LE L2CAP server. If the server has an 710 ** active connection, it would be closed. 711 ** 712 ** Returns BTA_JV_SUCCESS, if the request is being processed. 713 ** BTA_JV_FAILURE, otherwise. 714 ** 715 *******************************************************************************/ 716 extern tBTA_JV_STATUS BTA_JvL2capStopServer(UINT16 local_psm, void *user_data); 717 718 /******************************************************************************* 719 ** 720 ** Function BTA_JvL2capRead 721 ** 722 ** Description This function reads data from an L2CAP connection 723 ** When the operation is complete, tBTA_JV_L2CAP_CBACK is 724 ** called with BTA_JV_L2CAP_READ_EVT. 725 ** 726 ** Returns BTA_JV_SUCCESS, if the request is being processed. 727 ** BTA_JV_FAILURE, otherwise. 728 ** 729 *******************************************************************************/ 730 extern tBTA_JV_STATUS BTA_JvL2capRead(UINT32 handle, UINT32 req_id, 731 UINT8 *p_data, UINT16 len); 732 733 /******************************************************************************* 734 ** 735 ** Function BTA_JvL2capReceive 736 ** 737 ** Description This function reads data from an L2CAP connection 738 ** When the operation is complete, tBTA_JV_L2CAP_CBACK is 739 ** called with BTA_JV_L2CAP_RECEIVE_EVT. 740 ** If there are more data queued in L2CAP than len, the extra data will be discarded. 741 ** 742 ** Returns BTA_JV_SUCCESS, if the request is being processed. 743 ** BTA_JV_FAILURE, otherwise. 744 ** 745 *******************************************************************************/ 746 extern tBTA_JV_STATUS BTA_JvL2capReceive(UINT32 handle, UINT32 req_id, 747 UINT8 *p_data, UINT16 len); 748 749 /******************************************************************************* 750 ** 751 ** Function BTA_JvL2capReady 752 ** 753 ** Description This function determined if there is data to read from 754 ** an L2CAP connection 755 ** 756 ** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size. 757 ** BTA_JV_FAILURE, if error. 758 ** 759 *******************************************************************************/ 760 extern tBTA_JV_STATUS BTA_JvL2capReady(UINT32 handle, UINT32 *p_data_size); 761 762 /******************************************************************************* 763 ** 764 ** Function BTA_JvL2capWrite 765 ** 766 ** Description This function writes data to an L2CAP connection 767 ** When the operation is complete, tBTA_JV_L2CAP_CBACK is 768 ** called with BTA_JV_L2CAP_WRITE_EVT. Works for 769 ** PSM-based connections 770 ** 771 ** Returns BTA_JV_SUCCESS, if the request is being processed. 772 ** BTA_JV_FAILURE, otherwise. 773 ** 774 *******************************************************************************/ 775 extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id, 776 UINT8 *p_data, UINT16 len, void *user_data); 777 778 779 /******************************************************************************* 780 ** 781 ** Function BTA_JvL2capWriteFixed 782 ** 783 ** Description This function writes data to an L2CAP connection 784 ** When the operation is complete, tBTA_JV_L2CAP_CBACK is 785 ** called with BTA_JV_L2CAP_WRITE_FIXED_EVT. Works for 786 ** fixed-channel connections 787 ** 788 ** Returns BTA_JV_SUCCESS, if the request is being processed. 789 ** BTA_JV_FAILURE, otherwise. 790 ** 791 *******************************************************************************/ 792 extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id, 793 tBTA_JV_L2CAP_CBACK *p_cback, 794 UINT8 *p_data, UINT16 len, void *user_data); 795 #endif /* BTA_JV_L2CAP_INCLUDED */ 796 797 /******************************************************************************* 798 ** 799 ** Function BTA_JvRfcommConnect 800 ** 801 ** Description This function makes an RFCOMM conection to a remote BD 802 ** Address. 803 ** When the connection is initiated or failed to initiate, 804 ** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CL_INIT_EVT 805 ** When the connection is established or failed, 806 ** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_OPEN_EVT 807 ** 808 ** Returns BTA_JV_SUCCESS, if the request is being processed. 809 ** BTA_JV_FAILURE, otherwise. 810 ** 811 *******************************************************************************/ 812 extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask, 813 tBTA_JV_ROLE role, UINT8 remote_scn, BD_ADDR peer_bd_addr, 814 tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); 815 816 /******************************************************************************* 817 ** 818 ** Function BTA_JvRfcommClose 819 ** 820 ** Description This function closes an RFCOMM connection 821 ** 822 ** Returns BTA_JV_SUCCESS, if the request is being processed. 823 ** BTA_JV_FAILURE, otherwise. 824 ** 825 *******************************************************************************/ 826 extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); 827 828 /******************************************************************************* 829 ** 830 ** Function BTA_JvRfcommStartServer 831 ** 832 ** Description This function starts listening for an RFCOMM connection 833 ** request from a remote Bluetooth device. When the server is 834 ** started successfully, tBTA_JV_RFCOMM_CBACK is called 835 ** with BTA_JV_RFCOMM_START_EVT. 836 ** When the connection is established, tBTA_JV_RFCOMM_CBACK 837 ** is called with BTA_JV_RFCOMM_OPEN_EVT. 838 ** 839 ** Returns BTA_JV_SUCCESS, if the request is being processed. 840 ** BTA_JV_FAILURE, otherwise. 841 ** 842 *******************************************************************************/ 843 extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role, 844 UINT8 local_scn, UINT8 max_session, 845 tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data); 846 847 /******************************************************************************* 848 ** 849 ** Function BTA_JvRfcommStopServer 850 ** 851 ** Description This function stops the RFCOMM server. If the server has an 852 ** active connection, it would be closed. 853 ** 854 ** Returns BTA_JV_SUCCESS, if the request is being processed. 855 ** BTA_JV_FAILURE, otherwise. 856 ** 857 *******************************************************************************/ 858 extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data); 859 860 /******************************************************************************* 861 ** 862 ** Function BTA_JvRfcommRead 863 ** 864 ** Description This function reads data from an RFCOMM connection 865 ** When the operation is complete, tBTA_JV_RFCOMM_CBACK is 866 ** called with BTA_JV_RFCOMM_READ_EVT. 867 ** 868 ** Returns BTA_JV_SUCCESS, if the request is being processed. 869 ** BTA_JV_FAILURE, otherwise. 870 ** 871 *******************************************************************************/ 872 extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len); 873 874 /******************************************************************************* 875 ** 876 ** Function BTA_JvRfcommReady 877 ** 878 ** Description This function determined if there is data to read from 879 ** an RFCOMM connection 880 ** 881 ** Returns BTA_JV_SUCCESS, if data queue size is in *p_data_size. 882 ** BTA_JV_FAILURE, if error. 883 ** 884 *******************************************************************************/ 885 extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size); 886 887 /******************************************************************************* 888 ** 889 ** Function BTA_JvRfcommWrite 890 ** 891 ** Description This function writes data to an RFCOMM connection 892 ** When the operation is complete, tBTA_JV_RFCOMM_CBACK is 893 ** called with BTA_JV_RFCOMM_WRITE_EVT. 894 ** 895 ** Returns BTA_JV_SUCCESS, if the request is being processed. 896 ** BTA_JV_FAILURE, otherwise. 897 ** 898 *******************************************************************************/ 899 extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data); 900 901 /******************************************************************************* 902 ** 903 ** Function BTA_JvRfcommFlowControl 904 ** 905 ** Description This function gives the credit to the peer 906 ** 907 ** Returns BTA_JV_SUCCESS, if the request is being processed. 908 ** BTA_JV_FAILURE, otherwise. 909 ** 910 *******************************************************************************/ 911 extern tBTA_JV_STATUS BTA_JvRfcommFlowControl(UINT32 handle, UINT16 credits_given); 912 913 /******************************************************************************* 914 ** 915 ** Function BTA_JVSetPmProfile 916 ** 917 ** Description This function set or free power mode profile for different JV application 918 ** 919 ** Parameters: handle, JV handle from RFCOMM or L2CAP 920 ** app_id: app specific pm ID, can be BTA_JV_PM_ALL, see bta_dm_cfg.c for details 921 ** BTA_JV_PM_ID_CLEAR: removes pm management on the handle. init_st is ignored and 922 ** BTA_JV_CONN_CLOSE is called implicitely 923 ** init_st: state after calling this API. typically it should be BTA_JV_CONN_OPEN 924 ** 925 ** Returns BTA_JV_SUCCESS, if the request is being processed. 926 ** BTA_JV_FAILURE, otherwise. 927 ** 928 ** NOTE: BTA_JV_PM_ID_CLEAR: In general no need to be called as jv pm calls automatically 929 ** BTA_JV_CONN_CLOSE to remove in case of connection close! 930 ** 931 *******************************************************************************/ 932 extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st); 933 934 /******************************************************************************* 935 ** 936 ** Function BTA_JvRfcommGetPortHdl 937 ** 938 ** Description This function fetches the rfcomm port handle 939 ** 940 ** Returns BTA_JV_SUCCESS, if the request is being processed. 941 ** BTA_JV_FAILURE, otherwise. 942 ** 943 *******************************************************************************/ 944 UINT16 BTA_JvRfcommGetPortHdl(UINT32 handle); 945 946 #endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == 1 947 #endif /* BTA_JV_API_H */ 948