gap_int.h 5.4 KB

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