diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2017-08-10 12:30:57 +0300 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2017-08-10 16:32:07 +0300 |
commit | 177eccc14523bfd936323ba6bb422ff087a3b626 (patch) | |
tree | 81ccc3e86562402673506c06dc309c3e8cfdf8b5 /client/advertising.c | |
parent | e90c5ee0ba3451f70adcc99880e72413de82dad0 (diff) | |
download | bluez-177eccc14523bfd936323ba6bb422ff087a3b626.tar.gz |
client: Enable set-advertise-name to set LocalName
This enables set-advertise-name to use LocalName property:
[bluetooth]# set-advertise-name blah
[bluetooth]# advertise on
@ MGMT Command: Add Advertising (0x003e) plen 17
Instance: 1
Flags: 0x00000003
Switch into Connectable mode
Advertise as Discoverable
Duration: 0
Timeout: 0
Advertising data length: 0
Scan response length: 6
Name (complete): blah
Diffstat (limited to 'client/advertising.c')
-rw-r--r-- | client/advertising.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/client/advertising.c b/client/advertising.c index 35e582afc..571b6e619 100644 --- a/client/advertising.c +++ b/client/advertising.c @@ -57,6 +57,7 @@ struct manufacturer_data { static struct ad { bool registered; char *type; + char *local_name; char **uuids; size_t uuids_len; struct service_data service; @@ -290,6 +291,19 @@ static gboolean get_includes(const GDBusPropertyTable *property, return TRUE; } +static gboolean local_name_exits(const GDBusPropertyTable *property, void *data) +{ + return ad.local_name ? TRUE : FALSE; +} + +static gboolean get_local_name(const GDBusPropertyTable *property, + DBusMessageIter *iter, void *user_data) +{ + dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &ad.local_name); + + return TRUE; +} + static const GDBusPropertyTable ad_props[] = { { "Type", "s", get_type }, { "ServiceUUIDs", "as", get_uuids, NULL, uuids_exists }, @@ -297,6 +311,7 @@ static const GDBusPropertyTable ad_props[] = { { "ManufacturerData", "a{qv}", get_manufacturer_data, NULL, manufacturer_data_exists }, { "Includes", "as", get_includes, NULL, includes_exists }, + { "LocalName", "s", get_local_name, NULL, local_name_exits }, { } }; @@ -495,6 +510,15 @@ void ad_advertise_tx_power(bool value) void ad_advertise_name(bool value) { ad.name = value; + + if (!value) + free(ad.local_name); +} + +void ad_advertise_local_name(const char *name) +{ + free(ad.local_name); + ad.local_name = strdup(name); } void ad_advertise_appearance(bool value) |