bta_gattc_int.h 19.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
/******************************************************************************
 *
 *  Copyright (C) 2003-2012 Broadcom Corporation
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at:
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 *
 ******************************************************************************/

/******************************************************************************
 *
 *  This is the private file for the file transfer client (FTC).
 *
 ******************************************************************************/
#ifndef BTA_GATTC_INT_H
#define BTA_GATTC_INT_H

#include "bt_target.h"
#include "bta_sys.h"
#include "bta_gatt_api.h"
#include "bta_gattc_ci.h"
#include "bta_gattc_co.h"

#include "gki.h"

/*****************************************************************************
**  Constants and data types
*****************************************************************************/
enum
{
    BTA_GATTC_API_OPEN_EVT   = BTA_SYS_EVT_START(BTA_ID_GATTC),
    BTA_GATTC_INT_OPEN_FAIL_EVT,
    BTA_GATTC_API_CANCEL_OPEN_EVT,
    BTA_GATTC_INT_CANCEL_OPEN_OK_EVT,

    BTA_GATTC_API_READ_EVT,
    BTA_GATTC_API_WRITE_EVT,
    BTA_GATTC_API_EXEC_EVT,
48
    BTA_GATTC_API_CFG_MTU_EVT,
49 50 51 52 53 54

    BTA_GATTC_API_CLOSE_EVT,

    BTA_GATTC_API_SEARCH_EVT,
    BTA_GATTC_API_CONFIRM_EVT,
    BTA_GATTC_API_READ_MULTI_EVT,
55
    BTA_GATTC_API_REFRESH_EVT,
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71

    BTA_GATTC_INT_CONN_EVT,
    BTA_GATTC_INT_DISCOVER_EVT,
    BTA_GATTC_DISCOVER_CMPL_EVT,
    BTA_GATTC_OP_CMPL_EVT,
    BTA_GATTC_INT_DISCONN_EVT,

    /* for cache loading/saving */
    BTA_GATTC_START_CACHE_EVT,
    BTA_GATTC_CI_CACHE_OPEN_EVT,
    BTA_GATTC_CI_CACHE_LOAD_EVT,
    BTA_GATTC_CI_CACHE_SAVE_EVT,

    BTA_GATTC_INT_START_IF_EVT,
    BTA_GATTC_API_REG_EVT,
    BTA_GATTC_API_DEREG_EVT,
72
    BTA_GATTC_API_LISTEN_EVT,
73
    BTA_GATTC_API_BROADCAST_EVT,
74 75
    BTA_GATTC_API_DISABLE_EVT,
    BTA_GATTC_ENC_CMPL_EVT
76 77 78 79 80
};
typedef UINT16 tBTA_GATTC_INT_EVT;

/* max client application GATTC can support */
#ifndef     BTA_GATTC_CL_MAX
81
#define     BTA_GATTC_CL_MAX    32
82 83 84 85
#endif

/* max known devices GATTC can support */
#ifndef     BTA_GATTC_KNOWN_SR_MAX
86
#define     BTA_GATTC_KNOWN_SR_MAX    10
87 88
#endif

89 90
#define BTA_GATTC_CONN_MAX      GATT_MAX_PHY_CHANNEL

91 92 93 94 95 96
#ifndef BTA_GATTC_CLCB_MAX
    #define BTA_GATTC_CLCB_MAX      GATT_CL_MAX_LCB
#endif

#define BTA_GATTC_WRITE_PREPARE          GATT_WRITE_PREPARE

97

98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130
/* internal strucutre for GATTC register API  */
typedef struct
{
    BT_HDR                  hdr;
    tBT_UUID                app_uuid;
    tBTA_GATTC_CBACK        *p_cback;
}tBTA_GATTC_API_REG;

typedef struct
{
    BT_HDR                  hdr;
    tBTA_GATTC_IF           client_if;
}tBTA_GATTC_INT_START_IF;

typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;

typedef struct
{
    BT_HDR                  hdr;
    BD_ADDR                 remote_bda;
    tBTA_GATTC_IF           client_if;
    BOOLEAN                 is_direct;
} tBTA_GATTC_API_OPEN;

typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;

typedef struct
{
    BT_HDR                  hdr;
    tBTA_GATT_AUTH_REQ      auth_req;
    tBTA_GATT_SRVC_ID       srvc_id;
    tBTA_GATT_ID            char_id;
Andre Eisenbach's avatar
Andre Eisenbach committed
131
    tBTA_GATT_ID            *p_descr_type;
132 133 134 135 136 137 138 139
} tBTA_GATTC_API_READ;

typedef struct
{
    BT_HDR                  hdr;
    tBTA_GATT_AUTH_REQ      auth_req;
    tBTA_GATT_SRVC_ID       srvc_id;
    tBTA_GATT_ID            char_id;
Andre Eisenbach's avatar
Andre Eisenbach committed
140
    tBTA_GATT_ID            *p_descr_type;
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
    tBTA_GATTC_WRITE_TYPE   write_type;
    UINT16                  offset;
    UINT16                  len;
    UINT8                   *p_value;
}tBTA_GATTC_API_WRITE;

typedef struct
{
    BT_HDR                  hdr;
    BOOLEAN                 is_execute;
}tBTA_GATTC_API_EXEC;

typedef struct
{
    BT_HDR                  hdr;
    tBTA_GATT_SRVC_ID       srvc_id;
    tBTA_GATT_ID            char_id;
} tBTA_GATTC_API_CONFIRM;

typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;

typedef struct
{
    BT_HDR                  hdr;
    UINT8                   op_code;
    tGATT_STATUS            status;
    tBTA_GATTC_CMPL         *p_cmpl;
}tBTA_GATTC_OP_CMPL;

typedef struct
{
    BT_HDR              hdr;
Andre Eisenbach's avatar
Andre Eisenbach committed
173
    tBT_UUID            *p_srvc_uuid;
174 175 176 177 178 179 180 181 182 183
}tBTA_GATTC_API_SEARCH;

typedef struct
{
    BT_HDR                  hdr;
    tBTA_GATT_AUTH_REQ      auth_req;
    UINT8                   num_attr;
    tBTA_GATTC_ATTR_ID      *p_id_list;
}tBTA_GATTC_API_READ_MULTI;

184 185 186 187 188 189 190 191
typedef struct
{
    BT_HDR                  hdr;
    BD_ADDR_PTR             remote_bda;
    tBTA_GATTC_IF           client_if;
    BOOLEAN                 start;
} tBTA_GATTC_API_LISTEN;

192 193 194 195 196 197 198

typedef struct
{
    BT_HDR              hdr;
    UINT16              mtu;
}tBTA_GATTC_API_CFG_MTU;

Andre Eisenbach's avatar
Andre Eisenbach committed
199 200 201 202 203 204 205 206 207
typedef struct
{
    BT_HDR                  hdr;
    BD_ADDR                 remote_bda;
    tBTA_GATTC_IF           client_if;
    UINT8                   role;
    tGATT_DISCONN_REASON    reason;
}tBTA_GATTC_INT_CONN;

208 209 210 211 212 213 214
typedef struct
{
    BT_HDR                  hdr;
    BD_ADDR                 remote_bda;
    tBTA_GATTC_IF           client_if;
}tBTA_GATTC_ENC_CMPL;

