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);
153 * @fn int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data)
154 * @brief Initialize HID Device service and register the callback
156 * This function is a synchronous call.
158 * @return HID_ERROR_NONE - Success \n
159 * HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
160 * HID_ERROR_INTERNAL - Internal Error \n
161 * HID_ERROR_NOT_ENABLED - Not enabled \n
166 int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
169 * @fn int bluetooth_hid_device_deinit(void)
170 * @brief Initialize HID service and register the callback
172 * This function is a synchronous call.
174 * @return HID_ERROR_NONE - Success \n
175 * HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
180 int bluetooth_hid_device_deinit();
183 * @fn int bluetooth_hid_device_activate()
185 * @brief Register the HID Device UUID with bluez with RegisterProfile.
187 * This function is a asynchronous call.
189 * @return HID_ERROR_NONE - Success \n
190 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
191 * HID_ERROR_NOT_ENABLED - Not enabled \n
192 * HID_ERROR_INTERNAL - Not enabled \n
197 int bluetooth_hid_device_activate(void);
200 * @fn int bluetooth_hid_device_deactivate()
202 * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
204 * This function is a asynchronous call.
206 * @return HID_ERROR_NONE - Success \n
207 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
208 * HID_ERROR_NOT_ENABLED - Not enabled \n
209 * HID_ERROR_INTERNAL - Not enabled \n
214 int bluetooth_hid_device_deactivate(void);
217 * @fn int bluetooth_hid_device_connect(const char *remote_addr)
219 * @brief Initiate the connection for HID device role with remote device
220 * address specified as parameter.
222 * This function is a asynchronous call.
224 * @return HID_ERROR_NONE - Success \n
227 * @param[in] remote_addr device address of remote device.
230 int bluetooth_hid_device_connect(const char *remote_addr);
232 * @fn int bluetooth_hid_device_disconnect()
234 * @brief Terminate the connection with HID host device with DisconnectProfile.
236 * This function is a asynchronous call.
238 * @return HID_ERROR_NONE - Success \n
239 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
240 * HID_ERROR_NOT_ENABLED - Not enabled \n
241 * HID_ERROR_INTERNAL - Not enabled \n
244 * @param[in] remote_addr device address of remote device.
248 int bluetooth_hid_device_disconnect(const char *remote_addr);
251 * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
253 * @brief write the event data on the socket.
255 * This function is a asynchronous call.
257 * @return HID_ERROR_NONE - Success \n
258 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
259 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
260 * HID_ERROR_NOT_ENABLED - Not enabled \n
261 * HID_ERROR_INTERNAL - Not enabled \n
264 * @param[in] remote_addr device address of remote device.
265 * @param[in] send_event This indicates the event data to send to remote device.
268 int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
269 hid_send_mouse_event_t send_event);
272 * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
274 * @brief write the event data on the socket.
276 * This function is a asynchronous call.
278 * @return HID_ERROR_NONE - Success \n
279 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
280 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
281 * HID_ERROR_NOT_ENABLED - Not enabled \n
282 * HID_ERROR_INTERNAL - Not enabled \n
285 * @param[in] remote_addr device address of remote device.
286 * @param[in] send_event This indicates the event data to send to remote device.
289 int bluetooth_hid_device_send_key_event(const char *remote_addr,
290 hid_send_key_event_t send_event);
293 * @fn int bluetooth_hid_device_send_rc_key_event(
294 * const char *remote_addr, hid_send_rc_key_event_t send_event)
296 * @brief write the event data on the socket.
298 * This function is a asynchronous call.
300 * @return HID_ERROR_NONE - Success \n
301 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
302 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
303 * HID_ERROR_NOT_ENABLED - Not enabled \n
304 * HID_ERROR_INTERNAL - Not enabled \n
307 * @param[in] remote_addr device address of remote device.
308 * @param[in] send_event This indicates the event data to send to remote device.
311 int bluetooth_hid_device_send_rc_key_event(const char *remote_addr,
312 hid_send_rc_key_event_t send_event);
314 * @fn int bluetooth_hid_device_reply_to_report(const char *remote_addr,
315 * bluetooth_hid_header_type_t htype,
316 * bluetooth_hid_param_type_t ptype,
319 * @brief write the event data on the socket.
321 * This function is a asynchronous call.
323 * @return HID_ERROR_NONE - Success \n
324 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
325 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
326 * HID_ERROR_NOT_ENABLED - Not enabled \n
327 * HID_ERROR_INTERNAL - Not enabled \n
330 * @param[in] remote_addr device address of remote device.
331 * @param[in] htype header type to be present in response
332 * @param[in] ptype Parameter type to be present in response.
333 * @param[in] buffer Data need to be send in reponse payload.
336 int bluetooth_hid_device_reply_to_report(const char *remote_addr,
337 bluetooth_hid_header_type_t htype,
338 bluetooth_hid_param_type_t ptype,
340 unsigned int data_len);
345 #endif /* __BLUETOOTH_HID_API_H */