1 /* 2 * 3 * BlueZ - Bluetooth protocol stack for Linux 4 * 5 * Copyright (C) 2006-2007 Nokia Corporation 6 * Copyright (C) 2004-2009 Marcel Holtmann <marcel (at) 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.Device" 26 27 struct btd_device; 28 29 typedef enum { 30 AUTH_TYPE_PINCODE, 31 AUTH_TYPE_PASSKEY, 32 AUTH_TYPE_CONFIRM, 33 AUTH_TYPE_NOTIFY, 34 AUTH_TYPE_AUTO, 35 AUTH_TYPE_PAIRING_CONSENT, 36 } auth_type_t; 37 38 struct btd_device *device_create(DBusConnection *conn, struct btd_adapter *adapter, 39 const gchar *address); 40 void device_set_name(struct btd_device *device, const char *name); 41 void device_remove(struct btd_device *device, DBusConnection *conn, 42 gboolean remove_stored); 43 gint device_address_cmp(struct btd_device *device, const gchar *address); 44 int device_browse(struct btd_device *device, DBusConnection *conn, 45 DBusMessage *msg, uuid_t *search, gboolean reverse); 46 void device_probe_drivers(struct btd_device *device, GSList *profiles); 47 const sdp_record_t *btd_device_get_record(struct btd_device *device, 48 const char *uuid); 49 void btd_device_add_uuid(struct btd_device *device, const char *uuid); 50 struct btd_adapter *device_get_adapter(struct btd_device *device); 51 void device_get_address(struct btd_device *adapter, bdaddr_t *bdaddr); 52 const gchar *device_get_path(struct btd_device *device); 53 struct agent *device_get_agent(struct btd_device *device); 54 void device_set_agent(struct btd_device *device, struct agent *agent); 55 gboolean device_is_busy(struct btd_device *device); 56 gboolean device_is_temporary(struct btd_device *device); 57 gboolean device_is_paired(struct btd_device *device); 58 void device_set_temporary(struct btd_device *device, gboolean temporary); 59 void device_set_cap(struct btd_device *device, uint8_t cap); 60 uint8_t device_get_cap(struct btd_device *device); 61 void device_set_auth(struct btd_device *device, uint8_t auth); 62 uint8_t device_get_auth(struct btd_device *device); 63 gboolean device_is_connected(struct btd_device *device); 64 void device_set_secmode3_conn(struct btd_device *device, gboolean enable); 65 DBusMessage *device_create_bonding(struct btd_device *device, 66 DBusConnection *conn, DBusMessage *msg, 67 const char *agent_path, uint8_t capability); 68 void device_remove_bondind(struct btd_device *device, DBusConnection *connection); 69 void device_bonding_complete(struct btd_device *device, uint8_t status); 70 void device_simple_pairing_complete(struct btd_device *device, uint8_t status); 71 gboolean device_is_creating(struct btd_device *device, const char *sender); 72 gboolean device_is_bonding(struct btd_device *device, const char *sender); 73 void device_cancel_bonding(struct btd_device *device, uint8_t status); 74 int device_request_authentication(struct btd_device *device, auth_type_t type, 75 uint32_t passkey, void *cb); 76 void device_cancel_authentication(struct btd_device *device, gboolean aborted); 77 gboolean device_is_authenticating(struct btd_device *device); 78 gboolean device_is_authorizing(struct btd_device *device); 79 void device_set_authorizing(struct btd_device *device, gboolean auth); 80 void device_set_renewed_key(struct btd_device *device, gboolean renewed); 81 void device_add_connection(struct btd_device *device, DBusConnection *conn, 82 uint16_t handle); 83 uint16_t device_get_handle(struct btd_device *device); 84 void device_remove_connection(struct btd_device *device, DBusConnection *conn, 85 uint16_t handle); 86 gboolean device_has_connection(struct btd_device *device, uint16_t handle); 87 void device_request_disconnect(struct btd_device *device, DBusMessage *msg); 88 89 typedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, 90 void *user_data); 91 92 guint device_add_disconnect_watch(struct btd_device *device, 93 disconnect_watch watch, void *user_data, 94 GDestroyNotify destroy); 95 void device_remove_disconnect_watch(struct btd_device *device, guint id); 96 97 #define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) 98 99 struct btd_device_driver { 100 const char *name; 101 const char **uuids; 102 int (*probe) (struct btd_device *device, GSList *uuids); 103 void (*remove) (struct btd_device *device); 104 }; 105 106 int btd_register_device_driver(struct btd_device_driver *driver); 107 void btd_unregister_device_driver(struct btd_device_driver *driver); 108 109 struct btd_device *btd_device_ref(struct btd_device *device); 110 void btd_device_unref(struct btd_device *device); 111