daf08e54676d2c607942ecdfb97946bcd1be57c2
[platform/core/connectivity/bluetooth-frwk.git] / bt-oal / bluez_hal / src / bt-hal-dbus-common-utils.h
1 /*
2  * BLUETOOTH HAL
3  *
4  * Copyright (c) 2015 -2016 Samsung Electronics Co., Ltd All Rights Reserved.
5  *
6  * Contact: Anupam Roy <anupam.r@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *              http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22 #ifndef _BT_HAL_DBUS_COMMON_UTILS_H_
23 #define _BT_HAL_DBUS_COMMON_UTILS_H_
24
25 #include <glib.h>
26 #include <sys/types.h>
27
28 #include "bt-hal.h"
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #include <stdio.h>
35 #include <string.h>
36 #include <glib.h>
37 #include <dlog.h>
38 #include <fcntl.h>
39 #include <errno.h>
40 #include <termios.h>
41 #include <dbus/dbus-glib-lowlevel.h>
42 #include <dbus/dbus-glib.h>
43 #include <dbus/dbus.h>
44 #include <glib.h>
45 #include <dlog.h>
46 #include <fcntl.h>
47 #include <errno.h>
48 #include <termios.h>
49
50 #define BT_HAL_MAX_DBUS_TIMEOUT 45000
51 #define BT_HAL_TIMEOUT_MESSAGE "Did not receive a reply. Possible causes include: " \
52                         "the remote application did not send a reply, " \
53                         "the message bus security policy blocked the reply, " \
54                         "the reply timeout expired, or the network connection " \
55                         "was broken."
56 #define BT_HAL_ACCESS_DENIED_MSG "Rejected send message"
57
58 #define BT_HAL_DISCOVERY_FINISHED_DELAY 200
59
60 #define BT_HAL_UUID_SIZE 16
61 #define BT_HAL_UUID_STRING_LEN 37
62 #define BT_HAL_ADDRESS_LENGTH_MAX 6
63 #define BT_HAL_ADDRESS_STRING_SIZE 18
64 #define BT_HAL_LOWER_ADDRESS_LENGTH 9
65 #define BT_HAL_AGENT_NEW_LINE "\r\n"
66
67 #define BT_HAL_HARDWARE_ERROR "HardwareError"
68 #define BT_HAL_TX_TIMEOUT_ERROR "TxTimeoutError"
69
70 #define BT_HAL_VERSION_LENGTH_MAX       30 /**< This specifies bluetooth device version length */
71 #define BT_HAL_INTERFACE_NAME_LENGTH        16
72 #define BT_HAL_DEVICE_NAME_LENGTH_MAX       248 /**< This specifies maximum device name length */
73 #define BT_HAL_DEVICE_PASSKEY_LENGTH_MAX       50 /**< This specifies maximum length of the passkey */
74 #define BT_HAL_ADVERTISING_DATA_LENGTH_MAX   31 /**< This specifies maximum AD data length */
75 #define BT_HAL_SCAN_RESP_DATA_LENGTH_MAX     31 /**< This specifies maximum LE Scan response data length */
76 #define BT_HAL_MANUFACTURER_DATA_LENGTH_MAX  240 /**< This specifies maximum manufacturer data length */
77 #define BT_HAL_BLUEZ_NAME "org.bluez"
78 #define BT_HAL_BLUEZ_PATH "/org/bluez"
79 #define BT_HAL_MANAGER_PATH "/"
80 #define BT_HAL_BLUEZ_HCI_PATH "/org/bluez/hci0"
81
82 #define BT_HAL_DEVICE_AGENT_PATH "/org/tizen/device_agent"
83 #define BT_HAL_ADAPTER_AGENT_PATH "/org/tizen/adapter_agent"
84
85 #define BT_HAL_MANAGER_INTERFACE "org.freedesktop.DBus.ObjectManager"
86 #define BT_HAL_ADAPTER_INTERFACE "org.bluez.Adapter1"
87 #define BT_HAL_DEVICE_INTERFACE "org.bluez.Device1"
88 #define BT_HAL_PROPERTIES_INTERFACE "org.freedesktop.DBus.Properties"
89
90 #define BT_HAL_HARDWARE_ERROR "HardwareError"
91 #define BT_HAL_TX_TIMEOUT_ERROR "TxTimeoutError"
92
93 #define BT_HAL_FREEDESKTOP_INTERFACE "org.freedesktop.DBus"
94 #define BT_HAL_FREEDESKTOP_PATH "/org/freedesktop/DBus"
95
96 #define BT_HAL_SINK_INTERFACE "org.bluez.AudioSink"
97 #define BT_HAL_AUDIO_INTERFACE "org.bluez.Audio"
98 #define BT_HAL_INPUT_INTERFACE "org.bluez.Input1"
99 #define BT_HAL_AGENT_INTERFACE "org.bluez.Agent1"
100 #define BT_HAL_AGENT_MANAGER_INTERFACE "org.bluez.AgentManager1"
101 #define BT_HAL_MEDIA_INTERFACE "org.bluez.Media1"
102 #define BT_HAL_MEDIA_PLAYER_INTERFACE "org.mpris.MediaPlayer2.Player"
103 #define BT_HAL_MEDIATRANSPORT_INTERFACE "org.bluez.MediaTransport1"
104 #define BT_HAL_MEDIA_CONTROL_INTERFACE "org.bluez.MediaControl1"
105 #define BT_HAL_PLAYER_CONTROL_INTERFACE "org.bluez.MediaPlayer1"
106 #define BT_HAL_GATT_CHAR_INTERFACE "org.bluez.GattCharacteristic1"
107 #define BT_HAL_NETWORK_INTERFACE "org.bluez.Network"
108 #define BT_HAL_NETWORK_CLIENT_INTERFACE "org.bluez.Network1"
109 #define BT_HAL_NETWORK_SERVER_INTERFACE "org.bluez.NetworkServer1"
110 #define BT_HAL_MEDIA_INTERFACE "org.bluez.Media1"
111 #define BT_HAL_MEDIA_PLAYER_INTERFACE "org.mpris.MediaPlayer2.Player"
112 #define BT_HAL_OBEX_TRANSFER_INTERFACE "org.bluez.obex.Transfer1"
113 #define BT_HAL_HEADSET_INTERFACE "org.bluez.Headset"
114
115
116 #define BT_HAL_INTERFACES_ADDED "InterfacesAdded"
117 #define BT_HAL_INTERFACES_REMOVED "InterfacesRemoved"
118 #define BT_HAL_NAME_OWNER_CHANGED "NameOwnerChanged"
119 #define BT_HAL_PROPERTIES_CHANGED "PropertiesChanged"
120
121 /**
122  * This is Bluetooth error code
123  */
124 #define BT_HAL_ERROR_BASE                   ((int)0)         /**< Error code base */
125
126 #define BT_HAL_ERROR_NONE                   ((int)0)         /**< No error #0 */
127 #define BT_HAL_ERROR_CANCEL                 ((int)BT_HAL_ERROR_BASE - 0x01)
128                                                                 /**< cancelled */
129 #define BT_HAL_ERROR_INVALID_CALLBACK       ((int)BT_HAL_ERROR_BASE - 0x02)
130                                                                 /**< Callback error */
131 #define BT_HAL_ERROR_INVALID_PARAM          ((int)BT_HAL_ERROR_BASE - 0x03)
132                                                                 /**< invalid paramerror */
133 #define BT_HAL_ERROR_INVALID_DATA           ((int)BT_HAL_ERROR_BASE - 0x04)
134                                                                 /**< invalid data error */
135 #define BT_HAL_ERROR_MEMORY_ALLOCATION      ((int)BT_HAL_ERROR_BASE - 0x05)
136                                                                 /**< Memory allocation error */
137 #define BT_HAL_ERROR_OUT_OF_MEMORY          ((int)BT_HAL_ERROR_BASE - 0x06)
138                                                                 /**< out of memory error */
139 #define BT_HAL_ERROR_TIMEOUT                ((int)BT_HAL_ERROR_BASE - 0x07)
140                                                                 /**< timeout error */
141 #define BT_HAL_ERROR_NO_RESOURCES           ((int)BT_HAL_ERROR_BASE - 0x08)
142                                                                 /**< No resource error */
143 #define BT_HAL_ERROR_INTERNAL               ((int)BT_HAL_ERROR_BASE - 0x09)
144                                                                 /**< internal error */
145 #define BT_HAL_ERROR_NOT_SUPPORT            ((int)BT_HAL_ERROR_BASE - 0x0a)
146                                                                 /**< Not supported error */
147 #define BT_HAL_ERROR_DEVICE_NOT_ENABLED     ((int)BT_HAL_ERROR_BASE - 0x0b)
148                                                                 /**< Operation is failed because
149                                                                 of not enabled BT Adapter */
150 #define BT_HAL_ERROR_DEVICE_ALREADY_ENABLED  ((int)BT_HAL_ERROR_BASE - 0x0c)
151                                                                 /**< Enabling is failed because of
152                                                                 already enabled BT Adapter */
153 #define BT_HAL_ERROR_DEVICE_BUSY            ((int)BT_HAL_ERROR_BASE - 0x0d)
154                                                                 /**< Operation is failed because of
155                                                                 other on going operation */
156 #define BT_HAL_ERROR_ACCESS_DENIED          ((int)BT_HAL_ERROR_BASE - 0x0e)
157                                                                 /**< access denied error */
158 #define BT_HAL_ERROR_MAX_CLIENT             ((int)BT_HAL_ERROR_BASE - 0x0f)
159                                                                 /**< max client error */
160 #define BT_HAL_ERROR_NOT_FOUND              ((int)BT_HAL_ERROR_BASE - 0x10)
161                                                                 /**< not found error */
162 #define BT_HAL_ERROR_SERVICE_SEARCH_ERROR   ((int)BT_HAL_ERROR_BASE - 0x11)
163                                                                 /**< service search fail */
164 #define BT_HAL_ERROR_PARING_FAILED          ((int)BT_HAL_ERROR_BASE - 0x12)
165                                                                 /**< pairing failed error */
166 #define BT_HAL_ERROR_NOT_PAIRED             ((int)BT_HAL_ERROR_BASE - 0x13)
167                                                                 /**< Not paired error */
168 #define BT_HAL_ERROR_SERVICE_NOT_FOUND      ((int)BT_HAL_ERROR_BASE - 0x14)
169                                                                 /**< no service error */
170 #define BT_HAL_ERROR_NOT_CONNECTED          ((int)BT_HAL_ERROR_BASE - 0x15)
171                                                                 /**< no connection error */
172 #define BT_HAL_ERROR_ALREADY_CONNECT        ((int)BT_HAL_ERROR_BASE - 0x16)
173                                                                 /**< alread connected error */
174 #define BT_HAL_ERROR_CONNECTION_BUSY        ((int)BT_HAL_ERROR_BASE - 0x17)
175                                                                 /**< connection busy error */
176 #define BT_HAL_ERROR_CONNECTION_ERROR       ((int)BT_HAL_ERROR_BASE - 0x18)
177                                                                 /**< connection error */
178 #define BT_HAL_ERROR_MAX_CONNECTION         ((int)BT_HAL_ERROR_BASE - 0x19)
179                                                                 /**< max connection error*/
180 #define BT_HAL_ERROR_NOT_IN_OPERATION       ((int)BT_HAL_ERROR_BASE - 0x1a)
181                                                                 /**< Not in operation */
182 #define BT_HAL_ERROR_CANCEL_BY_USER         ((int)BT_HAL_ERROR_BASE - 0x1b)
183                                                                 /**< Cancelled by user */
184 #define BT_HAL_ERROR_REGISTRATION_FAILED    ((int)BT_HAL_ERROR_BASE - 0x1c)
185                                                                 /**< Service record registration failed */
186 #define BT_HAL_ERROR_IN_PROGRESS            ((int)BT_HAL_ERROR_BASE - 0x1d)
187                                                                 /**< Operation in progress */
188 #define BT_HAL_ERROR_AUTHENTICATION_FAILED  ((int)BT_HAL_ERROR_BASE - 0x1e)
189                                                                 /**< authentication failed error when paring*/
190 #define BT_HAL_ERROR_HOST_DOWN              ((int)BT_HAL_ERROR_BASE - 0x1f)
191                                                                 /**< Remote host is down */
192 #define BT_HAL_ERROR_END_OF_DEVICE_LIST     ((int)BT_HAL_ERROR_BASE - 0x20)
193                                                                 /**< End of device list */
194
195 #define BT_HAL_ERROR_AGENT_ALREADY_EXIST      ((int)BT_HAL_ERROR_BASE - 0x21)
196                                                                 /**< Obex agent already exists */
197 #define BT_HAL_ERROR_AGENT_DOES_NOT_EXIST    ((int)BT_HAL_ERROR_BASE - 0x22)
198                                                                 /**< Obex agent does not exist */
199
200 #define BT_HAL_ERROR_ALREADY_INITIALIZED    ((int)BT_HAL_ERROR_BASE - 0x23)
201                                                                 /**< Already initialized */
202
203 #define BT_HAL_ERROR_PERMISSION_DEINED    ((int)BT_HAL_ERROR_BASE - 0x24)
204                                                                 /**< Permission deined */
205
206 #define BT_HAL_ERROR_ALREADY_DEACTIVATED    ((int)BT_HAL_ERROR_BASE - 0x25)
207                                                                 /**< Nap already done */
208
209 #define BT_HAL_ERROR_NOT_INITIALIZED    ((int)BT_HAL_ERROR_BASE - 0x26)
210                                                                 /**< Not initialized */
211
212 #define BT_HAL_ERROR_DEVICE_POLICY_RESTRICTION    ((int)BT_HAL_ERROR_BASE - 0x27)
213                                                                 /**< Device Policy Restricted */
214 /**
215 * Service class part of class of device returned from device discovery
216 */
217 typedef enum {
218         BT_HAL_DEVICE_SERVICE_CLASS_LIMITED_DISCOVERABLE_MODE = 0x002000,
219         BT_HAL_DEVICE_SERVICE_CLASS_POSITIONING = 0x010000,                  /**<  */
220         BT_HAL_DEVICE_SERVICE_CLASS_NETWORKING = 0x020000,                   /**<  */
221         BT_HAL_DEVICE_SERVICE_CLASS_RENDERING = 0x040000,                    /**<  */
222         BT_HAL_DEVICE_SERVICE_CLASS_CAPTURING = 0x080000,                    /**<  */
223         BT_HAL_DEVICE_SERVICE_CLASS_OBJECT_TRANSFER = 0x100000,              /**<  */
224         BT_HAL_DEVICE_SERVICE_CLASS_AUDIO = 0x200000,                        /**<  */
225         BT_HAL_DEVICE_SERVICE_CLASS_TELEPHONY = 0x400000,                    /**<  */
226         BT_HAL_DEVICE_SERVICE_CLASS_INFORMATION = 0x800000,                  /**<  */
227 } bt_hal_device_service_class_t;
228
229 /**
230  * Major device mask (For device discovery)
231  */
232 typedef enum {
233         BT_HAL_DEVICE_MAJOR_MASK_MISC = 0x00,
234         BT_HAL_DEVICE_MAJOR_MASK_COMPUTER = 0x0001,
235         BT_HAL_DEVICE_MAJOR_MASK_PHONE = 0x0002,
236         BT_HAL_DEVICE_MAJOR_MASK_LAN_ACCESS_POINT = 0x0004,
237         BT_HAL_DEVICE_MAJOR_MASK_AUDIO = 0x0008,
238         BT_HAL_DEVICE_MAJOR_MASK_PERIPHERAL = 0x0010,
239         BT_HAL_DEVICE_MAJOR_MASK_IMAGING = 0x0020,
240         BT_HAL_DEVICE_MAJOR_MASK_WEARABLE = 0x0040,
241         BT_HAL_DEVICE_MAJOR_MASK_TOY = 0x0080,
242         BT_HAL_DEVICE_MAJOR_MASK_HEALTH = 0x0100,
243 } bt_hal_device_major_mask_t;
244
245 /**
246  * Major device class (part of Class of Device)
247  */
248 typedef enum {
249         BT_HAL_DEVICE_MAJOR_CLASS_MISC = 0x00,       /**< Miscellaneous major device class*/
250         BT_HAL_DEVICE_MAJOR_CLASS_COMPUTER = 0x01,           /**< Computer major device class*/
251         BT_HAL_DEVICE_MAJOR_CLASS_PHONE = 0x02,              /**< Phone major device class*/
252         BT_HAL_DEVICE_MAJOR_CLASS_LAN_ACCESS_POINT = 0x03,   /**< LAN major device class*/
253         BT_HAL_DEVICE_MAJOR_CLASS_AUDIO = 0x04,              /**< AUDIO major device class*/
254         BT_HAL_DEVICE_MAJOR_CLASS_PERIPHERAL = 0x05,         /**< Peripheral major device class*/
255         BT_HAL_DEVICE_MAJOR_CLASS_IMAGING = 0x06,            /**< Imaging major device class*/
256         BT_HAL_DEVICE_MAJOR_CLASS_WEARABLE = 0x07,           /**< Wearable device class*/
257         BT_HAL_DEVICE_MAJOR_CLASS_TOY = 0x08,                /**< Toy device class*/
258         BT_HAL_DEVICE_MAJOR_CLASS_HEALTH = 0x09,             /**< Health device class*/
259         BT_HAL_DEVICE_MAJOR_CLASS_UNCLASSIFIED = 0x1F        /**< Unknown major device class*/
260 } bt_hal_device_major_class_t;
261
262
263 typedef enum {
264         BT_HAL_DEVICE_MINOR_CLASS_UNCLASSIFIED = 0x00,       /**< unclassified minor class */
265
266         /* About Computer Major class */
267         BT_HAL_DEVICE_MINOR_CLASS_DESKTOP_WORKSTATION = 0x04,        /**< desktop workstation
268                                                                           minor class */
269         BT_HAL_DEVICE_MINOR_CLASS_SERVER_CLASS_COMPUTER = 0x08,      /**< server minor class */
270         BT_HAL_DEVICE_MINOR_CLASS_LAPTOP = 0x0C,                     /**< laptop minor class */
271         BT_HAL_DEVICE_MINOR_CLASS_HANDHELD_PC_OR_PDA = 0x10,         /**< PDA minor class */
272         BT_HAL_DEVICE_MINOR_CLASS_PALM_SIZED_PC_OR_PDA = 0x14,       /**< PALM minor class */
273         BT_HAL_DEVICE_MINOR_CLASS_WEARABLE_COMPUTER = 0x18,  /**< Wearable PC minor class */
274
275         /* About Phone Major class */
276         BT_HAL_DEVICE_MINOR_CLASS_CELLULAR = 0x04,                   /**< Cellular minor class */
277         BT_HAL_DEVICE_MINOR_CLASS_CORDLESS = 0x08,                   /**< cordless minor class */
278         BT_HAL_DEVICE_MINOR_CLASS_SMART_PHONE = 0x0C,        /**< smart phone minor class */
279         BT_HAL_DEVICE_MINOR_CLASS_WIRED_MODEM_OR_VOICE_GATEWAY = 0x10,
280         /**< voice gateway minor class */
281         BT_HAL_DEVICE_MINOR_CLASS_COMMON_ISDN_ACCESS = 0x14,         /**< ISDN minor class */
282
283         /* About LAN/Network Access Point Major class */
284         BT_HAL_DEVICE_MINOR_CLASS_FULLY_AVAILABLE = 0x04,            /**< Fully available minor class */
285         BT_HAL_DEVICE_MINOR_CLASS_1_TO_17_PERCENT_UTILIZED = 0x20,   /**< 1-17% utilized minor class */
286         BT_HAL_DEVICE_MINOR_CLASS_17_TO_33_PERCENT_UTILIZED = 0x40,  /**< 17-33% utilized minor class */
287         BT_HAL_DEVICE_MINOR_CLASS_33_TO_50_PERCENT_UTILIZED = 0x60,  /**< 33-50% utilized minor class */
288         BT_HAL_DEVICE_MINOR_CLASS_50_to_67_PERCENT_UTILIZED = 0x80,  /**< 50-67% utilized minor class */
289         BT_HAL_DEVICE_MINOR_CLASS_67_TO_83_PERCENT_UTILIZED = 0xA0,  /**< 67-83% utilized minor class */
290         BT_HAL_DEVICE_MINOR_CLASS_83_TO_99_PERCENT_UTILIZED = 0xC0,  /**< 83-99% utilized minor class */
291         BT_HAL_DEVICE_MINOR_CLASS_NO_SERVICE_AVAILABLE = 0xE0,               /**< No service available minor class */
292
293         /* About Audio/Video Major class */
294         BT_HAL_DEVICE_MINOR_CLASS_HEADSET_PROFILE = 0x04,            /**< Headset minor class */
295         BT_HAL_DEVICE_MINOR_CLASS_HANDSFREE = 0x08,                  /**< Handsfree minor class*/
296
297         BT_HAL_DEVICE_MINOR_CLASS_MICROPHONE = 0x10,         /**< Microphone minor class */
298         BT_HAL_DEVICE_MINOR_CLASS_LOUD_SPEAKER = 0x14,       /**< Loud Speaker minor class */
299         BT_HAL_DEVICE_MINOR_CLASS_HEADPHONES = 0x18,         /**< Headphones minor class */
300         BT_HAL_DEVICE_MINOR_CLASS_PORTABLE_AUDIO = 0x1C,     /**< Portable Audio minor class */
301         BT_HAL_DEVICE_MINOR_CLASS_CAR_AUDIO = 0x20,           /**< Car Audio minor class */
302         BT_HAL_DEVICE_MINOR_CLASS_SET_TOP_BOX = 0x24,        /**< Set top box minor class */
303         BT_HAL_DEVICE_MINOR_CLASS_HIFI_AUDIO_DEVICE = 0x28,  /**< Hifi minor class */
304         BT_HAL_DEVICE_MINOR_CLASS_VCR = 0x2C,                /**< VCR minor class */
305         BT_HAL_DEVICE_MINOR_CLASS_VIDEO_CAMERA = 0x30,       /**< Video Camera minor class */
306         BT_HAL_DEVICE_MINOR_CLASS_CAM_CORDER = 0x34,         /**< CAM Corder minor class */
307         BT_HAL_DEVICE_MINOR_CLASS_VIDEO_MONITOR = 0x38,      /**<Video Monitor minor class */
308         BT_HAL_DEVICE_MINOR_CLASS_VIDEO_DISPLAY_AND_LOUD_SPEAKER = 0x3C,
309         /**< Video Display and Loud
310           Speaker minor class */
311         BT_HAL_DEVICE_MINOR_CLASS_VIDEO_CONFERENCING = 0x40, /**< Video Conferencing minor*/
312
313         BT_HAL_DEVICE_MINOR_CLASS_GAMING_OR_TOY = 0x48,      /**< Gaming or toy minor class */
314
315         /* About Peripheral Major class */
316         BT_HAL_DEVICE_MINOR_CLASS_KEY_BOARD = 0x40,          /**< Key board minor class */
317         BT_HAL_DEVICE_MINOR_CLASS_POINTING_DEVICE = 0x80,    /**< Pointing Device minor class */
318         BT_HAL_DEVICE_MINOR_CLASS_COMBO_KEYBOARD_OR_POINTING_DEVICE = 0xC0,
319         /**< Combo Keyboard or pointing
320           device minorclass */
321
322         BT_HAL_DEVICE_MINOR_CLASS_JOYSTICK = 0x04,           /**< JoyStick minor class */
323         BT_HAL_DEVICE_MINOR_CLASS_GAME_PAD = 0x08,           /**< Game Pad minor class */
324         BT_HAL_DEVICE_MINOR_CLASS_REMOTE_CONTROL = 0x0C,     /**< Remote Control minor class */
325         BT_HAL_DEVICE_MINOR_CLASS_SENSING_DEVICE = 0x10,     /**< Sensing Device minor class */
326         BT_HAL_DEVICE_MINOR_CLASS_DIGITIZER_TABLET = 0x14,   /**< Digitizer minor class */
327         BT_HAL_DEVICE_MINOR_CLASS_CARD_READER = 0x18,        /**< Card Reader minor class */
328         BT_HAL_DEVICE_MINOR_CLASS_DIGITAL_PEN = 0x1C,        /**< Digital pen minor class */
329         BT_HAL_DEVICE_MINOR_CLASS_HANDHELD_SCANNER = 0x20,   /**< Handheld scanner for bar-codes, RFID minor class */
330         BT_HAL_DEVICE_MINOR_CLASS_HANDHELD_GESTURAL_INPUT_DEVICE = 0x24,     /**< Handheld gestural input device minor class */
331
332         /* About Imaging Major class */
333         BT_HAL_DEVICE_MINOR_CLASS_DISPLAY = 0x10,            /**< Display minor class */
334         BT_HAL_DEVICE_MINOR_CLASS_CAMERA = 0x20,             /**< Camera minor class */
335         BT_HAL_DEVICE_MINOR_CLASS_SCANNER = 0x40,            /**< Scanner minor class */
336         BT_HAL_DEVICE_MINOR_CLASS_PRINTER = 0x80,            /**< Printer minor class */
337
338         /* About Wearable Major class */
339         BT_HAL_DEVICE_MINOR_CLASS_WRIST_WATCH = 0x04,        /**< Wrist watch minor class */
340         BT_HAL_DEVICE_MINOR_CLASS_PAGER = 0x08,              /**< Pager minor class */
341         BT_HAL_DEVICE_MINOR_CLASS_JACKET = 0x0C,             /**< Jacket minor class */
342         BT_HAL_DEVICE_MINOR_CLASS_HELMET = 0x10,             /**< Helmet minor class */
343         BT_HAL_DEVICE_MINOR_CLASS_GLASSES = 0x14,            /**< Glasses minor class */
344
345         /* About Toy Major class */
346         BT_HAL_DEVICE_MINOR_CLASS_ROBOT = 0x04,              /**< Robot minor class */
347         BT_HAL_DEVICE_MINOR_CLASS_VEHICLE = 0x08,            /**< Vehicle minor class */
348         BT_HAL_DEVICE_MINOR_CLASS_DOLL_OR_ACTION = 0x0C,     /**< Doll or Action minor class */
349         BT_HAL_DEVICE_MINOR_CLASS_CONTROLLER = 0x10,         /**< Controller minor class */
350         BT_HAL_DEVICE_MINOR_CLASS_GAME = 0x14,               /**< Game minor class */
351
352         /* About Health Major class */
353         BT_HAL_DEVICE_MINOR_CLASS_BLOOD_PRESSURE_MONITOR = 0x04,     /**< Blood Pressure minor class */
354         BT_HAL_DEVICE_MINOR_CLASS_THERMOMETER = 0x08,                /**< Thermometer minor class */
355         BT_HAL_DEVICE_MINOR_CLASS_WEIGHING_SCALE = 0x0C,             /**< Weighing Scale minor class */
356         BT_HAL_DEVICE_MINOR_CLASS_GLUCOSE_METER = 0x10,              /**< Glucose minor class */
357         BT_HAL_DEVICE_MINOR_CLASS_PULSE_OXIMETER = 0x14,             /**< Pulse Oximeter minor class */
358         BT_HAL_DEVICE_MINOR_CLASS_HEART_OR_PULSE_RATE_MONITOR = 0x18,/**< Heart or pulse rate monitor minor class */
359         BT_HAL_DEVICE_MINOR_CLASS_MEDICAL_DATA_DISPLAY = 0x1C,       /**< Medical minor class */
360         BT_HAL_DEVICE_MINOR_CLASS_STEP_COUNTER = 0x20,               /**< Step Counter minor class */
361         BT_HAL_DEVICE_MINOR_CLASS_BODY_COMPOSITION_ANALYZER = 0x24,  /**< Body composition analyzer minor class */
362         BT_HAL_DEVICE_MINOR_CLASS_PEAK_FLOW_MONITOR = 0x28,  /**< Peak flow monitor minor class */
363         BT_HAL_DEVICE_MINOR_CLASS_MEDICATION_MONITOR = 0x2C, /**< Medication monitor minor class */
364         BT_HAL_DEVICE_MINOR_CLASS_KNEE_PROSTHESIS = 0x30,    /**< Knee prosthesis minor class */
365         BT_HAL_DEVICE_MINOR_CLASS_ANKLE_PROSTHESIS = 0x34,   /**< Ankle prosthesis minor class */
366 } bt_hal_device_minor_class_t;
367
368 typedef enum {
369         BT_HAL_GATT_PERMISSION_READ = 0x01,
370         BT_HAL_GATT_PERMISSION_WRITE = 0x02,
371         BT_HAL_GATT_PERMISSION_ENCRYPT_READ = 0x04,
372         BT_HAL_GATT_PERMISSION_ENCRYPT_WRITE = 0x08,
373         BT_HAL_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_READ = 0x10,
374         BT_HAL_GATT_PERMISSION_ENCRYPT_AUTHENTICATED_WRITE = 0x20,
375 } bt_hal_gatt_permission_t;
376
377 typedef enum {
378         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_BROADCAST = 0x01,
379         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_READ = 0x02,
380         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_WRITE_NO_RESPONSE = 0x04,
381         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_WRITE = 0x08,
382         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_NOTIFY = 0x10,
383         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_INDICATE = 0x20,
384         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_SIGNED_WRITE = 0x40,
385         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_RELIABLE_WRITE = 0x80,
386         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_WRITABLE_AUXILIARIES = 0x100,
387         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_ENCRYPT_READ = 0x200,
388         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_ENCRYPT_WRITE = 0x400,
389         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_ENCRYPT_AUTHENTICATED_READ = 0x800,
390         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_ENCRYPT_AUTHENTICATED_WRITE = 0x1000,
391         BT_HAL_GATT_CHARACTERISTIC_PROPERTY_EXTENDED_PROPS = 0xffff,
392 } bt_hal_gatt_characteristic_property_t;
393
394 /**
395  * This is Bluetooth device address type, fixed to 6 bytes ##:##:##:##:##:##
396  */
397 typedef struct {
398         unsigned char addr[BT_HAL_ADDRESS_LENGTH_MAX];
399 } bt_hal_device_address_t;
400
401 /**
402  * structure to hold the device information
403  */
404 typedef struct {
405         bt_hal_device_major_class_t major_class; /**< major device class */
406         bt_hal_device_minor_class_t minor_class; /**< minor device class */
407         bt_hal_device_service_class_t service_class;
408                                                     /**< service device class */
409 } bt_hal_device_class_t;
410
411 /**
412  * Connected state types
413  */
414 typedef enum {
415         BT_HAL_CONNECTED_LINK_NONE = 0x00,
416         BT_HAL_CONNECTED_LINK_BREDR = 0x01,
417         BT_HAL_CONNECTED_LINK_LE = 0x02,
418         BT_HAL_CONNECTED_LINK_BREDR_LE = 0x03,
419 } bt_hal_connected_link_t;
420
421 typedef struct {
422         char *obj_path;
423         char *uuid;
424         gboolean authentication;
425         gboolean authorization;
426         char *role;
427         char *service;
428 } bt_hal_register_profile_info_t;
429
430 typedef int (*bt_hal_new_connection_cb) (const char *path, int fd, bt_bdaddr_t *address);
431
432 GDBusProxy *_bt_get_adapter_proxy(void);
433 GDBusProxy *_bt_get_adapter_properties_proxy(void);
434 GDBusConnection *_bt_get_system_gconn(void);
435 GDBusProxy *_bt_hal_get_manager_proxy(void);
436 GDBusProxy *_bt_get_profile_proxy(void);
437 GDBusProxy *_bt_get_avrcp_ctrl_proxy(bt_bdaddr_t *bd_addr);
438 GDBusProxy *_bt_get_avrcp_ctrl_properties_proxy(bt_bdaddr_t *bd_addr);
439 char *_bt_hal_get_adapter_path(void);
440
441 char *_bt_get_device_object_path(char *address);
442 void _bt_convert_device_path_to_address(const char *device_path, char *device_address);
443
444 void _bt_convert_addr_string_to_type(unsigned char *addr, const char *address);
445 void _bt_convert_addr_type_to_string(char *address, const unsigned char *addr);
446 void _bt_convert_uuid_string_to_type(unsigned char *uuid, const char *device_uuid);
447 void _bt_convert_uuid_type_to_string(char *str, const unsigned char *uuid);
448
449 int _bt_connect_profile(char *address, char *uuid, void *cb, gpointer func_data);
450 int _bt_disconnect_profile(char *address, char *uuid, void *cb, gpointer func_data);
451 int _bt_register_profile(bt_hal_register_profile_info_t *info, gboolean use_default_rfcomm);
452 void _bt_unregister_profile(char *path);
453
454
455 int _bt_discover_services(char *address, char *uuid, void *cb, gpointer func_data);
456 int _bt_cancel_discovers(char *address);
457 int _bt_discover_service_uuids(char *address, char *remote_uuid);
458
459 int _bt_register_new_gdbus_object(const char *path, bt_hal_new_connection_cb cb);
460 void _bt_unregister_gdbus_object(int object_id);
461
462 char *_bt_hal_get_control_device_path(bt_bdaddr_t *bd_addr);
463 void _bt_hal_set_control_device_path(const char *path);
464 void _bt_hal_remove_control_device_path(const char *path);
465
466
467 int bt_hal_gatt_convert_prop2string(
468                         bt_hal_gatt_characteristic_property_t properties,
469                         char *char_properties[]);
470
471 int bt_hal_gatt_convert_perm2string(
472                         bt_hal_gatt_permission_t properties,
473                         char *char_properties[]);
474
475 gboolean _bt_hal_uuid_is_standard(bt_uuid_t *p_uuid);
476
477 gboolean _bt_hal_is_service_enabled(const char *uuid);
478
479 #ifdef __cplusplus
480 }
481 #endif /* __cplusplus */
482 #endif /* _BT_HAL_DBUS_COMMON_UTILS_H_ */