hidh_api.h 8.5 KB

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