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"
40
#define GATT_UUID "00001801-0000-1000-8000-00805f9b34fb"
42
static DBusConnection *connection;
44
static int client_probe(struct btd_device *device, GSList *uuids)
46
const sdp_record_t *rec;
49
rec = btd_device_get_record(device, GATT_UUID);
52
if (sdp_get_access_protos(rec, &list) < 0)
55
psm = sdp_get_proto_port(list, L2CAP_UUID);
57
sdp_list_foreach(list, (sdp_list_func_t) sdp_list_free, NULL);
58
sdp_list_free(list, NULL);
64
return attrib_client_register(device, psm);
67
static void client_remove(struct btd_device *device)
69
attrib_client_unregister(device);
72
static struct btd_device_driver client_driver = {
73
.name = "gatt-client",
74
.uuids = BTD_UUIDS(GATT_UUID),
75
.probe = client_probe,
76
.remove = client_remove,
79
int attrib_manager_init(DBusConnection *conn)
81
connection = dbus_connection_ref(conn);
83
attrib_client_init(connection);
85
btd_register_device_driver(&client_driver);
88
* FIXME: Add config file option to allow
89
* enable/disable the GATT server and client.
92
return server_example_init();
95
void attrib_manager_exit(void)
97
btd_unregister_device_driver(&client_driver);
99
server_example_exit();
100
attrib_client_exit();
102
dbus_connection_unref(connection);