4 * Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef _BT_SERVICE_COMMON_H_
21 #define _BT_SERVICE_COMMON_H_
23 #include <sys/types.h>
25 #include <dbus/dbus-glib.h>
26 #include <dbus/dbus.h>
28 #include "bluetooth-api.h"
35 #define LOG_TAG "BLUETOOTH_FRWK_SERVICE"
37 #define BT_DBG(fmt, args...) \
39 #define BT_ERR(fmt, args...) \
42 #define ret_if(expr) \
45 BT_ERR("(%s) return", #expr); \
50 #define retv_if(expr, val) \
53 BT_ERR("(%s) return", #expr); \
58 #define BT_CHECK_PARAMETER(arg, func) \
62 BT_ERR("INVALID PARAMETER"); \
63 func BLUETOOTH_ERROR_INVALID_PARAM; \
67 #define BT_CHANNEL_LENGTH_MAX 5
68 #define BT_ADDRESS_LENGTH_MAX 6
69 #define BT_ADDRESS_STRING_SIZE 18
70 #define BT_RFCOMM_BUFFER_MAX 1024
71 #define BT_LOWER_ADDRESS_LENGTH 9
73 #define BT_AGENT_AUTO_PAIR_BLACKLIST_FILE (APP_SYSCONFDIR"/auto-pair-blacklist")
74 #define BT_AGENT_NEW_LINE "\r\n"
76 #define BT_MAX_DBUS_TIMEOUT 45000
77 #define BT_ENABLE_TIMEOUT 5000 /* 5 seconds */
78 #define BT_DISCOVERY_FINISHED_DELAY 200
80 #define MANAGER_EVENT_MATCH_RULE \
85 #define EVENT_MATCH_RULE \
89 #define BT_TEMINATING_WAIT_TIME 200
91 #define BT_TIMEOUT_MESSAGE "Did not receive a reply. Possible causes include: " \
92 "the remote application did not send a reply, " \
93 "the message bus security policy blocked the reply, " \
94 "the reply timeout expired, or the network connection " \
97 #define BT_BLUEZ_NAME "org.bluez"
98 #define BT_AGENT_NAME "org.bluez.frwk_agent"
99 #define BT_AGENT_PATH "/org/bluez/agent/frwk_agent"
100 #define BT_DEVICE_AGENT_PATH "/org/tizen/device_agent"
101 #define BT_ADAPTER_AGENT_PATH "/org/tizen/adapter_agent"
102 #define BT_MANAGER_PATH "/"
103 #define BT_MANAGER_INTERFACE "org.bluez.Manager"
104 #define BT_ADAPTER_INTERFACE "org.bluez.Adapter"
105 #define BT_AGENT_INTERFACE "org.bluez.Agent"
106 #define BT_DEVICE_INTERFACE "org.bluez.Device"
107 #define BT_INPUT_INTERFACE "org.bluez.Input"
108 #define BT_NETWORK_INTERFACE "org.bluez.Network"
109 #define BT_NETWORK_SERVER_INTERFACE "org.bluez.NetworkServer"
110 #define BT_NETWORK_CLIENT_INTERFACE "org.bluez.Network"
111 #define BT_SERIAL_INTERFACE "org.bluez.Serial"
112 #define BT_SERIAL_MANAGER_INTERFACE "org.bluez.SerialProxyManager"
113 #define BT_SERIAL_PROXY_INTERFACE "org.bluez.SerialProxy"
114 #define BT_HEADSET_INTERFACE "org.bluez.Headset"
115 #define BT_SINK_INTERFACE "org.bluez.AudioSink"
116 #define BT_AUDIO_INTERFACE "org.bluez.Audio"
117 #define BT_OOB_INTERFACE "org.bluez.OutOfBand"
118 #define BT_MEDIA_INTERFACE "org.bluez.Media"
119 #define BT_MEDIA_PLAYER_INTERFACE "org.bluez.MediaPlayer"
120 #define BT_OBEXD_INTERFACE "org.openobex"
121 #define BT_OBEXD_MANAGER_INTERFACE "org.openobex.Manager"
122 #define BT_OBEXD_TRANSFER_INTERFACE "org.openobex.Transfer"
124 #define BT_OBEX_SERVICE_NAME "org.openobex.client"
126 #define BT_OBEX_CLIENT_PATH "/"
127 #define BT_OBEX_CLIENT_INTERFACE "org.openobex.Client"
128 #define BT_OBEX_TRANSFER_INTERFACE "org.openobex.Transfer"
129 #define BT_OBEX_AGENT_INTERFACE "org.openobex.Agent"
131 #define BT_FREEDESKTOP_INTERFACE "org.freedesktop.DBus"
132 #define BT_FREEDESKTOP_PATH "/org/freedesktop/DBus"
135 #define BT_PRIVILEGE_MANAGER "bt-service::manager"
136 #define BT_PRIVILEGE_ADMIN "bt-service::admin"
137 #define BT_PRIVILEGE_GAP "bt-service::gap"
138 #define BT_PRIVILEGE_OPP "bt-service::opp"
139 #define BT_PRIVILEGE_SPP "bt-service::spp"
140 #define BT_PRIVILEGE_HEALTH "bt-service::health"
143 BT_OBEX_SERVER = 0x00,
144 BT_RFCOMM_SERVER = 0x01,
145 } bt_osp_server_type_t;
157 } bt_remote_dev_info_t;
159 /* RFCOMM client /server will use this structure*/
162 GIOChannel *io_channel;
172 } bt_function_data_t;
174 DBusConnection *_bt_get_system_conn(void);
176 DBusGConnection *_bt_get_system_gconn(void);
178 DBusGConnection *_bt_get_session_gconn(void);
180 DBusGProxy *_bt_get_manager_proxy(void);
182 DBusGProxy *_bt_get_adapter_proxy(void);
184 char *_bt_get_adapter_path(void);
186 void _bt_deinit_proxys(void);
188 void _bt_convert_device_path_to_address(const char *device_path,
189 char *device_address);
191 void _bt_convert_addr_string_to_type(unsigned char *addr,
192 const char *address);
194 void _bt_convert_addr_type_to_string(char *address,
195 unsigned char *addr);
197 void _bt_print_device_address_t(const bluetooth_device_address_t *addr);
199 void _bt_divide_device_class(bluetooth_device_class_t *device_class,
202 void _bt_free_device_info(bt_remote_dev_info_t *dev_info);
204 int _bt_register_osp_server_in_agent(int type, char *uuid);
206 int _bt_unregister_osp_server_in_agent(int type, char *uuid);
208 int _bt_set_socket_non_blocking(int socket_fd);
210 int _bt_set_non_blocking_tty(int sk);
212 gboolean _bt_is_headset_class(int dev_class);
214 void _bt_deinit_bluez_proxy(void);
218 #endif /* __cplusplus */
219 #endif /*_BT_COMMON_H_*/