hidh_api.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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 "hiddefs.h"
  21. #include "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_HostRemoveDev
  128. **
  129. ** Description This removes the device from list devices that host has to manage.
  130. **
  131. ** Returns tHID_STATUS
  132. **
  133. *******************************************************************************/
  134. extern tHID_STATUS HID_HostRemoveDev (UINT8 dev_handle );
  135. /*******************************************************************************
  136. **
  137. ** Function HID_HostOpenDev
  138. **
  139. ** Description This function is called when the user wants to initiate a
  140. ** connection attempt to a device.
  141. **
  142. ** Returns void
  143. **
  144. *******************************************************************************/
  145. extern tHID_STATUS HID_HostOpenDev (UINT8 dev_handle );
  146. /*******************************************************************************
  147. **
  148. ** Function HID_HostWriteDev
  149. **
  150. ** Description This function is called when the host has a report to send.
  151. **
  152. ** Returns void
  153. **
  154. *******************************************************************************/
  155. extern tHID_STATUS HID_HostWriteDev(UINT8 dev_handle, UINT8 t_type,
  156. UINT8 param, UINT16 data,
  157. UINT8 report_id, BT_HDR *pbuf);
  158. /*******************************************************************************
  159. **
  160. ** Function HID_HostCloseDev
  161. **
  162. ** Description This function disconnects the device.
  163. **
  164. ** Returns void
  165. **
  166. *******************************************************************************/
  167. extern tHID_STATUS HID_HostCloseDev(UINT8 dev_handle );
  168. /*******************************************************************************
  169. ** Function HID_HostInit
  170. **
  171. ** Description This function initializes the control block and trace variable
  172. **
  173. ** Returns void
  174. *******************************************************************************/
  175. extern void HID_HostInit(void);
  176. /*******************************************************************************
  177. ** Function HID_HostSetSecurityLevel
  178. **
  179. ** Description This function sets the security level for the devices which
  180. ** are marked by application as requiring security
  181. **
  182. ** Returns tHID_STATUS
  183. *******************************************************************************/
  184. extern tHID_STATUS HID_HostSetSecurityLevel( char serv_name[], UINT8 sec_lvl );
  185. /*******************************************************************************
  186. **
  187. ** Function hid_known_hid_device
  188. **
  189. ** Description This function checks if this device is of type HID Device
  190. **
  191. ** Returns TRUE if device exists else FALSE
  192. **
  193. *******************************************************************************/
  194. BOOLEAN hid_known_hid_device (BD_ADDR bd_addr);
  195. /*******************************************************************************
  196. **
  197. ** Function HID_HostSetTraceLevel
  198. **
  199. ** Description This function sets the trace level for HID Host. If called with
  200. ** a value of 0xFF, it simply reads the current trace level.
  201. **
  202. ** Returns the new (current) trace level
  203. **
  204. *******************************************************************************/
  205. extern UINT8 HID_HostSetTraceLevel (UINT8 new_level);
  206. #ifdef __cplusplus
  207. }
  208. #endif
  209. #endif ///HID_HOST_INCLUDED == TRUE
  210. #endif /* HIDH_API_H */