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