2016-09-26 09:37:39 -04:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
2018-04-08 00:10:50 -04:00
|
|
|
#include "common/bt_target.h"
|
|
|
|
#include "bta/bta_sys.h"
|
|
|
|
#include "bta/bta_gatt_api.h"
|
|
|
|
#include "bta/bta_gattc_ci.h"
|
|
|
|
#include "bta/bta_gattc_co.h"
|
|
|
|
#include "osi/fixed_queue.h"
|
|
|
|
#include "osi/mutex.h"
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
/*****************************************************************************
|
|
|
|
** Constants and data types
|
|
|
|
*****************************************************************************/
|
2016-11-24 13:10:15 -05:00
|
|
|
enum {
|
2016-09-26 09:37:39 -04:00
|
|
|
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,
|
|
|
|
BTA_GATTC_API_CFG_MTU_EVT,
|
|
|
|
|
|
|
|
BTA_GATTC_API_CLOSE_EVT,
|
|
|
|
|
|
|
|
BTA_GATTC_API_SEARCH_EVT,
|
|
|
|
BTA_GATTC_API_CONFIRM_EVT,
|
|
|
|
BTA_GATTC_API_READ_MULTI_EVT,
|
|
|
|
BTA_GATTC_API_REFRESH_EVT,
|
2018-12-12 08:40:31 -05:00
|
|
|
BTA_GATTC_API_CACHE_CLEAN_EVT,
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
|
|
BTA_GATTC_INT_START_IF_EVT,
|
|
|
|
BTA_GATTC_API_REG_EVT,
|
|
|
|
BTA_GATTC_API_DEREG_EVT,
|
|
|
|
BTA_GATTC_API_LISTEN_EVT,
|
|
|
|
BTA_GATTC_API_BROADCAST_EVT,
|
|
|
|
BTA_GATTC_API_DISABLE_EVT,
|
2018-03-11 23:34:20 -04:00
|
|
|
BTA_GATTC_ENC_CMPL_EVT,
|
2018-04-20 02:16:33 -04:00
|
|
|
BTA_GATTC_API_CACHE_ASSOC_EVT,
|
2018-03-11 23:34:20 -04:00
|
|
|
BTA_GATTC_API_CACHE_GET_ADDR_LIST_EVT,
|
2016-09-26 09:37:39 -04:00
|
|
|
};
|
|
|
|
typedef UINT16 tBTA_GATTC_INT_EVT;
|
|
|
|
|
2017-08-24 02:24:04 -04:00
|
|
|
#define BTA_GATTC_SERVICE_CHANGED_LEN 4
|
|
|
|
|
2018-09-28 02:12:32 -04:00
|
|
|
typedef enum {
|
|
|
|
BTA_GATTC_SERVICE_INFO_FROM_REMOTE_DEVICE = 0,
|
|
|
|
BTA_GATTC_SERVICE_INFO_FROM_NVS_FLASH = 1,
|
|
|
|
BTA_GATTC_SERVICE_INFO_FROM_UNKNOWN = 2,
|
|
|
|
} tBTA_SERVICE_SOURCE_t;
|
|
|
|
|
2016-09-26 09:37:39 -04:00
|
|
|
/* max client application GATTC can support */
|
|
|
|
#ifndef BTA_GATTC_CL_MAX
|
2017-10-12 09:07:40 -04:00
|
|
|
#if (GATT_MAX_PHY_CHANNEL > 3)
|
|
|
|
#define BTA_GATTC_CL_MAX GATT_MAX_PHY_CHANNEL
|
|
|
|
#else
|
|
|
|
#define BTA_GATTC_CL_MAX 3 // The origin value is 10
|
|
|
|
#endif
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* max known devices GATTC can support */
|
|
|
|
#ifndef BTA_GATTC_KNOWN_SR_MAX
|
2017-07-12 23:19:54 -04:00
|
|
|
#if (GATT_MAX_PHY_CHANNEL > 3)
|
|
|
|
#define BTA_GATTC_KNOWN_SR_MAX GATT_MAX_PHY_CHANNEL
|
|
|
|
#else
|
|
|
|
#define BTA_GATTC_KNOWN_SR_MAX 3 // The origin value is 10
|
|
|
|
#endif
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BTA_GATTC_CONN_MAX GATT_MAX_PHY_CHANNEL
|
|
|
|
|
|
|
|
#ifndef BTA_GATTC_CLCB_MAX
|
2016-11-24 13:10:15 -05:00
|
|
|
#define BTA_GATTC_CLCB_MAX GATT_CL_MAX_LCB
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE
|
2017-08-24 02:24:04 -04:00
|
|
|
#define BTA_GATTC_INVALID_HANDLE 0
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
/* internal strucutre for GATTC register API */
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
tBT_UUID app_uuid;
|
|
|
|
tBTA_GATTC_CBACK *p_cback;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_API_REG;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
tBTA_GATTC_IF client_if;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_INT_START_IF;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
|
|
|
|
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
BD_ADDR remote_bda;
|
2018-03-22 23:08:03 -04:00
|
|
|
tBTA_ADDR_TYPE remote_addr_type;
|
2016-09-26 09:37:39 -04:00
|
|
|
tBTA_GATTC_IF client_if;
|
|
|
|
BOOLEAN is_direct;
|
|
|
|
tBTA_TRANSPORT transport;
|
|
|
|
} tBTA_GATTC_API_OPEN;
|
|
|
|
|
|
|
|
typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
tBTA_GATT_AUTH_REQ auth_req;
|
2017-08-24 02:24:04 -04:00
|
|
|
UINT16 handle;
|
|
|
|
tBTA_GATTC_EVT cmpl_evt;
|
2016-09-26 09:37:39 -04:00
|
|
|
} tBTA_GATTC_API_READ;
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
tBTA_GATT_AUTH_REQ auth_req;
|
2017-08-24 02:24:04 -04:00
|
|
|
UINT16 handle;
|
|
|
|
tBTA_GATTC_EVT cmpl_evt;
|
2016-09-26 09:37:39 -04:00
|
|
|
tBTA_GATTC_WRITE_TYPE write_type;
|
|
|
|
UINT16 offset;
|
|
|
|
UINT16 len;
|
|
|
|
UINT8 *p_value;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_API_WRITE;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
BOOLEAN is_execute;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_API_EXEC;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
2017-08-24 02:24:04 -04:00
|
|
|
UINT16 handle;
|
2016-09-26 09:37:39 -04:00
|
|
|
} tBTA_GATTC_API_CONFIRM;
|
|
|
|
|
|
|
|
typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
UINT8 op_code;
|
|
|
|
tGATT_STATUS status;
|
|
|
|
tBTA_GATTC_CMPL *p_cmpl;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_OP_CMPL;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
tBT_UUID *p_srvc_uuid;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_API_SEARCH;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
tBTA_GATT_AUTH_REQ auth_req;
|
|
|
|
UINT8 num_attr;
|
2017-08-24 02:24:04 -04:00
|
|
|
UINT16 handles[GATT_MAX_READ_MULTI_HANDLES];
|
2017-09-19 04:50:26 -04:00
|
|
|
tBTA_GATTC_EVT cmpl_evt;
|
2017-08-24 02:24:04 -04:00
|
|
|
}tBTA_GATTC_API_READ_MULTI;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
BD_ADDR_PTR remote_bda;
|
|
|
|
tBTA_GATTC_IF client_if;
|
|
|
|
BOOLEAN start;
|
|
|
|
} tBTA_GATTC_API_LISTEN;
|
|
|
|
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_API_CFG_MTU;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2018-03-11 23:34:20 -04:00
|
|
|
typedef struct {
|
|
|
|
BT_HDR hdr;
|
|
|
|
tBTA_GATTC_IF client_if;
|
|
|
|
BD_ADDR src_addr;
|
2018-04-20 02:16:33 -04:00
|
|
|
BD_ADDR assoc_addr;
|
|
|
|
BOOLEAN is_assoc;
|
|
|
|
} tBTA_GATTC_API_CACHE_ASSOC;
|
2018-03-11 23:34:20 -04:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
BT_HDR hdr;
|
|
|
|
tBTA_GATTC_IF client_if;
|
|
|
|
} tBTA_GATTC_API_GET_ADDR;
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
BD_ADDR remote_bda;
|
|
|
|
tBTA_GATTC_IF client_if;
|
|
|
|
UINT8 role;
|
|
|
|
tBT_TRANSPORT transport;
|
|
|
|
tGATT_DISCONN_REASON reason;
|
2018-03-02 08:33:28 -05:00
|
|
|
BOOLEAN already_connect;
|
2019-05-23 02:44:16 -04:00
|
|
|
tBTA_GATT_CONN_PARAMS conn_params;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_INT_CONN;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BT_HDR hdr;
|
|
|
|
BD_ADDR remote_bda;
|
|
|
|
tBTA_GATTC_IF client_if;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_ENC_CMPL;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef union {
|
2016-09-26 09:37:39 -04:00
|
|
|
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;
|
|
|
|
tBTA_GATTC_API_CFG_MTU api_mtu;
|
2018-04-20 02:16:33 -04:00
|
|
|
tBTA_GATTC_API_CACHE_ASSOC api_assoc;
|
2018-03-11 23:34:20 -04:00
|
|
|
tBTA_GATTC_API_GET_ADDR api_get_addr;
|
2016-09-26 09:37:39 -04:00
|
|
|
tBTA_GATTC_OP_CMPL op_cmpl;
|
|
|
|
tBTA_GATTC_INT_CONN int_conn;
|
|
|
|
tBTA_GATTC_ENC_CMPL enc_cmpl;
|
|
|
|
|
|
|
|
tBTA_GATTC_INT_START_IF int_start_if;
|
|
|
|
tBTA_GATTC_INT_DEREG int_dereg;
|
|
|
|
/* if peripheral role is supported */
|
|
|
|
tBTA_GATTC_API_LISTEN api_listen;
|
|
|
|
|
|
|
|
} tBTA_GATTC_DATA;
|
|
|
|
|
|
|
|
|
|
|
|
/* GATT server cache on the client */
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
tBT_UUID uuid;
|
|
|
|
UINT16 s_handle;
|
|
|
|
UINT16 e_handle;
|
2017-08-24 02:24:04 -04:00
|
|
|
// this field is set only for characteristic
|
|
|
|
UINT16 char_decl_handle;
|
2016-09-26 09:37:39 -04:00
|
|
|
BOOLEAN is_primary;
|
|
|
|
tBTA_GATT_CHAR_PROP property;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_ATTR_REC;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
#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
|
2016-11-24 13:10:15 -05:00
|
|
|
#define BTA_GATTC_CACHE_SRVR_SIZE 600
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
enum {
|
2016-09-26 09:37:39 -04:00
|
|
|
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;
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
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
|
|
|
|
#define BTA_GATTC_SERV_DISC 3
|
|
|
|
#define BTA_GATTC_SERV_DISC_ACT 4
|
|
|
|
|
|
|
|
UINT8 state;
|
|
|
|
|
2017-08-24 02:24:04 -04:00
|
|
|
list_t *p_srvc_cache; /* list of tBTA_GATTC_SERVICE */
|
2016-09-26 09:37:39 -04:00
|
|
|
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;
|
2017-08-24 02:24:04 -04:00
|
|
|
UINT16 total_attr;
|
2016-09-26 09:37:39 -04:00
|
|
|
UINT8 srvc_hdl_chg; /* service handle change indication pending */
|
|
|
|
UINT16 attr_index; /* cahce NV saving/loading attribute index */
|
|
|
|
|
|
|
|
UINT16 mtu;
|
2018-07-13 08:58:19 -04:00
|
|
|
bool update_incl_srvc;
|
2016-09-26 09:37:39 -04:00
|
|
|
} tBTA_GATTC_SERV;
|
|
|
|
|
|
|
|
#ifndef BTA_GATTC_NOTIF_REG_MAX
|
2017-04-23 00:48:23 -04:00
|
|
|
#define BTA_GATTC_NOTIF_REG_MAX 7//15
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BOOLEAN in_use;
|
|
|
|
BD_ADDR remote_bda;
|
2017-08-24 02:24:04 -04:00
|
|
|
UINT16 handle;
|
|
|
|
}tBTA_GATTC_NOTIF_REG;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
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];
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_RCB;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
/* client channel is a mapping between a BTA client(cl_id) and a remote BD address */
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
UINT16 bta_conn_id; /* client channel ID, unique for clcb */
|
|
|
|
BD_ADDR bda;
|
|
|
|
tBTA_TRANSPORT transport; /* channel transport */
|
|
|
|
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 */
|
2017-09-21 06:17:38 -04:00
|
|
|
list_t *p_cmd_list; /* The list to store the command to be sent */
|
2017-11-13 22:44:27 -05:00
|
|
|
BOOLEAN is_full; /* The gattc command queue is full or not */
|
2016-09-26 09:37:39 -04:00
|
|
|
#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 disc_active;
|
|
|
|
BOOLEAN in_use;
|
|
|
|
tBTA_GATTC_STATE state;
|
|
|
|
tBTA_GATT_STATUS status;
|
|
|
|
UINT16 reason;
|
2018-09-28 02:12:32 -04:00
|
|
|
UINT8 searched_service_source;
|
2016-09-26 09:37:39 -04:00
|
|
|
} tBTA_GATTC_CLCB;
|
|
|
|
|
2018-02-13 01:55:18 -05:00
|
|
|
/* background connection tracking information */
|
2016-09-26 09:37:39 -04:00
|
|
|
#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
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BOOLEAN in_use;
|
|
|
|
BD_ADDR remote_bda;
|
|
|
|
tBTA_GATTC_CIF_MASK cif_mask;
|
|
|
|
tBTA_GATTC_CIF_MASK cif_adv_mask;
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_BG_TCK;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2016-09-26 09:37:39 -04:00
|
|
|
BOOLEAN in_use;
|
|
|
|
BD_ADDR remote_bda;
|
2018-06-26 04:39:30 -04:00
|
|
|
UINT16 svc_change_descr_handle;
|
|
|
|
BOOLEAN write_remote_svc_change_ccc_done;
|
2016-11-24 13:10:15 -05:00
|
|
|
} tBTA_GATTC_CONN;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
BTA_GATTC_STATE_DISABLED,
|
|
|
|
BTA_GATTC_STATE_ENABLING,
|
|
|
|
BTA_GATTC_STATE_ENABLED,
|
|
|
|
BTA_GATTC_STATE_DISABLING
|
2016-09-26 09:37:39 -04:00
|
|
|
};
|
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
typedef struct {
|
2018-01-27 06:03:06 -05:00
|
|
|
UINT8 state;
|
2016-09-26 09:37:39 -04:00
|
|
|
tBTA_GATTC_CONN conn_track[BTA_GATTC_CONN_MAX];
|
|
|
|
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];
|
2017-08-24 02:24:04 -04:00
|
|
|
}tBTA_GATTC_CB;
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2017-06-11 09:59:49 -04:00
|
|
|
typedef enum {
|
|
|
|
SERVICE_CHANGE_CCC_WRITTEN_SUCCESS = 0,
|
|
|
|
SERVICE_CHANGE_CACHE_NOT_FOUND,
|
|
|
|
SERVICE_CHANGE_SERVICE_NOT_FOUND,
|
|
|
|
SERVICE_CHANGE_CHAR_NOT_FOUND,
|
|
|
|
SERVICE_CHANGE_CCC_NOT_FOUND,
|
|
|
|
SERVICE_CHANGE_WRITE_CCC_FAILED
|
|
|
|
}tBTA_GATTC_FIND_SERVICE_CB;
|
|
|
|
|
|
|
|
|
2016-09-26 09:37:39 -04:00
|
|
|
/*****************************************************************************
|
|
|
|
** 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 BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_DATA *p_data);
|
|
|
|
|
|
|
|
/* function processed outside SM */
|
|
|
|
extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb);
|
|
|
|
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);
|
2016-11-24 13:10:15 -05:00
|
|
|
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);
|
2016-09-26 09:37:39 -04:00
|
|
|
extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB *p_clreg);
|
|
|
|
extern void bta_gattc_process_enc_cmpl(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
|
|
|
|
|
|
|
/* 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);
|
2017-06-01 03:56:36 -04:00
|
|
|
extern void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data);
|
|
|
|
extern void bta_gattc_disconncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data);
|
2016-09-26 09:37:39 -04:00
|
|
|
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);
|
|
|
|
extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
|
|
|
|
|
|
|
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);
|
2017-09-25 02:27:08 -04:00
|
|
|
extern void bta_gattc_free_command_data(tBTA_GATTC_CLCB *p_clcb);
|
2016-09-26 09:37:39 -04:00
|
|
|
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_close(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);
|
2016-11-24 13:10:15 -05:00
|
|
|
extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_msg);
|
2016-09-26 09:37:39 -04:00
|
|
|
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,
|
|
|
|
BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu);
|
2019-05-23 02:44:16 -04:00
|
|
|
extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, tBTA_GATT_CONN_PARAMS conn_params);
|
2017-10-16 04:27:38 -04:00
|
|
|
extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason,
|
2017-06-01 03:56:36 -04:00
|
|
|
BD_ADDR remote_bda, UINT16 conn_id);
|
2016-11-24 13:10:15 -05:00
|
|
|
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
2018-12-12 08:40:31 -05:00
|
|
|
extern void bta_gattc_process_api_cache_clean(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
2018-04-20 02:16:33 -04:00
|
|
|
extern void bta_gattc_process_api_cache_assoc(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
2018-03-11 23:34:20 -04:00
|
|
|
extern void bta_gattc_process_api_cache_get_addr_list(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
2016-09-26 09:37:39 -04:00
|
|
|
extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
|
|
|
#if BLE_INCLUDED == TRUE
|
2016-11-24 13:10:15 -05:00
|
|
|
extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
|
|
|
extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif
|
|
|
|
/* utility functions */
|
2016-11-24 13:10:15 -05:00
|
|
|
extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
|
|
|
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, tBTA_TRANSPORT transport);
|
2016-09-26 09:37:39 -04:00
|
|
|
extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
|
2016-11-24 13:10:15 -05:00
|
|
|
extern tBTA_GATTC_CLCB *bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
|
|
|
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);
|
|
|
|
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);
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
|
|
|
|
2017-08-24 02:24:04 -04:00
|
|
|
extern BOOLEAN bta_gattc_uuid_compare (const tBT_UUID *p_src, const tBT_UUID *p_tar, BOOLEAN is_precise);
|
2016-09-26 09:37:39 -04:00
|
|
|
extern BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV *p_srcb, tBTA_GATTC_NOTIFY *p_notify);
|
|
|
|
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);
|
|
|
|
extern UINT8 bta_gattc_num_reg_app(void);
|
2017-08-24 02:24:04 -04:00
|
|
|
extern void bta_gattc_clear_notif_registration(tBTA_GATTC_SERV *p_srcb, UINT16 conn_id, UINT16 start_handle, UINT16 end_handle);
|
|
|
|
extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
|
2016-09-26 09:37:39 -04:00
|
|
|
|
|
|
|
/* 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);
|
|
|
|
extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
|
2017-08-24 02:24:04 -04:00
|
|
|
extern const list_t* bta_gattc_get_services(UINT16 conn_id);
|
|
|
|
extern const tBTA_GATTC_SERVICE* bta_gattc_get_service_for_handle(UINT16 conn_id, UINT16 handle);
|
|
|
|
tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic_srcb(tBTA_GATTC_SERV *p_srcb, UINT16 handle);
|
|
|
|
extern tBTA_GATTC_CHARACTERISTIC* bta_gattc_get_characteristic(UINT16 conn_id, UINT16 handle);
|
|
|
|
extern tBTA_GATTC_DESCRIPTOR* bta_gattc_get_descriptor(UINT16 conn_id, UINT16 handle);
|
|
|
|
extern void bta_gattc_get_db_size_handle(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, int *count);
|
|
|
|
extern void bta_gattc_get_db_size_with_type_handle(UINT16 conn_id, bt_gatt_db_attribute_type_t type,
|
|
|
|
UINT16 start_handle, UINT16 end_handle, UINT16 char_handle, int *count);
|
|
|
|
extern void bta_gattc_get_service_with_uuid(UINT16 conn_id, tBT_UUID *svc_uuid,
|
|
|
|
btgatt_db_element_t **svc_db,
|
|
|
|
int *count);
|
|
|
|
|
|
|
|
extern void bta_gattc_get_db_with_opration(UINT16 conn_id,
|
|
|
|
bt_gatt_get_db_op_t op,
|
|
|
|
UINT16 char_handle,
|
|
|
|
tBT_UUID *incl_uuid,
|
|
|
|
tBT_UUID *char_uuid,
|
|
|
|
tBT_UUID *descr_uuid,
|
|
|
|
UINT16 start_handle, UINT16 end_handle,
|
|
|
|
btgatt_db_element_t **char_db,
|
|
|
|
int *count);
|
|
|
|
|
|
|
|
extern void bta_gattc_get_gatt_db(UINT16 conn_id, UINT16 start_handle, UINT16 end_handle, btgatt_db_element_t **db, int *count);
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2017-08-24 02:24:04 -04:00
|
|
|
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 *attr);
|
|
|
|
extern void bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
|
|
|
|
extern void bta_gattc_reset_discover_st(tBTA_GATTC_SERV *p_srcb, tBTA_GATT_STATUS status);
|
2016-09-26 09:37:39 -04:00
|
|
|
|
2016-11-24 13:10:15 -05:00
|
|
|
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);
|
2016-09-26 09:37:39 -04:00
|
|
|
extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
|
|
|
|
|
2017-08-24 02:24:04 -04:00
|
|
|
extern bool bta_gattc_cache_load(tBTA_GATTC_CLCB *p_clcb);
|
|
|
|
extern void bta_gattc_cache_reset(BD_ADDR server_bda);
|
2017-10-18 03:34:43 -04:00
|
|
|
extern void bta_gattc_deinit(void);
|
2017-08-24 02:24:04 -04:00
|
|
|
|
2016-09-26 09:37:39 -04:00
|
|
|
#endif /* BTA_GATTC_INT_H */
|