Tizen 2.0 Release
[profile/ivi/bluetooth.git] / include / bluetooth_private.h
1 /*
2  * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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 __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__
19 #define __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__
20
21 #include <dlog.h>
22 #include <stdbool.h>
23 #include <bluetooth-api.h>
24 #include <bluetooth-audio-api.h>
25 #include <bluetooth-telephony-api.h>
26 #include <bluetooth-media-control.h>
27 #include <bluetooth-hid-api.h>
28
29 #include "bluetooth.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 #undef LOG_TAG
36 #define LOG_TAG "CAPI_NETWORK_BLUETOOTH"
37
38 #define BT_INFO(fmt, args...) SLOGI(fmt, ##args)
39 #define BT_DBG(fmt, args...) SLOGD(fmt, ##args)
40 #define BT_ERR(fmt, args...) SLOGE(fmt, ##args)
41
42 #define OPP_UUID "00001105-0000-1000-8000-00805f9b34fb"
43
44 /**
45  * @internal
46  * @brief Bluetooth callback.
47  */
48 typedef enum
49 {
50         BT_EVENT_STATE_CHANGED = 0x00, /**< Adapter state is changed */
51         BT_EVENT_NAME_CHANGED, /**< Adapter name is changed */
52         BT_EVENT_VISIBILITY_MODE_CHANGED, /**< Adapter visibility mode is changed */
53         BT_EVENT_DEVICE_DISCOVERY_STATE_CHANGED, /**< Device discovery state is changed */
54         BT_EVENT_BOND_CREATED, /**< A bond is created */
55         BT_EVENT_BOND_DESTROYED, /**< A bond is destroyed */
56         BT_EVENT_AUTHORIZATION_CHANGED, /**< Authorization is changed */
57         BT_EVENT_SERVICE_SEARCHED, /**< Service search finish */
58         BT_EVENT_DATA_RECEIVED, /**< Data is received */
59         BT_EVENT_CONNECTION_STATE_CHANGED, /**< Connection state is changed */
60         BT_EVENT_RFCOMM_CONNECTION_REQUESTED, /**< RFCOMM connection is requested */
61         BT_EVENT_OPP_CONNECTION_REQUESTED, /**< OPP connection is requested */
62         BT_EVENT_OPP_PUSH_REQUESTED, /**< OPP push is requested */
63         BT_EVENT_OPP_SERVER_TRANSFER_PROGRESS, /**< OPP transfer progress */
64         BT_EVENT_OPP_SERVER_TRANSFER_FINISHED, /**< OPP transfer is completed */
65         BT_EVENT_OPP_CLIENT_PUSH_RESPONSED, /**< OPP client connection is reponsed */
66         BT_EVENT_OPP_CLIENT_PUSH_PROGRESS, /**< OPP client push progress */
67         BT_EVENT_OPP_CLIENT_PUSH_FINISHED, /**< OPP client push is finished */
68         BT_EVENT_PAN_CONNECTION_STATE_CHANGED, /**< PAN connection change */
69         BT_EVENT_NAP_CONNECTION_STATE_CHANGED, /**< NAP connection change */
70         BT_EVENT_HDP_CONNECTED, /**< HDP connection change */
71         BT_EVENT_HDP_DISCONNECTED, /**< HDP disconnection change */
72         BT_EVENT_HDP_DATA_RECEIVED, /**< HDP Data receive Callabck */
73         BT_EVENT_AUDIO_CONNECTION_STATUS, /**< Audio Connection change callback */
74         BT_EVENT_AG_SCO_CONNECTION_STATUS, /**< Audio - AG SCO Connection state change callback */
75         BT_EVENT_AG_CALL_HANDLING_EVENT, /**< Audio - AG call event callback */
76         BT_EVENT_AG_MULTI_CALL_HANDLING_EVENT, /**< Audio - AG 3-way call event callback */
77         BT_EVENT_AG_DTMF_TRANSMITTED, /**< Audio - DTMF tone sending request */
78         BT_EVENT_AG_MICROPHONE_GAIN_CHANGE, /**< Audio Microphone change callback */
79         BT_EVENT_AG_SPEAKER_GAIN_CHANGE, /**< Audio Speaker gain change callback */
80         BT_EVENT_AVRCP_CONNECTION_STATUS, /**< AVRCP connection change callback */
81         BT_EVENT_AVRCP_EQUALIZER_STATE_CHANGED, /**< AVRCP equalizer state change callback */
82         BT_EVENT_AVRCP_REPEAT_MODE_CHANGED, /**< AVRCP repeat mode change callback */
83         BT_EVENT_AVRCP_SHUFFLE_MODE_CHANGED, /**< AVRCP equalizer mode change callback */
84         BT_EVENT_AVRCP_SCAN_MODE_CHANGED, /**< AVRCP scan mode change callback */
85         BT_EVENT_HID_CONNECTION_STATUS, /**< HID connection status callback */
86         BT_EVENT_DEVICE_CONNECTION_STATUS, /**< Device connection status callback */
87         BT_EVENT_GATT_CHARACTERISTIC_DISCOVERED, /**< GATT characteristic discovered callback */
88         BT_EVENT_GATT_VALUE_CHANGED, /**< GATT characteristic value changed callback */
89 } bt_event_e;
90
91 /**
92  * @internal
93  */
94 typedef struct bt_event_sig_event_slot_s
95 {
96     int event_type;
97     const void *callback;
98     void *user_data;
99 } bt_event_sig_event_slot_s;
100
101
102 #define BT_CHECK_INPUT_PARAMETER(arg) \
103         if (arg == NULL) \
104         { \
105                 LOGE("[%s] INVALID_PARAMETER(0x%08x)", __FUNCTION__, BT_ERROR_INVALID_PARAMETER); \
106                 return BT_ERROR_INVALID_PARAMETER; \
107         }
108
109 /**
110  * @internal
111  * @brief Check the initialzating status
112  */
113 int _bt_check_init_status(void);
114
115 #define BT_CHECK_INIT_STATUS() \
116         if (_bt_check_init_status() == BT_ERROR_NOT_INITIALIZED) \
117         { \
118                 LOGE("[%s] NOT_INITIALIZED(0x%08x)", __FUNCTION__, BT_ERROR_NOT_INITIALIZED); \
119                 return BT_ERROR_NOT_INITIALIZED; \
120         }
121
122 /**
123  * @internal
124  * @brief Set the event callback.
125  */
126 void _bt_set_cb(int events, void *callback, void *user_data);
127
128 /**
129  * @internal
130  * @brief Unset the event callback.
131  */
132 void _bt_unset_cb(int events);
133
134 /**
135  * @internal
136  * @brief Check if the event callback exist or not.
137  */
138 bool _bt_check_cb(int events);
139
140 /**
141  * @internal
142  * @brief Convert Bluetooth F/W error codes to capi Bluetooth error codes.
143  */
144 int _bt_get_error_code(int origin_error);
145
146
147 /**
148  * @internal
149  * @brief Convert Bluetooth F/W bluetooth_device_info_t to capi bt_device_info_s.
150  */
151 int _bt_get_bt_device_info_s(bt_device_info_s **dest_dev, bluetooth_device_info_t *source_dev);
152
153
154 /**
155  * @internal
156  * @brief Free bt_device_info_s.
157  */
158 void _bt_free_bt_device_info_s(bt_device_info_s *device_info);
159
160 /**
161  * @internal
162  * @brief Convert Bluetooth F/W bluetooth_device_address_t to string.
163  */
164 int _bt_convert_address_to_string(char **addr_str, bluetooth_device_address_t *addr_hex);
165
166
167 /**
168  * @internal
169  * @brief Convert string to Bluetooth F/W bluetooth_device_address_t.
170  */
171 void _bt_convert_address_to_hex(bluetooth_device_address_t *addr_hex, const char *addr_str);
172
173
174 /**
175  * @internal
176  * @brief Convert error code to string.
177  */
178 char* _bt_convert_error_to_string(int error);
179
180 /**
181  * @internal
182  * @brief Convert the visibility mode
183  */
184 bt_adapter_visibility_mode_e _bt_get_bt_visibility_mode_e(bluetooth_discoverable_mode_t mode);
185
186 /**
187  * @internal
188  * @brief Since the Audio call back and event proxy call backs have different prototype it is wrapper function.
189  */
190 void _bt_audio_event_proxy(int event, bt_audio_event_param_t *param, void *user_data);
191
192 /**
193  * @internal
194  * @brief Since the Telephony call back and event proxy call backs have different prototype it is wrapper function.
195  */
196 void _bt_telephony_event_proxy(int event, telephony_event_param_t *param, void *user_data);
197
198 /**
199  * @internal
200  * @brief Since the AVRCP call back and event proxy call backs have different prototype it is wrapper function.
201  */
202 void _bt_avrcp_event_proxy(int event, media_event_param_t *param, void *user_data);
203
204 /**
205  * @internal
206  * @brief Since the HID call back and event proxy call backs have different prototype it is wrapper function.
207  */
208 void _bt_hid_event_proxy(int event, hid_event_param_t *param, void *user_data);
209
210
211 #ifdef __cplusplus
212 }
213 #endif
214
215 #endif /* __TIZEN_NETWORK_BLUETOOTH_PRIVATE_H__ */