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: [PATCH 7/9] tools/btpclient: Get initial values for adapter setttings
Date: Thu,  7 Dec 2017 15:21:41 +0100	[thread overview]
Message-ID: <20171207142143.27324-8-szymon.janc@codecoup.pl> (raw)
In-Reply-To: <20171207142143.27324-1-szymon.janc@codecoup.pl>

---
 tools/btpclient.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/tools/btpclient.c b/tools/btpclient.c
index 7db65b8b4..5f7fb85f1 100644
--- a/tools/btpclient.c
+++ b/tools/btpclient.c
@@ -326,6 +326,49 @@ static void btp_device_free(struct btp_device *device)
 	l_free(device);
 }
 
+static void extract_settings(struct l_dbus_proxy *proxy, uint32_t *current,
+						uint32_t *supported)
+{
+	bool prop;
+
+	*supported = 0;
+	*current = 0;
+
+	/* TODO not all info is available via D-Bus API */
+	*supported |=  BTP_GAP_SETTING_POWERED;
+	*supported |=  BTP_GAP_SETTING_CONNECTABLE;
+	*supported |=  BTP_GAP_SETTING_DISCOVERABLE;
+	*supported |=  BTP_GAP_SETTING_BONDABLE;
+	*supported |=  BTP_GAP_SETTING_SSP;
+	*supported |=  BTP_GAP_SETTING_BREDR;
+	*supported |=  BTP_GAP_SETTING_LE;
+	*supported |=  BTP_GAP_SETTING_ADVERTISING;
+	*supported |=  BTP_GAP_SETTING_SC;
+	*supported |=  BTP_GAP_SETTING_PRIVACY;
+	/* *supported |=  BTP_GAP_SETTING_STATIC_ADDRESS; */
+
+	/* TODO not all info is availbe via D-Bus API so some are assumed to be
+	 * enabled by bluetoothd or simply hardcoded until API is extended
+	 */
+	*current |=  BTP_GAP_SETTING_CONNECTABLE;
+	*current |=  BTP_GAP_SETTING_SSP;
+	*current |=  BTP_GAP_SETTING_BREDR;
+	*current |=  BTP_GAP_SETTING_LE;
+	*current |=  BTP_GAP_SETTING_PRIVACY;
+	*current |=  BTP_GAP_SETTING_SC;
+	/* *supported |=  BTP_GAP_SETTING_STATIC_ADDRESS; */
+
+	if (l_dbus_proxy_get_property(proxy, "Powered", "b", &prop) && prop)
+		*current |=  BTP_GAP_SETTING_POWERED;
+
+	if (l_dbus_proxy_get_property(proxy, "Discoverable", "b", &prop) &&
+									prop)
+		*current |=  BTP_GAP_SETTING_DISCOVERABLE;
+
+	if (l_dbus_proxy_get_property(proxy, "Pairable", "b", &prop) && prop)
+		*current |=  BTP_GAP_SETTING_BONDABLE;
+}
+
 static void proxy_added(struct l_dbus_proxy *proxy, void *user_data)
 {
 	const char *interface = l_dbus_proxy_get_interface(proxy);
@@ -348,6 +391,9 @@ static void proxy_added(struct l_dbus_proxy *proxy, void *user_data)
 		adapter->proxy = proxy;
 		adapter->index = index;
 
+		extract_settings(proxy, &adapter->current_settings,
+						&adapter->supported_settings);
+
 		l_queue_push_tail(adapters, adapter);
 		return;
 	}
-- 
2.14.3


  parent reply	other threads:[~2017-12-07 14:21 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-07 14:21 [PATCH 0/9] Initial code for BTP client Szymon Janc
2017-12-07 14:21 ` [PATCH 1/9] shared/btp: Add initial code for library Szymon Janc
2017-12-07 14:21 ` [PATCH 2/9] tools/btpclient: Add initial code Szymon Janc
2017-12-07 14:21 ` [PATCH 3/9] shared/btp: Add definitions for GAP service Szymon Janc
2017-12-07 14:21 ` [PATCH 4/9] tools/btpclient: Store index along with adapter proxy Szymon Janc
2017-12-07 17:42   ` Luiz Augusto von Dentz
2017-12-08 10:12     ` Szymon Janc
2017-12-07 14:21 ` [PATCH 5/9] tools/btpclient: Add initial support for GAP service Szymon Janc
2017-12-07 14:21 ` [PATCH 6/9] tools/btpclient: Add initial support for read controller info command Szymon Janc
2017-12-07 14:21 ` Szymon Janc [this message]
2017-12-07 14:21 ` [PATCH 8/9] tools/btpclient: Add support for tracking mutable adapter settings Szymon Janc
2017-12-07 14:21 ` [PATCH 9/9] tools/btpclient: Add support for configuring " Szymon Janc

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=20171207142143.27324-8-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).