From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 3/5] client: Add scan.discoverable command
Date: Mon, 30 Jul 2018 09:44:22 +0300 [thread overview]
Message-ID: <20180730064424.13996-3-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20180730064424.13996-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds discoverable command to scan menu which can be used to set
if adapter should become discoverable while scanning:
[bluetooth]# scan.discoverable on
[bluetooth]# scan on
SetDiscoveryFilter success
[CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: yes
Discovery started
[CHG] Controller XX:XX:XX:XX:XX:XX Discovering: yes
[bluetooth]# scan off
Discovery stopped
[CHG] Controller XX:XX:XX:XX:XX:XX Discoverable: no
---
client/main.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/client/main.c b/client/main.c
index 6f472d050..6e6f6d2fb 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1166,6 +1166,7 @@ static struct set_discovery_filter_args {
char **uuids;
size_t uuids_len;
dbus_bool_t duplicate;
+ dbus_bool_t discoverable;
bool set;
} filter = {
.rssi = DISTANCE_VAL_INVALID,
@@ -1205,6 +1206,11 @@ static void set_discovery_filter_setup(DBusMessageIter *iter, void *user_data)
DBUS_TYPE_BOOLEAN,
&args->duplicate);
+ if (args->discoverable)
+ g_dbus_dict_append_entry(&dict, "Discoverable",
+ DBUS_TYPE_BOOLEAN,
+ &args->discoverable);
+
dbus_message_iter_close_container(iter, &dict);
}
@@ -1362,6 +1368,26 @@ static void cmd_scan_filter_duplicate_data(int argc, char *argv[])
filter.set = false;
}
+static void cmd_scan_filter_discoverable(int argc, char *argv[])
+{
+ if (argc < 2 || !strlen(argv[1])) {
+ bt_shell_printf("Discoverable: %s\n",
+ filter.discoverable ? "on" : "off");
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+ }
+
+ if (!strcmp(argv[1], "on"))
+ filter.discoverable = true;
+ else if (!strcmp(argv[1], "off"))
+ filter.discoverable = false;
+ else {
+ bt_shell_printf("Invalid option: %s\n", argv[1]);
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+ }
+
+ filter.set = false;
+}
+
static void filter_clear_uuids(void)
{
g_strfreev(filter.uuids);
@@ -2510,6 +2536,9 @@ static const struct bt_shell_menu scan_menu = {
{ "duplicate-data", "[on/off]", cmd_scan_filter_duplicate_data,
"Set/Get duplicate data filter",
NULL },
+ { "discoverable", "[on/off]", cmd_scan_filter_discoverable,
+ "Set/Get discoverable filter",
+ NULL },
{ "clear", "[uuids/rssi/pathloss/transport/duplicate-data]",
cmd_scan_filter_clear,
"Clears discovery filter.",
--
2.17.1
next prev parent reply other threads:[~2018-07-30 6:44 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 6:44 [PATCH v2 1/5] doc/adapter-api: Add Discoverable option to SetDiscoveryFilter Luiz Augusto von Dentz
2018-07-30 6:44 ` [PATCH v2 2/5] adapter: Discovery filter discoverable Luiz Augusto von Dentz
2018-07-30 6:44 ` Luiz Augusto von Dentz [this message]
2018-07-30 10:21 ` [PATCH v2 3/5] client: Add scan.discoverable command Bastien Nocera
2018-07-30 10:45 ` Luiz Augusto von Dentz
2018-07-30 6:44 ` [PATCH v2 4/5] client: Add scan.clear discoverable Luiz Augusto von Dentz
2018-07-30 6:44 ` [PATCH v2 5/5] adapter: Fix not keeping discovery filters Luiz Augusto von Dentz
2018-07-30 10:21 ` [PATCH v2 1/5] doc/adapter-api: Add Discoverable option to SetDiscoveryFilter Bastien Nocera
2018-07-30 11:09 ` Marcel Holtmann
2018-07-30 11:43 ` 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=20180730064424.13996-3-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).