2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifndef __BLUETOOTH_HID_API_H
19 #define __BLUETOOTH_HID_API_H
26 #define HID_ADDRESS_LENGTH 6
28 #define HID_ERROR_NONE ((int)0)
30 #define HID_ERROR_BASE ((int)0)
31 #define HID_ERROR_ALREADY_INITIALIZED ((int)HID_ERROR_BASE - 0x01)
32 #define HID_ERROR_NOT_INITIALIZED ((int)HID_ERROR_BASE - 0x01)
33 #define HID_ERROR_NOT_PAIRED ((int)HID_ERROR_BASE - 0x02)
34 #define HID_ERROR_INTERNAL ((int)HID_ERROR_BASE - 0x03)
35 #define HID_ERROR_INVALID_PARAM ((int)HID_ERROR_BASE - 0x04)
36 #define HID_ERROR_NOT_ENABLED ((int)HID_ERROR_BASE - 0x05)
37 #define HID_ERROR_CONNECTION_FAILED ((int)HID_ERROR_BASE - 0x06)
53 } hid_send_mouse_event_t;
60 } hid_send_key_event_t;
65 unsigned short key[3];
66 } hid_send_rc_key_event_t;
68 typedef void (*hid_cb_func_ptr)(int, hid_event_param_t *, void *);
71 unsigned char addr[HID_ADDRESS_LENGTH];
72 } hid_device_address_t;
76 * @fn int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data)
77 * @brief Initialize HID service and register the callback
79 * This function is a synchronous call.
81 * @return HID_ERROR_NONE - Success \n
82 * HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
83 * HID_ERROR_INTERNAL - Internal Error \n
84 * HID_ERROR_NOT_ENABLED - Not enabled \n
89 int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data);
92 * @fn int bluetooth_hid_deinit(void)
93 * @brief Initialize HID service and register the callback
95 * This function is a synchronous call.
97 * @return HID_ERROR_NONE - Success \n
98 * HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
103 int bluetooth_hid_deinit(void);
107 * @fn int bluetooth_hid_connect(hid_device_address_t *device_address)
109 * @brief Connect the HID device in the peer
111 * This function is a asynchronous call.
112 * The HID connect request is responded by BLUETOOTH_HID_CONNECTED event.
114 * @return HID_ERROR_NONE - Success \n
115 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
116 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
117 * HID_ERROR_NOT_ENABLED - Not enabled \n
118 * HID_ERROR_INTERNAL - Not enabled \n
119 * HID_ERROR_NOT_PAIRED - Not enabled \n
120 * HID_ERROR_CONNECTION_FAILED - Connection Fail \n
123 * @param[in] device_address This indicates an address of the device with which the pairing
124 * should be initiated
127 int bluetooth_hid_connect(hid_device_address_t *device_address);
130 * @fn int bluetooth_hid_disconnect(hid_device_address_t *device_address)
132 * @brief Disconnect the HID device in the peer
134 * This function is a asynchronous call.
135 * The HID connect request is responded by BLUETOOTH_HID_DISCONNECTED event.
137 * @return HID_ERROR_NONE - Success \n
138 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
139 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
140 * HID_ERROR_NOT_ENABLED - Not enabled \n
141 * HID_ERROR_INTERNAL - Not enabled \n
142 * HID_ERROR_NOT_PAIRED - Not enabled \n
143 * HID_ERROR_CONNECTION_FAILED - Connection Fail \n
146 * @param[in] device_address This indicates an address of the device with which the pairing
147 * should be initiated
150 int bluetooth_hid_disconnect(hid_device_address_t *device_address);
152 int bluetooth_hid_enable_barcode_feature(void);
155 * @fn int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data)
156 * @brief Initialize HID Device service and register the callback
158 * This function is a synchronous call.
160 * @return HID_ERROR_NONE - Success \n
161 * HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
162 * HID_ERROR_INTERNAL - Internal Error \n
163 * HID_ERROR_NOT_ENABLED - Not enabled \n
168 int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
171 * @fn int bluetooth_hid_device_deinit(void)
172 * @brief Initialize HID service and register the callback
174 * This function is a synchronous call.
176 * @return HID_ERROR_NONE - Success \n
177 * HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
182 int bluetooth_hid_device_deinit();
185 * @fn int bluetooth_hid_device_activate()
187 * @brief Register the HID Device UUID with bluez with RegisterProfile.
189 * This function is a asynchronous call.
191 * @return HID_ERROR_NONE - Success \n
192 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
193 * HID_ERROR_NOT_ENABLED - Not enabled \n
194 * HID_ERROR_INTERNAL - Not enabled \n
199 int bluetooth_hid_device_activate(void);
202 * @fn int bluetooth_hid_device_deactivate()
204 * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
206 * This function is a asynchronous call.
208 * @return HID_ERROR_NONE - Success \n
209 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
210 * HID_ERROR_NOT_ENABLED - Not enabled \n
211 * HID_ERROR_INTERNAL - Not enabled \n
216 int bluetooth_hid_device_deactivate(void);
219 * @fn int bluetooth_hid_device_connect(const char *remote_addr)
221 * @brief Initiate the connection for HID device role with remote device
222 * address specified as parameter.
224 * This function is a asynchronous call.
226 * @return HID_ERROR_NONE - Success \n
229 * @param[in] remote_addr device address of remote device.
232 int bluetooth_hid_device_connect(const char *remote_addr);
234 * @fn int bluetooth_hid_device_disconnect()
236 * @brief Terminate the connection with HID host device with DisconnectProfile.
238 * This function is a asynchronous call.
240 * @return HID_ERROR_NONE - Success \n
241 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
242 * HID_ERROR_NOT_ENABLED - Not enabled \n
243 * HID_ERROR_INTERNAL - Not enabled \n
246 * @param[in] remote_addr device address of remote device.
250 int bluetooth_hid_device_disconnect(const char *remote_addr);
253 * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
255 * @brief write the event data on the socket.
257 * This function is a asynchronous call.
259 * @return HID_ERROR_NONE - Success \n
260 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
261 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
262 * HID_ERROR_NOT_ENABLED - Not enabled \n
263 * HID_ERROR_INTERNAL - Not enabled \n
266 * @param[in] remote_addr device address of remote device.
267 * @param[in] send_event This indicates the event data to send to remote device.
270 int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
271 hid_send_mouse_event_t send_event);
274 * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
276 * @brief write the event data on the socket.
278 * This function is a asynchronous call.
280 * @return HID_ERROR_NONE - Success \n
281 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
282 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
283 * HID_ERROR_NOT_ENABLED - Not enabled \n
284 * HID_ERROR_INTERNAL - Not enabled \n
287 * @param[in] remote_addr device address of remote device.
288 * @param[in] send_event This indicates the event data to send to remote device.
291 int bluetooth_hid_device_send_key_event(const char *remote_addr,
292 hid_send_key_event_t send_event);
295 * @fn int bluetooth_hid_device_send_rc_key_event(
296 * const char *remote_addr, hid_send_rc_key_event_t send_event)
298 * @brief write the event data on the socket.
300 * This function is a asynchronous call.
302 * @return HID_ERROR_NONE - Success \n
303 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
304 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
305 * HID_ERROR_NOT_ENABLED - Not enabled \n
306 * HID_ERROR_INTERNAL - Not enabled \n
309 * @param[in] remote_addr device address of remote device.
310 * @param[in] send_event This indicates the event data to send to remote device.
313 int bluetooth_hid_device_send_rc_key_event(const char *remote_addr,
314 hid_send_rc_key_event_t send_event);
316 * @fn int bluetooth_hid_device_reply_to_report(const char *remote_addr,
317 * bt_hid_header_type_t htype,
318 * bt_hid_param_type_t ptype,
321 * @brief write the event data on the socket.
323 * This function is a asynchronous call.
325 * @return HID_ERROR_NONE - Success \n
326 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
327 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
328 * HID_ERROR_NOT_ENABLED - Not enabled \n
329 * HID_ERROR_INTERNAL - Not enabled \n
332 * @param[in] remote_addr device address of remote device.
333 * @param[in] htype header type to be present in response
334 * @param[in] ptype Parameter type to be present in response.
335 * @param[in] buffer Data need to be send in reponse payload.
338 int bluetooth_hid_device_reply_to_report(const char *remote_addr,
339 bt_hid_header_type_t htype,
340 bt_hid_param_type_t ptype,
342 unsigned int data_len);
347 #endif /* __BLUETOOTH_HID_API_H */