All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Janssen <jamuraa@chromium.org>
To: linux-bluetooth@vger.kernel.org
Cc: Michael Janssen <jamuraa@chromium.org>
Subject: [BlueZ v7 04/10] core/advertising: Parse SolicitUUIDs
Date: Tue, 31 Mar 2015 10:23:58 -0700	[thread overview]
Message-ID: <1427822644-39009-5-git-send-email-jamuraa@chromium.org> (raw)
In-Reply-To: <1427822644-39009-1-git-send-email-jamuraa@chromium.org>

Parse the SolicitUUIDs property of the LEAdvertisement1 object.
---
 src/advertising.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/src/advertising.c b/src/advertising.c
index 9867e1e..d736ea9 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -205,6 +205,45 @@ fail:
 	return false;
 }
 
+static bool parse_advertising_solicit_uuids(GDBusProxy *proxy,
+							struct bt_ad *data)
+{
+	DBusMessageIter iter, ariter;
+
+	if (!g_dbus_proxy_get_property(proxy, "SolicitUUIDs", &iter))
+		return true;
+
+	if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY)
+		return false;
+
+	dbus_message_iter_recurse(&iter, &ariter);
+
+	bt_ad_clear_solicit_uuid(data);
+
+	while (dbus_message_iter_get_arg_type(&ariter) == DBUS_TYPE_STRING) {
+		const char *uuid_str;
+		bt_uuid_t uuid;
+
+		dbus_message_iter_get_basic(&ariter, &uuid_str);
+
+		DBG("Adding SolicitUUID: %s", uuid_str);
+
+		if (bt_string_to_uuid(&uuid, uuid_str) < 0)
+			goto fail;
+
+		if (!bt_ad_add_solicit_uuid(data, &uuid))
+			goto fail;
+
+		dbus_message_iter_next(&ariter);
+	}
+
+	return true;
+
+fail:
+	bt_ad_clear_solicit_uuid(data);
+	return false;
+}
+
 static void refresh_advertisement(struct advertisement *ad)
 {
 	DBG("Refreshing advertisement: %s", ad->path);
@@ -222,6 +261,11 @@ static bool parse_advertisement(struct advertisement *ad)
 		return false;
 	}
 
+	if (!parse_advertising_solicit_uuids(ad->proxy, ad->data)) {
+		error("Property \"SolicitUUIDs\" failed to parse");
+		return false;
+	}
+
 	/* TODO: parse the rest of the properties */
 
 	refresh_advertisement(ad);
-- 
2.2.0.rc0.207.ga3a616c


  parent reply	other threads:[~2015-03-31 17:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 17:23 [BlueZ v7 00/10] Implement LE Advertisement D-Bus API Michael Janssen
2015-03-31 17:23 ` [BlueZ v7 01/10] shared: add bt_ad structure Michael Janssen
2015-04-01  6:53   ` Szymon Janc
2015-04-01  7:40   ` Luiz Augusto von Dentz
2015-03-31 17:23 ` [BlueZ v7 02/10] core/advertising: use bt_ad Michael Janssen
2015-03-31 17:23 ` [BlueZ v7 03/10] core/advertising: Parse ServiceUUIDs Michael Janssen
2015-03-31 17:23 ` Michael Janssen [this message]
2015-03-31 17:23 ` [BlueZ v7 05/10] core/advertising: Parse ManufacturerSpecificData Michael Janssen
2015-03-31 17:24 ` [BlueZ v7 06/10] core/advertising: Parse ServiceData Michael Janssen
2015-03-31 17:24 ` [BlueZ v7 07/10] Update TODO for LE Advertising Michael Janssen
2015-03-31 17:24 ` [BlueZ v7 08/10] shared/ad: implement bt_ad_generate Michael Janssen
2015-03-31 22:28   ` Arman Uguray
2015-03-31 17:24 ` [BlueZ v7 09/10] core/advertising: Add and Remove AD using MGMT Michael Janssen
2015-03-31 17:24 ` [BlueZ v7 10/10] test: improvements to advertising-example Michael Janssen

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=1427822644-39009-5-git-send-email-jamuraa@chromium.org \
    --to=jamuraa@chromium.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.