• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "gap_api.h"
25 #include "gki.h"
26 #include "gatt_api.h"
27 #define GAP_MAX_BLOCKS 2        /* Concurrent GAP commands pending at a time*/
28 /* Define the Generic Access Profile control structure */
29 typedef struct
30 {
31     void          *p_data;      /* Pointer to any data returned in callback */
32     tGAP_CALLBACK *gap_cback;   /* Pointer to users callback function */
33     tGAP_CALLBACK *gap_inq_rslt_cback; /* Used for inquiry results */
34     UINT16         event;       /* Passed back in the callback */
35     UINT8          index;       /* Index of this control block and callback */
36     BOOLEAN        in_use;      /* True when structure is allocated */
37 } tGAP_INFO;
38 
39 /* Define the control block for the FindAddrByName operation (Only 1 active at a time) */
40 typedef struct
41 {
42     tGAP_CALLBACK           *p_cback;
43     tBTM_INQ_INFO           *p_cur_inq; /* Pointer to the current inquiry database entry */
44     tGAP_FINDADDR_RESULTS    results;
45     BOOLEAN                  in_use;
46 } tGAP_FINDADDR_CB;
47 
48 /* Define the GAP Connection Control Block.
49 */
50 typedef struct
51 {
52 #define GAP_CCB_STATE_IDLE              0
53 #define GAP_CCB_STATE_LISTENING         1
54 #define GAP_CCB_STATE_CONN_SETUP        2
55 #define GAP_CCB_STATE_CFG_SETUP         3
56 #define GAP_CCB_STATE_WAIT_SEC          4
57 #define GAP_CCB_STATE_CONNECTED         5
58     UINT8             con_state;
59 
60 #define GAP_CCB_FLAGS_IS_ORIG           0x01
61 #define GAP_CCB_FLAGS_HIS_CFG_DONE      0x02
62 #define GAP_CCB_FLAGS_MY_CFG_DONE       0x04
63 #define GAP_CCB_FLAGS_SEC_DONE          0x08
64 #define GAP_CCB_FLAGS_CONN_DONE         0x0E
65     UINT8             con_flags;
66 
67     UINT8             service_id;           /* Used by BTM                          */
68     UINT16            gap_handle;           /* GAP handle                           */
69     UINT16            connection_id;        /* L2CAP CID                            */
70     BOOLEAN           rem_addr_specified;
71     UINT8             chan_mode_mask;       /* Supported channel modes (FCR)        */
72     BD_ADDR           rem_dev_address;
73     UINT16            psm;
74     UINT16            rem_mtu_size;
75 
76     BOOLEAN           is_congested;
77     BUFFER_Q          tx_queue;             /* Queue of buffers waiting to be sent  */
78     BUFFER_Q          rx_queue;             /* Queue of buffers waiting to be read  */
79 
80     UINT32            rx_queue_size;        /* Total data count in rx_queue         */
81 
82     tGAP_CONN_CALLBACK *p_callback;         /* Users callback function              */
83 
84     tL2CAP_CFG_INFO   cfg;                  /* Configuration                        */
85     tL2CAP_ERTM_INFO  ertm_info;            /* Pools and modes for ertm */
86 } tGAP_CCB;
87 
88 typedef struct
89 {
90 #if AMP_INCLUDED == TRUE
91     tAMP_APPL_INFO    reg_info;
92 #else
93     tL2CAP_APPL_INFO  reg_info;                     /* L2CAP Registration info */
94 #endif
95     tGAP_CCB    ccb_pool[GAP_MAX_CONNECTIONS];
96 } tGAP_CONN;
97 
98 
99 #if BLE_INCLUDED == TRUE
100 #define GAP_MAX_CHAR_NUM          4
101 
102 typedef struct
103 {
104     UINT16                  handle;
105     UINT16                  uuid;
106     tGAP_BLE_ATTR_VALUE     attr_value;
107 }tGAP_ATTR;
108 #endif
109 /**********************************************************************
110 ** M A I N   C O N T R O L   B L O C K
111 ***********************************************************************/
112 
113 #define GAP_MAX_CL GATT_CL_MAX_LCB
114 
115 typedef struct
116 {
117     UINT16 uuid;
118     tGAP_BLE_CMPL_CBACK *p_cback;
119 } tGAP_BLE_REQ;
120 
121 typedef struct
122 {
123     BD_ADDR                 bda;
124     tGAP_BLE_CMPL_CBACK     *p_cback;
125     UINT16                  conn_id;
126     UINT16                  cl_op_uuid;
127     BOOLEAN                 in_use;
128     BOOLEAN                 connected;
129     BUFFER_Q                pending_req_q;
130 
131 }tGAP_CLCB;
132 
133 typedef struct
134 {
135     tGAP_INFO        blk[GAP_MAX_BLOCKS];
136     tBTM_CMPL_CB    *btm_cback[GAP_MAX_BLOCKS];
137     UINT8            trace_level;
138     tGAP_FINDADDR_CB findaddr_cb;   /* Contains the control block for finding a device addr */
139     tBTM_INQ_INFO   *cur_inqptr;
140 
141 #if GAP_CONN_INCLUDED == TRUE
142     tGAP_CONN        conn;
143 #endif
144 
145     /* LE GAP attribute database */
146 #if BLE_INCLUDED == TRUE
147     tGAP_ATTR               gatt_attr[GAP_MAX_CHAR_NUM];
148     tGAP_CLCB               clcb[GAP_MAX_CL]; /* connection link*/
149     tGATT_IF                gatt_if;
150 #endif
151 } tGAP_CB;
152 
153 
154 extern tGAP_CB  gap_cb;
155 #if (GAP_CONN_INCLUDED == TRUE)
156     extern void gap_conn_init(void);
157 #endif
158 #if (BLE_INCLUDED == TRUE)
159     extern void gap_attr_db_init(void);
160 #endif
161 
162 #endif
163