From: Don Zickus <dzickus@redhat.com>
To: linux-bluetooth@vger.kernel.org
Cc: luiz.dentz@gmail.com, brn@deako.com, Don Zickus <dzickus@redhat.com>
Subject: [RFC 3/3] core/adapter: Hook le_duplicates into d-bus interface
Date: Tue, 6 Dec 2016 16:40:00 -0500 [thread overview]
Message-ID: <1481060400-7088-4-git-send-email-dzickus@redhat.com> (raw)
In-Reply-To: <1481060400-7088-1-git-send-email-dzickus@redhat.com>
The previous patch provided the management hooks to disable duplicate
device filtering on the adapter. This patch allows the d-bus
interface to use it with another field in SetDiscoveryFilter()
The new field is:
bool LE_Duplicates
The adapter-api.txt doc has been updated to reflect this.
Signed-off-by: Don Zickus <dzickus@redhat.com>
---
client/main.c | 5 +++++
doc/adapter-api.txt | 1 +
src/adapter.c | 22 ++++++++++++++++++++--
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/client/main.c b/client/main.c
index e1198a8..d74d068 100644
--- a/client/main.c
+++ b/client/main.c
@@ -1153,6 +1153,7 @@ struct set_discovery_filter_args {
dbus_int16_t pathloss;
char **uuids;
size_t uuids_len;
+ bool le_duplicates;
};
static void set_discovery_filter_setup(DBusMessageIter *iter, void *user_data)
@@ -1180,6 +1181,10 @@ static void set_discovery_filter_setup(DBusMessageIter *iter, void *user_data)
dict_append_entry(&dict, "Transport", DBUS_TYPE_STRING,
&args->transport);
+ if (args->le_duplicates)
+ dict_append_entry(&dict, "LE_Duplicates", DBUS_TYPE_BOOLEAN,
+ &args->le_duplicates);
+
dbus_message_iter_close_container(iter, &dict);
}
diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index 08de6cd..dc09752 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -58,6 +58,7 @@ Methods void StartDiscovery()
int16 RSSI : RSSI threshold value
uint16 Pathloss : Pathloss threshold value
string Transport : type of scan to run
+ bool LE_Duplicates : Disable LE Duplicate filtering
When a remote device is found that advertises any UUID
from UUIDs, it will be reported if:
diff --git a/src/adapter.c b/src/adapter.c
index ddf0d11..1e961a1 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -2220,6 +2220,16 @@ static bool parse_transport(DBusMessageIter *value, uint8_t *transport)
return true;
}
+static bool parse_le_duplicates(DBusMessageIter *value, bool *le_duplicates)
+{
+ if (dbus_message_iter_get_arg_type(value) != DBUS_TYPE_BOOLEAN)
+ return false;
+
+ dbus_message_iter_get_basic(value, le_duplicates);
+
+ return true;
+}
+
static bool parse_discovery_filter_entry(char *key, DBusMessageIter *value,
struct discovery_filter *filter)
{
@@ -2235,6 +2245,9 @@ static bool parse_discovery_filter_entry(char *key, DBusMessageIter *value,
if (!strcmp("Transport", key))
return parse_transport(value, &filter->type);
+ if (!strcmp("LE_Duplicates", key))
+ return parse_le_duplicates(value, &filter->le_duplicates);
+
DBG("Unknown key parameter: %s!\n", key);
return false;
}
@@ -2260,6 +2273,7 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter,
(*filter)->pathloss = DISTANCE_VAL_INVALID;
(*filter)->rssi = DISTANCE_VAL_INVALID;
(*filter)->type = get_scan_type(adapter);
+ (*filter)->le_duplicates = false;
dbus_message_iter_init(msg, &iter);
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY ||
@@ -2304,8 +2318,12 @@ static bool parse_discovery_filter_dict(struct btd_adapter *adapter,
(*filter)->rssi != DISTANCE_VAL_INVALID)
goto invalid_args;
- DBG("filtered discovery params: transport: %d rssi: %d pathloss: %d",
- (*filter)->type, (*filter)->rssi, (*filter)->pathloss);
+ /* only allow LE duplicates for type LE */
+ if ((*filter)->le_duplicates && (*filter)->type != SCAN_TYPE_LE)
+ goto invalid_args;
+
+ DBG("filtered discovery params: transport: %d rssi: %d pathloss: %d le_duplicates: %d",
+ (*filter)->type, (*filter)->rssi, (*filter)->pathloss, (*filter)->le_duplicates);
return true;
--
1.8.3.1
next prev parent reply other threads:[~2016-12-06 21:40 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-06 21:39 [RFC 0/3] core/adapter: Add disabling duplicate device filtering from d-bus Don Zickus
2016-12-06 21:39 ` [RFC 1/3] bluetooth: Add managment ability to disable duplicate device fitlering Don Zickus
2016-12-06 21:39 ` [RFC 2/3] core/adapter: Add le_duplicates flag to management interface Don Zickus
2016-12-06 21:40 ` Don Zickus [this message]
2016-12-07 10:21 ` [RFC 0/3] core/adapter: Add disabling duplicate device filtering from d-bus Luiz Augusto von Dentz
2016-12-07 20:16 ` Don Zickus
2016-12-08 6:18 ` Marcel Holtmann
2016-12-08 12:29 ` Northfield Stuart
2016-12-08 16:04 ` Don Zickus
2016-12-08 21:07 ` Marcel Holtmann
2016-12-12 19:12 ` Don Zickus
2016-12-08 20:13 ` Brennan Ashton
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=1481060400-7088-4-git-send-email-dzickus@redhat.com \
--to=dzickus@redhat.com \
--cc=brn@deako.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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).