hidkbdservice.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. #ifndef HIDKBDSERVICE_H
  29. #define HIDKBDSERVICE_H
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #endif
  34. /*********************************************************************
  35. * INCLUDES
  36. */
  37. /*********************************************************************
  38. * CONSTANTS
  39. */
  40. #define FOLLOW_TI_MAP 1
  41. #if FOLLOW_TI_MAP
  42. // Number of HID reports defined in the service
  43. #define HID_NUM_REPORTS 5//7
  44. // HID Report IDs for the service
  45. #define HID_RPT_ID_LED_OUT 0 // LED output report ID
  46. #define HID_RPT_ID_KEY_IN 1 // Keyboard input report ID
  47. #define HID_RPT_ID_CC_IN 2 // Consumer Control input report ID
  48. #define HID_RPT_ID_VOICE_START_IN 10 // Voice Start input report ID
  49. #define HID_RPT_ID_VOICE_DATA_IN 11 // Voice Data input report ID
  50. //voice defines
  51. #define BLE_VOICE_CMD_STOP 0x00
  52. #define BLE_VOICE_CMD_START 0x04
  53. #define HID_VOICE_IN_START_LEN 5
  54. #define HID_RPT_ID_MOUSE_IN 0xFF
  55. enum
  56. {
  57. HID_SERVICE_IDX, // HID Service
  58. HID_INCLUDED_SERVICE_IDX, // Included Service (battery)
  59. HID_INFO_DECL_IDX, // HID Information characteristic declaration
  60. HID_INFO_IDX, // HID Information characteristic
  61. HID_CONTROL_POINT_DECL_IDX, // HID Control Point characteristic declaration
  62. HID_CONTROL_POINT_IDX, // HID Control Point characteristic
  63. HID_PROTOCOL_MODE_DECL_IDX, // HID Protocol Mode characteristic declaration
  64. HID_PROTOCOL_MODE_IDX, // HID Protocol Mode characteristic
  65. HID_REPORT_MAP_DECL_IDX, // HID Report Map characteristic declaration
  66. HID_REPORT_MAP_IDX, // HID Report Map characteristic
  67. HID_EXT_REPORT_REF_DESC_IDX, // HID External Report Reference Descriptor
  68. HID_REPORT_KEY_IN_DECL_IDX, // HID Report characteristic declaration, key input
  69. HID_REPORT_KEY_IN_IDX, // HID Report characteristic, key input
  70. HID_REPORT_KEY_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration, key input
  71. HID_REPORT_REF_KEY_IN_IDX, // HID Report Reference characteristic descriptor, key input
  72. HID_REPORT_LED_OUT_DECL_IDX, // HID Report characteristic, LED output declaration
  73. HID_REPORT_LED_OUT_IDX, // HID Report characteristic, LED output
  74. HID_REPORT_REF_LED_OUT_IDX, // HID Report Reference characteristic descriptor, LED output
  75. HID_BOOT_KEY_IN_DECL_IDX, // HID Boot Keyboard Input Report declaration
  76. HID_BOOT_KEY_IN_IDX, // HID Boot Keyboard Input Report
  77. HID_BOOT_KEY_IN_CCCD_IDX, // HID Boot Keyboard Input Report characteristic client characteristic configuration
  78. HID_BOOT_KEY_OUT_DECL_IDX, // HID Boot Keyboard Output Report declaration
  79. HID_BOOT_KEY_OUT_IDX, // HID Boot Keyboard Output Report
  80. HID_REPORT_CC_IN_DECL_IDX, // HID Report characteristic declaration, consumer control
  81. HID_REPORT_CC_IN_IDX, // HID Report characteristic, consumer control
  82. HID_REPORT_CC_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration, consumer control
  83. HID_REPORT_REF_CC_IN_IDX, // HID Report Reference characteristic descriptor, consumer control
  84. HID_VOICE_START_IN_DECL_IDX, // HID Voice Start Input Report declaration
  85. HID_VOICE_START_IN_IDX, // HID Voice Start Input Report
  86. HID_VOICE_START_IN_CCCD_IDX, // HID Voice Start Input Report characteristic client characteristic configuration
  87. HID_REPORT_REF_VOICE_START_IDX, // HID Report Reference characteristic descriptor, Voice Start
  88. HID_VOICE_DATA_IN_DECL_IDX, // HID Voice Start Input Report declaration
  89. HID_VOICE_DATA_IN_IDX, // HID Voice Start Input Report
  90. HID_VOICE_DATA_IN_CCCD_IDX, // HID Voice Start Input Report characteristic client characteristic configuration
  91. HID_REPORT_REF_VOICE_DATA_IDX, // HID Report Reference characteristic descriptor, Voice Start
  92. };
  93. #else
  94. // HID Report IDs for the service
  95. #define HID_RPT_ID_MOUSE_IN 1 // Mouse input report ID
  96. #define HID_RPT_ID_KEY_IN 2 // Keyboard input report ID
  97. #define HID_RPT_ID_CC_IN 3
  98. #define HID_RPT_ID_LED_OUT 0 // LED output report ID
  99. #define HID_RPT_ID_FEATURE 0 // Feature report ID
  100. #define EN_VOICE_MODE 1
  101. #define EN_CONSUMER_MODE 1
  102. #define EN_MOUSE_REPORT 1
  103. #if EN_VOICE_MODE
  104. #define HID_RPT_ID_VOICE_START_IN 10 // Voice Start input report ID
  105. #define HID_RPT_ID_VOICE_DATA_IN 11 // Voice Data input report ID
  106. // Number of HID reports defined in the service
  107. #define HID_NUM_REPORTS 11
  108. //voice defines
  109. #define BLE_VOICE_CMD_STOP 0x00
  110. #define BLE_VOICE_CMD_START 0x04
  111. #else
  112. // Number of HID reports defined in the service
  113. #define HID_NUM_REPORTS 7
  114. #endif
  115. // Attribute index enumeration-- these indexes match array elements above
  116. enum
  117. {
  118. HID_SERVICE_IDX, // HID Service
  119. HID_INCLUDED_SERVICE_IDX, // Included Service
  120. HID_INFO_DECL_IDX, // HID Information characteristic declaration
  121. HID_INFO_IDX, // HID Information characteristic
  122. HID_CONTROL_POINT_DECL_IDX, // HID Control Point characteristic declaration
  123. HID_CONTROL_POINT_IDX, // HID Control Point characteristic
  124. HID_PROTOCOL_MODE_DECL_IDX, // HID Protocol Mode characteristic declaration
  125. HID_PROTOCOL_MODE_IDX, // HID Protocol Mode characteristic
  126. HID_REPORT_MAP_DECL_IDX, // HID Report Map characteristic declaration
  127. HID_REPORT_MAP_IDX, // HID Report Map characteristic
  128. HID_EXT_REPORT_REF_DESC_IDX, // HID External Report Reference Descriptor
  129. #if EN_MOUSE_REPORT
  130. HID_REPORT_MOUSE_IN_DECL_IDX, // HID Report characteristic, mouse input declaration
  131. HID_REPORT_MOUSE_IN_IDX, // HID Report characteristic, mouse input
  132. HID_REPORT_MOUSE_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration
  133. HID_REPORT_REF_MOUSE_IN_IDX, // HID Report Reference characteristic descriptor, mouse input
  134. #endif
  135. HID_REPORT_KEY_IN_DECL_IDX, // HID Report characteristic, key input declaration
  136. HID_REPORT_KEY_IN_IDX, // HID Report characteristic, key input
  137. HID_REPORT_KEY_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration
  138. HID_REPORT_REF_KEY_IN_IDX, // HID Report Reference characteristic descriptor, key input
  139. HID_REPORT_LED_OUT_DECL_IDX, // HID Report characteristic, LED output declaration
  140. HID_REPORT_LED_OUT_IDX, // HID Report characteristic, LED output
  141. HID_REPORT_REF_LED_OUT_IDX, // HID Report Reference characteristic descriptor, LED output
  142. HID_BOOT_KEY_IN_DECL_IDX, // HID Boot Keyboard Input Report declaration
  143. HID_BOOT_KEY_IN_IDX, // HID Boot Keyboard Input Report
  144. HID_BOOT_KEY_IN_CCCD_IDX, // HID Boot Keyboard Input Report characteristic client characteristic configuration
  145. HID_BOOT_KEY_OUT_DECL_IDX, // HID Boot Keyboard Output Report declaration
  146. HID_BOOT_KEY_OUT_IDX, // HID Boot Keyboard Output Report
  147. #if EN_CONSUMER_MODE
  148. HID_REPORT_CC_IN_DECL_IDX, // HID Report characteristic declaration, consumer control
  149. HID_REPORT_CC_IN_IDX, // HID Report characteristic, consumer control
  150. HID_REPORT_CC_IN_CCCD_IDX, // HID Report characteristic client characteristic configuration, consumer control
  151. HID_REPORT_REF_CC_IN_IDX, // HID Report Reference characteristic descriptor, consumer control
  152. #endif
  153. HID_BOOT_MOUSE_IN_DECL_IDX, // HID Boot Mouse Input Report declaration
  154. HID_BOOT_MOUSE_IN_IDX, // HID Boot Mouse Input Report
  155. HID_BOOT_MOUSE_IN_CCCD_IDX, // HID Boot Mouse Input Report characteristic client characteristic configuration
  156. HID_FEATURE_DECL_IDX, // Feature Report declaration
  157. HID_FEATURE_IDX, // Feature Report
  158. HID_REPORT_REF_FEATURE_IDX // HID Report Reference characteristic descriptor, feature
  159. #if EN_VOICE_MODE
  160. ,
  161. HID_VOICE_START_IN_DECL_IDX, // HID Voice Start Input Report declaration
  162. HID_VOICE_START_IN_IDX, // HID Voice Start Input Report
  163. HID_VOICE_START_IN_CCCD_IDX, // HID Voice Start Input Report characteristic client characteristic configuration
  164. HID_REPORT_REF_VOICE_START_IDX, // HID Report Reference characteristic descriptor, Voice Start
  165. HID_VOICE_DATA_IN_DECL_IDX, // HID Voice Start Input Report declaration
  166. HID_VOICE_DATA_IN_IDX, // HID Voice Start Input Report
  167. HID_VOICE_DATA_IN_CCCD_IDX, // HID Voice Start Input Report characteristic client characteristic configuration
  168. HID_REPORT_REF_VOICE_DATA_IDX, // HID Report Reference characteristic descriptor, Voice Start
  169. #endif
  170. };
  171. #endif
  172. // HID feature flags
  173. #define HID_KBD_FLAGS HID_FLAGS_REMOTE_WAKE
  174. /*********************************************************************
  175. * TYPEDEFS
  176. */
  177. /*********************************************************************
  178. * MACROS
  179. */
  180. /*********************************************************************
  181. * Profile Callbacks
  182. */
  183. /*********************************************************************
  184. * API FUNCTIONS
  185. */
  186. /*********************************************************************
  187. * @fn HidKbd_AddService
  188. *
  189. * @brief Initializes the HID service for keyboard by registering
  190. * GATT attributes with the GATT server.
  191. *
  192. * @param none
  193. *
  194. * @return Success or Failure
  195. */
  196. extern bStatus_t HidKbd_AddService(void);
  197. /*********************************************************************
  198. * @fn HidKbd_SetParameter
  199. *
  200. * @brief Set a HID Kbd parameter.
  201. *
  202. * @param id - HID report ID.
  203. * @param type - HID report type.
  204. * @param uuid - attribute uuid.
  205. * @param len - length of data to right.
  206. * @param pValue - pointer to data to write. This is dependent on
  207. * the input parameters and WILL be cast to the appropriate
  208. * data type (example: data type of uint16 will be cast to
  209. * uint16 pointer).
  210. *
  211. * @return GATT status code.
  212. */
  213. extern uint8 HidKbd_SetParameter( uint8 id, uint8 type, uint16 uuid, uint8 len, void *pValue );
  214. /*********************************************************************
  215. * @fn HidKbd_GetParameter
  216. *
  217. * @brief Get a HID Kbd parameter.
  218. *
  219. * @param id - HID report ID.
  220. * @param type - HID report type.
  221. * @param uuid - attribute uuid.
  222. * @param pLen - length of data to be read.
  223. * @param pValue - pointer to data to get. This is dependent on
  224. * the input parameters and WILL be cast to the appropriate
  225. * data type (example: data type of uint16 will be cast to
  226. * uint16 pointer).
  227. *
  228. * @return GATT status code.
  229. */
  230. extern uint8 HidKbd_GetParameter( uint8 id, uint8 type, uint16 uuid, uint8 *pLen, void *pValue );
  231. /*********************************************************************
  232. *********************************************************************/
  233. #ifdef __cplusplus
  234. }
  235. #endif
  236. #endif /* HIDKBDSERVICE_H */