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);
147 * @fn int bluetooth_hid_device_init(hid_cb_func_ptr callback_ptr, void *user_data)
148 * @brief Initialize HID Device service and register the callback
150 * This function is a synchronous call.
152 * @return HID_ERROR_NONE - Success \n
153 * HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
154 * HID_ERROR_INTERNAL - Internal Error \n
155 * HID_ERROR_NOT_ENABLED - Not enabled \n
160 int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
163 * @fn int bluetooth_hid_device_deinit(void)
164 * @brief Initialize HID service and register the callback
166 * This function is a synchronous call.
168 * @return HID_ERROR_NONE - Success \n
169 * HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
174 int bluetooth_hid_device_deinit();
177 * @fn int bluetooth_hid_device_activate()
179 * @brief Register the HID Device UUID with bluez with RegisterProfile.
181 * This function is a asynchronous call.
183 * @return HID_ERROR_NONE - Success \n
184 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
185 * HID_ERROR_NOT_ENABLED - Not enabled \n
186 * HID_ERROR_INTERNAL - Not enabled \n
191 int bluetooth_hid_device_activate(void);
194 * @fn int bluetooth_hid_device_deactivate()
196 * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
198 * This function is a asynchronous call.
200 * @return HID_ERROR_NONE - Success \n
201 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
202 * HID_ERROR_NOT_ENABLED - Not enabled \n
203 * HID_ERROR_INTERNAL - Not enabled \n
208 int bluetooth_hid_device_deactivate(void);
211 * @fn int bluetooth_hid_device_connect(const char *remote_addr)
213 * @brief Initiate the connection for HID device role with remote device
214 * address specified as parameter.
216 * This function is a asynchronous call.
218 * @return HID_ERROR_NONE - Success \n
221 * @param[in] remote_addr device address of remote device.
224 int bluetooth_hid_device_connect(const char *remote_addr);
226 * @fn int bluetooth_hid_device_disconnect()
228 * @brief Terminate the connection with HID host device with DisconnectProfile.
230 * This function is a asynchronous call.
232 * @return HID_ERROR_NONE - Success \n
233 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
234 * HID_ERROR_NOT_ENABLED - Not enabled \n
235 * HID_ERROR_INTERNAL - Not enabled \n
238 * @param[in] remote_addr device address of remote device.
242 int bluetooth_hid_device_disconnect(const char *remote_addr);
245 * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
247 * @brief write the event data on the socket.
249 * This function is a asynchronous call.
251 * @return HID_ERROR_NONE - Success \n
252 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
253 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
254 * HID_ERROR_NOT_ENABLED - Not enabled \n
255 * HID_ERROR_INTERNAL - Not enabled \n
258 * @param[in] remote_addr device address of remote device.
259 * @param[in] send_event This indicates the event data to send to remote device.
262 int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
263 hid_send_mouse_event_t send_event);
266 * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
268 * @brief write the event data on the socket.
270 * This function is a asynchronous call.
272 * @return HID_ERROR_NONE - Success \n
273 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
274 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
275 * HID_ERROR_NOT_ENABLED - Not enabled \n
276 * HID_ERROR_INTERNAL - Not enabled \n
279 * @param[in] remote_addr device address of remote device.
280 * @param[in] send_event This indicates the event data to send to remote device.
283 int bluetooth_hid_device_send_key_event(const char *remote_addr,
284 hid_send_key_event_t send_event);
287 * @fn int bluetooth_hid_device_reply_to_report(const char *remote_addr,
288 * bt_hid_header_type_t htype,
289 * bt_hid_param_type_t ptype,
292 * @brief write the event data on the socket.
294 * This function is a asynchronous call.
296 * @return HID_ERROR_NONE - Success \n
297 * HID_ERROR_INVALID_PARAM - Invalid parameter \n
298 * HID_ERROR_NOT_INITIALIZED - Internal Error \n
299 * HID_ERROR_NOT_ENABLED - Not enabled \n
300 * HID_ERROR_INTERNAL - Not enabled \n
303 * @param[in] remote_addr device address of remote device.
304 * @param[in] htype header type to be present in response
305 * @param[in] ptype Parameter type to be present in response.
306 * @param[in] buffer Data need to be send in reponse payload.
309 int bluetooth_hid_device_reply_to_report(const char *remote_addr,
310 bt_hid_header_type_t htype,
311 bt_hid_param_type_t ptype,
313 unsigned int data_len);
318 #endif /* __BLUETOOTH_HID_API_H */