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