Merge "Fix the function and variable name for IPSP" into tizen
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-hid-api.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  *              http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17
18 #ifndef __BLUETOOTH_HID_API_H
19 #define __BLUETOOTH_HID_API_H
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25
26 #define HID_ADDRESS_LENGTH 6
27
28 #define HID_ERROR_NONE                  ((int)0)
29
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)
38
39 typedef struct {
40         int event;
41         int result;
42         void *param_data;
43         void *user_data;
44 } hid_event_param_t;
45
46 typedef struct {
47         unsigned char btcode;
48         unsigned char rep_id;
49         unsigned char button;
50         signed char axis_x;
51         signed char axis_y;
52         signed char axis_z;
53 } hid_send_mouse_event_t;
54
55 typedef struct {
56         unsigned char   btcode;
57         unsigned char   rep_id;
58         unsigned char   modify;
59         unsigned char   key[8];
60 } hid_send_key_event_t;
61
62 typedef struct {
63         unsigned char   btcode;
64         unsigned char   rep_id;
65         unsigned short  key[3];
66 } hid_send_rc_key_event_t;
67
68 typedef void (*hid_cb_func_ptr)(int, hid_event_param_t *, void *);
69
70 typedef struct {
71         unsigned char addr[HID_ADDRESS_LENGTH];
72 } hid_device_address_t;
73
74
75 /**
76  * @fn int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data)
77  * @brief Initialize HID service and register the callback
78  *
79  * This function is a synchronous call.
80  *
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
85  *
86  * @remark      None
87  *
88  */
89 int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data);
90
91 /**
92  * @fn int bluetooth_hid_deinit(void)
93  * @brief Initialize HID service and register the callback
94  *
95  * This function is a synchronous call.
96  *
97  * @return  HID_ERROR_NONE  - Success \n
98  *              HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
99  *
100  * @remark      None
101  *
102  */
103 int bluetooth_hid_deinit(void);
104
105
106 /**
107  * @fn int bluetooth_hid_connect(hid_device_address_t *device_address)
108  *
109  * @brief Connect the HID device in the peer
110  *
111  * This function is a asynchronous call.
112  * The HID connect request is responded by BLUETOOTH_HID_CONNECTED event.
113  *
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
121  *
122  * @exception   None
123  * @param[in]  device_address   This indicates an address of the device with which the pairing
124  *                              should be initiated
125  * @remark      None
126  */
127 int bluetooth_hid_connect(hid_device_address_t *device_address);
128
129 /**
130  * @fn int bluetooth_hid_disconnect(hid_device_address_t *device_address)
131  *
132  * @brief Disconnect the HID device in the peer
133  *
134  * This function is a asynchronous call.
135  * The HID connect request is responded by BLUETOOTH_HID_DISCONNECTED event.
136  *
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
144  *
145  * @exception   None
146  * @param[in]  device_address   This indicates an address of the device with which the pairing
147  *                              should be initiated
148  * @remark      None
149  */
150 int bluetooth_hid_disconnect(hid_device_address_t *device_address);
151
152 /**
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
155  *
156  * This function is a synchronous call.
157  *
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
162  *
163  * @remark      None
164  *
165  */
166 int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
167
168 /**
169  * @fn int bluetooth_hid_device_deinit(void)
170  * @brief Initialize HID service and register the callback
171  *
172  * This function is a synchronous call.
173  *
174  * @return  HID_ERROR_NONE  - Success \n
175  *              HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
176  *
177  * @remark      None
178  *
179  */
180 int bluetooth_hid_device_deinit();
181
182 /**
183  * @fn int bluetooth_hid_device_activate()
184  *
185  * @brief Register the HID Device UUID with bluez with RegisterProfile.
186  *
187  * This function is a asynchronous call.
188  *
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
193  *
194  * @exception   None
195  * @remark      None
196  */
197 int bluetooth_hid_device_activate(void);
198
199 /**
200  * @fn int bluetooth_hid_device_deactivate()
201  *
202  * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
203  *
204  * This function is a asynchronous call.
205  *
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
210  *
211  * @exception   None
212  * @remark      None
213  */
214 int bluetooth_hid_device_deactivate(void);
215
216 /**
217  * @fn int bluetooth_hid_device_connect(const char *remote_addr)
218  *
219  * @brief Initiate the connection for HID device role with remote device
220  * address specified as parameter.
221  *
222  * This function is a asynchronous call.
223  *
224  * @return  HID_ERROR_NONE  - Success \n
225  *
226  * @exception   None
227  * @param[in]  remote_addr   device address of remote device.
228  * @remark      None
229  */
230 int bluetooth_hid_device_connect(const char *remote_addr);
231 /**
232  * @fn int bluetooth_hid_device_disconnect()
233  *
234  * @brief Terminate the connection with HID host device with DisconnectProfile.
235  *
236  * This function is a asynchronous call.
237  *
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
242  *
243  * @exception   None
244  * @param[in]  remote_addr   device address of remote device.
245  * @remark      None
246  */
247
248 int bluetooth_hid_device_disconnect(const char *remote_addr);
249
250 /**
251  * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
252  *
253  * @brief write the event data on the socket.
254  *
255  * This function is a asynchronous call.
256  *
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
262  *
263  * @exception   None
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.
266  * @remark      None
267  */
268 int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
269                 hid_send_mouse_event_t send_event);
270
271 /**
272  * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
273  *
274  * @brief write the event data on the socket.
275  *
276  * This function is a asynchronous call.
277  *
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
283  *
284  * @exception   None
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.
287  * @remark      None
288  */
289 int bluetooth_hid_device_send_key_event(const char *remote_addr,
290                 hid_send_key_event_t send_event);
291
292 /**
293  * @fn int bluetooth_hid_device_send_rc_key_event(
294  *              const char *remote_addr, hid_send_rc_key_event_t send_event)
295  *
296  * @brief write the event data on the socket.
297  *
298  * This function is a asynchronous call.
299  *
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
305  *
306  * @exception   None
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.
309  * @remark      None
310  */
311 int bluetooth_hid_device_send_rc_key_event(const char *remote_addr,
312                                         hid_send_rc_key_event_t send_event);
313 /**
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,
317  *                      char *buffer)
318  *
319  * @brief write the event data on the socket.
320  *
321  * This function is a asynchronous call.
322  *
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
328  *
329  * @exception   None
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.
334  * @remark      None
335  */
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,
339                 const char *data,
340                 unsigned int data_len);
341
342 #ifdef __cplusplus
343 }
344 #endif
345 #endif /* __BLUETOOTH_HID_API_H */