• 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 /* Attributes mask values to be used in HID_HostAddDev API */
29 #define HID_VIRTUAL_CABLE 0x0001
30 #define HID_NORMALLY_CONNECTABLE 0x0002
31 #define HID_RECONN_INIT 0x0004
32 #define HID_SDP_DISABLE 0x0008
33 #define HID_BATTERY_POWER 0x0010
34 #define HID_REMOTE_WAKE 0x0020
35 #define HID_SUP_TOUT_AVLBL 0x0040
36 #define HID_SSR_MAX_LATENCY 0x0080
37 #define HID_SSR_MIN_TOUT 0x0100
38 
39 #define HID_SEC_REQUIRED 0x8000
40 #define HID_ATTR_MASK_IGNORE 0
41 
42 /*****************************************************************************
43  *  Type Definitions
44  ****************************************************************************/
45 
46 typedef void(tHID_HOST_SDP_CALLBACK)(uint16_t result, uint16_t attr_mask,
47                                      tHID_DEV_SDP_INFO* sdp_rec);
48 
49 /* HID-HOST returns the events in the following table to the application via
50  * tHID_HOST_DEV_CALLBACK
51  * HID_HDEV_EVT_OPEN  Connected to device with Interrupt and Control Channels
52  *                    in OPEN state.
53  *                                                      Data = NA
54  * HID_HDEV_EVT_CLOSE Connection with device is closed. Data = reason code.
55  * HID_HDEV_EVT_RETRYING   Lost connection is being re-connected.
56  *                                                      Data = Retrial number
57  * HID_HDEV_EVT_IN_REPORT  Device sent an input report  Data = Report Type
58  *                                                      pdata = pointer to
59  *                                                              BT_HDR
60  *                                                      (GKI buffer with report
61  *                                                       data.)
62  * HID_HDEV_EVT_HANDSHAKE  Device sent SET_REPORT       Data = Result-code
63  *                                                      pdata = NA.
64  * HID_HDEV_EVT_VC_UNPLUG  Device sent Virtual Unplug   Data = NA. pdata = NA.
65  */
66 
67 enum {
68   HID_HDEV_EVT_OPEN,
69   HID_HDEV_EVT_CLOSE,
70   HID_HDEV_EVT_RETRYING,
71   HID_HDEV_EVT_INTR_DATA,
72   HID_HDEV_EVT_INTR_DATC,
73   HID_HDEV_EVT_CTRL_DATA,
74   HID_HDEV_EVT_CTRL_DATC,
75   HID_HDEV_EVT_HANDSHAKE,
76   HID_HDEV_EVT_VC_UNPLUG
77 };
78 typedef void(tHID_HOST_DEV_CALLBACK)(
79     uint8_t dev_handle, const RawAddress& addr,
80     uint8_t event,  /* Event from HID-DEVICE. */
81     uint32_t data,  /* Integer data corresponding to the event.*/
82     BT_HDR* p_buf); /* Pointer data corresponding to the event. */
83 
84 /*****************************************************************************
85  *  External Function Declarations
86  ****************************************************************************/
87 
88 /*******************************************************************************
89  *
90  * Function         HID_HostGetSDPRecord
91  *
92  * Description      This function reads the device SDP record.
93  *
94  * Returns          tHID_STATUS
95  *
96  ******************************************************************************/
97 extern tHID_STATUS HID_HostGetSDPRecord(const RawAddress& addr,
98                                         tSDP_DISCOVERY_DB* p_db,
99                                         uint32_t db_len,
100                                         tHID_HOST_SDP_CALLBACK* sdp_cback);
101 
102 /*******************************************************************************
103  *
104  * Function         HID_HostRegister
105  *
106  * Description      This function registers HID-Host with lower layers.
107  *
108  * Returns          tHID_STATUS
109  *
110  ******************************************************************************/
111 extern tHID_STATUS HID_HostRegister(tHID_HOST_DEV_CALLBACK* dev_cback);
112 
113 /*******************************************************************************
114  *
115  * Function         HID_HostDeregister
116  *
117  * Description      This function is called when the host is about power down.
118  *
119  * Returns          tHID_STATUS
120  *
121  ******************************************************************************/
122 extern tHID_STATUS HID_HostDeregister(void);
123 
124 /*******************************************************************************
125  *
126  * Function         HID_HostAddDev
127  *
128  * Description      This is called so HID-host may manage this device.
129  *
130  * Returns          tHID_STATUS
131  *
132  ******************************************************************************/
133 extern tHID_STATUS HID_HostAddDev(const RawAddress& addr, uint16_t attr_mask,
134                                   uint8_t* handle);
135 
136 /*******************************************************************************
137  *
138  * Function         HID_HostRemoveDev
139  *
140  * Description      Removes the device from the list of devices that the host
141  *                  has to manage.
142  *
143  * Returns          tHID_STATUS
144  *
145  ******************************************************************************/
146 extern tHID_STATUS HID_HostRemoveDev(uint8_t dev_handle);
147 
148 /*******************************************************************************
149  *
150  * Function         HID_HostOpenDev
151  *
152  * Description      This function is called when the user wants to initiate a
153  *                  connection attempt to a device.
154  *
155  * Returns          void
156  *
157  ******************************************************************************/
158 extern tHID_STATUS HID_HostOpenDev(uint8_t dev_handle);
159 
160 /*******************************************************************************
161  *
162  * Function         HID_HostWriteDev
163  *
164  * Description      This function is called when the host has a report to send.
165  *
166  * Returns          void
167  *
168  ******************************************************************************/
169 extern tHID_STATUS HID_HostWriteDev(uint8_t dev_handle, uint8_t t_type,
170                                     uint8_t param, uint16_t data,
171                                     uint8_t report_id, BT_HDR* pbuf);
172 
173 /*******************************************************************************
174  *
175  * Function         HID_HostCloseDev
176  *
177  * Description      This function disconnects the device.
178  *
179  * Returns          void
180  *
181  ******************************************************************************/
182 extern tHID_STATUS HID_HostCloseDev(uint8_t dev_handle);
183 
184 /*******************************************************************************
185  * Function         HID_HostInit
186  *
187  * Description      Initialize the control block and trace variable
188  *
189  * Returns          void
190  ******************************************************************************/
191 extern void HID_HostInit(void);
192 
193 /*******************************************************************************
194  *
195  * Function         HID_HostSetTraceLevel
196  *
197  * Description      Set the trace level for HID Host. If called with the value
198  *                  0xFF, it simply reads the current trace level.
199  *
200  * Returns          the new (current) trace level
201  *
202  ******************************************************************************/
203 extern uint8_t HID_HostSetTraceLevel(uint8_t new_level);
204 
205 #endif /* HIDH_API_H */
206