215 216 217 218 219 220 221 222 223 224 225 226 227
typedef union
{
    BT_HDR                      hdr;
    tBTA_GATTC_API_REG          api_reg;
    tBTA_GATTC_API_DEREG        api_dereg;
    tBTA_GATTC_API_OPEN         api_conn;
    tBTA_GATTC_API_CANCEL_OPEN  api_cancel_conn;
    tBTA_GATTC_API_READ         api_read;
    tBTA_GATTC_API_SEARCH       api_search;
    tBTA_GATTC_API_WRITE        api_write;
    tBTA_GATTC_API_CONFIRM      api_confirm;
    tBTA_GATTC_API_EXEC         api_exec;
    tBTA_GATTC_API_READ_MULTI   api_read_multi;
228
    tBTA_GATTC_API_CFG_MTU      api_mtu;
229 230 231 232
    tBTA_GATTC_OP_CMPL          op_cmpl;
    tBTA_GATTC_CI_EVT           ci_open;
    tBTA_GATTC_CI_EVT           ci_save;
    tBTA_GATTC_CI_LOAD          ci_load;
Andre Eisenbach's avatar
Andre Eisenbach committed
233
    tBTA_GATTC_INT_CONN         int_conn;
234
    tBTA_GATTC_ENC_CMPL         enc_cmpl;
235 236 237

    tBTA_GATTC_INT_START_IF     int_start_if;
    tBTA_GATTC_INT_DEREG        int_dereg;
238 239
    /* if peripheral role is supported */
    tBTA_GATTC_API_LISTEN       api_listen;
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273

} tBTA_GATTC_DATA;


/* GATT server cache on the client */
typedef union
{
    UINT8               uuid128[LEN_UUID_128];
    UINT16              uuid16;
}tBTA_GATTC_UUID;

typedef struct gattc_attr_cache
{
    tBTA_GATTC_UUID         *p_uuid;
    struct                  gattc_attr_cache *p_next;
    UINT16                  uuid_len;
    UINT16                  attr_handle;
    UINT8                   inst_id;
    tBTA_GATT_CHAR_PROP     property; /* if characteristic, it is char property;
                                         if included service, flag primary,
                                         if descriptor, not used */
    tBTA_GATTC_ATTR_TYPE    attr_type;
// btla-specific ++
} __attribute__((packed)) tBTA_GATTC_CACHE_ATTR;
// btla-specific --

typedef struct gattc_svc_cache
{
    tBTA_GATT_SRVC_ID       service_uuid;
    tBTA_GATTC_CACHE_ATTR   *p_attr;
    tBTA_GATTC_CACHE_ATTR   *p_last_attr;
    UINT16                  s_handle;
    UINT16                  e_handle;
    struct                  gattc_svc_cache *p_next;
Andre Eisenbach's avatar
Andre Eisenbach committed
274
    tBTA_GATTC_CACHE_ATTR   *p_cur_char;
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
// btla-specific ++
} __attribute__((packed)) tBTA_GATTC_CACHE;
// btla-specific --

typedef struct
{
    tBT_UUID            uuid;
    UINT16              s_handle;
    UINT16              e_handle;
    BOOLEAN             is_primary;
    UINT8               srvc_inst_id;
    tBTA_GATT_CHAR_PROP property;
}tBTA_GATTC_ATTR_REC;


#define BTA_GATTC_MAX_CACHE_CHAR    40
#define BTA_GATTC_ATTR_LIST_SIZE    (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))

#ifndef BTA_GATTC_CACHE_SRVR_SIZE
    #define BTA_GATTC_CACHE_SRVR_SIZE   600
#endif

enum
{
    BTA_GATTC_IDLE_ST = 0,      /* Idle  */
    BTA_GATTC_W4_CONN_ST,       /* Wait for connection -  (optional) */
    BTA_GATTC_CONN_ST,          /* connected state */
    BTA_GATTC_DISCOVER_ST       /* discover is in progress */
};
typedef UINT8 tBTA_GATTC_STATE;

typedef struct
{
    BOOLEAN             in_use;
    BD_ADDR             server_bda;
    BOOLEAN             connected;

#define BTA_GATTC_SERV_IDLE     0
#define BTA_GATTC_SERV_LOAD     1
#define BTA_GATTC_SERV_SAVE     2
315 316
#define BTA_GATTC_SERV_DISC     3
#define BTA_GATTC_SERV_DISC_ACT 4
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338

    UINT8               state;

    tBTA_GATTC_CACHE    *p_srvc_cache;
    tBTA_GATTC_CACHE    *p_cur_srvc;
    BUFFER_Q            cache_buffer;   /* buffer queue used for storing the cache data */
    UINT8               *p_free;        /* starting point to next available byte */
    UINT16              free_byte;      /* number of available bytes in server cache buffer */
    UINT8               update_count;   /* indication received */
    UINT8               num_clcb;       /* number of associated CLCB */


    tBTA_GATTC_ATTR_REC *p_srvc_list;
    UINT8               cur_srvc_idx;
    UINT8               cur_char_idx;
    UINT8               next_avail_idx;
    UINT8               total_srvc;
    UINT8               total_char;

    UINT8               srvc_hdl_chg;   /* service handle change indication pending */
    UINT16              attr_index;     /* cahce NV saving/loading attribute index */

339
    UINT16              mtu;
340 341 342
} tBTA_GATTC_SERV;

