From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [RFC 5/7] advertising: Add Data implementation
Date: Wed, 18 Apr 2018 14:05:00 +0300 [thread overview]
Message-ID: <20180418110502.13099-5-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20180418110502.13099-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds the support for Data property.
---
src/advertising.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 59 insertions(+)
diff --git a/src/advertising.c b/src/advertising.c
index b976562c4..400c21b5e 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -583,6 +583,64 @@ static bool parse_timeout(DBusMessageIter *iter,
return true;
}
+static bool parse_data(DBusMessageIter *iter, struct btd_adv_client *client)
+{
+ DBusMessageIter entries;
+
+ if (!iter) {
+ bt_ad_clear_data(client->data);
+ return true;
+ }
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+ return false;
+
+ dbus_message_iter_recurse(iter, &entries);
+
+ bt_ad_clear_data(client->data);
+
+ while (dbus_message_iter_get_arg_type(&entries)
+ == DBUS_TYPE_DICT_ENTRY) {
+ DBusMessageIter value, entry, array;
+ uint8_t type;
+ uint8_t *data;
+ int len;
+
+ dbus_message_iter_recurse(&entries, &entry);
+ dbus_message_iter_get_basic(&entry, &type);
+
+ dbus_message_iter_next(&entry);
+
+ if (dbus_message_iter_get_arg_type(&entry) != DBUS_TYPE_VARIANT)
+ goto fail;
+
+ dbus_message_iter_recurse(&entry, &value);
+
+ if (dbus_message_iter_get_arg_type(&value) != DBUS_TYPE_ARRAY)
+ goto fail;
+
+ dbus_message_iter_recurse(&value, &array);
+
+ if (dbus_message_iter_get_arg_type(&array) != DBUS_TYPE_BYTE)
+ goto fail;
+
+ dbus_message_iter_get_fixed_array(&array, &data, &len);
+
+ DBG("Adding Data for type 0x%02x len %u", type, len);
+
+ if (!bt_ad_add_data(client->data, type, data, len))
+ goto fail;
+
+ dbus_message_iter_next(&entries);
+ }
+
+ return true;
+
+fail:
+ bt_ad_clear_data(client->data);
+ return false;
+}
+
static struct adv_parser {
const char *name;
bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client);
@@ -597,6 +655,7 @@ static struct adv_parser {
{ "Appearance", parse_appearance },
{ "Duration", parse_duration },
{ "Timeout", parse_timeout },
+ { "Data", parse_data },
{ },
};
--
2.14.3
next prev parent reply other threads:[~2018-04-18 11:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 11:04 [RFC 1/7] shared/ad: Add support for arbritary type Luiz Augusto von Dentz
2018-04-18 11:04 ` [RFC 2/7] doc/device-api: Add AdvertisingData property Luiz Augusto von Dentz
2018-04-18 14:19 ` Marcel Holtmann
2018-04-18 14:44 ` Luiz Augusto von Dentz
2018-04-18 14:54 ` Marcel Holtmann
2018-04-18 11:04 ` [RFC 3/7] device: Add implementation of AdvertisingData Luiz Augusto von Dentz
2018-04-18 11:04 ` [RFC 4/7] doc/advertising-api: Add Data property Luiz Augusto von Dentz
2018-04-18 11:05 ` Luiz Augusto von Dentz [this message]
2018-04-18 11:05 ` [RFC 6/7] monitor: Add support for Transport Discovery AD Luiz Augusto von Dentz
2018-04-18 11:05 ` [RFC 7/7] client: Add support for setting advertising Data property Luiz Augusto von Dentz
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=20180418110502.13099-5-luiz.dentz@gmail.com \
--to=luiz.dentz@gmail.com \
--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).