OSDN Git Service

build: Add --enable-midi to bootstrap-configure
[android-x86/external-bluetooth-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 struct btd_device *device_create(struct btd_adapter *adapter,
30                                 const bdaddr_t *address, uint8_t bdaddr_type);
31 struct btd_device *device_create_from_storage(struct btd_adapter *adapter,
32                                 const char *address, GKeyFile *key_file);
33 char *btd_device_get_storage_path(struct btd_device *device,
34                                 const char *filename);
35
36 void btd_device_device_set_name(struct btd_device *device, const char *name);
37 void device_store_cached_name(struct btd_device *dev, const char *name);
38 void device_get_name(struct btd_device *device, char *name, size_t len);
39 bool device_name_known(struct btd_device *device);
40 void device_set_class(struct btd_device *device, uint32_t class);
41 void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
42                                                         uint8_t bdaddr_type);
43 void device_set_bredr_support(struct btd_device *device);
44 void device_set_le_support(struct btd_device *device, uint8_t bdaddr_type);
45 void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type);
46 void device_merge_duplicate(struct btd_device *dev, struct btd_device *dup);
47 uint32_t btd_device_get_class(struct btd_device *device);
48 uint16_t btd_device_get_vendor(struct btd_device *device);
49 uint16_t btd_device_get_vendor_src(struct btd_device *device);
50 uint16_t btd_device_get_product(struct btd_device *device);
51 uint16_t btd_device_get_version(struct btd_device *device);
52 void device_remove(struct btd_device *device, gboolean remove_stored);
53 int device_address_cmp(gconstpointer a, gconstpointer b);
54 int device_bdaddr_cmp(gconstpointer a, gconstpointer b);
55
56 /* Struct used by device_addr_type_cmp() */
57 struct device_addr_type {
58         bdaddr_t bdaddr;
59         uint8_t bdaddr_type;
60 };
61
62 int device_addr_type_cmp(gconstpointer a, gconstpointer b);
63 GSList *btd_device_get_uuids(struct btd_device *device);
64 void device_probe_profiles(struct btd_device *device, GSList *profiles);
65 const sdp_record_t *btd_device_get_record(struct btd_device *device,
66                                                 const char *uuid);
67 struct gatt_primary *btd_device_get_primary(struct btd_device *device,
68                                                         const char *uuid);
69 GSList *btd_device_get_primaries(struct btd_device *device);
70 struct gatt_db *btd_device_get_gatt_db(struct btd_device *device);
71 struct bt_gatt_client *btd_device_get_gatt_client(struct btd_device *device);
72 struct bt_gatt_server *btd_device_get_gatt_server(struct btd_device *device);
73 void *btd_device_get_attrib(struct btd_device *device);
74 void btd_device_gatt_set_service_changed(struct btd_device *device,
75                                                 uint16_t start, uint16_t end);
76 bool device_attach_att(struct btd_device *dev, GIOChannel *io);
77 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
78 void device_add_eir_uuids(struct btd_device *dev, GSList *uuids);
79 void device_set_manufacturer_data(struct btd_device *dev, GSList *list);
80 void device_set_service_data(struct btd_device *dev, GSList *list);
81 void device_probe_profile(gpointer a, gpointer b);
82 void device_remove_profile(gpointer a, gpointer b);
83 struct btd_adapter *device_get_adapter(struct btd_device *device);
84 const bdaddr_t *device_get_address(struct btd_device *device);
85 const char *device_get_path(const struct btd_device *device);
86 gboolean device_is_temporary(struct btd_device *device);
87 bool device_is_paired(struct btd_device *device, uint8_t bdaddr_type);
88 bool device_is_bonded(struct btd_device *device, uint8_t bdaddr_type);
89 gboolean device_is_trusted(struct btd_device *device);
90 void device_set_paired(struct btd_device *dev, uint8_t bdaddr_type);
91 void device_set_unpaired(struct btd_device *dev, uint8_t bdaddr_type);
92 void btd_device_set_temporary(struct btd_device *device, bool temporary);
93 void btd_device_set_trusted(struct btd_device *device, gboolean trusted);
94 void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type);
95 void device_set_legacy(struct btd_device *device, bool legacy);
96 void device_set_rssi_with_delta(struct btd_device *device, int8_t rssi,
97                                                         int8_t delta_threshold);
98 void device_set_rssi(struct btd_device *device, int8_t rssi);
99 void device_set_tx_power(struct btd_device *device, int8_t tx_power);
100 void device_set_flags(struct btd_device *device, uint8_t flags);
101 bool btd_device_is_connected(struct btd_device *dev);
102 uint8_t btd_device_get_bdaddr_type(struct btd_device *dev);
103 bool device_is_retrying(struct btd_device *device);
104 void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
105                                                         uint8_t status);
106 gboolean device_is_bonding(struct btd_device *device, const char *sender);
107 void device_bonding_attempt_failed(struct btd_device *device, uint8_t status);
108 void device_bonding_failed(struct btd_device *device, uint8_t status);
109 struct btd_adapter_pin_cb_iter *device_bonding_iter(struct btd_device *device);
110 int device_bonding_attempt_retry(struct btd_device *device);
111 long device_bonding_last_duration(struct btd_device *device);
112 void device_bonding_restart_timer(struct btd_device *device);
113 int device_request_pincode(struct btd_device *device, gboolean secure);
114 int device_request_passkey(struct btd_device *device, uint8_t type);
115 int device_confirm_passkey(struct btd_device *device, uint8_t type,
116                                         int32_t passkey, uint8_t confirm_hint);
117 int device_notify_passkey(struct btd_device *device, uint8_t type,
118                                         uint32_t passkey, uint8_t entered);
119 int device_notify_pincode(struct btd_device *device, gboolean secure,
120                                                         const char *pincode);
121 void device_cancel_authentication(struct btd_device *device, gboolean aborted);
122 gboolean device_is_authenticating(struct btd_device *device);
123 void device_add_connection(struct btd_device *dev, uint8_t bdaddr_type);
124 void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type);
125 void device_request_disconnect(struct btd_device *device, DBusMessage *msg);
126 bool device_is_disconnecting(struct btd_device *device);
127
128 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal,
129                                         void *user_data);
130
131 guint device_add_disconnect_watch(struct btd_device *device,
132                                 disconnect_watch watch, void *user_data,
133                                 GDestroyNotify destroy);
134 void device_remove_disconnect_watch(struct btd_device *device, guint id);
135 int device_get_appearance(struct btd_device *device, uint16_t *value);
136 void device_set_appearance(struct btd_device *device, uint16_t value);
137
138 struct btd_device *btd_device_ref(struct btd_device *device);
139 void btd_device_unref(struct btd_device *device);
140
141 int device_block(struct btd_device *device, gboolean update_only);
142 int device_unblock(struct btd_device *device, gboolean silent,
143                                                         gboolean update_only);
144 void btd_device_set_pnpid(struct btd_device *device, uint16_t source,
145                         uint16_t vendor, uint16_t product, uint16_t version);
146
147 int device_connect_le(struct btd_device *dev);
148
149 typedef void (*device_svc_cb_t) (struct btd_device *dev, int err,
150                                                         void *user_data);
151
152 unsigned int device_wait_for_svc_complete(struct btd_device *dev,
153                                                         device_svc_cb_t func,
154                                                         void *user_data);
155 bool device_remove_svc_complete_callback(struct btd_device *dev,
156                                                         unsigned int id);
157
158 struct btd_service *btd_device_get_service(struct btd_device *dev,
159                                                 const char *remote_uuid);
160
161 int device_discover_services(struct btd_device *device);
162 int btd_device_connect_services(struct btd_device *dev, GSList *services);
163
164 void btd_device_init(void);
165 void btd_device_cleanup(void);