Skip to contentSkip to conversation

Added Manufacturer Data for Scan Response

PATCH In review Klein, Thorsten (BSH) 3 participants 7 messages Apr 3, 2020 – Apr 6, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Added Manufacturer Data for Scan Response

A ManufacturerData field is added to the ScanResponse. Keys are the Manufacturer ID to associate with the data.

Schachschal, Maximilian (BSH) (1):
ManufacturerData field added to ScanResponse

 doc/advertising-api.txt |  6 ++++++
 src/advertising.c       | 25 +++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 ManufacturerData field added to ScanResponse

From: "Schachschal, Maximilian (BSH)" <[email protected]>

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(-)
doc/advertising-api.txt +6 -0
index b0565ea..14ccae2 100644
@@ -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"
src/advertising.c +19 -6
index 45ff19f..0e1a3f1 100644
@@ -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 },
Signature · 1 line
2.7.4
#2 lore raw

Re: [PATCH BlueZ] ManufacturerData field added to ScanResponse

Hi Thorsten,

Quoted 14 lines · Thorsten (BSH)

From: "Schachschal, Maximilian (BSH)" <[email protected]>

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(-)
doc/advertising-api.txt +0 -0
index b0565ea..14ccae2 100644

doc/advertising-api.txt Properties string Type · line 59

Quoted 9 lines
doc/advertising-api.txt +6 -0
@@ -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.
+

Don't really like to do this, beside it seems to be optional to enter either on AD or on SRD so the scanner is really at fault here if it only able to parse the data if placed on SRD, that said we could have some logic that detects if manufacturer don't fit on the AD push it to SRD if that has more space if the advertisement is discoverable.

Quoted 77 lines
doc/advertising-api.txt +0 -0
                array{string} SolicitUUIDs
 
                        Array of UUIDs to include in "Service Solicitation"
src/advertising.c +19 -7
index 45ff19f..0e1a3f1 100644
@@ -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 },
--

2.7.4

Signature · 1 line
Luiz Augusto von Dentz
#3 lore raw

RE: [PATCH BlueZ] ManufacturerData field added to ScanResponse

Hi Luiz,

Quoted 1 line

Don't really like to do this, beside it seems to be optional to enter either on AD or on SRD so the scanner is really at fault here if it only able to parse the data if placed on SRD, that said we could have some logic that detects if manufacturer don't fit on the AD push it to SRD if that has more space if the advertisement is discoverable.

I agree on that, that may be the best solution.
We already thought about that. However it looked like some major changes in shared part would be necessary for that and we didn't want to change too much here. So this was the easiest (although little dirty) solution for us to start with. We wanted to share it here and start discussion on that. What needs to be considered for changes to shared part?

BR
Max

-----Original Message-----
From: Luiz Augusto von Dentz <[email protected]>
Sent: Friday, April 3, 2020 11:42 PM
To: Klein, Thorsten (BSH) <[email protected]>
Cc: [email protected]; Schachschal, Maximilian (GED-SDD2) <[email protected]>
Subject: Re: [PATCH BlueZ] ManufacturerData field added to ScanResponse

Hi Thorsten,

Quoted 15 lines · Thorsten (BSH)

From: "Schachschal, Maximilian (BSH)"
<[email protected]>

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(-)
doc/advertising-api.txt index renamed from doc/advertising-api.txt +0 -0

b0565ea..14ccae2 100644

doc/advertising-api.txt Properties string Type · line 59

Quoted 9 lines
doc/advertising-api.txt +6 -0
@@ -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.
+

Don't really like to do this, beside it seems to be optional to enter either on AD or on SRD so the scanner is really at fault here if it only able to parse the data if placed on SRD, that said we could have some logic that detects if manufacturer don't fit on the AD push it to SRD if that has more space if the advertisement is discoverable.

Quoted 75 lines
doc/advertising-api.txt +0 -0
                array{string} SolicitUUIDs
 
                        Array of UUIDs to include in "Service Solicitation"
src/advertising.c index renamed from src/advertising.c +0 -0

45ff19f..0e1a3f1 100644

