path: root/thermometer
diff options
authorBruna Moreira <bruna.moreira@openbossa.org>2012-02-15 08:38:17 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2012-02-16 15:11:29 +0200
commit63dcb5cdff6037e81d65150a5f3116fceeed299b (patch)
treeea3276c2c4d0609ab8683a6435edf7f5ec0b752b /thermometer
parent1f38c67bec894f704de9dda18eea06bc3436252a (diff)
thermometer: Fix device driver probe
The probe() function for GATT profiles should be transport agnostic. There is a btd_device_get_primaries() method which can be used to return a list of discovered GATT Primary Services, and it works for BR/EDR and LE. It is already used for Proximity, for instance. device_services_from_record() is BR/EDR specific and should not be used by GATT profile code. It also fixes a memory leak, given device_services_from_record() returns a heap allocated GSList.
Diffstat (limited to 'thermometer')
1 files changed, 15 insertions, 4 deletions
diff --git a/thermometer/manager.c b/thermometer/manager.c
index 6b98bcaf..9dfbbe81 100644
--- a/thermometer/manager.c
+++ b/thermometer/manager.c
@@ -34,16 +34,27 @@
static DBusConnection *connection = NULL;
+static gint primary_uuid_cmp(gconstpointer a, gconstpointer b)
+ const struct att_primary *prim = a;
+ const char *uuid = b;
+ return g_strcmp0(prim->uuid, uuid);
static int thermometer_driver_probe(struct btd_device *device, GSList *uuids)
struct att_primary *tattr;
- GSList *list;
+ GSList *primaries, *l;
+ primaries = btd_device_get_primaries(device);
- list = device_services_from_record(device, uuids);
- if (list == NULL)
+ l = g_slist_find_custom(primaries, HEALTH_THERMOMETER_UUID,
+ primary_uuid_cmp);
+ if (l == NULL)
return -EINVAL;
- tattr = list->data;
+ tattr = l->data;
return thermometer_register(connection, device, tattr);