All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arman Uguray <armansito@chromium.org>
To: Jakub Pawlowski <jpawlowski@google.com>
Cc: BlueZ development <linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH v6 7/8] core: adapter: filter discovery results when filered discovery is used
Date: Mon, 30 Mar 2015 18:18:22 -0700	[thread overview]
Message-ID: <CAHrH25SX6Yd8g9b6CGQXqj0gH-Zq0b48bgrDhN533Y5KN1gd-w@mail.gmail.com> (raw)
In-Reply-To: <1427758340-14949-7-git-send-email-jpawlowski@google.com>

Hi Jakub,

> On Mon, Mar 30, 2015 at 4:32 PM, Jakub Pawlowski <jpawlowski@google.com> wrote:
> This patch adds filtering to device found event, and enforces lack
> of RSSI delta for filtered scan.
>
> When filtering, we compare against each client filter. That
> additionally removes some of reports.
> ---
>  src/adapter.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 68 insertions(+), 1 deletion(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index 67db99c..8d78e0a 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -5297,6 +5297,63 @@ static void adapter_msd_notify(struct btd_adapter *adapter,
>         }
>  }
>
> +static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
> +                                                               int8_t rssi)
> +{
> +       GSList *l, *m;
> +       bool got_match = false;
> +
> +       for (l = discovery_filter; l != NULL && got_match != true;
> +                                                       l = g_slist_next(l)) {
> +               struct watch_client *client = l->data;
> +               struct discovery_filter *item = client->discovery_filter;
> +
> +               /*
> +                * If one of currently running scans is regular scan, then
> +                * return all devices as matches
> +                */
> +               if (!item) {
> +                       got_match = true;
> +                       continue;
> +               }
> +
> +               /* if someone started discovery with empty uuids, he wants all
> +                * devices in given proximity.
> +                */
> +               if (!item->uuids)
> +                       got_match = true;
> +               else
> +                       for (m = item->uuids; m != NULL && got_match != true;
> +                                                          m = g_slist_next(m))
> +                               /* m->data contains string representation of
> +                                * uuid.
> +                                */
> +                               if (g_slist_find_custom(eir_data->services,
> +                                                       m->data,
> +                                                       g_strcmp) != NULL)
> +                                       got_match = true;

Use curly braces for the else statement here. It's contents are
difficult to parse otherwise. Same for the for loop.

> +
> +               if (got_match) {
> +                       /* we have service match, check proximity */
> +                       if (item->rssi != DISTANCE_VAL_INVALID &&
> +                           item->rssi > rssi)
> +                               got_match = false;
> +                       if (item->pathloss != DISTANCE_VAL_INVALID &&
> +                          (eir_data->tx_power == 127 ||
> +                          eir_data->tx_power - rssi > item->pathloss))
> +                               got_match = false;

Just return true if both of these if statements evaluate to false?

> +
> +                       if (got_match)
> +                               return true;
> +               }
> +       }
> +
> +       if (!got_match)
> +               return false;
> +
> +       return true;
> +}
> +
>  static void update_found_devices(struct btd_adapter *adapter,
>                                         const bdaddr_t *bdaddr,
>                                         uint8_t bdaddr_type, int8_t rssi,
> @@ -5363,8 +5420,18 @@ static void update_found_devices(struct btd_adapter *adapter,
>                 return;
>         }
>
> +       if (adapter->filtered_discovery &&
> +           !is_filter_match(adapter->discovery_list, &eir_data, rssi)) {
> +               eir_data_free(&eir_data);
> +               return;
> +       }
> +
>         device_set_legacy(dev, legacy);
> -       device_set_rssi(dev, rssi);
> +
> +       if (adapter->filtered_discovery)
> +               device_set_rssi_with_delta(dev, rssi, 0);
> +       else
> +               device_set_rssi(dev, rssi);
>
>         if (eir_data.appearance != 0)
>                 device_set_appearance(dev, eir_data.appearance);
> --
> 2.2.0.rc0.207.ga3a616c
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks,
Arman

  reply	other threads:[~2015-03-31  1:18 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-30 23:32 [PATCH v6 1/8] core: device: add device_set_rssi_no_delta Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 2/8] core/adapter: Refactor of scan type Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 3/8] core: adapter: Add SetDiscoveryFilter method Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 4/8] core: adapter: Add parameter parsing to SetDiscoveryFilter Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 5/8] core: adapter: set the filter for each discovery client Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 6/8] core: adapter: start proper discovery depending on filter type Jakub Pawlowski
2015-03-31  1:26   ` Arman Uguray
2015-03-31  7:33     ` Jakub Pawlowski
2015-03-30 23:32 ` [PATCH v6 7/8] core: adapter: filter discovery results when filered discovery is used Jakub Pawlowski
2015-03-31  1:18   ` Arman Uguray [this message]
2015-03-30 23:32 ` [PATCH v6 8/8] client: main: add support for SetDiscoveryFilter Jakub Pawlowski
2015-03-31  0:56   ` Arman Uguray
2015-03-31  5:11 ` [PATCH v6 1/8] core: device: add device_set_rssi_no_delta Johan Hedberg
  -- strict thread matches above, loose matches on Subject: below --
2015-03-26  8:29 Jakub Pawlowski
2015-03-26  8:29 ` [PATCH v6 7/8] core: adapter: filter discovery results when filered discovery is used Jakub Pawlowski

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=CAHrH25SX6Yd8g9b6CGQXqj0gH-Zq0b48bgrDhN533Y5KN1gd-w@mail.gmail.com \
    --to=armansito@chromium.org \
    --cc=jpawlowski@google.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.