1 /******************************************************************************
2  *
3  *  Copyright (C) 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 #ifndef HIDH_API_H
19 #define HIDH_API_H
20 
21 #include "stack/hiddefs.h"
22 #include "stack/sdp_api.h"
23 
24 #if (HID_HOST_INCLUDED == TRUE)
25 /*****************************************************************************
26 **  Constants
27 *****************************************************************************/
28 
29 enum {
30     HID_SDP_NO_SERV_UUID = (SDP_ILLEGAL_PARAMETER + 1),
31     HID_SDP_MANDATORY_MISSING
32 };
33 
34 /* Attributes mask values to be used in HID_HostAddDev API */
35 #define HID_VIRTUAL_CABLE        0x0001
36 #define HID_NORMALLY_CONNECTABLE 0x0002
37 #define HID_RECONN_INIT          0x0004
38 #define HID_SDP_DISABLE          0x0008
39 #define HID_BATTERY_POWER        0x0010
40 #define HID_REMOTE_WAKE          0x0020
41 #define HID_SUP_TOUT_AVLBL       0x0040
42 #define HID_SSR_MAX_LATENCY      0x0080
43 #define HID_SSR_MIN_TOUT         0x0100
44 
45 #define HID_SEC_REQUIRED         0x8000
46 #define HID_ATTR_MASK_IGNORE     0
47 
48 
49 /*****************************************************************************
50 **  Type Definitions
51 *****************************************************************************/
52 
53 typedef void (tHID_HOST_SDP_CALLBACK) (UINT16 result, UINT16 attr_mask,
54                                        tHID_DEV_SDP_INFO *sdp_rec );
55 
56 /* HID-HOST returns the events in the following table to the application via tHID_HOST_DEV_CALLBACK
57 HID_HDEV_EVT_OPEN   Connected to device with Interrupt and Control Channels in OPEN state.
58                                                         Data = NA
59 HID_HDEV_EVT_CLOSE  Connection with device is closed.   Data=reason code.
60 HID_HDEV_EVT_RETRYING   Lost connection is being re-connected.
61                                                         Data=Retrial number
62 HID_HDEV_EVT_IN_REPORT  Device sent an input report     Data=Report Type pdata= pointer to BT_HDR
63                                                         (GKI buffer having report data.)
64 HID_HDEV_EVT_HANDSHAKE  Device sent SET_REPORT          Data=Result-code pdata=NA.
65 HID_HDEV_EVT_VC_UNPLUG  Device sent Virtual Unplug      Data=NA. pdata=NA.
66 */
67 
68 enum {
69     HID_HDEV_EVT_OPEN,
70     HID_HDEV_EVT_CLOSE,
71     HID_HDEV_EVT_RETRYING,
72     HID_HDEV_EVT_INTR_DATA,
73     HID_HDEV_EVT_INTR_DATC,
74     HID_HDEV_EVT_CTRL_DATA,
75     HID_HDEV_EVT_CTRL_DATC,
76     HID_HDEV_EVT_HANDSHAKE,
77     HID_HDEV_EVT_VC_UNPLUG
78 };
79 typedef void (tHID_HOST_DEV_CALLBACK) (UINT8 dev_handle,
80                                        BD_ADDR addr,
81                                        UINT8 event, /* Event from HID-DEVICE. */
82                                        UINT32 data, /* Integer data corresponding to the event.*/
83                                        BT_HDR *p_buf ); /* Pointer data corresponding to the event. */
84 
85 
86 /*****************************************************************************
87 **  External Function Declarations
88 *****************************************************************************/
89 #ifdef __cplusplus
90 extern "C"
91 {
92 #endif
93 
94 /*******************************************************************************
95 **
96 ** Function         HID_HostGetSDPRecord
97 **
98 ** Description      This function reads the device SDP record.
99 **
100 ** Returns          tHID_STATUS
101 **
102 *******************************************************************************/
103 extern tHID_STATUS HID_HostGetSDPRecord (BD_ADDR addr,
104         tSDP_DISCOVERY_DB *p_db,
105         UINT32 db_len,
106         tHID_HOST_SDP_CALLBACK *sdp_cback );
107 
108 /*******************************************************************************
109 **
110 ** Function         HID_HostRegister
111 **
112 ** Description      This function registers HID-Host with lower layers.
113 **
114 ** Returns          tHID_STATUS
115 **
116 *******************************************************************************/
117 extern tHID_STATUS HID_HostRegister (tHID_HOST_DEV_CALLBACK *dev_cback);
118 
119 /*******************************************************************************
120 **
121 ** Function         HID_HostDeregister
122 **
123 ** Description      This function is called when the host is about power down.
124 **
125 ** Returns          tHID_STATUS
126 **
127 *******************************************************************************/
128 extern tHID_STATUS HID_HostDeregister(void);
129 
130 /*******************************************************************************
131 **
132 ** Function         HID_HostAddDev
133 **
134 ** Description      This is called so HID-host may manage this device.
135 **
136 ** Returns          tHID_STATUS
137 **
138 *******************************************************************************/
139 extern tHID_STATUS HID_HostAddDev (BD_ADDR addr, UINT16 attr_mask,
140                                    UINT8 *handle );
141 
142 /*******************************************************************************
143 **
144 ** Function         HID_HostGetDev
145 **
146 ** Description      This is called so HID-host can find this device.
147 **
148 ** Returns          tHID_STATUS
149 **
150 *******************************************************************************/
151 extern tHID_STATUS HID_HostGetDev(BD_ADDR addr, UINT8 *handle);
152 
153 /*******************************************************************************
154 **
155 ** Function         HID_HostRemoveDev
156 **
157 ** Description      This removes the device from list devices that host has to manage.
158 **
159 ** Returns          tHID_STATUS
160 **
161 *******************************************************************************/
162 extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle );
163 
164 /*******************************************************************************
165 **
166 ** Function         HID_HostOpenDev
167 **
168 ** Description      This function is called when the user wants to initiate a
169 **                  connection attempt to a device.
170 **
171 ** Returns          void
172 **
173 *******************************************************************************/
174 extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle );
175 
176 /*******************************************************************************
177 **
178 ** Function         HID_HostWriteDev
179 **
180 ** Description      This function is called when the host has a report to send.
181 **
182 ** Returns          void
183 **
184 *******************************************************************************/
185 extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type,
186                                     UINT8 param, UINT16 data,
187                                     UINT8 report_id, BT_HDR *pbuf);
188 
189 /*******************************************************************************
190 **
191 ** Function         HID_HostCloseDev
192 **
193 ** Description      This function disconnects the device.
194 **
195 ** Returns          void
196 **
197 *******************************************************************************/
198 extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle );
199 
200 /*******************************************************************************
201 ** Function         HID_HostInit
202 **
203 ** Description      This function initializes the control block and trace variable
204 **
205 ** Returns          tHID_STATUS
206 *******************************************************************************/
207 extern tHID_STATUS HID_HostInit(void);
208 
209 /*******************************************************************************
210 ** Function         HID_HostDeinit
211 **
212 ** Description      This function deinitializes the control block
213 **
214 ** Returns          void
215 *******************************************************************************/
216 extern void HID_HostDeinit(void);
217 
218 /*******************************************************************************
219 ** Function        HID_HostSetSecurityLevel
220 **
221 ** Description     This function sets the security level for the devices which
222 **                 are marked by application as requiring security
223 **
224 ** Returns         tHID_STATUS
225 *******************************************************************************/
226 extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl );
227 
228 /*******************************************************************************
229 **
230 ** Function         hid_known_hid_device
231 **
232 ** Description      This function checks if this device is  of type HID Device
233 **
234 ** Returns          TRUE if device exists else FALSE
235 **
236 *******************************************************************************/
237 BOOLEAN hid_known_hid_device (BD_ADDR bd_addr);
238 
239 
240 /*******************************************************************************
241 **
242 ** Function         HID_HostSetTraceLevel
243 **
244 ** Description      This function sets the trace level for HID Host. If called with
245 **                  a value of 0xFF, it simply reads the current trace level.
246 **
247 ** Returns          the new (current) trace level
248 **
249 *******************************************************************************/
250 extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
251 
252 #ifdef __cplusplus
253 }
254 #endif
255 
256 #endif  ///HID_HOST_INCLUDED == TRUE
257 
258 #endif  /* HIDH_API_H */
259