OSDN Git Service

Fix bug where a bonded device could enter BONDING and BONDED states again. am: b32b3d7c1b
[android-x86/system-bt.git] / stack / gap / gap_int.h
1 /******************************************************************************
2  *
3  *  Copyright (C) 2009-2013 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 #ifndef GAP_INT_H
21 #define GAP_INT_H
22
23 #include "bt_target.h"
24 #include "osi/include/fixed_queue.h"
25 #include "gap_api.h"
26 #include "bt_common.h"
27 #include "gatt_api.h"
28 #define GAP_MAX_BLOCKS 2        /* Concurrent GAP commands pending at a time*/
29 /* Define the Generic Access Profile control structure */
30 typedef struct
31 {
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 */
38 } tGAP_INFO;
39
40 /* Define the control block for the FindAddrByName operation (Only 1 active at a time) */
41 typedef struct
42 {
43     tGAP_CALLBACK           *p_cback;
44     tBTM_INQ_INFO           *p_cur_inq; /* Pointer to the current inquiry database entry */
45     tGAP_FINDADDR_RESULTS    results;
46     BOOLEAN                  in_use;
47 } tGAP_FINDADDR_CB;
48
49 /* Define the GAP Connection Control Block.
50 */
51 typedef struct
52 {
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
59     UINT8             con_state;
60
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
66     UINT8             con_flags;
67
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;
74     UINT16            psm;
75     UINT16            rem_mtu_size;
76
77     BOOLEAN           is_congested;
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  */
80
81     UINT32            rx_queue_size;        /* Total data count in rx_queue         */
82
83     tGAP_CONN_CALLBACK *p_callback;         /* Users callback function              */
84
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 */
90 } tGAP_CCB;
91
92 typedef struct
93 {
94 #if AMP_INCLUDED == TRUE
95     tAMP_APPL_INFO    reg_info;
96 #else
97     tL2CAP_APPL_INFO  reg_info;                     /* L2CAP Registration info */
98 #endif
99     tGAP_CCB    ccb_pool[GAP_MAX_CONNECTIONS];
100 } tGAP_CONN;
101
102
103 #if BLE_INCLUDED == TRUE
104 #define GAP_MAX_CHAR_NUM          4
105
106 typedef struct
107 {
108     UINT16                  handle;
109     UINT16                  uuid;
110     tGAP_BLE_ATTR_VALUE     attr_value;
111 }tGAP_ATTR;
112 #endif
113 /**********************************************************************
114 ** M A I N   C O N T R O L   B L O C K
115 ***********************************************************************/
116
117 #define GAP_MAX_CL GATT_CL_MAX_LCB
118
119 typedef struct
120 {
121     UINT16 uuid;
122     tGAP_BLE_CMPL_CBACK *p_cback;
123 } tGAP_BLE_REQ;
124
125 typedef struct
126 {
127     BD_ADDR                 bda;
128     tGAP_BLE_CMPL_CBACK     *p_cback;
129     UINT16                  conn_id;
130     UINT16                  cl_op_uuid;
131     BOOLEAN                 in_use;
132     BOOLEAN                 connected;
133     fixed_queue_t           *pending_req_q;
134
135 }tGAP_CLCB;
136
137 typedef struct
138 {
139     tGAP_INFO        blk[GAP_MAX_BLOCKS];
140     tBTM_CMPL_CB    *btm_cback[GAP_MAX_BLOCKS];
141     UINT8            trace_level;
142     tGAP_FINDADDR_CB findaddr_cb;   /* Contains the control block for finding a device addr */
143     tBTM_INQ_INFO   *cur_inqptr;
144
145 #if GAP_CONN_INCLUDED == TRUE
146     tGAP_CONN        conn;
147 #endif
148
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*/
153     tGATT_IF                gatt_if;
154 #endif
155 } tGAP_CB;
156
157
158 extern tGAP_CB  gap_cb;
159 #if (GAP_CONN_INCLUDED == TRUE)
160     extern void gap_conn_init(void);
161 #endif
162 #if (BLE_INCLUDED == TRUE)
163     extern void gap_attr_db_init(void);
164 #endif
165
166 #endif