1 /******************************************************************************
3 * Copyright (C) 2009-2013 Broadcom Corporation
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:
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 ******************************************************************************/
23 #include "bt_target.h"
24 #include "osi/include/fixed_queue.h"
26 #include "bt_common.h"
28 #define GAP_MAX_BLOCKS 2 /* Concurrent GAP commands pending at a time*/
29 /* Define the Generic Access Profile control structure */
32 void *p_data; /* Pointer to any data returned in callback */
33 tGAP_CALLBACK *gap_cback; /* Pointer to users callback function */
34 tGAP_CALLBACK *gap_inq_rslt_cback; /* Used for inquiry results */
35 UINT16 event; /* Passed back in the callback */
36 UINT8 index; /* Index of this control block and callback */
37 BOOLEAN in_use; /* True when structure is allocated */
40 /* Define the control block for the FindAddrByName operation (Only 1 active at a time) */
43 tGAP_CALLBACK *p_cback;
44 tBTM_INQ_INFO *p_cur_inq; /* Pointer to the current inquiry database entry */
45 tGAP_FINDADDR_RESULTS results;
49 /* Define the GAP Connection Control Block.
53 #define GAP_CCB_STATE_IDLE 0
54 #define GAP_CCB_STATE_LISTENING 1
55 #define GAP_CCB_STATE_CONN_SETUP 2
56 #define GAP_CCB_STATE_CFG_SETUP 3
57 #define GAP_CCB_STATE_WAIT_SEC 4
58 #define GAP_CCB_STATE_CONNECTED 5
61 #define GAP_CCB_FLAGS_IS_ORIG 0x01
62 #define GAP_CCB_FLAGS_HIS_CFG_DONE 0x02
63 #define GAP_CCB_FLAGS_MY_CFG_DONE 0x04
64 #define GAP_CCB_FLAGS_SEC_DONE 0x08
65 #define GAP_CCB_FLAGS_CONN_DONE 0x0E
68 UINT8 service_id; /* Used by BTM */
69 UINT16 gap_handle; /* GAP handle */
70 UINT16 connection_id; /* L2CAP CID */
71 BOOLEAN rem_addr_specified;
72 UINT8 chan_mode_mask; /* Supported channel modes (FCR) */
73 BD_ADDR rem_dev_address;
78 fixed_queue_t *tx_queue; /* Queue of buffers waiting to be sent */
79 fixed_queue_t *rx_queue; /* Queue of buffers waiting to be read */
81 UINT32 rx_queue_size; /* Total data count in rx_queue */
83 tGAP_CONN_CALLBACK *p_callback; /* Users callback function */
85 tL2CAP_CFG_INFO cfg; /* Configuration */
86 tL2CAP_ERTM_INFO ertm_info; /* Pools and modes for ertm */
87 tBT_TRANSPORT transport; /* Transport channel BR/EDR or BLE */
88 tL2CAP_LE_CFG_INFO local_coc_cfg; /* local configuration for LE Coc */
89 tL2CAP_LE_CFG_INFO peer_coc_cfg; /* local configuration for LE Coc */
94 #if AMP_INCLUDED == TRUE
95 tAMP_APPL_INFO reg_info;
97 tL2CAP_APPL_INFO reg_info; /* L2CAP Registration info */
99 tGAP_CCB ccb_pool[GAP_MAX_CONNECTIONS];
103 #if BLE_INCLUDED == TRUE
104 #define GAP_MAX_CHAR_NUM 4
110 tGAP_BLE_ATTR_VALUE attr_value;
113 /**********************************************************************
114 ** M A I N C O N T R O L B L O C K
115 ***********************************************************************/
117 #define GAP_MAX_CL GATT_CL_MAX_LCB
122 tGAP_BLE_CMPL_CBACK *p_cback;
128 tGAP_BLE_CMPL_CBACK *p_cback;
133 fixed_queue_t *pending_req_q;
139 tGAP_INFO blk[GAP_MAX_BLOCKS];
140 tBTM_CMPL_CB *btm_cback[GAP_MAX_BLOCKS];
142 tGAP_FINDADDR_CB findaddr_cb; /* Contains the control block for finding a device addr */
143 tBTM_INQ_INFO *cur_inqptr;
145 #if GAP_CONN_INCLUDED == TRUE
149 /* LE GAP attribute database */
150 #if BLE_INCLUDED == TRUE
151 tGAP_ATTR gatt_attr[GAP_MAX_CHAR_NUM];
152 tGAP_CLCB clcb[GAP_MAX_CL]; /* connection link*/
158 extern tGAP_CB gap_cb;
159 #if (GAP_CONN_INCLUDED == TRUE)
160 extern void gap_conn_init(void);
162 #if (BLE_INCLUDED == TRUE)
163 extern void gap_attr_db_init(void);