#ifndef BTA_GATTC_NOTIF_REG_MAX
343
#define BTA_GATTC_NOTIF_REG_MAX     7
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
#endif

typedef struct
{
    BOOLEAN             in_use;
    BD_ADDR             remote_bda;
    tBTA_GATTC_CHAR_ID  char_id;
}tBTA_GATTC_NOTIF_REG;

typedef struct
{
    tBTA_GATTC_CBACK        *p_cback;
    BOOLEAN                 in_use;
    tBTA_GATTC_IF           client_if;      /* client interface with BTE stack for this application */
    UINT8                   num_clcb;       /* number of associated CLCB */
    BOOLEAN                 dereg_pending;
    tBT_UUID                app_uuid;
    tBTA_GATTC_NOTIF_REG    notif_reg[BTA_GATTC_NOTIF_REG_MAX];
}tBTA_GATTC_RCB;

/* client channel is a mapping between a BTA client(cl_id) and a remote BD address */
typedef struct
{
    UINT16              bta_conn_id;    /* client channel ID, unique for clcb */
    BD_ADDR             bda;
    tBTA_GATTC_RCB      *p_rcb;         /* pointer to the registration CB */
    tBTA_GATTC_SERV     *p_srcb;    /* server cache CB */
    tBTA_GATTC_DATA     *p_q_cmd;   /* command in queue waiting for execution */

#define BTA_GATTC_NO_SCHEDULE       0
#define BTA_GATTC_DISC_WAITING      0x01
#define BTA_GATTC_REQ_WAITING       0x10

    UINT8               auto_update; /* auto update is waiting */
    BOOLEAN             in_use;
    tBTA_GATTC_STATE    state;
    tBTA_GATT_STATUS    status;
    UINT16              reason;
} tBTA_GATTC_CLCB;

/* back ground connection tracking information */
#if GATT_MAX_APPS <= 8
typedef UINT8 tBTA_GATTC_CIF_MASK ;
#elif GATT_MAX_APPS <= 16
typedef UINT16 tBTA_GATTC_CIF_MASK;
#elif GATT_MAX_APPS <= 32
typedef UINT32 tBTA_GATTC_CIF_MASK;
#endif

typedef struct
{
    BOOLEAN                 in_use;
    BD_ADDR                 remote_bda;
    tBTA_GATTC_CIF_MASK     cif_mask;
398
    tBTA_GATTC_CIF_MASK     cif_adv_mask;
399 400 401 402 403

}tBTA_GATTC_BG_TCK;

typedef struct
{
404 405 406 407
    BOOLEAN             in_use;
    BD_ADDR             remote_bda;
}tBTA_GATTC_CONN;

408 409 410 411 412 413 414 415
enum
{
   BTA_GATTC_STATE_DISABLED,
   BTA_GATTC_STATE_ENABLING,
   BTA_GATTC_STATE_ENABLED,
   BTA_GATTC_STATE_DISABLING
};

416 417
typedef struct
{
418 419
    UINT8             state;

420
    tBTA_GATTC_CONN     conn_track[BTA_GATTC_CONN_MAX];
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449
    tBTA_GATTC_BG_TCK   bg_track[BTA_GATTC_KNOWN_SR_MAX];
    tBTA_GATTC_RCB      cl_rcb[BTA_GATTC_CL_MAX];

    tBTA_GATTC_CLCB     clcb[BTA_GATTC_CLCB_MAX];
    tBTA_GATTC_SERV     known_server[BTA_GATTC_KNOWN_SR_MAX];

    tSDP_DISCOVERY_DB   *p_sdp_db;
    UINT16              sdp_conn_id;
}tBTA_GATTC_CB;

