linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Szymon Janc <szymon.janc@codecoup.pl>
To: linux-bluetooth@vger.kernel.org
Cc: Szymon Janc <szymon.janc@codecoup.pl>
Subject: [RFC 3/4] device: Add support for LEAddressType property
Date: Mon, 11 Dec 2017 11:38:36 +0100	[thread overview]
Message-ID: <20171211103837.25150-3-szymon.janc@codecoup.pl> (raw)
In-Reply-To: <20171211103837.25150-1-szymon.janc@codecoup.pl>

---
 src/device.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/src/device.c b/src/device.c
index 9f9c47807..02c97bdc6 100644
--- a/src/device.c
+++ b/src/device.c
@@ -727,6 +727,30 @@ static gboolean dev_property_get_address(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean property_exists_address_type(const GDBusPropertyTable *property,
+							void *user_data)
+{
+	struct btd_device *device = user_data;
+
+	return device->le ? TRUE : FALSE;
+}
+
+static gboolean property_get_address_type(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *user_data)
+{
+	struct btd_device *device = user_data;
+	const char *str;
+
+	if (device->bdaddr_type == BDADDR_LE_PUBLIC)
+		str = "public";
+	else
+		str = "static";
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &str);
+
+	return TRUE;
+}
+
 static gboolean dev_property_get_name(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -2607,6 +2631,8 @@ static const GDBusMethodTable device_methods[] = {
 
 static const GDBusPropertyTable device_properties[] = {
 	{ "Address", "s", dev_property_get_address },
+	{ "LEAddressType", "s", property_get_address_type, NULL,
+						property_exists_address_type },
 	{ "Name", "s", dev_property_get_name, NULL, dev_property_exists_name },
 	{ "Alias", "s", dev_property_get_alias, dev_property_set_alias },
 	{ "Class", "u", dev_property_get_class, NULL,
@@ -3850,6 +3876,8 @@ void device_update_addr(struct btd_device *device, const bdaddr_t *bdaddr,
 
 	g_dbus_emit_property_changed(dbus_conn, device->path,
 						DEVICE_INTERFACE, "Address");
+	g_dbus_emit_property_changed(dbus_conn, device->path,
+					DEVICE_INTERFACE, "LEAddressType");
 }
 
 void device_set_bredr_support(struct btd_device *device)
-- 
2.14.3


  parent reply	other threads:[~2017-12-11 10:38 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-11 10:38 [RFC 1/4] Add LEAddressType property for Adapter1 and Device1 interfaces Szymon Janc
2017-12-11 10:38 ` [RFC 2/4] adapter: Add support for LEAddressType property Szymon Janc
2017-12-11 10:38 ` Szymon Janc [this message]
2017-12-11 10:38 ` [RFC 4/4] client: Print LEAddress type in show and info commands Szymon Janc
2017-12-11 12:10   ` Luiz Augusto von Dentz
2017-12-11 12:40     ` Szymon Janc
2017-12-13  8:50       ` Marcel Holtmann
2017-12-11 11:59 ` [RFC 1/4] Add LEAddressType property for Adapter1 and Device1 interfaces Luiz Augusto von Dentz
2017-12-11 12:40   ` Szymon Janc
2017-12-13  8:47 ` Marcel Holtmann

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=20171211103837.25150-3-szymon.janc@codecoup.pl \
    --to=szymon.janc@codecoup.pl \
    --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).