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;
62 typedef void (*hid_cb_func_ptr)(int, hid_event_param_t *, void *);
65 unsigned char addr[HID_ADDRESS_LENGTH];
66 } hid_device_address_t;
70 * @fn int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data)
71 * @brief Initialize HID service and register the callback
73 * This function is a synchronous call.
75 * @return HID_ERROR_NONE - Success \n
76 * HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
77 * HID_ERROR_INTERNAL - Internal Error \n
78 * HID_ERROR_NOT_ENABLED - Not enabled \n
83 int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data);
86 * @fn int bluetooth_hid_deinit(void)
87 * @brief Initialize HID service and register the callback
89 * This function is a synchronous call.
91 * @return HID_ERROR_NONE - Success \n
92 * HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
97 int bluetooth_hid_deinit(void);
101 * @fn int bluetooth_hid_connect(hid_device_address_t *device_address)
103 * @brief Connect the HID device in the peer
105 * This function is a asynchronous call.
106 * The HID connect request is responded by BLUETOOTH_HID_CONNECTED event.
108 * @return HID_ERROR_NONE - Success \n
109 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
110 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
111 * HID_ERROR_NOT_ENABLED - Not enabled \n
112 * HID_ERROR_INTERNAL - Not enabled \n
113 * HID_ERROR_NOT_PAIRED - Not enabled \n
114 * HID_ERROR_CONNECTION_FAILED - Connection Fail \n
117 * @param[in] device_address This indicates an address of the device with which the pairing
118 * should be initiated
121 int bluetooth_hid_connect(hid_device_address_t *device_address);
124 * @fn int bluetooth_hid_disconnect(hid_device_address_t *device_address)
126 * @brief Disconnect the HID device in the peer
128 * This function is a asynchronous call.
129 * The HID connect request is responded by BLUETOOTH_HID_DISCONNECTED event.
131 * @return HID_ERROR_NONE - Success \n
132 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
133 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
134 * HID_ERROR_NOT_ENABLED - Not enabled \n
135 * HID_ERROR_INTERNAL - Not enabled \n
136 * HID_ERROR_NOT_PAIRED - Not enabled \n
137 * HID_ERROR_CONNECTION_FAILED - Connection Fail \n
140 * @param[in] device_address This indicates an address of the device with which the pairing
141 * should be initiated
144 int bluetooth_hid_disconnect(hid_device_address_t *device_address);
146 int bluetooth_hid_enable_barcode_feature(void);
149 * @fn int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data)
150 * @brief Initialize HID Device service and register the callback
152 * This function is a synchronous call.
154 * @return HID_ERROR_NONE - Success \n
155 * HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
156 * HID_ERROR_INTERNAL - Internal Error \n
157 * HID_ERROR_NOT_ENABLED - Not enabled \n
162 int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
165 * @fn int bluetooth_hid_device_deinit(void)
166 * @brief Initialize HID service and register the callback
168 * This function is a synchronous call.
170 * @return HID_ERROR_NONE - Success \n
171 * HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
176 int bluetooth_hid_device_deinit();
179 * @fn int bluetooth_hid_device_activate()
181 * @brief Register the HID Device UUID with bluez with RegisterProfile.
183 * This function is a asynchronous call.
185 * @return HID_ERROR_NONE - Success \n
186 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
187 * HID_ERROR_NOT_ENABLED - Not enabled \n
188 * HID_ERROR_INTERNAL - Not enabled \n
193 int bluetooth_hid_device_activate(void);
196 * @fn int bluetooth_hid_device_deactivate()
198 * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
200 * This function is a asynchronous call.
202 * @return HID_ERROR_NONE - Success \n
203 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
204 * HID_ERROR_NOT_ENABLED - Not enabled \n
205 * HID_ERROR_INTERNAL - Not enabled \n
210 int bluetooth_hid_device_deactivate(void);
213 * @fn int bluetooth_hid_device_connect(const char *remote_addr)
215 * @brief Initiate the connection for HID device role with remote device
216 * address specified as parameter.
218 * This function is a asynchronous call.
220 * @return HID_ERROR_NONE - Success \n
223 * @param[in] remote_addr device address of remote device.
226 int bluetooth_hid_device_connect(const char *remote_addr);
228 * @fn int bluetooth_hid_device_disconnect()
230 * @brief Terminate the connection with HID host device with DisconnectProfile.
232 * This function is a asynchronous call.
234 * @return HID_ERROR_NONE - Success \n
235 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
236 * HID_ERROR_NOT_ENABLED - Not enabled \n
237 * HID_ERROR_INTERNAL - Not enabled \n
240 * @param[in] remote_addr device address of remote device.
244 int bluetooth_hid_device_disconnect(const char *remote_addr);
247 * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
249 * @brief write the event data on the socket.
251 * This function is a asynchronous call.
253 * @return HID_ERROR_NONE - Success \n
254 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
255 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
256 * HID_ERROR_NOT_ENABLED - Not enabled \n
257 * HID_ERROR_INTERNAL - Not enabled \n
260 * @param[in] remote_addr device address of remote device.
261 * @param[in] send_event This indicates the event data to send to remote device.
264 int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
265 hid_send_mouse_event_t send_event);
268 * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
270 * @brief write the event data on the socket.
272 * This function is a asynchronous call.
274 * @return HID_ERROR_NONE - Success \n
275 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
276 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
277 * HID_ERROR_NOT_ENABLED - Not enabled \n
278 * HID_ERROR_INTERNAL - Not enabled \n
281 * @param[in] remote_addr device address of remote device.
282 * @param[in] send_event This indicates the event data to send to remote device.
285 int bluetooth_hid_device_send_key_event(const char *remote_addr,
286 hid_send_key_event_t send_event);
289 * @fn int bluetooth_hid_device_send_custom_event(const char *remote_addr,
290 * unsigned char btcode, unsigned char report_id,
291 * const char *data, unsigned int data_len)
293 * @brief write the event data on the socket.
295 * This function is a asynchronous call.
297 * @return HID_ERROR_NONE - Success \n
298 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
299 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
300 * HID_ERROR_NOT_ENABLED - Not enabled \n
301 * HID_ERROR_INTERNAL - Not enabled \n
304 * @param[in] remote_addr device address of remote device.
305 * @param[in] btcode The btcode
306 * @param[in] report_id The report id
307 * @param[in] data This indicates the event data to send to remote device.
308 * @param[in] data_len The length of the data
311 int bluetooth_hid_device_send_custom_event(const char *remote_addr,
312 unsigned char btcode, unsigned char report_id,
313 const char *data, unsigned int data_len);
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 */