3880d765c47327fb470886cba5e1821c424e0cbc
[platform/core/connectivity/bluetooth-frwk.git] / include / bluetooth-hid-api.h
1 /*
2  * bluetooth-frwk
3  *
4  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *              http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 #ifndef __BLUETOOTH_HID_API_H
21 #define __BLUETOOTH_HID_API_H
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27
28 #define HID_ADDRESS_LENGTH 6
29
30 #define HID_ERROR_NONE                  ((int)0)
31
32 #define HID_ERROR_BASE                  ((int)0)
33 #define HID_ERROR_ALREADY_INITIALIZED   ((int)HID_ERROR_BASE - 0x01)
34 #define HID_ERROR_NOT_INITIALIZED       ((int)HID_ERROR_BASE - 0x01)
35 #define HID_ERROR_NOT_PAIRED            ((int)HID_ERROR_BASE - 0x02)
36 #define HID_ERROR_INTERNAL              ((int)HID_ERROR_BASE - 0x03)
37 #define HID_ERROR_INVALID_PARAM         ((int)HID_ERROR_BASE - 0x04)
38 #define HID_ERROR_NOT_ENABLED           ((int)HID_ERROR_BASE - 0x05)
39 #define HID_ERROR_CONNECTION_FAILED     ((int)HID_ERROR_BASE - 0x06)
40
41 typedef struct {
42         int event;
43         int result;
44         void *param_data;
45         void *user_data;
46 } hid_event_param_t;
47
48 typedef void (*hid_cb_func_ptr)(int, hid_event_param_t *, void *);
49
50 typedef struct {
51         unsigned char addr[HID_ADDRESS_LENGTH];
52 } hid_device_address_t;
53
54
55 /**
56  * @fn int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data)
57  * @brief Initialize HID service and register the callback
58  *
59  * This function is a synchronous call.
60  *
61  * @return  HID_ERROR_NONE  - Success \n
62  *              HID_ERROR_ALREADY_INITIALIZED - Aready Initialized \n
63  *              HID_ERROR_INTERNAL - Internal Error \n
64  *              HID_ERROR_NOT_ENABLED - Not enabled \n
65  *
66  * @remark      None
67  *
68  */
69 int bluetooth_hid_init(hid_cb_func_ptr callback_ptr, void *user_data);
70
71 /**
72  * @fn int bluetooth_hid_deinit(void)
73  * @brief Initialize HID service and register the callback
74  *
75  * This function is a synchronous call.
76  *
77  * @return  HID_ERROR_NONE  - Success \n
78  *              HID_ERROR_NOT_INITIALIZED - Not Initialiezed \n
79  *
80  * @remark      None
81  *
82  */
83 int bluetooth_hid_deinit(void);
84
85
86 /**
87  * @fn int bluetooth_hid_connect(hid_device_address_t *device_address)
88  *
89  * @brief Connect the HID device in the peer
90  *
91  * This function is a asynchronous call.
92  * The HID connect request is responded by BLUETOOTH_HID_CONNECTED event.
93  *
94  * @return  HID_ERROR_NONE  - Success \n
95  *              HID_ERROR_INVALID_PARAM - Invalid parameter \n
96  *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
97  *              HID_ERROR_NOT_ENABLED - Not enabled \n
98  *              HID_ERROR_INTERNAL - Not enabled \n
99  *              HID_ERROR_NOT_PAIRED - Not enabled \n
100  *              HID_ERROR_CONNECTION_FAILED - Connection Fail \n
101  *
102  * @exception   None
103  * @param[in]  device_address   This indicates an address of the device with which the pairing
104  *                              should be initiated
105  * @remark      None
106  */
107 int bluetooth_hid_connect(hid_device_address_t *device_address);
108
109 /**
110  * @fn int bluetooth_hid_disconnect(hid_device_address_t *device_address)
111  *
112  * @brief Disconnect the HID device in the peer
113  *
114  * This function is a asynchronous call.
115  * The HID connect request is responded by BLUETOOTH_HID_DISCONNECTED event.
116  *
117  * @return  HID_ERROR_NONE  - Success \n
118  *              HID_ERROR_INVALID_PARAM - Invalid parameter \n
119  *              HID_ERROR_NOT_INITIALIZED - Internal Error \n
120  *              HID_ERROR_NOT_ENABLED - Not enabled \n
121  *              HID_ERROR_INTERNAL - Not enabled \n
122  *              HID_ERROR_NOT_PAIRED - Not enabled \n
123  *              HID_ERROR_CONNECTION_FAILED - Connection Fail \n
124  *
125  * @exception   None
126  * @param[in]  device_address   This indicates an address of the device with which the pairing
127  *                              should be initiated
128  * @remark      None
129  */
130 int bluetooth_hid_disconnect(hid_device_address_t *device_address);
131
132
133 #ifdef __cplusplus
134 }
135 #endif
136 #endif /* __BLUETOOTH_HID_API_H */