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