* [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel
@ 2019-02-15 14:22 Luiz Augusto von Dentz
2019-02-15 14:22 ` [PATCH BlueZ 2/4] advertising: Add implementation of SupportedSecondaryChannels Luiz Augusto von Dentz
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2019-02-15 14:22 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This enables reading and setting the Secondary Channel/PHY supported
by the controller.
---
doc/advertising-api.txt | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt
index cfce0f9a3..b0565eab2 100644
--- a/doc/advertising-api.txt
+++ b/doc/advertising-api.txt
@@ -129,6 +129,15 @@ Properties string Type
Timeout of the advertisement in seconds. This defines
the lifetime of the advertisement.
+ string SecondaryChannel [Experimental]
+
+ Secondary channel to be used. Primary channel is
+ always set to "1M" except when "Coded" is set.
+
+ Possible value: "1M" (default)
+ "2M"
+ "Coded"
+
LE Advertising Manager hierarchy
================================
@@ -190,3 +199,13 @@ Properties byte ActiveInstances
Possible values: "tx-power"
"appearance"
"local-name"
+
+ array{string} SupportedSecondaryChannels [Experimental]
+
+ List of supported Secondary channels. Secondary
+ channels can be used to advertise with the
+ corresponding PHY.
+
+ Possible values: "1M"
+ "2M"
+ "Coded"
--
2.17.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 2/4] advertising: Add implementation of SupportedSecondaryChannels
2019-02-15 14:22 [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
@ 2019-02-15 14:22 ` Luiz Augusto von Dentz
2019-02-15 14:23 ` [PATCH BlueZ 3/4] advertising: Add implementation of SecondaryChannel Luiz Augusto von Dentz
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2019-02-15 14:22 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This implements SupportedSecondaryChannels property which expose what
the supported secondary channels.
---
src/advertising.c | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/advertising.c b/src/advertising.c
index a843dbba3..df7ebbf81 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1234,10 +1234,50 @@ static gboolean get_supported_includes(const GDBusPropertyTable *property,
return TRUE;
}
+static struct adv_secondary {
+ int flag;
+ const char *name;
+} secondary[] = {
+ { MGMT_ADV_FLAG_SEC_1M, "1M" },
+ { MGMT_ADV_FLAG_SEC_2M, "2M" },
+ { MGMT_ADV_FLAG_SEC_CODED, "Codec" },
+ { },
+};
+
+static void append_secondary(struct btd_adv_manager *manager,
+ DBusMessageIter *iter)
+{
+ struct adv_secondary *sec;
+
+ for (sec = secondary; sec && sec->name; sec++) {
+ if (manager->supported_flags & sec->flag)
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+ &sec->name);
+ }
+}
+
+static gboolean get_supported_secondary(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_secondary(manager, &entry);
+
+ dbus_message_iter_close_container(iter, &entry);
+
+ return TRUE;
+}
+
static const GDBusPropertyTable properties[] = {
{ "ActiveInstances", "y", get_active_instances, NULL, NULL },
{ "SupportedInstances", "y", get_instances, NULL, NULL },
{ "SupportedIncludes", "as", get_supported_includes, NULL, NULL },
+ { "SupportedSecondaryChannels", "as", get_supported_secondary, NULL,
+ NULL },
{ }
};
--
2.17.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 3/4] advertising: Add implementation of SecondaryChannel
2019-02-15 14:22 [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
2019-02-15 14:22 ` [PATCH BlueZ 2/4] advertising: Add implementation of SupportedSecondaryChannels Luiz Augusto von Dentz
@ 2019-02-15 14:23 ` Luiz Augusto von Dentz
2019-02-15 14:23 ` [PATCH BlueZ 4/4] client: Add advertise.secondary command Luiz Augusto von Dentz
2019-02-21 12:09 ` [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2019-02-15 14:23 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This add the parsing for SecondaryChannel which indicates what secondary
PHY shall be used.
---
src/advertising.c | 52 ++++++++++++++++++++++++++++++++++++++---------
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/src/advertising.c b/src/advertising.c
index df7ebbf81..8cda6a372 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -874,6 +874,47 @@ static bool parse_discoverable_timeout(DBusMessageIter *iter,
return true;
}
+static struct adv_secondary {
+ int flag;
+ const char *name;
+} secondary[] = {
+ { MGMT_ADV_FLAG_SEC_1M, "1M" },
+ { MGMT_ADV_FLAG_SEC_2M, "2M" },
+ { MGMT_ADV_FLAG_SEC_CODED, "Codec" },
+ { },
+};
+
+static bool parse_secondary(DBusMessageIter *iter,
+ struct btd_adv_client *client)
+{
+ const char *str;
+ struct adv_secondary *sec;
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return false;
+
+ /* Reset secondary channels before parsing */
+ client->flags &= 0xfe00;
+
+ dbus_message_iter_get_basic(iter, &str);
+
+ for (sec = secondary; sec && sec->name; sec++) {
+ if (strcmp(str, sec->name))
+ continue;
+
+ if (!(client->manager->supported_flags & sec->flag))
+ return false;
+
+ DBG("Secondary Channel: %s", str);
+
+ client->flags |= sec->flag;
+
+ return true;
+ }
+
+ return false;
+}
+
static struct adv_parser {
const char *name;
bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client);
@@ -891,6 +932,7 @@ static struct adv_parser {
{ "Data", parse_data },
{ "Discoverable", parse_discoverable },
{ "DiscoverableTimeout", parse_discoverable_timeout },
+ { "SecondaryChannel", parse_secondary },
{ },
};
@@ -1234,16 +1276,6 @@ static gboolean get_supported_includes(const GDBusPropertyTable *property,
return TRUE;
}
-static struct adv_secondary {
- int flag;
- const char *name;
-} secondary[] = {
- { MGMT_ADV_FLAG_SEC_1M, "1M" },
- { MGMT_ADV_FLAG_SEC_2M, "2M" },
- { MGMT_ADV_FLAG_SEC_CODED, "Codec" },
- { },
-};
-
static void append_secondary(struct btd_adv_manager *manager,
DBusMessageIter *iter)
{
--
2.17.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ 4/4] client: Add advertise.secondary command
2019-02-15 14:22 [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
2019-02-15 14:22 ` [PATCH BlueZ 2/4] advertising: Add implementation of SupportedSecondaryChannels Luiz Augusto von Dentz
2019-02-15 14:23 ` [PATCH BlueZ 3/4] advertising: Add implementation of SecondaryChannel Luiz Augusto von Dentz
@ 2019-02-15 14:23 ` Luiz Augusto von Dentz
2019-02-21 12:09 ` [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2019-02-15 14:23 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This adds advertose.secondary command which can be used to set a
secondary channel to advertise.
---
client/advertising.c | 43 +++++++++++++++++++++++++++++++++++++++++++
client/advertising.h | 1 +
client/main.c | 20 ++++++++++++++++++++
3 files changed, 64 insertions(+)
diff --git a/client/advertising.c b/client/advertising.c
index 960cdd62d..72f91b9a5 100644
--- a/client/advertising.c
+++ b/client/advertising.c
@@ -64,6 +64,7 @@ static struct ad {
bool registered;
char *type;
char *local_name;
+ char *secondary;
uint16_t local_appearance;
uint16_t duration;
uint16_t timeout;
@@ -441,6 +442,20 @@ static gboolean get_discoverable_timeout(const GDBusPropertyTable *property,
return TRUE;
}
+static gboolean secondary_exits(const GDBusPropertyTable *property, void *data)
+{
+ return ad.secondary ? TRUE : FALSE;
+}
+
+static gboolean get_secondary(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING,
+ &ad.secondary);
+
+ return TRUE;
+}
+
static const GDBusPropertyTable ad_props[] = {
{ "Type", "s", get_type },
{ "ServiceUUIDs", "as", get_uuids, NULL, uuids_exists },
@@ -456,6 +471,7 @@ static const GDBusPropertyTable ad_props[] = {
{ "Appearance", "q", get_appearance, NULL, appearance_exits },
{ "Duration", "q", get_duration, NULL, duration_exits },
{ "Timeout", "q", get_timeout, NULL, timeout_exits },
+ { "SecondaryChannel", "s", get_secondary, NULL, secondary_exits },
{ }
};
@@ -919,3 +935,30 @@ void ad_advertise_timeout(DBusConnection *conn, long int *value)
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
+
+void ad_advertise_secondary(DBusConnection *conn, const char *value)
+{
+ if (!value) {
+ if (ad.secondary)
+ bt_shell_printf("Secondary Channel: %s\n",
+ ad.secondary);
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+ }
+
+ if (ad.secondary && !strcmp(value, ad.secondary))
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+
+ free(ad.secondary);
+
+ if (value[0] == '\0') {
+ ad.secondary = NULL;
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+ }
+
+ ad.secondary = strdup(value);
+
+ g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE,
+ "SecondaryChannel");
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
diff --git a/client/advertising.h b/client/advertising.h
index fe3a7c8c6..9967e657b 100644
--- a/client/advertising.h
+++ b/client/advertising.h
@@ -41,3 +41,4 @@ void ad_advertise_data(DBusConnection *conn, int argc, char *argv[]);
void ad_disable_data(DBusConnection *conn);
void ad_advertise_discoverable(DBusConnection *conn, dbus_bool_t *value);
void ad_advertise_discoverable_timeout(DBusConnection *conn, long int *value);
+void ad_advertise_secondary(DBusConnection *conn, const char *value);
diff --git a/client/main.c b/client/main.c
index 1f6e04578..2c5b05693 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2479,6 +2479,16 @@ static void cmd_advertise_timeout(int argc, char *argv[])
ad_advertise_timeout(dbus_conn, &value);
}
+static void cmd_advertise_secondary(int argc, char *argv[])
+{
+ if (argc < 2) {
+ ad_advertise_secondary(dbus_conn, NULL);
+ return;
+ }
+
+ ad_advertise_secondary(dbus_conn, argv[1]);
+}
+
static void ad_clear_uuids(void)
{
ad_disable_uuids(dbus_conn);
@@ -2530,6 +2540,13 @@ static void ad_clear_timeout(void)
ad_advertise_timeout(dbus_conn, &value);
}
+static void ad_clear_secondary(void)
+{
+ const char *value = "";
+
+ ad_advertise_secondary(dbus_conn, value);
+}
+
static const struct clear_entry ad_clear[] = {
{ "uuids", ad_clear_uuids },
{ "service", ad_clear_service },
@@ -2540,6 +2557,7 @@ static const struct clear_entry ad_clear[] = {
{ "appearance", ad_clear_appearance },
{ "duration", ad_clear_duration },
{ "timeout", ad_clear_timeout },
+ { "secondary", ad_clear_secondary },
{}
};
@@ -2583,6 +2601,8 @@ static const struct bt_shell_menu advertise_menu = {
"Set/Get advertise duration" },
{ "timeout", "[seconds]", cmd_advertise_timeout,
"Set/Get advertise timeout" },
+ { "secondary", "[1M/2M/Coded]", cmd_advertise_secondary,
+ "Set/Get advertise secondary channel" },
{ "clear", "[uuids/service/manufacturer/config-name...]", cmd_ad_clear,
"Clear advertise config" },
{ } },
--
2.17.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel
2019-02-15 14:22 [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
` (2 preceding siblings ...)
2019-02-15 14:23 ` [PATCH BlueZ 4/4] client: Add advertise.secondary command Luiz Augusto von Dentz
@ 2019-02-21 12:09 ` Luiz Augusto von Dentz
3 siblings, 0 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2019-02-21 12:09 UTC (permalink / raw)
To: linux-bluetooth
Hi,
On Fri, Feb 15, 2019 at 4:23 PM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> This enables reading and setting the Secondary Channel/PHY supported
> by the controller.
> ---
> doc/advertising-api.txt | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)
>
> diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt
> index cfce0f9a3..b0565eab2 100644
> --- a/doc/advertising-api.txt
> +++ b/doc/advertising-api.txt
> @@ -129,6 +129,15 @@ Properties string Type
> Timeout of the advertisement in seconds. This defines
> the lifetime of the advertisement.
>
> + string SecondaryChannel [Experimental]
> +
> + Secondary channel to be used. Primary channel is
> + always set to "1M" except when "Coded" is set.
> +
> + Possible value: "1M" (default)
> + "2M"
> + "Coded"
> +
> LE Advertising Manager hierarchy
> ================================
>
> @@ -190,3 +199,13 @@ Properties byte ActiveInstances
> Possible values: "tx-power"
> "appearance"
> "local-name"
> +
> + array{string} SupportedSecondaryChannels [Experimental]
> +
> + List of supported Secondary channels. Secondary
> + channels can be used to advertise with the
> + corresponding PHY.
> +
> + Possible values: "1M"
> + "2M"
> + "Coded"
> --
> 2.17.2
Applied.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-02-21 12:10 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-15 14:22 [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
2019-02-15 14:22 ` [PATCH BlueZ 2/4] advertising: Add implementation of SupportedSecondaryChannels Luiz Augusto von Dentz
2019-02-15 14:23 ` [PATCH BlueZ 3/4] advertising: Add implementation of SecondaryChannel Luiz Augusto von Dentz
2019-02-15 14:23 ` [PATCH BlueZ 4/4] client: Add advertise.secondary command Luiz Augusto von Dentz
2019-02-21 12:09 ` [PATCH BlueZ 1/4] doc/advertising-api: Add support for setting Secondary Channel Luiz Augusto von Dentz
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).