diff mbox series

[BlueZ] ManufacturerData field added to ScanResponse

Message ID 1585899591-14623-2-git-send-email-thorsten.klein@bshg.com
State New
Headers show
Series [BlueZ] ManufacturerData field added to ScanResponse | expand

Commit Message

Klein, Thorsten (BSH) April 3, 2020, 7:39 a.m. UTC
From: "Schachschal, Maximilian (BSH)" <maximilian.schachschal@bshg.com>

Keys are the Manufacturer ID to associate with the data.
---
 doc/advertising-api.txt |  6 ++++++
 src/advertising.c       | 25 +++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/doc/advertising-api.txt b/doc/advertising-api.txt
index b0565ea..14ccae2 100644
--- a/doc/advertising-api.txt
+++ b/doc/advertising-api.txt
@@ -51,6 +51,12 @@  Properties	string Type
 			the Advertising Data.  Keys are the Manufacturer ID
 			to associate with the data.
 
+		dict ManufacturerDataScanResponse [Experimental]
+
+			Manufactuer Data fields to include in
+			the Scan Response.  Keys are the Manufacturer ID
+			to associate with the data.
+
 		array{string} SolicitUUIDs
 
 			Array of UUIDs to include in "Service Solicitation"
diff --git a/src/advertising.c b/src/advertising.c
index 45ff19f..0e1a3f1 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -328,12 +328,12 @@  fail:
 }
 
 static bool parse_manufacturer_data(DBusMessageIter *iter,
-					struct btd_adv_client *client)
+					struct btd_ad *ad)
 {
 	DBusMessageIter entries;
 
 	if (!iter) {
-		bt_ad_clear_manufacturer_data(client->data);
+		bt_ad_clear_manufacturer_data(ad);
 		return true;
 	}
 
@@ -342,7 +342,7 @@  static bool parse_manufacturer_data(DBusMessageIter *iter,
 
 	dbus_message_iter_recurse(iter, &entries);
 
-	bt_ad_clear_manufacturer_data(client->data);
+	bt_ad_clear_manufacturer_data(ad);
 
 	while (dbus_message_iter_get_arg_type(&entries)
 						== DBUS_TYPE_DICT_ENTRY) {
@@ -373,7 +373,7 @@  static bool parse_manufacturer_data(DBusMessageIter *iter,
 
 		DBG("Adding ManufacturerData for %04x", manuf_id);
 
-		if (!bt_ad_add_manufacturer_data(client->data, manuf_id,
+		if (!bt_ad_add_manufacturer_data(ad, manuf_id,
 							manuf_data, len))
 			goto fail;
 
@@ -383,10 +383,22 @@  static bool parse_manufacturer_data(DBusMessageIter *iter,
 	return true;
 
 fail:
-	bt_ad_clear_manufacturer_data(client->data);
+	bt_ad_clear_manufacturer_data(ad);
 	return false;
 }
 
+static bool parse_manufacturer_data_adv(DBusMessageIter *iter,
+					struct btd_adv_client *client)
+{
+	return parse_manufacturer_data(iter, client->data);
+}
+
+static bool parse_manufacturer_data_scan(DBusMessageIter *iter,
+					struct btd_adv_client *client)
+{
+	return parse_manufacturer_data(iter, client->scan);
+}
+
 static bool parse_service_data(DBusMessageIter *iter,
 					struct btd_adv_client *client)
 {
@@ -941,7 +953,8 @@  static struct adv_parser {
 	{ "Type", parse_type },
 	{ "ServiceUUIDs", parse_service_uuids },
 	{ "SolicitUUIDs", parse_solicit_uuids },
-	{ "ManufacturerData", parse_manufacturer_data },
+	{ "ManufacturerData", parse_manufacturer_data_adv },
+	{ "ManufacturerDataScanResponse", parse_manufacturer_data_scan },
 	{ "ServiceData", parse_service_data },
 	{ "Includes", parse_includes },
 	{ "LocalName", parse_local_name },