linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Bruna Moreira <bruna.moreira@openbossa.org>
Subject: [PATCH BlueZ 1/3] thermometer: Fix device driver probe
Date: Tue, 14 Feb 2012 13:52:23 -0400	[thread overview]
Message-ID: <1329241945-32414-1-git-send-email-anderson.lizardo@openbossa.org> (raw)

From: Bruna Moreira <bruna.moreira@openbossa.org>

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.
---
 thermometer/manager.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/thermometer/manager.c b/thermometer/manager.c
index 6b98bca..9dfbbe8 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);
 }
-- 
1.7.5.4


             reply	other threads:[~2012-02-14 17:52 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-14 17:52 Anderson Lizardo [this message]
2012-02-14 17:52 ` [PATCH BlueZ 2/3] thermometer: Fix handling of missing Temperature Type Anderson Lizardo
2012-02-15  8:50   ` Santiago Carot
2012-02-15 10:41     ` Anderson Lizardo
2012-02-15 11:06       ` Santiago Carot
2012-02-15 11:53         ` Anderson Lizardo
2012-02-15 12:49         ` Anderson Lizardo
2012-02-14 17:52 ` [PATCH BlueZ 3/3] thermometer: Fix re-enabling notification/indication on reconnection Anderson Lizardo
2012-02-15  9:03   ` Santiago Carot
2012-02-15 10:44     ` Anderson Lizardo
2012-02-15 12:38 ` [PATCH v2 BlueZ 1/3] thermometer: Fix device driver probe Anderson Lizardo
2012-02-15 12:38   ` [PATCH v2 BlueZ 2/3] thermometer: Fix handling of missing Temperature Type Anderson Lizardo
2012-02-15 12:38   ` [PATCH v2 BlueZ 3/3] thermometer: Fix re-enabling notification/indication on reconnection Anderson Lizardo
2012-02-16 13:13   ` [PATCH v2 BlueZ 1/3] thermometer: Fix device driver probe Johan Hedberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1329241945-32414-1-git-send-email-anderson.lizardo@openbossa.org \
    --to=anderson.lizardo@openbossa.org \
    --cc=bruna.moreira@openbossa.org \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).