1 /******************************************************************************
2  *
3  *  Copyright 2002-2012 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  *
21  *  This file contains HID HOST internal definitions
22  *
23  ******************************************************************************/
24 
25 #ifndef HIDH_INT_H
26 #define HIDH_INT_H
27 
28 #include <cstdint>
29 
30 #include "internal_include/bt_target.h"
31 #include "stack/hid/hid_conn.h"
32 #include "stack/include/bt_hdr.h"
33 #include "stack/include/hidh_api.h"
34 #include "stack/include/l2c_api.h"  // tL2CAP_CFG_INFO
35 #include "types/raw_address.h"
36 
37 enum { HID_DEV_NO_CONN, HID_DEV_CONNECTED };
38 
39 typedef struct per_device_ctb {
40   bool in_use;
41   RawAddress addr;    /* BD-Addr of the host device */
42   uint16_t attr_mask; /* 0x01- virtual_cable; 0x02- normally_connectable; 0x03-
43                          reconn_initiate;
44                                  0x04- sdp_disable; */
45   uint8_t state;      /* Device state if in HOST-KNOWN mode */
46   uint8_t conn_tries; /* Remembers the number of connection attempts while
47                          CONNECTING */
48 
49   tHID_CONN conn; /* L2CAP channel info */
50 } tHID_HOST_DEV_CTB;
51 
52 typedef struct host_ctb {
53   tHID_HOST_DEV_CTB devices[HID_HOST_MAX_DEVICES];
54   tHID_HOST_DEV_CALLBACK* callback; /* Application callbacks */
55   tL2CAP_CFG_INFO l2cap_cfg;
56 
57 #define MAX_SERVICE_DB_SIZE 4000
58 
59   bool sdp_busy;
60   tHID_HOST_SDP_CALLBACK* sdp_cback;
61   tSDP_DISCOVERY_DB* p_sdp_db;
62   tHID_DEV_SDP_INFO sdp_rec;
63   bool reg_flag;
64 } tHID_HOST_CTB;
65 
66 tHID_STATUS hidh_conn_snd_data(uint8_t dhandle, uint8_t trans_type,
67                                uint8_t param, uint16_t data, uint8_t rpt_id,
68                                BT_HDR* buf);
69 tHID_STATUS hidh_conn_reg(void);
70 void hidh_conn_dereg(void);
71 tHID_STATUS hidh_conn_disconnect(uint8_t dhandle);
72 tHID_STATUS hidh_conn_initiate(uint8_t dhandle);
73 
74 /******************************************************************************
75  * Main Control Block
76  ******************************************************************************/
77 extern tHID_HOST_CTB hh_cb;
78 
79 #endif
80