device.h revision 9184e2eeb7b97371c6b83b747c8984e2340d2b47
186892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann/* 286892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 386892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * BlueZ - Bluetooth protocol stack for Linux 486892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 5f1659f19cfb3ef0c0c09b5f5b7e2b06d90d079abMarcel Holtmann * Copyright (C) 2006-2007 Nokia Corporation 69184e2eeb7b97371c6b83b747c8984e2340d2b47Marcel Holtmann * Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org> 786892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 886892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 986892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * This program is free software; you can redistribute it and/or modify 1086892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * it under the terms of the GNU General Public License as published by 1186892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * the Free Software Foundation; either version 2 of the License, or 1286892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * (at your option) any later version. 1386892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 1486892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * This program is distributed in the hope that it will be useful, 1586892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * but WITHOUT ANY WARRANTY; without even the implied warranty of 1686892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1786892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * GNU General Public License for more details. 1886892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 1986892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * You should have received a copy of the GNU General Public License 2086892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * along with this program; if not, write to the Free Software 2186892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 2286892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 2386892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann */ 2486892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann 257fe6ac58638e86d11494f5a785bcf1d074ca2c37Luiz Augusto von Dentz#define DEVICE_INTERFACE "org.bluez.Device" 267fe6ac58638e86d11494f5a785bcf1d074ca2c37Luiz Augusto von Dentz 272aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzstruct btd_device; 282aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz 292aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentztypedef enum { 302aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz AUTH_TYPE_PINCODE, 312aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz AUTH_TYPE_PASSKEY, 322aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz AUTH_TYPE_CONFIRM, 332aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz AUTH_TYPE_NOTIFY, 342aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz AUTH_TYPE_AUTO, 352aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz} auth_type_t; 362aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz 3718614bd2b008cb9f3879990883c569c37b72f195Alok Barsodestruct btd_device *device_create(DBusConnection *conn, struct btd_adapter *adapter, 3836dedff329b5ced8979a2161075e6a9d38c58785Luiz Augusto von Dentz const gchar *address); 39a721957f20ec79b1a19537e5c43d3a12e4286c6cLuiz Augusto von Dentzvoid device_set_name(struct btd_device *device, const char *name); 405d787d0c25ea650672d93459d7a898491f0b6344Johan Hedbergvoid device_get_name(struct btd_device *device, char *name, size_t len); 41204ab018f03d0d65f07b19cf4f777660b7d54249Claudio Takahasivoid device_remove(struct btd_device *device, gboolean remove_stored); 42555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodegint device_address_cmp(struct btd_device *device, const gchar *address); 43555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodeint device_browse(struct btd_device *device, DBusConnection *conn, 4469adac833c5633714b84bf840c75aa814193b8a6Johan Hedberg DBusMessage *msg, uuid_t *search, gboolean reverse); 45f1c3d8c1fabd801eac34c9069038d3f4cadcb58dLuiz Augusto von Dentzvoid device_probe_drivers(struct btd_device *device, GSList *profiles); 46548026e08bd9b83b3685d515a916e2cf674184f3Johan Hedbergconst sdp_record_t *btd_device_get_record(struct btd_device *device, 47548026e08bd9b83b3685d515a916e2cf674184f3Johan Hedberg const char *uuid); 4817541956196b13ee083852fd4124cd8cfd0928a4Johan Hedbergvoid btd_device_add_uuid(struct btd_device *device, const char *uuid); 4918614bd2b008cb9f3879990883c569c37b72f195Alok Barsodestruct btd_adapter *device_get_adapter(struct btd_device *device); 5019ce4933f3dadf3b04a2a9bd84d66d750cc010c3Alok Barsodevoid device_get_address(struct btd_device *adapter, bdaddr_t *bdaddr); 51555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodeconst gchar *device_get_path(struct btd_device *device); 52555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodestruct agent *device_get_agent(struct btd_device *device); 53555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodevoid device_set_agent(struct btd_device *device, struct agent *agent); 54555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodegboolean device_is_busy(struct btd_device *device); 55555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodegboolean device_is_temporary(struct btd_device *device); 56fee17aefe6b727ec790568aa4994039ff94bf44eJohan Hedberggboolean device_is_paired(struct btd_device *device); 576fe85942c1272ef3d4ef68a35eade7a276219bb6Johan Hedbergvoid device_set_paired(struct btd_device *device, gboolean paired); 58555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodevoid device_set_temporary(struct btd_device *device, gboolean temporary); 59555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodevoid device_set_cap(struct btd_device *device, uint8_t cap); 60f6646fcfe84b703d0657a0e827682702d64a4788Johan Hedberguint8_t device_get_cap(struct btd_device *device); 61555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodevoid device_set_auth(struct btd_device *device, uint8_t auth); 62555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodeuint8_t device_get_auth(struct btd_device *device); 63c4338c0b7a46d6288e350b8c05fc02ee28b4bdbcLuiz Augusto von Dentzgboolean device_is_connected(struct btd_device *device); 647f3f97e244322bf2e5943ee3c8a264146c9e03f1Johan Hedberggboolean device_get_secmode3_conn(struct btd_device *device); 65e21ec2652c54dbc8abbf84039b43fbd3be0b5ebcJohan Hedbergvoid device_set_secmode3_conn(struct btd_device *device, gboolean enable); 662aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von DentzDBusMessage *device_create_bonding(struct btd_device *device, 672aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz DBusConnection *conn, DBusMessage *msg, 682aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz const char *agent_path, uint8_t capability); 692aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzvoid device_remove_bondind(struct btd_device *device, DBusConnection *connection); 702aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzvoid device_bonding_complete(struct btd_device *device, uint8_t status); 71e35dd0c0246236371269b79cc28b1a23f4999560Johan Hedbergvoid device_simple_pairing_complete(struct btd_device *device, uint8_t status); 72e164ff20b95acd2a25c70623212c190abf7eee19Johan Hedberggboolean device_is_creating(struct btd_device *device, const char *sender); 732aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzgboolean device_is_bonding(struct btd_device *device, const char *sender); 742aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzvoid device_cancel_bonding(struct btd_device *device, uint8_t status); 752aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzint device_request_authentication(struct btd_device *device, auth_type_t type, 762aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz uint32_t passkey, void *cb); 77f7d1ee361e410e096929bd3918178af356c50bbdJohan Hedbergvoid device_cancel_authentication(struct btd_device *device, gboolean aborted); 782aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzgboolean device_is_authenticating(struct btd_device *device); 79837d65f3a7f94ed4e6fe95f4e845d7ae3242be24Johan Hedberggboolean device_is_authorizing(struct btd_device *device); 80837d65f3a7f94ed4e6fe95f4e845d7ae3242be24Johan Hedbergvoid device_set_authorizing(struct btd_device *device, gboolean auth); 81bcb6af7fc78234948ba1c997825c8859464b170bJohan Hedbergvoid device_set_renewed_key(struct btd_device *device, gboolean renewed); 82c4338c0b7a46d6288e350b8c05fc02ee28b4bdbcLuiz Augusto von Dentzvoid device_add_connection(struct btd_device *device, DBusConnection *conn, 83c4338c0b7a46d6288e350b8c05fc02ee28b4bdbcLuiz Augusto von Dentz uint16_t handle); 84c4338c0b7a46d6288e350b8c05fc02ee28b4bdbcLuiz Augusto von Dentzvoid device_remove_connection(struct btd_device *device, DBusConnection *conn, 85c4338c0b7a46d6288e350b8c05fc02ee28b4bdbcLuiz Augusto von Dentz uint16_t handle); 86c4338c0b7a46d6288e350b8c05fc02ee28b4bdbcLuiz Augusto von Dentzgboolean device_has_connection(struct btd_device *device, uint16_t handle); 87c3cfa26a86a25e35d8b0e7c24978a44f9af80a2aLuiz Augusto von Dentzvoid device_request_disconnect(struct btd_device *device, DBusMessage *msg); 888d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz 89a381d5342d27b99612fd31dc9cc80b01f412ad39Luiz Augusto von Dentztypedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, 90a381d5342d27b99612fd31dc9cc80b01f412ad39Luiz Augusto von Dentz void *user_data); 918d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz 928d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentzguint device_add_disconnect_watch(struct btd_device *device, 938d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz disconnect_watch watch, void *user_data, 948d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz GDestroyNotify destroy); 958d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentzvoid device_remove_disconnect_watch(struct btd_device *device, guint id); 96c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz 97c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) 98c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz 99c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentzstruct btd_device_driver { 100c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz const char *name; 101c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz const char **uuids; 102548026e08bd9b83b3685d515a916e2cf674184f3Johan Hedberg int (*probe) (struct btd_device *device, GSList *uuids); 103c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz void (*remove) (struct btd_device *device); 104c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz}; 105c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz 106c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentzint btd_register_device_driver(struct btd_device_driver *driver); 107c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentzvoid btd_unregister_device_driver(struct btd_device_driver *driver); 1080ba18c28575090e30fcb3023ea1b4039a2e27610Luiz Augusto von Dentz 1090ba18c28575090e30fcb3023ea1b4039a2e27610Luiz Augusto von Dentzstruct btd_device *btd_device_ref(struct btd_device *device); 1100ba18c28575090e30fcb3023ea1b4039a2e27610Luiz Augusto von Dentzvoid btd_device_unref(struct btd_device *device); 111