3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2010 Nokia Corporation
6 * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
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.
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.
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
29 #include <bluetooth/bluetooth.h>
30 #include <bluetooth/sdp.h>
31 #include <bluetooth/sdp_lib.h>
33 #include "../src/adapter.h"
34 #include "../src/device.h"
41 #define GATT_UUID "00001801-0000-1000-8000-00805f9b34fb"
43 static DBusConnection *connection;
45 static int client_probe(struct btd_device *device, GSList *uuids)
47 const sdp_record_t *rec;
50 rec = btd_device_get_record(device, GATT_UUID);
53 if (sdp_get_access_protos(rec, &list) < 0)
56 psm = sdp_get_proto_port(list, L2CAP_UUID);
58 sdp_list_foreach(list, (sdp_list_func_t) sdp_list_free, NULL);
59 sdp_list_free(list, NULL);
65 return attrib_client_register(device, psm);
68 static void client_remove(struct btd_device *device)
70 attrib_client_unregister(device);
73 static struct btd_device_driver client_driver = {
74 .name = "gatt-client",
75 .uuids = BTD_UUIDS(GATT_UUID),
76 .probe = client_probe,
77 .remove = client_remove,
80 int attrib_manager_init(DBusConnection *conn)
82 connection = dbus_connection_ref(conn);
84 attrib_client_init(connection);
86 btd_register_device_driver(&client_driver);
89 if (main_opts.attrib_server)
90 return server_example_init();
95 void attrib_manager_exit(void)
97 btd_unregister_device_driver(&client_driver);
99 if (main_opts.attrib_server)
100 server_example_exit();
102 attrib_client_exit();
104 dbus_connection_unref(connection);