linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/1] tools: Expose the raw advertising data available on D-bus to PTS tester
@ 2025-06-11  8:00 Adrian Dudau
  2025-06-11  8:00 ` [PATCH 1/1] " Adrian Dudau
  0 siblings, 1 reply; 6+ messages in thread
From: Adrian Dudau @ 2025-06-11  8:00 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, mihai-octavian.urzica, andrei.istodorescu,
	Adrian Dudau

This patch extracts the AdvertisingData property exposed by
bluetoothd on D-Bus. It will iterate the variable message structure
and will construct the eir buffer in the format described in
BLUETOOTH CORE SPECIFICATION Version 6.1 | Vol 3, Part C.

Adrian Dudau (1):
  tools: Expose the raw advertising data available on D-bus to PTS
    tester

 tools/btpclient.c | 80 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 76 insertions(+), 4 deletions(-)


base-commit: 5df9521ce4d50ffa48153503bc5156c11e6ed26b
-- 
2.45.2


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/1] tools: Expose the raw advertising data available on D-bus to PTS tester
  2025-06-11  8:00 [PATCH 0/1] tools: Expose the raw advertising data available on D-bus to PTS tester Adrian Dudau
@ 2025-06-11  8:00 ` Adrian Dudau
  2025-06-11  9:33   ` bluez.test.bot
  2025-06-11 14:44   ` [PATCH 1/1] " Luiz Augusto von Dentz
  0 siblings, 2 replies; 6+ messages in thread
From: Adrian Dudau @ 2025-06-11  8:00 UTC (permalink / raw)
  To: linux-bluetooth
  Cc: luiz.dentz, mihai-octavian.urzica, andrei.istodorescu,
	Adrian Dudau

This patch extracts the AdvertisingData property exposed by
bluetoothd on D-Bus. It will iterate the variable message structure
and will construct the eir buffer in the format described in
BLUETOOTH CORE SPECIFICATION Version 6.1 | Vol 3, Part C.

Signed-off-by: Adrian Dudau <adrian-constantin.dudau@nxp.com>
---
 tools/btpclient.c | 80 ++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 76 insertions(+), 4 deletions(-)

diff --git a/tools/btpclient.c b/tools/btpclient.c
index 055270edb51b..f80b4532a248 100644
--- a/tools/btpclient.c
+++ b/tools/btpclient.c
@@ -2510,12 +2510,23 @@ static void btp_gap_device_found_ev(struct l_dbus_proxy *proxy)
 {
 	struct btp_device *device = find_device_by_proxy(proxy);
 	struct btp_adapter *adapter = find_adapter_by_device(device);
+	struct l_dbus_message_iter dict_iter;
+	struct l_dbus_message_iter variant_iter;
+	struct l_dbus_message_iter array_iter;
+	struct btp_device_found_ev *p_ev = NULL;
+	struct btp_device_found_ev *p_ev_temp = NULL;
 	struct btp_device_found_ev ev;
 	struct btp_gap_device_connected_ev ev_conn;
 	const char *str, *addr_str;
 	int16_t rssi;
 	uint8_t address_type;
 	bool connected;
+	uint8_t key = 0U; /* AD Type will be stored here */
+	uint8_t *data = NULL; /* AD Data will be stored here */
+	uint32_t len = 0U; /* Length of the AD Data buffer */
+	uint32_t eir_couter = 0U; /* Byte count of AD Type, AD Length, AD Data */
+
+	ev.eir_len =  0U;
 
 	if (!l_dbus_proxy_get_property(proxy, "Address", "s", &addr_str) ||
 					str2ba(addr_str, &ev.address) < 0)
@@ -2538,11 +2549,72 @@ static void btp_gap_device_found_ev(struct l_dbus_proxy *proxy)
 					BTP_EV_GAP_DEVICE_FOUND_FLAG_AD |
 					BTP_EV_GAP_DEVICE_FOUND_FLAG_SR);
 
