1 /****************************************************************************** 2 * 3 * Copyright (C) 2003-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 private file for the file transfer client (FTC). 22 * 23 ******************************************************************************/ 24 #ifndef BTA_GATTC_INT_H 25 #define BTA_GATTC_INT_H 26 27 #include "common/bt_target.h" 28 #include "bta/bta_sys.h" 29 #include "bta/bta_gatt_api.h" 30 #include "bta/bta_gattc_ci.h" 31 #include "bta/bta_gattc_co.h" 32 #include "osi/fixed_queue.h" 33 #include "osi/mutex.h" 34 35 /***************************************************************************** 36 ** Constants and data types 37 *****************************************************************************/ 38 enum { 39 BTA_GATTC_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_GATTC), 40 BTA_GATTC_INT_OPEN_FAIL_EVT, 41 BTA_GATTC_API_CANCEL_OPEN_EVT, 42 BTA_GATTC_INT_CANCEL_OPEN_OK_EVT, 43 44 BTA_GATTC_API_READ_EVT, 45 BTA_GATTC_API_WRITE_EVT, 46 BTA_GATTC_API_EXEC_EVT, 47 BTA_GATTC_API_CFG_MTU_EVT, 48 49 BTA_GATTC_API_CLOSE_EVT, 50 51 BTA_GATTC_API_SEARCH_EVT, 52 BTA_GATTC_API_CONFIRM_EVT, 53 BTA_GATTC_API_READ_MULTI_EVT, 54 BTA_GATTC_API_REFRESH_EVT, 55 BTA_GATTC_API_CACHE_CLEAN_EVT, 56 57 BTA_GATTC_INT_CONN_EVT, 58 BTA_GATTC_INT_DISCOVER_EVT, 59 BTA_GATTC_DISCOVER_CMPL_EVT, 60 BTA_GATTC_OP_CMPL_EVT, 61 BTA_GATTC_INT_DISCONN_EVT, 62 63 BTA_GATTC_API_READ_BY_TYPE_EVT, 64 BTA_GATTC_API_READ_MULTI_VAR_EVT, 65 66 BTA_GATTC_INT_START_IF_EVT, 67 BTA_GATTC_API_REG_EVT, 68 BTA_GATTC_API_DEREG_EVT, 69 BTA_GATTC_API_LISTEN_EVT, 70 BTA_GATTC_API_BROADCAST_EVT, 71 BTA_GATTC_API_DISABLE_EVT, 72 BTA_GATTC_ENC_CMPL_EVT, 73 BTA_GATTC_API_CACHE_ASSOC_EVT, 74 BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT, 75 }; 76 typedef UINT16 tBTA_GATTC_INT_EVT; 77 78 #define BTA_GATTC_SERVICE_CHANGED_LEN 4 79 80 typedef enum { 81 BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE = 0, 82 BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH = 1, 83 BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN = 2, 84 } tBTA_SERVICE_SOURCE_t; 85 86 /* max client application GATTC can support */ 87 #ifndef BTA_GATTC_CL_MAX 88 #if (GATT_MAX_PHY_CHANNEL > 3) 89 #define BTA_GATTC_CL_MAX GATT_MAX_PHY_CHANNEL 90 #else 91 #define BTA_GATTC_CL_MAX 3 // The origin value is 10 92 #endif 93 #endif 94 95 /* max known devices GATTC can support */ 96 #ifndef BTA_GATTC_KNOWN_SR_MAX 97 #if (GATT_MAX_PHY_CHANNEL > 3) 98 #define BTA_GATTC_KNOWN_SR_MAX GATT_MAX_PHY_CHANNEL 99 #else 100 #define BTA_GATTC_KNOWN_SR_MAX 3 // The origin value is 10 101 #endif 102 #endif 103 104 #define BTA_GATTC_CONN_MAX GATT_MAX_PHY_CHANNEL 105 106 #ifndef BTA_GATTC_CLCB_MAX 107 #define BTA_GATTC_CLCB_MAX GATT_CL_MAX_LCB 108 #endif 109 110 #define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE 111 #define BTA_GATTC_INVALID_HANDLE 0 112 113 /* internal structure for GATTC register API */ 114 typedef struct { 115 BT_HDR hdr; 116 tBT_UUID app_uuid; 117 tBTA_GATTC_CBACK *p_cback; 118 } tBTA_GATTC_API_REG; 119 120 typedef struct { 121 BT_HDR hdr; 122 tBTA_GATTC_IF client_if; 123 } tBTA_GATTC_INT_START_IF; 124 125 typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG; 126 typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG; 127 128 typedef struct { 129 BT_HDR hdr; 130 BD_ADDR remote_bda; 131 tBTA_ADDR_TYPE remote_addr_type; 132 tBTA_GATTC_IF client_if; 133 BOOLEAN is_direct; 134 BOOLEAN is_aux; 135 tBTA_TRANSPORT transport; 136 tBTA_ADDR_TYPE own_addr_type; 137 UINT8 phy_mask; 138 tBTA_BLE_CONN_PARAMS phy_1m_conn_params; 139 tBTA_BLE_CONN_PARAMS phy_2m_conn_params; 140 tBTA_BLE_CONN_PARAMS phy_coded_conn_params; 141 } tBTA_GATTC_API_OPEN; 142 143 typedef struct { 144 BT_HDR hdr; 145 BD_ADDR remote_bda; 146 tBTA_ADDR_TYPE remote_addr_type; 147 tBTA_GATTC_IF client_if; 148 BOOLEAN is_direct; 149 } tBTA_GATTC_API_CANCEL_OPEN; 150 151 typedef struct { 152 BT_HDR hdr; 153 tBTA_GATT_AUTH_REQ auth_req; 154 UINT16 handle; 155 UINT16 s_handle; 156 UINT16 e_handle; 157 tBT_UUID uuid; 158 tBTA_GATTC_EVT cmpl_evt; 159 } tBTA_GATTC_API_READ; 160 161 typedef struct { 162 BT_HDR hdr; 163 tBTA_GATT_AUTH_REQ auth_req; 164 UINT16 handle; 165 tBTA_GATTC_EVT cmpl_evt; 166 tBTA_GATTC_WRITE_TYPE write_type; 167 UINT16 offset; 168 UINT16 len; 169 UINT8 *p_value; 170 } tBTA_GATTC_API_WRITE; 171 172 typedef struct { 173 BT_HDR hdr; 174 BOOLEAN is_execute; 175 } tBTA_GATTC_API_EXEC; 176 177 typedef struct { 178 BT_HDR hdr; 179 UINT16 handle; 180 } tBTA_GATTC_API_CONFIRM; 181 182 typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL; 183 184 typedef struct { 185 BT_HDR hdr; 186 UINT8 op_code; 187 tGATT_STATUS status; 188 tBTA_GATTC_CMPL *p_cmpl; 189 } tBTA_GATTC_OP_CMPL; 190 191 typedef struct { 192 BT_HDR hdr; 193 tBT_UUID *p_srvc_uuid; 194 } tBTA_GATTC_API_SEARCH; 195 196 typedef struct { 197 BT_HDR hdr; 198 tBTA_GATT_AUTH_REQ auth_req; 199 UINT8 num_attr; 200 UINT16 handles[GATT_MAX_READ_MULTI_HANDLES]; 201 tBTA_GATTC_EVT cmpl_evt; 202 }tBTA_GATTC_API_READ_MULTI; 203 204 typedef struct { 205 BT_HDR hdr; 206 BD_ADDR_PTR remote_bda; 207 tBTA_GATTC_IF client_if; 208 BOOLEAN start; 209 } tBTA_GATTC_API_LISTEN; 210 211 212 typedef struct { 213 BT_HDR hdr; 214 } tBTA_GATTC_API_CFG_MTU; 215 216 typedef struct { 217 BT_HDR hdr; 218 BD_ADDR remote_bda; 219 } tBTA_GATTC_API_CACHE_REFRESH; 220 221 typedef struct { 222 BT_HDR hdr; 223 tBTA_GATTC_IF client_if; 224 BD_ADDR src_addr; 225 BD_ADDR assoc_addr; 226 BOOLEAN is_assoc; 227 } tBTA_GATTC_API_CACHE_ASSOC; 228 229 typedef struct { 230 BT_HDR hdr; 231 tBTA_GATTC_IF client_if; 232 } tBTA_GATTC_API_GET_ADDR; 233 234 typedef struct { 235 BT_HDR hdr; 236 BD_ADDR remote_bda; 237 } tBTA_GATTC_API_CACHE_CLEAN; 238 239 typedef struct { 240 BT_HDR hdr; 241 BD_ADDR remote_bda; 242 tBTA_GATTC_IF client_if; 243 UINT8 role; 244 tBT_TRANSPORT transport; 245 tGATT_DISCONN_REASON reason; 246 BOOLEAN already_connect; 247 tBTA_GATT_CONN_PARAMS conn_params; 248 UINT8 ble_addr_type; 249 UINT16 conn_handle; 250 } tBTA_GATTC_INT_CONN; 251 252 typedef struct { 253 BT_HDR hdr; 254 BD_ADDR remote_bda; 255 tBTA_GATTC_IF client_if; 256 } tBTA_GATTC_ENC_CMPL; 257 258 typedef union { 259 BT_HDR hdr; 260 tBTA_GATTC_API_REG api_reg; 261 tBTA_GATTC_API_DEREG api_dereg; 262 tBTA_GATTC_API_OPEN api_conn; 263 tBTA_GATTC_API_CANCEL_OPEN api_cancel_conn; 264 tBTA_GATTC_API_READ api_read; 265 tBTA_GATTC_API_SEARCH api_search; 266 tBTA_GATTC_API_WRITE api_write; 267 tBTA_GATTC_API_CONFIRM api_confirm; 268 tBTA_GATTC_API_EXEC api_exec; 269 tBTA_GATTC_API_READ_MULTI api_read_multi; 270 tBTA_GATTC_API_CFG_MTU api_mtu; 271 tBTA_GATTC_API_CACHE_REFRESH api_refresh; 272 tBTA_GATTC_API_CACHE_ASSOC api_assoc; 273 tBTA_GATTC_API_GET_ADDR api_get_addr; 274 tBTA_GATTC_API_CACHE_CLEAN api_clean; 275 tBTA_GATTC_OP_CMPL op_cmpl; 276 tBTA_GATTC_INT_CONN int_conn; 277 tBTA_GATTC_ENC_CMPL enc_cmpl; 278 279 tBTA_GATTC_INT_START_IF int_start_if; 280 tBTA_GATTC_INT_DEREG int_dereg; 281 /* if peripheral role is supported */ 282 tBTA_GATTC_API_LISTEN api_listen; 283 284 } tBTA_GATTC_DATA; 285 286 287 /* GATT server cache on the client */ 288 typedef struct { 289 tBT_UUID uuid; 290 UINT16 s_handle; 291 UINT16 e_handle; 292 // this field is set only for characteristic 293 UINT16 char_decl_handle; 294 BOOLEAN is_primary; 295 tBTA_GATT_CHAR_PROP property; 296 } tBTA_GATTC_ATTR_REC; 297 298 299 #define BTA_GATTC_ATTR_LIST_SIZE (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC)) 300 301 #ifndef BTA_GATTC_CACHE_SRVR_SIZE 302 #define BTA_GATTC_CACHE_SRVR_SIZE 600 303 #endif 304 305 enum { 306 BTA_GATTC_IDLE_ST = 0, /* Idle */ 307 BTA_GATTC_W4_CONN_ST, /* Wait for connection - (optional) */ 308 BTA_GATTC_CONN_ST, /* connected state */ 309 BTA_GATTC_DISCOVER_ST /* discover is in progress */ 310 }; 311 typedef UINT8 tBTA_GATTC_STATE; 312 313 typedef struct { 314 BOOLEAN in_use; 315 BD_ADDR server_bda; 316 BOOLEAN connected; 317 318 #define BTA_GATTC_SERV_IDLE 0 319 #define BTA_GATTC_SERV_LOAD 1 320 #define BTA_GATTC_SERV_SAVE 2 321 #define BTA_GATTC_SERV_DISC 3 322 #define BTA_GATTC_SERV_DISC_ACT 4 323 324 UINT8 state; 325 326 list_t *p_srvc_cache; /* list of tBTA_GATTC_SERVICE */ 327 UINT8 update_count; /* indication received */ 328 UINT8 num_clcb; /* number of associated CLCB */ 329 330 331 tBTA_GATTC_ATTR_REC *p_srvc_list; 332 UINT8 cur_srvc_idx; 333 UINT16 cur_char_idx; 334 UINT16 next_avail_idx; 335 UINT8 total_srvc; 336 UINT16 total_char; 337 UINT16 total_attr; 338 UINT8 srvc_hdl_chg; /* service handle change indication pending */ 339 UINT16 attr_index; /* cache NV saving/loading attribute index */ 340 341 UINT16 mtu; 342 bool update_incl_srvc; 343 } tBTA_GATTC_SERV; 344 345 typedef struct { 346 BOOLEAN in_use; 347 BD_ADDR remote_bda; 348 UINT16 handle; 349 }tBTA_GATTC_NOTIF_REG; 350 351 typedef struct { 352 tBTA_GATTC_CBACK *p_cback; 353 BOOLEAN in_use; 354 tBTA_GATTC_IF client_if; /* client interface with BTE stack for this application */ 355 UINT8 num_clcb; /* number of associated CLCB */ 356 BOOLEAN dereg_pending; 357 tBT_UUID app_uuid; 358 tBTA_GATTC_NOTIF_REG notif_reg[BTA_GATTC_NOTIF_REG_MAX]; 359 } tBTA_GATTC_RCB; 360 361 /* client channel is a mapping between a BTA client(cl_id) and a remote BD address */ 362 typedef struct { 363 UINT16 bta_conn_id; /* client channel ID, unique for clcb */ 364 BD_ADDR bda; 365 tBTA_TRANSPORT transport; /* channel transport */ 366 tBTA_GATTC_RCB *p_rcb; /* pointer to the registration CB */ 367 tBTA_GATTC_SERV *p_srcb; /* server cache CB */ 368 tBTA_GATTC_DATA *p_q_cmd; /* command in queue waiting for execution */ 369 list_t *p_cmd_list; /* The list to store the command to be sent */ 370 BOOLEAN is_full; /* The gattc command queue is full or not */ 371 #define BTA_GATTC_NO_SCHEDULE 0 372 #define BTA_GATTC_DISC_WAITING 0x01 373 #define BTA_GATTC_REQ_WAITING 0x10 374 375 UINT8 auto_update; /* auto update is waiting */ 376 BOOLEAN disc_active; 377 BOOLEAN in_use; 378 tBTA_GATTC_STATE state; 379 tBTA_GATT_STATUS status; 380 UINT16 reason; 381 UINT8 searched_service_source; 382 } tBTA_GATTC_CLCB; 383 384 /* background connection tracking information */ 385 #if GATT_MAX_APPS <= 8 386 typedef UINT8 tBTA_GATTC_CIF_MASK ; 387 #elif GATT_MAX_APPS <= 16 388 typedef UINT16 tBTA_GATTC_CIF_MASK; 389 #elif GATT_MAX_APPS <= 32 390 typedef UINT32 tBTA_GATTC_CIF_MASK; 391 #endif 392 393 typedef struct { 394 BOOLEAN in_use; 395 BD_ADDR remote_bda; 396 tBTA_GATTC_CIF_MASK cif_mask; 397 tBTA_GATTC_CIF_MASK cif_adv_mask; 398 399 } tBTA_GATTC_BG_TCK; 400 401 typedef struct { 402 BOOLEAN in_use; 403 BD_ADDR remote_bda; 404 UINT16 svc_change_descr_handle; 405 BOOLEAN write_remote_svc_change_ccc_done; 406 } tBTA_GATTC_CONN; 407 408 enum { 409 BTA_GATTC_STATE_DISABLED, 410 BTA_GATTC_STATE_ENABLING, 411 BTA_GATTC_STATE_ENABLED, 412 BTA_GATTC_STATE_DISABLING 413 }; 414 415 typedef struct { 416 UINT8 state; 417 BOOLEAN auto_disc; /* internal use: true for auto discovering after connected */ 418 tBTA_GATTC_CONN conn_track[BTA_GATTC_CONN_MAX]; 419 tBTA_GATTC_BG_TCK bg_track[BTA_GATTC_KNOWN_SR_MAX]; 420 tBTA_GATTC_RCB cl_rcb[BTA_GATTC_CL_MAX]; 421 422 tBTA_GATTC_CLCB clcb[BTA_GATTC_CLCB_MAX]; 423 tBTA_GATTC_SERV known_server[BTA_GATTC_KNOWN_SR_MAX]; 424 }tBTA_GATTC_CB; 425 426 typedef enum { 427 SERVICE_CHANGE_CCC_WRITTEN_SUCCESS = 0, 428 SERVICE_CHANGE_CACHE_NOT_FOUND, 429 SERVICE_CHANGE_SERVICE_NOT_FOUND, 430 SERVICE_CHANGE_CHAR_NOT_FOUND, 431 SERVICE_CHANGE_CCC_NOT_FOUND, 432 SERVICE_CHANGE_WRITE_CCC_FAILED 433 }tBTA_GATTC_FIND_SERVICE_CB; 434 435 436 /***************************************************************************** 437 ** Global data 438 *****************************************************************************/ 439 440 /* GATTC control block */ 441 #if BTA_DYNAMIC_MEMORY == FALSE 442 extern tBTA_GATTC_CB bta_gattc_cb; 443 #else 444 extern tBTA_GATTC_CB *bta_gattc_cb_ptr; 445 #define bta_gattc_cb (*bta_gattc_cb_ptr) 446 #endif 447 448 /***************************************************************************** 449 ** Function prototypes 450 *****************************************************************************/ 451 extern BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg); 452 extern BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data); 453 454 /* function processed outside SM */ 455 extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb); 456 extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data); 457 extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data); 458 extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 459 extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 460 extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB *p_clreg); 461 extern void bta_gattc_process_enc_cmpl(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 462 463 /* function within state machine */ 464 extern void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 465 extern void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 466 extern void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 467 468 extern void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 469 extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 470 extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 471 472 extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 473 extern void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data); 474 extern void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data); 475 extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 476 extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 477 extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 478 479 extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 480 extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 481 extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 482 extern void bta_gattc_read_by_type(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 483 extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 484 extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 485 extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 486 extern void bta_gattc_free_command_data(tBTA_GATTC_CLCB *p_clcb); 487 extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 488 extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 489 extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 490 extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 491 extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 492 extern void bta_gattc_read_multi_var(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 493 extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 494 extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 495 extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 496 extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_msg); 497 extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg); 498 extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data); 499 extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status, 500 BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu); 501 extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, 502 tBTA_GATT_CONN_PARAMS conn_params, UINT8 link_role, UINT8 ble_addr_type, UINT16 conn_handle); 503 extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason, 504 BD_ADDR remote_bda, UINT16 conn_id); 505 extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 506 extern void bta_gattc_process_api_cache_clean(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 507 extern void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 508 extern void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 509 extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 510 #if BLE_INCLUDED == TRUE 511 extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 512 extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg); 513 #endif 514 /* utility functions */ 515 extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport); 516 extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_conn_id (UINT16 conn_id); 517 extern tBTA_GATTC_CLCB *bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport); 518 extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb); 519 extern tBTA_GATTC_CLCB *bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport); 520 extern tBTA_GATTC_RCB *bta_gattc_cl_get_regcb(UINT8 client_if); 521 extern tBTA_GATTC_SERV *bta_gattc_find_srcb(BD_ADDR bda); 522 extern tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda); 523 extern tBTA_GATTC_SERV *bta_gattc_find_scb_by_cid (UINT16 conn_id); 524 extern tBTA_GATTC_CLCB *bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg); 525 extern tBTA_GATTC_CLCB *bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg); 526 527 extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data); 528 529 extern BOOLEAN bta_gattc_uuid_compare (const tBT_UUID *p_src, const tBT_UUID *p_tar, BOOLEAN is_precise); 530 extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY *p_notify); 531 extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen); 532 extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, UINT8 role); 533 extern UINT8 bta_gattc_num_reg_app(void); 534 extern void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id, UINT16 start_handle, UINT16 end_handle); 535 extern void bta_gattc_clear_notif_registration_by_bda(tBTA_GATTC_RCB *p_clrcb, BD_ADDR remote_bda); 536 extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda); 537 538 /* discovery functions */ 539 extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data); 540 extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status); 541 extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type); 542 extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type); 543 extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid); 544 extern const list_t* bta_gattc_get_services(UINT16 conn_id); 545 extern const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle); 546 tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle); 547 extern tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle); 548 extern tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle); 549 extern void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, UINT16 *count); 550 extern void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute_type_t type, 551 UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, UINT16 *count); 552 extern void bta_gattc_get_service_with_uuid(UINT16 conn_id, tBT_UUID *svc_uuid, 553 btgatt_db_element_t **svc_db, 554 UINT16 *count); 555 556 extern void bta_gattc_get_db_with_opration(UINT16 conn_id, 557 bt_gatt_get_db_op_t op, 558 UINT16 char_handle, 559 tBT_UUID *incl_uuid, 560 tBT_UUID *char_uuid, 561 tBT_UUID *descr_uuid, 562 UINT16 start_handle, UINT16 end_handle, 563 btgatt_db_element_t **char_db, 564 UINT16 *count); 565 566 extern void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, UINT16 *count); 567 568 extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb); 569 extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *attr); 570 extern void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id); 571 extern void bta_gattc_reset_discover_st(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_STATUS status); 572 573 extern tBTA_GATTC_CONN *bta_gattc_conn_alloc(BD_ADDR remote_bda); 574 extern tBTA_GATTC_CONN *bta_gattc_conn_find(BD_ADDR remote_bda); 575 extern tBTA_GATTC_CONN *bta_gattc_conn_find_alloc(BD_ADDR remote_bda); 576 extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda); 577 578 extern bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb); 579 extern void bta_gattc_cache_reset(BD_ADDR server_bda); 580 extern void bta_gattc_deinit(void); 581 582 #endif /* BTA_GATTC_INT_H */ 583