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