/*****************************************************************************
**  Global data
*****************************************************************************/

/* GATTC control block */
#if BTA_DYNAMIC_MEMORY == FALSE
extern tBTA_GATTC_CB  bta_gattc_cb;
#else
extern tBTA_GATTC_CB *bta_gattc_cb_ptr;
#define bta_gattc_cb (*bta_gattc_cb_ptr)
#endif

/*****************************************************************************
**  Function prototypes
*****************************************************************************/
extern BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg);
extern void bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data);

/* function processed outside SM */
450
extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb);
451 452 453 454
extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
455
extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB  *p_clreg);
456
extern void bta_gattc_process_enc_cmpl(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
457 458 459 460 461 462 463 464 465 466 467 468 469 470

/* function within state machine */
extern void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_open_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);

extern void bta_gattc_cancel_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_cancel_open_ok(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_cancel_open_error(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);

extern void bta_gattc_conn(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);

extern void bta_gattc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_close_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
471
extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489

extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_search(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_fail(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_confirm(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_execute(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ci_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ci_load(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
490
extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA * p_msg);
491 492 493
extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
494
                                       BD_ADDR remote_bda, UINT16 conn_id, UINT16 mtu);
495
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
496
extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
497 498
#if BLE_INCLUDED == TRUE
extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
499
extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
500
#endif
501
/* utility functions */
502
extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda);
503 504 505 506 507 508 509 510
extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
extern tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda);
extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
extern tBTA_GATTC_CLCB * bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda);
extern tBTA_GATTC_RCB * bta_gattc_cl_get_regcb(UINT8 client_if);
extern tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda);
extern tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda);
extern tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id);
Andre Eisenbach's avatar
Andre Eisenbach committed
511 512 513
extern tBTA_GATTC_CLCB * bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg);
extern tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);

514 515
extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);

Andre Eisenbach's avatar
Andre Eisenbach committed
516 517 518
extern UINT16 bta_gattc_id2handle(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_SRVC_ID *p_service_id, tBTA_GATT_ID *p_char_id, tBTA_GATT_ID *p_descr_uuid);
extern BOOLEAN bta_gattc_handle2id(tBTA_GATTC_SERV *p_srcb, UINT16 handle, tBTA_GATT_SRVC_ID *service_id, tBTA_GATT_ID *char_id, tBTA_GATT_ID *p_type);
extern BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_precise);
519 520
extern void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR   *p_attr, tBT_UUID *p_uuid);
extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB  *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY  *p_notify);
Andre Eisenbach's avatar
Andre Eisenbach committed
521
extern tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb, tBT_UUID *p_descr_uuid, tGATT_VALUE *p_attr, tBTA_GATT_READ_VAL *p_value);
522 523
extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR_PTR remote_bda, BOOLEAN add, BOOLEAN is_listen);
extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if,  BD_ADDR remote_bda, UINT8 role);
524 525
extern UINT8 bta_gattc_num_reg_app(void);
extern void bta_gattc_clear_notif_registration(UINT16 conn_id);
526 527 528 529
extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
extern BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar);
extern BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar);
extern void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src);
530 531 532 533 534 535

/* discovery functions */
extern void bta_gattc_disc_res_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_DISC_RES *p_data);
extern void bta_gattc_disc_cmpl_cback (UINT16 conn_id, tGATT_DISC_TYPE disc_type, tGATT_STATUS status);
extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
Andre Eisenbach's avatar
Andre Eisenbach committed
536
extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
537 538
extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
                                              tBTA_GATT_ID *p_start_rec,tBT_UUID *p_uuid_cond,
Andre Eisenbach's avatar
Andre Eisenbach committed
539
                                              tBTA_GATT_ID *p_output, void *p_param);
540 541 542 543
extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);

544 545 546 547 548 549

extern tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda);
extern tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda);
extern tBTA_GATTC_CONN * bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);

550
#endif /* BTA_GATTC_INT_H */