src/advertising.c +3 -3
@@ -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);
src/advertising.c +15 -4
-               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 },
--
Quoted 2 lines

2.7.4

--
Luiz Augusto von Dentz

#4 lore raw

Re: [PATCH BlueZ] ManufacturerData field added to ScanResponse

Hi Maximilian,

Quoted 9 lines · On Mon, Apr 6, 2020 at 2:58 AM Schachschal, Maximilian (GED-SDD2)…

Hi Luiz,

Quoted 1 line

Don't really like to do this, beside it seems to be optional to enter either on AD or on SRD so the scanner is really at fault here if it only able to parse the data if placed on SRD, that said we could have some logic that detects if manufacturer don't fit on the AD push it to SRD if that has more space if the advertisement is discoverable.

I agree on that, that may be the best solution.
We already thought about that. However it looked like some major changes in shared part would be necessary for that and we didn't want to change too much here. So this was the easiest (although little dirty) solution for us to start with. We wanted to share it here and start discussion on that. What needs to be considered for changes to shared part?

Afaik we can just try to append to ad instance if that fails then proceed to add to sd instance after checking if the instance is discoverable, so this might not even need a change to bt_ad itself, but perhaps bt_ad don't actually indicate if a proper error for no space but we should be add a specific retur for that.

Quoted 121 lines

BR
Max

-----Original Message-----
From: Luiz Augusto von Dentz <[email protected]>
Sent: Friday, April 3, 2020 11:42 PM
To: Klein, Thorsten (BSH) <[email protected]>
Cc: [email protected]; Schachschal, Maximilian (GED-SDD2) <[email protected]>
Subject: Re: [PATCH BlueZ] ManufacturerData field added to ScanResponse

Hi Thorsten,

Quoted 15 lines · Thorsten (BSH)

From: "Schachschal, Maximilian (BSH)"
<[email protected]>

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(-)
doc/advertising-api.txt index renamed from doc/advertising-api.txt +0 -0

b0565ea..14ccae2 100644

doc/advertising-api.txt Properties string Type · line 59

Quoted 9 lines
doc/advertising-api.txt +6 -0
@@ -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.
+

Don't really like to do this, beside it seems to be optional to enter either on AD or on SRD so the scanner is really at fault here if it only able to parse the data if placed on SRD, that said we could have some logic that detects if manufacturer don't fit on the AD push it to SRD if that has more space if the advertisement is discoverable.

Quoted 75 lines
doc/advertising-api.txt +0 -0
                array{string} SolicitUUIDs
 
                        Array of UUIDs to include in "Service Solicitation"
src/advertising.c index renamed from src/advertising.c +0 -0

45ff19f..0e1a3f1 100644

src/advertising.c +3 -3
@@ -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);
src/advertising.c +15 -4
-               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 },
--
Quoted 2 lines

2.7.4

--
Luiz Augusto von Dentz

Signature · 1 line
Luiz Augusto von Dentz
#5 lore raw

RE: [PATCH BlueZ] ManufacturerData field added to ScanResponse

Hi Luiz,

Quoted 5 lines

Afaik we can just try to append to ad instance if that fails then proceed to add to sd instance after checking if the instance is discoverable, so this might not even need a change to bt_ad itself, but perhaps bt_ad don't actually indicate if a proper error for no space but we should be add a specific retur for that.

But where to store the data then? Is there a way to move it from client->data to client->scan?

BR,
Max

#6 lore raw
In reply to Klein, Thorsten (BSH)

Hi Thorsten,

Quoted 6 lines · Thorsten (BSH)

A ManufacturerData field is added to the ScanResponse. Keys are the Manufacturer ID to associate with the data.

Schachschal, Maximilian (BSH) (1):
ManufacturerData field added to ScanResponse

Quoted 6 lines
 doc/advertising-api.txt |  6 ++++++
 src/advertising.c       | 25 +++++++++++++++++++------
 2 files changed, 25 insertions(+), 6 deletions(-)

--
2.7.4

Was this suppose to be a cover letter? Imo it is pointless to send these for 1 patch set so please be more verbose on the actual patch description.

Signature · 1 line
Luiz Augusto von Dentz