doc/advertising-api: Add support for setting Secondary Channel
Luiz Augusto von Dentz
maintainerPATCH 1/4 doc/advertising-api: Add support for setting Secondary Channel
From: Luiz Augusto von Dentz <[email protected]>
This enables reading and setting the Secondary Channel/PHY supported by the controller.
--- doc/advertising-api.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
doc/advertising-api.txt +19 -0
@@ -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"
Signature · 1 line
2.17.2
Luiz Augusto von Dentz
maintainerPATCH 2/4 advertising: Add implementation of SupportedSecondaryChannels
From: Luiz Augusto von Dentz <[email protected]>
This implements SupportedSecondaryChannels property which expose what the supported secondary channels.
--- src/advertising.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+)
src/advertising.c +40 -0
@@ -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 }, { } };
Signature · 1 line
2.17.2
Luiz Augusto von Dentz
maintainerPATCH 3/4 advertising: Add implementation of SecondaryChannel
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
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(-)
src/advertising.c +42 -10
@@ -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) {
Signature · 1 line
2.17.2
Luiz Augusto von Dentz
maintainerPATCH 4/4 client: Add advertise.secondary command
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
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(+)
client/advertising.c +43 -0
@@ -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 ); +}
client/advertising.h +1 -0
@@ -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);
client/main.c +20 -0
@@ -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" }, { } },
Signature · 1 line
2.17.2
Hi,
Quoted 44 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
This enables reading and setting the Secondary Channel/PHY supported by the controller.
--- doc/advertising-api.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)doc/advertising-api.txt +19
-1@@ -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" --
Quoted 1 line
2.17.2
Applied.
Signature · 1 line
Luiz Augusto von Dentz