Diff between e90c5ee0ba3451f70adcc99880e72413de82dad0 and 177eccc14523bfd936323ba6bb422ff087a3b626

Changed Files

File Additions Deletions Status
client/advertising.c +24 -0 modified
client/advertising.h +1 -0 modified
client/main.c +2 -2 modified

Full Patch

diff --git a/client/advertising.c b/client/advertising.c
index 35e582a..571b6e6 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)
diff --git a/client/advertising.h b/client/advertising.h
index 77fc1cc..2557435 100644
--- a/client/advertising.h
+++ b/client/advertising.h
@@ -30,3 +30,4 @@ void ad_advertise_manufacturer(const char *arg);
 void ad_advertise_tx_power(bool value);
 void ad_advertise_name(bool value);
 void ad_advertise_appearance(bool value);
+void ad_advertise_local_name(const char *name);
diff --git a/client/main.c b/client/main.c
index 0bc2a88..328a5ee 100644
--- a/client/main.c
+++ b/client/main.c
@@ -2379,7 +2379,7 @@ static void cmd_set_advertise_name(const char *arg)
 		return;
 	}
 
-	rl_printf("Invalid argument\n");
+	ad_advertise_local_name(arg);
 }
 
 static void cmd_set_advertise_appearance(const char *arg)
@@ -2446,7 +2446,7 @@ static const struct {
 	{ "set-advertise-tx-power", "<on/off>",
 			cmd_set_advertise_tx_power,
 			"Enable/disable TX power to be advertised" },
-	{ "set-advertise-name", "<on/off>", cmd_set_advertise_name,
+	{ "set-advertise-name", "<on/off/name>", cmd_set_advertise_name,
 			"Enable/disable local name to be advertised" },
 	{ "set-advertise-appearance", "<value>", cmd_set_advertise_appearance,
 			"Set custom appearance to be advertised" },