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 #ifndef GAP_INT_H 20 #define GAP_INT_H 21 22 #include "bt_common.h" 23 #include "bt_target.h" 24 #include "gap_api.h" 25 #include "gatt_api.h" 26 #include "osi/include/fixed_queue.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 void* p_data; /* Pointer to any data returned in callback */ 31 tGAP_CALLBACK* gap_cback; /* Pointer to users callback function */ 32 tGAP_CALLBACK* gap_inq_rslt_cback; /* Used for inquiry results */ 33 uint16_t event; /* Passed back in the callback */ 34 uint8_t index; /* Index of this control block and callback */ 35 bool in_use; /* True when structure is allocated */ 36 } tGAP_INFO; 37 38 /* The control block for FindAddrByName (Only 1 active at a time) */ 39 typedef struct { 40 tGAP_CALLBACK* p_cback; 41 /* Pointer to the current inquiry database entry */ 42 tBTM_INQ_INFO* p_cur_inq; 43 tGAP_FINDADDR_RESULTS results; 44 bool in_use; 45 } tGAP_FINDADDR_CB; 46 47 /* Define the GAP Connection Control Block. 48 */ 49 typedef struct { 50 #define GAP_CCB_STATE_IDLE 0 51 #define GAP_CCB_STATE_LISTENING 1 52 #define GAP_CCB_STATE_CONN_SETUP 2 53 #define GAP_CCB_STATE_CFG_SETUP 3 54 #define GAP_CCB_STATE_WAIT_SEC 4 55 #define GAP_CCB_STATE_CONNECTED 5 56 uint8_t con_state; 57 58 #define GAP_CCB_FLAGS_IS_ORIG 0x01 59 #define GAP_CCB_FLAGS_HIS_CFG_DONE 0x02 60 #define GAP_CCB_FLAGS_MY_CFG_DONE 0x04 61 #define GAP_CCB_FLAGS_SEC_DONE 0x08 62 #define GAP_CCB_FLAGS_CONN_DONE 0x0E 63 uint8_t con_flags; 64 65 uint8_t service_id; /* Used by BTM */ 66 uint16_t gap_handle; /* GAP handle */ 67 uint16_t connection_id; /* L2CAP CID */ 68 bool rem_addr_specified; 69 uint8_t chan_mode_mask; /* Supported channel modes (FCR) */ 70 BD_ADDR rem_dev_address; 71 uint16_t psm; 72 uint16_t rem_mtu_size; 73 74 bool is_congested; 75 fixed_queue_t* tx_queue; /* Queue of buffers waiting to be sent */ 76 fixed_queue_t* rx_queue; /* Queue of buffers waiting to be read */ 77 78 uint32_t rx_queue_size; /* Total data count in rx_queue */ 79 80 tGAP_CONN_CALLBACK* p_callback; /* Users callback function */ 81 82 tL2CAP_CFG_INFO cfg; /* Configuration */ 83 tL2CAP_ERTM_INFO ertm_info; /* Pools and modes for ertm */ 84 tBT_TRANSPORT transport; /* Transport channel BR/EDR or BLE */ 85 tL2CAP_LE_CFG_INFO local_coc_cfg; /* local configuration for LE Coc */ 86 tL2CAP_LE_CFG_INFO peer_coc_cfg; /* local configuration for LE Coc */ 87 } tGAP_CCB; 88 89 typedef struct { 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 #define GAP_MAX_CHAR_NUM 4 99 100 typedef struct { 101 uint16_t handle; 102 uint16_t uuid; 103 tGAP_BLE_ATTR_VALUE attr_value; 104 } tGAP_ATTR; 105 /********************************************************************** 106 * M A I N C O N T R O L B L O C K 107 **********************************************************************/ 108 109 #define GAP_MAX_CL GATT_CL_MAX_LCB 110 111 typedef struct { 112 uint16_t uuid; 113 tGAP_BLE_CMPL_CBACK* p_cback; 114 } tGAP_BLE_REQ; 115 116 typedef struct { 117 BD_ADDR bda; 118 tGAP_BLE_CMPL_CBACK* p_cback; 119 uint16_t conn_id; 120 uint16_t cl_op_uuid; 121 bool in_use; 122 bool connected; 123 fixed_queue_t* pending_req_q; 124 125 } tGAP_CLCB; 126 127 typedef struct { 128 tGAP_INFO blk[GAP_MAX_BLOCKS]; 129 tBTM_CMPL_CB* btm_cback[GAP_MAX_BLOCKS]; 130 uint8_t trace_level; 131 tGAP_FINDADDR_CB 132 findaddr_cb; /* Contains the control block for finding a device addr */ 133 tBTM_INQ_INFO* cur_inqptr; 134 135 #if (GAP_CONN_INCLUDED == TRUE) 136 tGAP_CONN conn; 137 #endif 138 139 /* LE GAP attribute database */ 140 tGAP_ATTR gatt_attr[GAP_MAX_CHAR_NUM]; 141 tGAP_CLCB clcb[GAP_MAX_CL]; /* connection link*/ 142 tGATT_IF gatt_if; 143 } tGAP_CB; 144 145 extern tGAP_CB gap_cb; 146 #if (GAP_CONN_INCLUDED == TRUE) 147 extern void gap_conn_init(void); 148 #endif 149 extern void gap_attr_db_init(void); 150 #endif 151