From: Alexander Sarmanow <as@discnull.de>
To: linux-bluetooth@vger.kernel.org
Cc: Alexander Sarmanow <as@discnull.de>
Subject: [PATCH BlueZ 2/2] advertising: Add broadcast name property support
Date: Thu, 24 Sep 2026 17:17:20 +0200 [thread overview]
Message-ID: <20260924151720.1769259-3-as@discnull.de> (raw)
In-Reply-To: <20260924151720.1769259-1-as@discnull.de>
This update enables setting the BROADCAST_NAME property via the
LEAdvertisement1 object.
---
src/advertising.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
src/shared/ad.h | 3 +++
2 files changed, 47 insertions(+)
diff --git a/src/advertising.c b/src/advertising.c
index 1ed09c902..e1b7ce97a 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -69,6 +69,7 @@ struct btd_adv_client {
char *owner;
char *path;
char *name;
+ char *bcast_name;
uint16_t appearance;
uint16_t duration;
uint16_t timeout;
@@ -153,6 +154,7 @@ static void client_free(void *data)
g_free(client->path);
free(client->name);
+ free(client->bcast_name);
free(client);
}
@@ -674,6 +676,42 @@ static bool parse_local_name(DBusMessageIter *iter,
return true;
}
+static bool parse_bcast_name(DBusMessageIter *iter,
+ struct btd_adv_client *client)
+{
+ const char *bcast_name;
+ size_t len;
+
+ if (!iter) {
+ free(client->bcast_name);
+ client->bcast_name = NULL;
+ return true;
+ }
+
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
+ return false;
+
+ dbus_message_iter_get_basic(iter, &bcast_name);
+
+ len = strlen(bcast_name);
+ if (len < BT_AD_BC_NAME_MIN_LEN) {
+ error("Broacast name %s too short", bcast_name);
+ return false;
+ }
+
+ if (len > BT_AD_BC_NAME_MAX_LEN) {
+ warn("Broacast name %s too long. Truncating...", bcast_name);
+ len = BT_AD_BC_NAME_MAX_LEN;
+ }
+
+ free(client->bcast_name);
+ client->bcast_name = strndup(bcast_name, len);
+
+ DBG("Adding Broadcast Name %s to adv data", client->bcast_name);
+
+ return true;
+}
+
static bool parse_appearance(DBusMessageIter *iter,
struct btd_adv_client *client)
{
@@ -934,6 +972,11 @@ static uint8_t *generate_adv_data(struct btd_adv_client *client,
bt_ad_add_name(client->data, client->name);
}
+ if ((client->type == AD_TYPE_BROADCAST) && client->bcast_name) {
+ bt_ad_add_data(client->data, BT_AD_BC_NAME, client->bcast_name,
+ strlen(client->bcast_name));
+ }
+
return bt_ad_generate(client->data, len);
}
@@ -1329,6 +1372,7 @@ static struct adv_parser {
{ "ServiceData", parse_service_data_ad },
{ "ScanResponseServiceData", parse_service_data_sr, true },
{ "Includes", parse_includes },
+ { "BroadcastName", parse_bcast_name },
{ "LocalName", parse_local_name },
{ "Appearance", parse_appearance },
{ "Duration", parse_duration },
diff --git a/src/shared/ad.h b/src/shared/ad.h
index 71be8727b..f2843b5d6 100644
--- a/src/shared/ad.h
+++ b/src/shared/ad.h
@@ -15,6 +15,8 @@
#include "bluetooth/uuid.h"
#define BT_AD_MAX_DATA_LEN 31
+#define BT_AD_BC_NAME_MIN_LEN 4
+#define BT_AD_BC_NAME_MAX_LEN 32
#define BT_EA_MAX_DATA_LEN 251
#define BT_PA_MAX_DATA_LEN 252
@@ -60,6 +62,7 @@
#define BT_AD_MESH_DATA 0x2a
#define BT_AD_MESH_BEACON 0x2b
#define BT_AD_CSIP_RSI 0x2e
+#define BT_AD_BC_NAME 0x30
#define BT_AD_3D_INFO_DATA 0x3d
#define BT_AD_MANUFACTURER_DATA 0xff
--
2.30.2
next prev parent reply other threads:[~2026-09-24 15:24 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 15:17 [PATCH BlueZ 0/2] org.bluez.LEAdvertisement: Add broadcast name support Alexander Sarmanow
2026-09-24 15:17 ` [PATCH BlueZ 1/2] doc/org.bluez.LEAdvertisement: Add broadcast name Alexander Sarmanow
2026-09-24 19:06 ` org.bluez.LEAdvertisement: Add broadcast name support bluez.test.bot
2026-09-24 15:17 ` Alexander Sarmanow [this message]
2026-09-24 15:44 ` [PATCH BlueZ 0/2] " Luiz Augusto von Dentz
2026-09-24 18:57 ` Alexander Sarmanow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924151720.1769259-3-as@discnull.de \
--to=as@discnull.de \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.