hidh_api.h 9.3 KB

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