186892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann/* 286892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 386892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * BlueZ - Bluetooth protocol stack for Linux 486892be8d38960096f9b9c5613ba28fc9003d288Marcel Holtmann * 55592142cb9383df0556b27ac59e96547b380310bJohan Hedberg * Copyright (C) 2006-2010 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, 347050b0c6c21919186cddda6f2286f43cb99798b2Jaikumar Ganesh AUTH_TYPE_AUTO, 357050b0c6c21919186cddda6f2286f43cb99798b2Jaikumar Ganesh AUTH_TYPE_PAIRING_CONSENT, 362aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz} auth_type_t; 372aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz 38f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasitypedef enum { 39f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi DEVICE_TYPE_UNKNOWN, 40f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi DEVICE_TYPE_BREDR, 41f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi DEVICE_TYPE_LE, 42f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi DEVICE_TYPE_DUALMODE 43f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi} device_type_t; 44f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi 45e0c4ed89aeb863939bacc62ccb2f29a3b288ffcbClaudio Takahasistruct btd_device *device_create(DBusConnection *conn, 46f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi struct btd_adapter *adapter, 47f1beea3e80b6e02f49eeea926d398366b13d291cClaudio Takahasi const gchar *address, device_type_t type); 48a721957f20ec79b1a19537e5c43d3a12e4286c6cLuiz Augusto von Dentzvoid device_set_name(struct btd_device *device, const char *name); 495d787d0c25ea650672d93459d7a898491f0b6344Johan Hedbergvoid device_get_name(struct btd_device *device, char *name, size_t len); 507e6edb65cfabc1b9a7f131f6f51938bb1f57f0f9Sheldon Demariodevice_type_t device_get_type(struct btd_device *device); 51204ab018f03d0d65f07b19cf4f777660b7d54249Claudio Takahasivoid device_remove(struct btd_device *device, gboolean remove_stored); 52555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodegint device_address_cmp(struct btd_device *device, const gchar *address); 537e6edb65cfabc1b9a7f131f6f51938bb1f57f0f9Sheldon Demarioint device_browse_primary(struct btd_device *device, DBusConnection *conn, 547e6edb65cfabc1b9a7f131f6f51938bb1f57f0f9Sheldon Demario DBusMessage *msg, gboolean secure); 557e6edb65cfabc1b9a7f131f6f51938bb1f57f0f9Sheldon Demarioint device_browse_sdp(struct btd_device *device, DBusConnection *conn, 5669adac833c5633714b84bf840c75aa814193b8a6Johan Hedberg DBusMessage *msg, uuid_t *search, gboolean reverse); 57f1c3d8c1fabd801eac34c9069038d3f4cadcb58dLuiz Augusto von Dentzvoid device_probe_drivers(struct btd_device *device, GSList *profiles); 58548026e08bd9b83b3685d515a916e2cf674184f3Johan Hedbergconst sdp_record_t *btd_device_get_record(struct btd_device *device, 59548026e08bd9b83b3685d515a916e2cf674184f3Johan Hedberg const char *uuid); 6083d8b6546ccd98ce30c65bc7ec716c42437e569aVinicius Costa GomesGSList *btd_device_get_primaries(struct btd_device *device); 615eb9d13c5b75f3659454466d511533c2f413cbbdClaudio Takahasivoid device_register_services(DBusConnection *conn, struct btd_device *device, 625eb9d13c5b75f3659454466d511533c2f413cbbdClaudio Takahasi GSList *prim_list, int psm); 63d14f607a0374bc313e410987ddd357581336003eClaudio TakahasiGSList *device_services_from_record(struct btd_device *device, 64d14f607a0374bc313e410987ddd357581336003eClaudio Takahasi GSList *profiles); 6517541956196b13ee083852fd4124cd8cfd0928a4Johan Hedbergvoid btd_device_add_uuid(struct btd_device *device, const char *uuid); 6618614bd2b008cb9f3879990883c569c37b72f195Alok Barsodestruct btd_adapter *device_get_adapter(struct btd_device *device); 67057c6f4b1abd1e13f11a91b7bf445986b999114fJosé Antonio Santos Cadenasvoid device_get_address(struct btd_device *device, bdaddr_t *bdaddr); 68555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodeconst gchar *device_get_path(struct btd_device *device); 69555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodestruct agent *device_get_agent(struct btd_device *device); 70555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodegboolean device_is_busy(struct btd_device *device); 71555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodegboolean device_is_temporary(struct btd_device *device); 72fee17aefe6b727ec790568aa4994039ff94bf44eJohan Hedberggboolean device_is_paired(struct btd_device *device); 736da6e4e3de7f1800e5b736add0b944d33d3acf37Luiz Augusto von Dentzgboolean device_is_trusted(struct btd_device *device); 746fe85942c1272ef3d4ef68a35eade7a276219bb6Johan Hedbergvoid device_set_paired(struct btd_device *device, gboolean paired); 75555fcc9b4bf67e923708af8de46aa91b7077f050Alok Barsodevoid device_set_temporary(struct btd_device *device, gboolean temporary); 76fba8f0e7d1fdefe35074f808a691e242d19edf92Vinicius Costa Gomesvoid device_set_type(struct btd_device *device, device_type_t type); 773e28ead202ff45d0fd66876f6a9cd3e8c3dbf42eDmitriy Paliyvoid device_set_bonded(struct btd_device *device, gboolean bonded); 78c4338c0b7a46d6288e350b8c05fc02ee28b4bdbcLuiz Augusto von Dentzgboolean device_is_connected(struct btd_device *device); 792aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von DentzDBusMessage *device_create_bonding(struct btd_device *device, 802aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz DBusConnection *conn, DBusMessage *msg, 812aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz const char *agent_path, uint8_t capability); 82b31576d0de87754f2fa1c3ba2d231cdccbffaee1Luiz Augusto von Dentzvoid device_remove_bonding(struct btd_device *device); 832aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzvoid device_bonding_complete(struct btd_device *device, uint8_t status); 84e35dd0c0246236371269b79cc28b1a23f4999560Johan Hedbergvoid device_simple_pairing_complete(struct btd_device *device, uint8_t status); 85e164ff20b95acd2a25c70623212c190abf7eee19Johan Hedberggboolean device_is_creating(struct btd_device *device, const char *sender); 862aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzgboolean device_is_bonding(struct btd_device *device, const char *sender); 872aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzvoid device_cancel_bonding(struct btd_device *device, uint8_t status); 882aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzint device_request_authentication(struct btd_device *device, auth_type_t type, 892aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentz uint32_t passkey, void *cb); 90f7d1ee361e410e096929bd3918178af356c50bbdJohan Hedbergvoid device_cancel_authentication(struct btd_device *device, gboolean aborted); 912aad1cf41acbc69481915d24cef33fa721d4e1fdLuiz Augusto von Dentzgboolean device_is_authenticating(struct btd_device *device); 92837d65f3a7f94ed4e6fe95f4e845d7ae3242be24Johan Hedberggboolean device_is_authorizing(struct btd_device *device); 93837d65f3a7f94ed4e6fe95f4e845d7ae3242be24Johan Hedbergvoid device_set_authorizing(struct btd_device *device, gboolean auth); 94bda6bb0079268b7db27695f40168aba07e960d8bJohan Hedbergvoid device_add_connection(struct btd_device *device, DBusConnection *conn); 95bda6bb0079268b7db27695f40168aba07e960d8bJohan Hedbergvoid device_remove_connection(struct btd_device *device, DBusConnection *conn); 96c3cfa26a86a25e35d8b0e7c24978a44f9af80a2aLuiz Augusto von Dentzvoid device_request_disconnect(struct btd_device *device, DBusMessage *msg); 978d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz 98a381d5342d27b99612fd31dc9cc80b01f412ad39Luiz Augusto von Dentztypedef void (*disconnect_watch) (struct btd_device *device, gboolean removal, 99a381d5342d27b99612fd31dc9cc80b01f412ad39Luiz Augusto von Dentz void *user_data); 1008d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz 1018d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentzguint device_add_disconnect_watch(struct btd_device *device, 1028d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz disconnect_watch watch, void *user_data, 1038d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentz GDestroyNotify destroy); 1048d7017d8be3305ed828dee928fc2731d0d89a27bLuiz Augusto von Dentzvoid device_remove_disconnect_watch(struct btd_device *device, guint id); 1051f921e01c700151bcac3dc9477d85bfff36e05d3Sheldon Demariovoid device_set_class(struct btd_device *device, uint32_t value); 106c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz 107c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } ) 108c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz 109c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentzstruct btd_device_driver { 110c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz const char *name; 111c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz const char **uuids; 112548026e08bd9b83b3685d515a916e2cf674184f3Johan Hedberg int (*probe) (struct btd_device *device, GSList *uuids); 113c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz void (*remove) (struct btd_device *device); 114c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz}; 115c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentz 116c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentzint btd_register_device_driver(struct btd_device_driver *driver); 117c560d02ccf1dd156f068b1da8a3e7d75d2319dfdLuiz Augusto von Dentzvoid btd_unregister_device_driver(struct btd_device_driver *driver); 1180ba18c28575090e30fcb3023ea1b4039a2e27610Luiz Augusto von Dentz 1190ba18c28575090e30fcb3023ea1b4039a2e27610Luiz Augusto von Dentzstruct btd_device *btd_device_ref(struct btd_device *device); 1200ba18c28575090e30fcb3023ea1b4039a2e27610Luiz Augusto von Dentzvoid btd_device_unref(struct btd_device *device); 121