From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH v2 2/4] client: Make scan:clear clear individual fields
Date: Fri, 15 Dec 2017 14:09:52 -0200 [thread overview]
Message-ID: <20171215160954.3527-2-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20171215160954.3527-1-luiz.dentz@gmail.com>
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This reintroduces the option to clear individual fields which was
removed when redesining the commands which now read the fields when
no arguments are provided.
---
client/main.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 56 insertions(+), 5 deletions(-)
diff --git a/client/main.c b/client/main.c
index 5f7ec0103..53e03f56f 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1392,18 +1392,68 @@ static void clear_discovery_filter_setup(DBusMessageIter *iter, void *user_data)
dbus_message_iter_close_container(iter, &dict);
}
-static void cmd_scan_filter_clear(int argc, char *argv[])
+static void filter_clear_uuids(void)
{
- /* set default values for all options */
- filter.rssi = DISTANCE_VAL_INVALID;
- filter.pathloss = DISTANCE_VAL_INVALID;
g_strfreev(filter.uuids);
filter.uuids = NULL;
filter.uuids_len = 0;
+}
+
+static void filter_clear_rssi(void)
+{
+ filter.rssi = DISTANCE_VAL_INVALID;
+}
+
+static void filter_clear_pathloss(void)
+{
+ filter.pathloss = DISTANCE_VAL_INVALID;
+}
+
+static void filter_clear_transport(void)
+{
g_free(filter.transport);
filter.transport = NULL;
+}
+
+static void filter_clear_duplicate(void)
+{
filter.duplicate = false;
+}
+
+static const struct filter_clear {
+ const char *name;
+ void (*clear) (void);
+} filter_clear[] = {
+ { "uuids", filter_clear_uuids },
+ { "rssi", filter_clear_rssi },
+ { "pathloss", filter_clear_pathloss },
+ { "transport", filter_clear_transport },
+ { "duplicate-data", filter_clear_duplicate },
+ {}
+};
+
+static void cmd_scan_filter_clear(int argc, char *argv[])
+{
+ const struct filter_clear *fc;
+ bool all = false;
+
+ if (argc < 2 || !strlen(argv[1]))
+ all = true;
+ for (fc = filter_clear; fc && fc->name; fc++) {
+ if (all || !strcmp(fc->name, argv[1])) {
+ fc->clear();
+ if (!all)
+ goto done;
+ }
+ }
+
+ if (!all) {
+ bt_shell_printf("Invalid argument %s\n", argv[1]);
+ return;
+ }
+
+done:
if (check_default_ctrl() == FALSE)
return;
@@ -2256,7 +2306,8 @@ static const struct bt_shell_menu scan_menu = {
{ "duplicate-data", "[on/off]", cmd_scan_filter_duplicate_data,
"Set/Get duplicate data filter",
mode_generator },
- { "clear", NULL, cmd_scan_filter_clear,
+ { "clear", "[uuids/rssi/pathloss/transport/duplicate-data]",
+ cmd_scan_filter_clear,
"Clears discovery filter." },
{ } },
};
--
2.13.6
next prev parent reply other threads:[~2017-12-15 16:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-15 16:09 [PATCH v2 1/4] client: Group discovery filter variables into a struct Luiz Augusto von Dentz
2017-12-15 16:09 ` Luiz Augusto von Dentz [this message]
2017-12-15 16:09 ` [PATCH v2 3/4] client: Add generator for scan:clear Luiz Augusto von Dentz
2017-12-15 16:09 ` [PATCH v2 4/4] clien: Only set the discovery filter when necessary Luiz Augusto von Dentz
2017-12-16 16:21 ` [PATCH v2 1/4] client: Group discovery filter variables into a struct Johan Hedberg
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=20171215160954.3527-2-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.