DPM: Add Error code for device policy restriction.
[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 /**
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
149  *
150  * This function is a synchronous call.
151  *
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
156  *
157  * @remark      None
158  *
159  */
160 int bluetooth_hid_device_init(hid_cb_func_ptr callback, void *user_data);
161
162 /**
163  * @fn int bluetooth_hid_device_deinit(void)
164  * @brief Initialize HID service and register the callback
165  *
166  * This function is a synchronous call.
167  *
168  * @return  HID_ERROR_NONE  - Success \n
169  *              HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
170  *
171  * @remark      None
172  *
173  */
174 int bluetooth_hid_device_deinit();
175
176 /**
177  * @fn int bluetooth_hid_device_activate()
178  *
179  * @brief Register the HID Device UUID with bluez with RegisterProfile.
180  *
181  * This function is a asynchronous call.
182  *
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
187  *
188  * @exception   None
189  * @remark      None
190  */
191 int bluetooth_hid_device_activate(void);
192
193 /**
194  * @fn int bluetooth_hid_device_deactivate()
195  *
196  * @brief Unregister the HID Device UUID with bluez with UnRegisterProfile.
197  *
198  * This function is a asynchronous call.
199  *
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
204  *
205  * @exception   None
206  * @remark      None
207  */
208 int bluetooth_hid_device_deactivate(void);
209
210 /**
211  * @fn int bluetooth_hid_device_connect(const char *remote_addr)
212  *
213  * @brief Initiate the connection for HID device role with remote device
214  * address specified as parameter.
215  *
216  * This function is a asynchronous call.
217  *
218  * @return  HID_ERROR_NONE  - Success \n
219  *
220  * @exception   None
221  * @param[in]  remote_addr   device address of remote device.
222  * @remark      None
223  */
224 int bluetooth_hid_device_connect(const char *remote_addr);
225 /**
226  * @fn int bluetooth_hid_device_disconnect()
227  *
228  * @brief Terminate the connection with HID host device with DisconnectProfile.
229  *
230  * This function is a asynchronous call.
231  *
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
236  *
237  * @exception   None
238  * @param[in]  remote_addr   device address of remote device.
239  * @remark      None
240  */
241
242 int bluetooth_hid_device_disconnect(const char *remote_addr);
243
244 /**
245  * @fn int bluetooth_hid_send_mouse_event(hid_send_mouse_event_t send_event)
246  *
247  * @brief write the event data on the socket.
248  *
249  * This function is a asynchronous call.
250  *
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
256  *
257  * @exception   None
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.
260  * @remark      None
261  */
262 int bluetooth_hid_device_send_mouse_event(const char *remote_addr,
263                 hid_send_mouse_event_t send_event);
264
265 /**
266  * @fn int bluetooth_hid_device_send_key_event(hid_send_key_event_t send_event)
267  *
268  * @brief write the event data on the socket.
269  *
270  * This function is a asynchronous call.
271  *
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
277  *
278  * @exception   None
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.
281  * @remark      None
282  */
283 int bluetooth_hid_device_send_key_event(const char *remote_addr,
284                 hid_send_key_event_t send_event);
285
286 /**
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,
290  *                      char *buffer)
291  *
292  * @brief write the event data on the socket.
293  *
294  * This function is a asynchronous call.
295  *
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
301  *
302  * @exception   None
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.
307  * @remark      None
308  */
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,
312                 const char *data,
313                 unsigned int data_len);
314
315 #ifdef __cplusplus
316 }
317 #endif
318 #endif /* __BLUETOOTH_HID_API_H */