517f7d950859b1e2ad13e182736b2d6756697185
[platform/upstream/bluez.git] / src / device.h
1 /*
2  *
3  *  BlueZ - Bluetooth protocol stack for Linux
4  *
5  *  Copyright (C) 2006-2010  Nokia Corporation
6  *  Copyright (C) 2004-2010  Marcel Holtmann <marcel@holtmann.org>
7  *
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, write to the Free Software
21  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22  *
23  */
24
25 #define DEVICE_INTERFACE        "org.bluez.Device1"
26
27 struct btd_device;
28
29 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
30 /* Device Physical channel connection Type */
31 #define DEV_CONN_DEFAULT 0xFF /* Represents support for BREDR and LE */
32 #define DEV_CONN_BREDR 0x00 /* Only BREDR */
33 #define DEV_CONN_LE 0x01 /* Only LE*/
34 #endif
35
36 struct btd_device *device_create(struct btd_adapter *adapter,
37                                 const bdaddr_t *address, uint8_t bdaddr_type);
38 struct btd_device *device_create_from_storage(struct btd_adapter *adapter,
39                                 const char *address, GKeyFile *key_file);
40 char *btd_device_get_storage_path(struct btd_device *device,
41                                 const char *filename);
42
43 void btd_device_device_set_name(struct btd_device *device, const char *name);
44 void device_store_cached_name(struct btd_device *dev, const char *name);
45 void device_get_name(struct btd_device *device, char *name, size_t len);
46 bool device_name_known(struct btd_device *device);
47 void device_set_class(struct btd_device *device, uint32_t class);
48 void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
49                                                         uint8_t bdaddr_type);
50 void device_set_bredr_support(struct btd_device *device);
51 void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type);
52 void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type);
53 void device_merge_duplicate(struct btd_device *dev, struct btd_device *dup);
54 uint32_t btd_device_get_class(struct btd_device *device);
55 uint16_t btd_device_get_vendor(struct btd_device *device);
56 uint16_t btd_device_get_vendor_src(struct btd_device *device);
57 uint16_t btd_device_get_product(struct btd_device *device);
58 uint16_t btd_device_get_version(struct btd_device *device);
59 void device_remove(struct btd_device *device, gboolean remove_stored);
60 int device_address_cmp(gconstpointer a, gconstpointer b);
61 int device_bdaddr_cmp(gconstpointer a, gconstpointer b);
62
63 /* Struct used by device_addr_type_cmp() */
64 struct device_addr_type {
65         bdaddr_t bdaddr;
66         uint8_t bdaddr_type;
67 };
68
69 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
70 int device_addr_type_strict_cmp(gconstpointer a, gconstpointer b);
71 #endif
72 int device_addr_type_cmp(gconstpointer a, gconstpointer b);
73 GSList *btd_device_get_uuids(struct btd_device *device);
74 void device_probe_profiles(struct btd_device *device, GSList *profiles);
75
76 void btd_device_set_record(struct btd_device *device, const char *uuid,
77                                                         const char *record);
78 const sdp_record_t *btd_device_get_record(struct btd_device *device,
79                                                 const char *uuid);
80 struct gatt_primary *btd_device_get_primary(struct btd_device *device,
81                                                         const char *uuid);
82 GSList *btd_device_get_primaries(struct btd_device *device);
83 struct gatt_db *btd_device_get_gatt_db(struct btd_device *device);
84 struct bt_gatt_client *btd_device_get_gatt_client(struct btd_device *device);
85 struct bt_gatt_server *btd_device_get_gatt_server(struct btd_device *device);
86 void *btd_device_get_attrib(struct btd_device *device);
87 void btd_device_gatt_set_service_changed(struct btd_device *device,
88                                                 uint16_t start, uint16_t end);
89 bool device_attach_att(struct btd_device *dev, GIOChannel *io);
90 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
91 void device_add_eir_uuids(struct btd_device *dev, GSList *uuids);
92 void device_set_manufacturer_data(struct btd_device *dev, GSList *list,
93                                                         bool duplicate);
94 void device_set_service_data(struct btd_device *dev, GSList *list,
95                                                         bool duplicate);
96 void device_set_data(struct btd_device *dev, GSList *list,
97                                                         bool duplicate);
98 void device_probe_profile(gpointer a, gpointer b);
99 void device_remove_profile(gpointer a, gpointer b);
100 struct btd_adapter *device_get_adapter(struct btd_device *device);
101 const bdaddr_t *device_get_address(struct btd_device *device);
102 uint8_t device_get_le_address_type(struct btd_device *device);
103 const char *device_get_path(const struct btd_device *device);
104 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
105 void device_set_remote_feature_flag(struct btd_device *device, int flags);
106 gboolean device_is_bredrle(struct btd_device *device);
107 void device_set_disconnect_reason(struct btd_device *device, uint8_t reason);
108 void device_set_gatt_connected(struct btd_device *device, gboolean connected);
109 void device_unpair(struct btd_device *device, gboolean remove_stored);
110 gboolean device_get_gatt_connected(const struct btd_device *device);
111 void device_set_rpa(struct btd_device *device, const bdaddr_t *rpa_addr);
112 const bdaddr_t *device_get_rpa(struct btd_device *device);
113 bool device_get_rpa_exist(struct btd_device *device);
114 int device_rpa_cmp(gconstpointer a, gconstpointer b);
115 int device_addr_cmp(gconstpointer a, gconstpointer b);
116 int device_rpa_ida_cmp(gconstpointer a, gconstpointer b);
117 void device_remove_stored_folder(struct btd_device *device);
118 const uint8_t *device_get_irk_value(struct btd_device *device);
119 void device_set_irk_value(struct btd_device *device, const uint8_t *val);
120 void device_set_conn_update_state(struct btd_device *device, bool state);
121 bool device_get_conn_update_state(struct btd_device *device);
122 void btd_device_set_trusted_profiles(struct btd_device *device,
123                 uint32_t pbap, uint32_t map, uint32_t sap,
124                 uint32_t hfp_hs, uint32_t a2dp);
125 void device_set_le_connectable(struct btd_device *device, uint8_t adv_type);
126 #endif
127 gboolean device_is_temporary(struct btd_device *device);
128 bool device_is_connectable(struct btd_device *device);
129 bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type);
130 bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
131 gboolean device_is_trusted(struct btd_device *device);
132 void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
133 void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
134 void btd_device_set_temporary(struct btd_device *device, bool temporary);
135 void btd_device_set_trusted(struct btd_device *device, gboolean trusted);
136 void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type);
137 void device_set_legacy(struct btd_device *device, bool legacy);
138 void device_set_rssi_with_delta(struct btd_device *device, int8_t rssi,
139                                                         int8_t delta_threshold);
140 void device_set_rssi(struct btd_device *device, int8_t rssi);
141 void device_set_tx_power(struct btd_device *device, int8_t tx_power);
142 void device_set_flags(struct btd_device *device, uint8_t flags);
143 bool btd_device_is_connected(struct btd_device *dev);
144 uint8_t btd_device_get_bdaddr_type(struct btd_device *dev);
145 bool device_is_retrying(struct btd_device *device);
146 void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
147                                                         uint8_t status);
148 gboolean device_is_bonding(struct btd_device *device, const char *sender);
149 void device_bonding_attempt_failed(struct btd_device *device, uint8_t status);
150 void device_bonding_failed(struct btd_device *device, uint8_t status);
151 struct btd_adapter_pin_cb_iter *device_bonding_iter(struct btd_device *device);
152 int device_bonding_attempt_retry(struct btd_device *device);
153 long device_bonding_last_duration(struct btd_device *device);
154 void device_bonding_restart_timer(struct btd_device *device);
155 int device_request_pincode(struct btd_device *device, gboolean secure);
156 int device_request_passkey(struct btd_device *device, uint8_t type);
157 int device_confirm_passkey(struct btd_device *device, uint8_t type,
158                                         int32_t passkey, uint8_t confirm_hint);
159 int device_notify_passkey(struct btd_device *device, uint8_t type,
160                                         uint32_t passkey, uint8_t entered);
161 int device_notify_pincode(struct btd_device *device, gboolean secure,
162                                                         const char *pincode);
163 void device_cancel_authentication(struct btd_device *device, gboolean aborted);
164 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
165 gboolean device_is_authenticating(struct btd_device *dev, uint8_t bdaddr_type);
166 #else
167 gboolean device_is_authenticating(struct btd_device *device);
168 #endif
169 void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type);
170 void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type);
171 void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
172 bool device_is_disconnecting(struct btd_device *device);
173 void device_set_ltk_enc_size(struct btd_device *device, uint8_t enc_size);
174
175 void device_store_svc_chng_ccc(struct btd_device *device, uint8_t bdaddr_type,
176                                                                 uint16_t value);
177 void device_load_svc_chng_ccc(struct btd_device *device, uint16_t *ccc_le,
178                                                         uint16_t *ccc_bredr);
179
180 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal,
181                                         void *user_data);
182
183 guint device_add_disconnect_watch(struct btd_device *device,
184                                 disconnect_watch watch, void *user_data,
185                                 GDestroyNotify destroy);
186 void device_remove_disconnect_watch(struct btd_device *device, guint id);
187 int device_get_appearance(struct btd_device *device, uint16_t *value);
188 void device_set_appearance(struct btd_device *device, uint16_t value);
189
190 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
191 struct eir_data;
192 void device_set_manufacturer_info(struct btd_device *dev, struct eir_data *eir);
193 void device_set_adv_report_info(struct btd_device *device, void *data,
194                         uint8_t data_len, uint8_t adv_info, int8_t rssi);
195 void device_set_payload_timeout(struct btd_device *device,
196                         uint16_t payload_timeout);
197 void device_set_auth_addr_type(struct btd_device *device, uint8_t type);
198 void device_set_last_addr_type(struct btd_device *device, uint8_t type);
199 gboolean device_is_ipsp_connected(struct btd_device * device);
200 void device_set_ipsp_connected(struct btd_device *device, gboolean connected,
201                                                 const unsigned char *ifname);
202 int device_get_rpa_res_char_value(struct btd_device *device);
203 void device_set_rpa_res_char_value(struct btd_device *device, uint8_t value);
204 void device_le_data_length_changed(struct btd_device *device, uint16_t max_tx_octets,
205                         uint16_t max_tx_time, uint16_t max_rx_octets,
206                         uint16_t max_rx_time);
207 void device_get_tizen_addr(struct btd_device *device, uint8_t type,
208                            struct device_addr_type *addr);
209 #endif
210
211 struct btd_device *btd_device_ref(struct btd_device *device);
212 void btd_device_unref(struct btd_device *device);
213
214 int device_block(struct btd_device *device, gboolean update_only);
215 int device_unblock(struct btd_device *device, gboolean silent,
216                                                         gboolean update_only);
217 void btd_device_set_pnpid(struct btd_device *device, uint16_t source,
218                         uint16_t vendor, uint16_t product, uint16_t version);
219
220 int device_connect_le(struct btd_device *dev);
221
222 typedef void (*device_svc_cb_t) (struct btd_device *dev, int err,
223                                                         void *user_data);
224
225 unsigned int device_wait_for_svc_complete(struct btd_device *dev,
226                                                         device_svc_cb_t func,
227                                                         void *user_data);
228 bool device_remove_svc_complete_callback(struct btd_device *dev,
229                                                         unsigned int id);
230
231 struct btd_service *btd_device_get_service(struct btd_device *dev,
232                                                 const char *remote_uuid);
233
234 #ifdef TIZEN_FEATURE_BLUEZ_MODIFY
235 void device_print_addr(struct btd_device *dev);
236 gboolean device_is_profile_trusted(struct btd_device *device,
237                 const char *uuid);
238 gboolean device_is_profile_blocked(struct btd_device *device,
239                 const char *uuid);
240 void btd_device_disconnect(struct btd_device *dev);
241 void btd_device_set_legacy_pairing(struct btd_device *dev, bool legacy_pairing);
242 void btd_device_set_svc_changed_indication(struct btd_device *dev, bool value);
243 bool btd_device_get_svc_changed_indication(struct btd_device *dev);
244 #ifdef TIZEN_FEATURE_BLUEZ_BATTERY_WATCH
245 void device_change_pkt_type(gpointer data, gpointer user_data);
246 #endif  /* TIZEN_FEATURE_BLUEZ_BATTERY_WATCH */
247 #endif
248
249 int device_discover_services(struct btd_device *device);
250 int btd_device_connect_services(struct btd_device *dev, GSList *services);
251
252 void btd_device_init(void);
253 void btd_device_cleanup(void);