3 * BlueZ - Bluetooth protocol stack for Linux
5 * Copyright (C) 2011 GSyC/LibreSoft, Universidad Rey Juan Carlos.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include <bluetooth/uuid.h>
32 #include "thermometer.h"
35 static DBusConnection *connection = NULL;
37 static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
39 const struct gatt_primary *prim = a;
42 return g_strcmp0(prim->uuid, uuid);
45 static int thermometer_driver_probe(struct btd_device *device, GSList *uuids)
47 struct gatt_primary *tattr;
48 GSList *primaries, *l;
50 primaries = btd_device_get_primaries(device);
52 l = g_slist_find_custom(primaries, HEALTH_THERMOMETER_UUID,
59 return thermometer_register(connection, device, tattr);
62 static void thermometer_driver_remove(struct btd_device *device)
64 thermometer_unregister(device);
67 static struct btd_device_driver thermometer_device_driver = {
68 .name = "thermometer-device-driver",
69 .uuids = BTD_UUIDS(HEALTH_THERMOMETER_UUID),
70 .probe = thermometer_driver_probe,
71 .remove = thermometer_driver_remove
74 int thermometer_manager_init(DBusConnection *conn)
78 ret = btd_register_device_driver(&thermometer_device_driver);
82 connection = dbus_connection_ref(conn);
86 void thermometer_manager_exit(void)
88 btd_unregister_device_driver(&thermometer_device_driver);
90 dbus_connection_unref(connection);