All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: Daniel Winkler <danielwinkler@google.com>
Cc: "linux-bluetooth@vger.kernel.org"
	<linux-bluetooth@vger.kernel.org>,
	ChromeOS Bluetooth Upstreaming 
	<chromeos-bluetooth-upstreaming@chromium.org>,
	Miao-chen Chou <mcchou@chromium.org>
Subject: Re: [Bluez PATCH v3 1/3] advertising: Add SupportedFeatures to LEAdvertisingManager1
Date: Mon, 8 Mar 2021 10:38:27 -0800	[thread overview]
Message-ID: <CABBYNZLWOrzuY=WnAxxxyPK8Q4RxwBCA8qQRZO_wFOHcaswUHw@mail.gmail.com> (raw)
In-Reply-To: <20210305155113.Bluez.v3.1.Idf2f9f409a4df20b466ba723dd9b729275a5afbf@changeid>

Hi Daniel,

On Fri, Mar 5, 2021 at 3:59 PM Daniel Winkler <danielwinkler@google.com> wrote:
>
> The new SupportedFeatures member tells advertising clients whether the
> platform has hardware support for advertising or capability to set tx
> power of advertisements.
>
> Additionally, fix small typo in "secondary_exists" function name.
>
> Change is tested on hatch and kukui chromebooks by using dbus-send to
> verify that SupportedFeatures always exists, and is only populated when
> extended advertising is available.
>
> Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
> ---
>
> Changes in v3: None
> Changes in v2:
> - Expose empty SupportedFeatures if no support available
>
>  lib/mgmt.h        |  2 ++
>  src/advertising.c | 43 +++++++++++++++++++++++++++++++++++++++++--
>  2 files changed, 43 insertions(+), 2 deletions(-)
>
> diff --git a/lib/mgmt.h b/lib/mgmt.h
> index 76a03c9c2..c0021abd8 100644
> --- a/lib/mgmt.h
> +++ b/lib/mgmt.h
> @@ -503,6 +503,8 @@ struct mgmt_rp_add_advertising {
>  #define MGMT_ADV_FLAG_SEC_1M           (1 << 7)
>  #define MGMT_ADV_FLAG_SEC_2M           (1 << 8)
>  #define MGMT_ADV_FLAG_SEC_CODED                (1 << 9)
> +#define MGMT_ADV_FLAG_CAN_SET_TX_POWER (1 << 10)
> +#define MGMT_ADV_FLAG_HW_OFFLOAD       (1 << 11)
>  #define MGMT_ADV_PARAM_DURATION                (1 << 12)
>  #define MGMT_ADV_PARAM_TIMEOUT         (1 << 13)
>  #define MGMT_ADV_PARAM_INTERVALS       (1 << 14)
> diff --git a/src/advertising.c b/src/advertising.c
> index 15a343e52..dd6008cb9 100644
> --- a/src/advertising.c
> +++ b/src/advertising.c
> @@ -1616,7 +1616,8 @@ static void append_secondary(struct btd_adv_manager *manager,
>         }
>  }
>
> -static gboolean secondary_exits(const GDBusPropertyTable *property, void *data)
> +static gboolean secondary_exists(const GDBusPropertyTable *property,
> +                                               void *data)
>  {
>         struct btd_adv_manager *manager = data;
>
> @@ -1640,6 +1641,43 @@ static gboolean get_supported_secondary(const GDBusPropertyTable *property,
>         return TRUE;
>  }
>
> +static struct adv_feature {
> +       int flag;
> +       const char *name;
> +} features[] = {
> +       { MGMT_ADV_FLAG_CAN_SET_TX_POWER, "CanSetTxPower" },
> +       { MGMT_ADV_FLAG_HW_OFFLOAD, "HardwareOffload" },
> +       { },
> +};
> +
> +static void append_features(struct btd_adv_manager *manager,
> +                                               DBusMessageIter *iter)
> +{
> +       struct adv_feature *feat;
> +
> +       for (feat = features; feat->name; feat++) {
> +               if (manager->supported_flags & feat->flag)
> +                       dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
> +                                                               &feat->name);
> +       }
> +}
> +
> +static gboolean get_supported_features(const GDBusPropertyTable *property,
> +                                       DBusMessageIter *iter, void *data)
> +{
> +       struct btd_adv_manager *manager = data;
> +       DBusMessageIter entry;
> +
> +       dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY,
> +                                       DBUS_TYPE_STRING_AS_STRING, &entry);
> +
> +       append_features(manager, &entry);
> +
> +       dbus_message_iter_close_container(iter, &entry);
> +
> +       return TRUE;
> +}
> +
>  static gboolean get_supported_cap(const GDBusPropertyTable *property,
>                                         DBusMessageIter *iter, void *data)
>  {
> @@ -1678,7 +1716,8 @@ static const GDBusPropertyTable properties[] = {
>         { "SupportedInstances", "y", get_instances, NULL, NULL },
>         { "SupportedIncludes", "as", get_supported_includes, NULL, NULL },
>         { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL,
> -                                                       secondary_exits },
> +                                                       secondary_exists },
> +       { "SupportedFeatures", "as", get_supported_features, NULL, NULL },

Missing G_DBUS_PROPERTY_FLAG_EXPERIMENTAL.

>         { "SupportedCapabilities", "a{sv}", get_supported_cap, NULL, NULL,
>                                         G_DBUS_PROPERTY_FLAG_EXPERIMENTAL},
>         { }
> --
> 2.30.1.766.gb4fecdf3b7-goog
>


-- 
Luiz Augusto von Dentz

  parent reply	other threads:[~2021-03-08 18:39 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-05 23:52 [Bluez PATCH v3 0/3] Expose extended adv feature support via bluez API Daniel Winkler
2021-03-05 23:52 ` [Bluez PATCH v3 1/3] advertising: Add SupportedFeatures to LEAdvertisingManager1 Daniel Winkler
2021-03-06  1:12   ` Expose extended adv feature support via bluez API bluez.test.bot
2021-03-08 18:38   ` Luiz Augusto von Dentz [this message]
2021-03-05 23:52 ` [Bluez PATCH v3 2/3] client: Add adv SupportedFeatures to bluetoothctl Daniel Winkler
2021-03-05 23:52 ` [Bluez PATCH v3 3/3] doc/advertising-api: Add adv SupportedFeatures to doc Daniel Winkler
2021-03-08 18:36   ` 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='CABBYNZLWOrzuY=WnAxxxyPK8Q4RxwBCA8qQRZO_wFOHcaswUHw@mail.gmail.com' \
    --to=luiz.dentz@gmail.com \
    --cc=chromeos-bluetooth-upstreaming@chromium.org \
    --cc=danielwinkler@google.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=mcchou@chromium.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.