-	/* TODO Add eir to device found event */
-	ev.eir_len = 0;
+	/* dict_iter will contain the variant for AdvertisingData */
+	if (l_dbus_proxy_get_property(proxy, "AdvertisingData", "a{yv}", &dict_iter)) {
+		/* key will contain the AD Type, variant_iter will contain the variant
+		 * for the current elem
+		 */
+		while (l_dbus_message_iter_next_entry(&dict_iter, &key, &variant_iter)) {
+			/* Unpack the variant to get the byte array */
+			if (!l_dbus_message_iter_get_variant(&variant_iter, "ay", &array_iter))
+				continue;
+
+			/* data contains AD Data, len is the length excluding the AD Type*/
+			if (!l_dbus_message_iter_get_fixed_array(&array_iter, &data, &len))
+				continue;
+
+			if (len <= 0U)
+				continue;
 
-	btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_DEVICE_FOUND, adapter->index,
-						sizeof(ev) + ev.eir_len, &ev);
+			p_ev_temp = p_ev;
+
+			/* Allocate new buffer, recalculated to sustain new data
+			 * eir_counter length from previous data,
+			 * len is size for new data,
+			 * 2U (1Byte AD Type, 1Byte AD Length)
+			 */
+			p_ev = (struct btp_device_found_ev *)
+					malloc(sizeof(struct btp_device_found_ev) +
+					eir_couter + len + 2U);
+
+			if (!p_ev) {
+				p_ev = p_ev_temp;
+				break;
+			}
+
+			/* There is AD data elemets to be moved after resize */
+			if (p_ev_temp && eir_couter != 0U) {
+				memcpy(p_ev, p_ev_temp,
+					sizeof(struct btp_device_found_ev) + eir_couter);
+				free(p_ev_temp);
+			} else {
+				memcpy(p_ev, &ev, sizeof(struct btp_device_found_ev));
+			}
+
+			/* Populate buffer with length */
+			p_ev->eir[eir_couter++] = len + 1U;
+			/* Populate buffer with AD Type */
+			p_ev->eir[eir_couter++] = key;
+
+			/* Move the data in the p_ev->eir that will be sent via btp */
+			for (uint32_t i = 0U; i < len; i++)
+				p_ev->eir[eir_couter + i] = data[i];
+
+			eir_couter += len;
+		}
+	}
+
+	if (p_ev) {
+		p_ev->eir_len = eir_couter;
+
+		btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_DEVICE_FOUND, adapter->index,
+		 sizeof(struct btp_device_found_ev) + eir_couter, p_ev);
+
+		free(p_ev);
+	} else {
+		btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_DEVICE_FOUND, adapter->index,
+		 sizeof(ev) + ev.eir_len, &ev);
+	}
 
 	if (l_dbus_proxy_get_property(proxy, "Connected", "b", &connected) &&
 								connected) {
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* RE: tools: Expose the raw advertising data available on D-bus to PTS tester
  2025-06-11  8:00 ` [PATCH 1/1] " Adrian Dudau
@ 2025-06-11  9:33   ` bluez.test.bot
  2025-06-11 14:44   ` [PATCH 1/1] " Luiz Augusto von Dentz
  1 sibling, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-06-11  9:33 UTC (permalink / raw)
  To: linux-bluetooth, adrian-constantin.dudau

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=970691

---Test result---

Test Summary:
CheckPatch                    PENDING   0.24 seconds
GitLint                       PENDING   0.27 seconds
BuildEll                      PASS      20.13 seconds
BluezMake                     PASS      2712.63 seconds
MakeCheck                     PASS      20.10 seconds
MakeDistcheck                 PASS      198.89 seconds
CheckValgrind                 PASS      274.89 seconds
CheckSmatch                   PASS      304.25 seconds
bluezmakeextell               PASS      127.76 seconds
IncrementalBuild              PENDING   0.27 seconds
ScanBuild                     PASS      907.85 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] tools: Expose the raw advertising data available on D-bus to PTS tester
  2025-06-11  8:00 ` [PATCH 1/1] " Adrian Dudau
  2025-06-11  9:33   ` bluez.test.bot
@ 2025-06-11 14:44   ` Luiz Augusto von Dentz
  1 sibling, 0 replies; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2025-06-11 14:44 UTC (permalink / raw)
  To: Adrian Dudau; +Cc: linux-bluetooth, mihai-octavian.urzica, andrei.istodorescu

Hi Adrian,

On Wed, Jun 11, 2025 at 4:01 AM Adrian Dudau
<adrian-constantin.dudau@nxp.com> wrote:
>
> This patch extracts the AdvertisingData property exposed by
> bluetoothd on D-Bus. It will iterate the variable message structure
> and will construct the eir buffer in the format described in
> BLUETOOTH CORE SPECIFICATION Version 6.1 | Vol 3, Part C.
>
> Signed-off-by: Adrian Dudau <adrian-constantin.dudau@nxp.com>
> ---
>  tools/btpclient.c | 80 ++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 76 insertions(+), 4 deletions(-)
>
> diff --git a/tools/btpclient.c b/tools/btpclient.c
> index 055270edb51b..f80b4532a248 100644
> --- a/tools/btpclient.c
> +++ b/tools/btpclient.c
> @@ -2510,12 +2510,23 @@ static void btp_gap_device_found_ev(struct l_dbus_proxy *proxy)
>  {
>         struct btp_device *device = find_device_by_proxy(proxy);
>         struct btp_adapter *adapter = find_adapter_by_device(device);
> +       struct l_dbus_message_iter dict_iter;
> +       struct l_dbus_message_iter variant_iter;
> +       struct l_dbus_message_iter array_iter;
> +       struct btp_device_found_ev *p_ev = NULL;
> +       struct btp_device_found_ev *p_ev_temp = NULL;
>         struct btp_device_found_ev ev;
>         struct btp_gap_device_connected_ev ev_conn;
>         const char *str, *addr_str;
>         int16_t rssi;
>         uint8_t address_type;
>         bool connected;
> +       uint8_t key = 0U; /* AD Type will be stored here */
> +       uint8_t *data = NULL; /* AD Data will be stored here */
> +       uint32_t len = 0U; /* Length of the AD Data buffer */
> +       uint32_t eir_couter = 0U; /* Byte count of AD Type, AD Length, AD Data */
> +
> +       ev.eir_len =  0U;
>
>         if (!l_dbus_proxy_get_property(proxy, "Address", "s", &addr_str) ||
>                                         str2ba(addr_str, &ev.address) < 0)
> @@ -2538,11 +2549,72 @@ static void btp_gap_device_found_ev(struct l_dbus_proxy *proxy)
>                                         BTP_EV_GAP_DEVICE_FOUND_FLAG_AD |
>                                         BTP_EV_GAP_DEVICE_FOUND_FLAG_SR);
>
> -       /* TODO Add eir to device found event */
> -       ev.eir_len = 0;
> +       /* dict_iter will contain the variant for AdvertisingData */
> +       if (l_dbus_proxy_get_property(proxy, "AdvertisingData", "a{yv}", &dict_iter)) {
> +               /* key will contain the AD Type, variant_iter will contain the variant
> +                * for the current elem
> +                */
> +               while (l_dbus_message_iter_next_entry(&dict_iter, &key, &variant_iter)) {
> +                       /* Unpack the variant to get the byte array */
> +                       if (!l_dbus_message_iter_get_variant(&variant_iter, "ay", &array_iter))
> +                               continue;
> +
> +                       /* data contains AD Data, len is the length excluding the AD Type*/
> +                       if (!l_dbus_message_iter_get_fixed_array(&array_iter, &data, &len))
> +                               continue;
> +
> +                       if (len <= 0U)
> +                               continue;
>
> -       btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_DEVICE_FOUND, adapter->index,
> -                                               sizeof(ev) + ev.eir_len, &ev);
> +                       p_ev_temp = p_ev;
> +
> +                       /* Allocate new buffer, recalculated to sustain new data
> +                        * eir_counter length from previous data,
> +                        * len is size for new data,
> +                        * 2U (1Byte AD Type, 1Byte AD Length)
> +                        */
> +                       p_ev = (struct btp_device_found_ev *)
> +                                       malloc(sizeof(struct btp_device_found_ev) +
> +                                       eir_couter + len + 2U);
> +
> +                       if (!p_ev) {
> +                               p_ev = p_ev_temp;
> +                               break;
> +                       }
> +
> +                       /* There is AD data elemets to be moved after resize */
> +                       if (p_ev_temp && eir_couter != 0U) {
> +                               memcpy(p_ev, p_ev_temp,
> +                                       sizeof(struct btp_device_found_ev) + eir_couter);
> +                               free(p_ev_temp);
> +                       } else {
> +                               memcpy(p_ev, &ev, sizeof(struct btp_device_found_ev));
> +                       }
> +
> +                       /* Populate buffer with length */
> +                       p_ev->eir[eir_couter++] = len + 1U;
> +                       /* Populate buffer with AD Type */
> +                       p_ev->eir[eir_couter++] = key;
> +
> +                       /* Move the data in the p_ev->eir that will be sent via btp */
> +                       for (uint32_t i = 0U; i < len; i++)
> +                               p_ev->eir[eir_couter + i] = data[i];
> +
> +                       eir_couter += len;
> +               }
> +       }
> +
> +       if (p_ev) {
> +               p_ev->eir_len = eir_couter;
> +
> +               btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_DEVICE_FOUND, adapter->index,
> +                sizeof(struct btp_device_found_ev) + eir_couter, p_ev);
> +
> +               free(p_ev);
> +       } else {
> +               btp_send(btp, BTP_GAP_SERVICE, BTP_EV_GAP_DEVICE_FOUND, adapter->index,
> +                sizeof(ev) + ev.eir_len, &ev);
> +       }
>
>         if (l_dbus_proxy_get_property(proxy, "Connected", "b", &connected) &&
>                                                                 connected) {
> --
> 2.45.2

There is quite a lot of lines going over 80 columns:

https://github.com/bluez/bluez/actions/runs/15579687793/job/43871802897?pr=1336

Also notice the usage of sizeof(type) rather than just use sizeof(var)
which normally is a lot shorter and may help staying within 80
columns.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: tools: Expose the raw advertising data available on D-bus to PTS tester
  2025-06-19 14:24 Adrian Dudau
@ 2025-06-19 15:47 ` bluez.test.bot
  0 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-06-19 15:47 UTC (permalink / raw)
  To: linux-bluetooth, adrian-constantin.dudau

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=973861

---Test result---

Test Summary:
CheckPatch                    PENDING   0.32 seconds
GitLint                       PENDING   0.34 seconds
BuildEll                      PASS      20.04 seconds
BluezMake                     PASS      2635.66 seconds
MakeCheck                     PASS      20.79 seconds
MakeDistcheck                 PASS      200.26 seconds
CheckValgrind                 PASS      274.98 seconds
CheckSmatch                   PASS      305.23 seconds
bluezmakeextell               PASS      127.92 seconds
IncrementalBuild              PENDING   0.33 seconds
ScanBuild                     PASS      915.46 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: tools: Expose the raw advertising data available on D-bus to PTS tester
  2025-08-01  7:09 [PATCH v2 1/1] " Adrian Dudau
@ 2025-08-01  8:34 ` bluez.test.bot
  0 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2025-08-01  8:34 UTC (permalink / raw)
  To: linux-bluetooth, adrian-constantin.dudau

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=987581

---Test result---

Test Summary:
CheckPatch                    PENDING   0.27 seconds
GitLint                       PENDING   0.28 seconds
BuildEll                      PASS      20.49 seconds
BluezMake                     PASS      2787.97 seconds
MakeCheck                     PASS      20.68 seconds
MakeDistcheck                 PASS      187.73 seconds
CheckValgrind                 PASS      238.78 seconds
CheckSmatch                   PASS      309.14 seconds
bluezmakeextell               PASS      129.85 seconds
IncrementalBuild              PENDING   0.29 seconds
ScanBuild                     PASS      927.61 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-08-01  8:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11  8:00 [PATCH 0/1] tools: Expose the raw advertising data available on D-bus to PTS tester Adrian Dudau
2025-06-11  8:00 ` [PATCH 1/1] " Adrian Dudau
2025-06-11  9:33   ` bluez.test.bot
2025-06-11 14:44   ` [PATCH 1/1] " Luiz Augusto von Dentz
  -- strict thread matches above, loose matches on Subject: below --
2025-06-19 14:24 Adrian Dudau
2025-06-19 15:47 ` bluez.test.bot
2025-08-01  7:09 [PATCH v2 1/1] " Adrian Dudau
2025-08-01  8:34 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).