Remove wrong dependency in the systemd service file
[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 void (*hid_cb_func_ptr)(int, hid_event_param_t *, void *);
63
64 typedef struct {
65         unsigned char addr[HID_ADDRESS_LENGTH];
66 } hid_device_address_t;
67
68
69 /**
70  * @fn int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data)
71  * @brief Initialize HID service and register the callback
72  *
73  * This function is a synchronous call.
74  *
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
79  *
80  * @remark      None
81  *
82  */
83 int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data);
84
85 /**
86  * @fn int bluetooth_hid_deinit(void)
87  * @brief Initialize HID service and register the callback
88  *
89  * This function is a synchronous call.
90  *
91  * @return  HID_ERROR_NONE  - Success \n
92  *              HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
93  *
94  * @remark      None
95  *
96  */
97 int bluetooth_hid_deinit(void);
98
99
100 /**
101  * @fn int bluetooth_hid_connect(hid_device_address_t *device_address)
102  *
103  * @brief Connect the HID device in the peer
104  *
105  * This function is a asynchronous call.
106  * The HID connect request is responded by BLUETOOTH_HID_CONNECTED event.
107  *
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
115  *
116  * @exception   None
117  * @param[in]  device_address   This indicates an address of the device with which the pairing
118  *                              should be initiated
119  * @remark      None
120  */
121 int bluetooth_hid_connect(hid_device_address_t *device_address);
122
123 /**
124  * @fn int bluetooth_hid_disconnect(hid_device_address_t *device_address)
125  *
126  * @brief Disconnect the HID device in the peer
127  *
128  * This function is a asynchronous call.
129  * The HID connect request is responded by BLUETOOTH_HID_DISCONNECTED event.
130  *
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
138  *
139  * @exception   None
140  * @param[in]  device_address   This indicates an address of the device with which the pairing
141  *                              should be initiated
142  * @remark      None
143  */
144 int bluetooth_hid_disconnect(hid_device_address_t *device_address);
145
146 int bluetooth_hid_enable_barcode_feature(void);
147
148 /**
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
151  *
152  * This function is a synchronous call.
153  *
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
158  *
159  * @remark      None
160  *
161  */
162 int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
163
164 /**
165  * @fn int bluetooth_hid_device_deinit(void)
166  * @brief Initialize HID service and register the callback
167  *
168  * This function is a synchronous call.
169  *
170  * @return  HID_ERROR_NONE  - Success \n
171  *              HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
172  *
173  * @remark      None
174  *
175  */
176 int bluetooth_hid_device_deinit();
177
178 /**
179  * @fn int bluetooth_hid_device_activate()
180  *
181  * @brief Register the HID Device UUID with bluez with RegisterProfile.
182  *
183  * This function is a asynchronous call.
184  *
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
189  *
190  * @exception   None
191  * @remark      None
192  */
193 int bluetooth_hid_device_activate(void);
194
195 /**
196  * @fn int bluetooth_hid_device_deactivate()
197  *
198  * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
199  *
200  * This function is a asynchronous call.
201  *
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
206  *
207  * @exception   None
208  * @remark      None
209  */
210 int bluetooth_hid_device_deactivate(void);
211
212 /**
213  * @fn int bluetooth_hid_device_connect(const char *remote_addr)
214  *
215  * @brief Initiate the connection for HID device role with remote device
216  * address specified as parameter.
217  *
218  * This function is a asynchronous call.
219  *
220  * @return  HID_ERROR_NONE  - Success \n
221  *
222  * @exception   None
223  * @param[in]  remote_addr   device address of remote device.
224  * @remark      None
225  */
226 int bluetooth_hid_device_connect(const char *remote_addr);
227 /**
228  * @fn int bluetooth_hid_device_disconnect()
229  *
230  * @brief Terminate the connection with HID host device with DisconnectProfile.
231  *
232  * This function is a asynchronous call.
233  *
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
238  *
239  * @exception   None
240  * @param[in]  remote_addr   device address of remote device.
241  * @remark      None
242  */
243
244 int bluetooth_hid_device_disconnect(const char *remote_addr);
245
246 /**
247  * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
248  *
249  * @brief write the event data on the socket.
250  *
251  * This function is a asynchronous call.
252  *
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
258  *
259  * @exception   None
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.
262  * @remark      None
263  */
264 int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
265                 hid_send_mouse_event_t send_event);
266
267 /**
268  * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
269  *
270  * @brief write the event data on the socket.
271  *
272  * This function is a asynchronous call.
273  *
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
279  *
280  * @exception   None
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.
283  * @remark      None
284  */
285 int bluetooth_hid_device_send_key_event(const char *remote_addr,
286                 hid_send_key_event_t send_event);
287
288 /**
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)
292  *
293  * @brief write the event data on the socket.
294  *
295  * This function is a asynchronous call.
296  *
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
302  *
303  * @exception   None
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
309  * @remark      None
310  */
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);
314
315 /**
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,
319  *                      char *buffer)
320  *
321  * @brief write the event data on the socket.
322  *
323  * This function is a asynchronous call.
324  *
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
330  *
331  * @exception   None
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.
336  * @remark      None
337  */
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,
341                 const char *data,
342                 unsigned int data_len);
343
344 #ifdef __cplusplus
345 }
346 #endif
347 #endif /* __BLUETOOTH_HID_API_H */