diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2019-02-15 16:19:59 +0200 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2019-02-21 14:08:52 +0200 |
commit | bd0808bf01eb4debe450dcd36ab6cddfd3b57779 (patch) | |
tree | cdf8dc624867edbe4bbce777b27e6887292eea34 /client/advertising.c | |
parent | 5c8816f0db64462a0f093b82c923c2d12dce95e0 (diff) | |
download | bluez-bd0808bf01eb4debe450dcd36ab6cddfd3b57779.tar.gz |
client: Add advertise.secondary command
This adds advertose.secondary command which can be used to set a
secondary channel to advertise.
Diffstat (limited to 'client/advertising.c')
-rw-r--r-- | client/advertising.c | 43 |
1 files changed, 43 insertions, 0 deletions
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); +} |