From: Johan Hedberg <johan.hedberg@gmail.com>
To: Szymon Janc <szymon.janc@tieto.com>
Cc: linux-bluetooth@vger.kernel.org
Subject: Re: [PATCH v2 2/5] android/bluetooth: Filter out not discoverable LE devices
Date: Mon, 24 Mar 2014 11:12:41 +0200 [thread overview]
Message-ID: <20140324091241.GB30302@t440s.lan> (raw)
In-Reply-To: <1395610854-30579-3-git-send-email-szymon.janc@tieto.com>
Hi Szymon,
On Sun, Mar 23, 2014, Szymon Janc wrote:
> Filter out the LE devices that do not have Discoverable flag or Limited
> Discoverable flag set.
> ---
> android/bluetooth.c | 23 ++++++++++++++++++-----
> 1 file changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/android/bluetooth.c b/android/bluetooth.c
> index d2795e3..3c859e8 100644
> --- a/android/bluetooth.c
> +++ b/android/bluetooth.c
> @@ -1258,6 +1258,11 @@ static void update_device(struct device *dev, int8_t rssi,
> HAL_EV_REMOTE_DEVICE_PROPS, size, buf);
> }
>
> +static bool is_le_dev_discoverable(unsigned int flags)
> +{
> + return flags & (EIR_FLAG_LIM_DISC | EIR_FLAG_GEN_DISC);
> +}
> +
> static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
> int8_t rssi, bool confirm,
> const uint8_t *data, uint8_t data_len)
> @@ -1271,6 +1276,19 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
>
> dev = find_device(bdaddr);
>
> + if (bdaddr_type != BDADDR_BREDR) {
> + /* Notify Gatt if its registered for LE events */
> + if (gatt_device_found_cb)
> + gatt_device_found_cb(bdaddr, bdaddr_type, rssi,
> + sizeof(eir), &eir);
> +
> + if (adapter.cur_discovery_type != SCAN_TYPE_NONE &&
> + !is_le_dev_discoverable(eir.flags)) {
> + eir_data_free(&eir);
> + return;
> + }
> + }
Do note the recent changes I had to do for the normal bluetoothd since
it's not possible to distinguish ADV_IND/ADV_SCAN_IND from SCAN_RSP
events. The flags field is not permitted to be in the SCAN_RSP so you'd
not be able to take advantage of any data in such events if you discard
the data when the flags are not around.
Also be aware of the recent kernel patch set I sent which merges these
events into a single device found event and again makes it possible to
do strict checking of the flags. That said, this all depends on what
kind of kernel version we want to depend on. If we're going to rely also
on the kernel-side passive for LE (which will probably land in 3.16)
then it's probably fine to overlook this issue for now.
Johan
next prev parent reply other threads:[~2014-03-24 9:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-23 21:40 [PATCH v2 0/5] android: LE device handling improvements Szymon Janc
2014-03-23 21:40 ` [PATCH v2 1/5] core: Move EIR flags definitions to eir.h Szymon Janc
2014-03-24 9:08 ` Johan Hedberg
2014-03-23 21:40 ` [PATCH v2 2/5] android/bluetooth: Filter out not discoverable LE devices Szymon Janc
2014-03-24 9:12 ` Johan Hedberg [this message]
2014-03-23 21:40 ` [PATCH v2 3/5] android/bluetooth: Add support for loading LTKs Szymon Janc
2014-03-23 21:40 ` [PATCH v2 4/5] android/bluetooth: Add support for new long term key mgmt event Szymon Janc
2014-03-23 21:40 ` [PATCH v2 5/5] android/bluetooth: Fix handling of BREDR, LE and dual mode devices 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=20140324091241.GB30302@t440s.lan \
--to=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=szymon.janc@tieto.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).