linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: puthik@chromium.org
To: linux-bluetooth@vger.kernel.org
Cc: Puthikorn Voravootivat <puthik@chromium.org>
Subject: [PATCH v2 2/2] core: Add implementation of AdvertisingFlags
Date: Tue, 18 Oct 2016 12:11:00 -0700	[thread overview]
Message-ID: <1476817861-24158-4-git-send-email-puthik@chromium.org> (raw)
In-Reply-To: <1476817861-24158-1-git-send-email-puthik@chromium.org>

From: Puthikorn Voravootivat <puthik@chromium.org>

This adds 'AdvertisingFlags' property to Device interface.

Bluetooth Core Supplementary Spec v6 Chapter 1.3 defines Bluetooth
Flags as one of the data in advertise data. BlueZ also correctly
parses this data but never exposes it to upper layer.

Signed-off-by: Puthikorn Voravootivat <puthik@chromium.org>
---
 src/adapter.c |  2 ++
 src/device.c  | 36 ++++++++++++++++++++++++++++++++++++
 src/device.h  |  1 +
 3 files changed, 39 insertions(+)

diff --git a/src/adapter.c b/src/adapter.c
index b096d48..1abb5c0 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5552,6 +5552,8 @@ static void update_found_devices(struct btd_adapter *adapter,
 	if (eir_data.sd_list)
 		device_set_service_data(dev, eir_data.sd_list);
 
+	device_set_flags(dev, eir_data.flags);
+
 	eir_data_free(&eir_data);
 
 	/*
diff --git a/src/device.c b/src/device.c
index fb6104f..993b8e7 100644
--- a/src/device.c
+++ b/src/device.c
@@ -247,6 +247,8 @@ struct btd_device {
 
 	GIOChannel	*att_io;
 	guint		store_id;
+
+	uint8_t         flags;
 };
 
 static const uint16_t uuid_list[] = {
@@ -939,6 +941,23 @@ dev_property_get_svc_resolved(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean
+dev_property_get_flags(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct btd_device *device = data;
+	uint8_t flags[] = { device->flags };
+	DBusMessageIter array;
+
+	dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
+					DBUS_TYPE_BYTE_AS_STRING, &array);
+	dbus_message_iter_append_fixed_array(&array, DBUS_TYPE_BYTE,
+						&flags, sizeof(flags));
+	dbus_message_iter_close_container(iter, &array);
+
+	return TRUE;
+}
+
 static gboolean dev_property_get_trusted(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -2534,6 +2553,7 @@ static const GDBusPropertyTable device_properties[] = {
 	{ "TxPower", "n", dev_property_get_tx_power, NULL,
 					dev_property_exists_tx_power },
 	{ "ServicesResolved", "b", dev_property_get_svc_resolved, NULL, NULL },
+	{ "AdvertisingFlags", "ay", dev_property_get_flags },
 
 	{ }
 };
@@ -5221,6 +5241,22 @@ void device_set_tx_power(struct btd_device *device, int8_t tx_power)
 						DEVICE_INTERFACE, "TxPower");
 }
 
+void device_set_flags(struct btd_device *device, uint8_t flags)
+{
+	if (!device)
+		return;
+
+	DBG("flags %d", flags);
+
+	if (device->flags == flags)
+		return;
+
+	device->flags = flags;
+
+	g_dbus_emit_property_changed(dbus_conn, device->path,
+					DEVICE_INTERFACE, "AdvertisingFlags");
+}
+
 static gboolean start_discovery(gpointer user_data)
 {
 	struct btd_device *device = user_data;
diff --git a/src/device.h b/src/device.h
index 387f598..93a159a 100644
--- a/src/device.h
+++ b/src/device.h
@@ -97,6 +97,7 @@ void device_set_rssi_with_delta(struct btd_device *device, int8_t rssi,
 							int8_t delta_threshold);
 void device_set_rssi(struct btd_device *device, int8_t rssi);
 void device_set_tx_power(struct btd_device *device, int8_t tx_power);
+void device_set_flags(struct btd_device *device, uint8_t flags);
 bool btd_device_is_connected(struct btd_device *dev);
 uint8_t btd_device_get_bdaddr_type(struct btd_device *dev);
 bool device_is_retrying(struct btd_device *device);
-- 
2.8.0.rc3.226.g39d4020


  parent reply	other threads:[~2016-10-18 19:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-18 19:10 [PATCH v2 0/2] Expose AdvertisingDataFlags in Device API puthik
2016-10-18 19:10 ` puthik
2016-10-18 19:10 ` [PATCH v2 1/2] doc/device-api: Add AdvertisingFlags puthik
2016-10-19  7:19   ` Luiz Augusto von Dentz
2016-10-19 16:15     ` Szymon Janc
2016-10-19 16:21       ` Luiz Augusto von Dentz
2016-10-19 17:15         ` Johan Hedberg
2016-10-20  1:54           ` Puthikorn Voravootivat
2016-10-18 19:11 ` puthik [this message]
2016-10-19  7:23   ` [PATCH v2 2/2] core: Add implementation of AdvertisingFlags 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=1476817861-24158-4-git-send-email-puthik@chromium.org \
    --to=puthik@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 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).