From: Kevin Dewald <kevin@simpleble.org>
To: linux-bluetooth@vger.kernel.org
Cc: Luiz Augusto von Dentz <luiz.dentz@gmail.com>,
Kevin Dewald <kevin@simpleble.org>
Subject: [PATCH BlueZ v2 4/6] bearer: Add Connectable property
Date: Thu, 1 Oct 2026 22:46:15 -0700 [thread overview]
Message-ID: <20261002054618.30994-5-kevin@simpleble.org> (raw)
In-Reply-To: <20261002054618.30994-1-kevin@simpleble.org>
This implements Connectable property for both bearers. For LE it
reflects whether the last advertising report was connectable, and
PropertiesChanged is emitted from device_update_last_seen when it
changes or first becomes known. BREDR always reports it as true.
---
src/bearer.c | 38 ++++++++++++++++++++++++++++++++++++++
src/bearer.h | 1 +
src/device.c | 18 ++++++++++++++++++
src/device.h | 2 ++
4 files changed, 59 insertions(+)
diff --git a/src/bearer.c b/src/bearer.c
index ac3a220..f3b7a23 100644
--- a/src/bearer.c
+++ b/src/bearer.c
@@ -249,6 +249,31 @@ static gboolean bearer_get_connected(const GDBusPropertyTable *property,
return TRUE;
}
+static gboolean bearer_get_connectable(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct btd_bearer *bearer = data;
+ dbus_bool_t connectable;
+
+ connectable = btd_device_bdaddr_type_connectable(bearer->device,
+ bearer->type);
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &connectable);
+
+ return TRUE;
+}
+
+static gboolean bearer_connectable_exists(const GDBusPropertyTable *property,
+ void *data)
+{
+ struct btd_bearer *bearer = data;
+
+ if (bearer->type == BDADDR_BREDR)
+ return TRUE;
+
+ return btd_device_bdaddr_type_seen(bearer->device, bearer->type);
+}
+
static const GDBusSignalTable bearer_signals[] = {
{ GDBUS_SIGNAL("Disconnected",
GDBUS_ARGS({ "name", "s" }, { "message", "s" })) },
@@ -264,6 +289,9 @@ static const GDBusPropertyTable bearer_properties[] = {
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
{ "Connected", "b", bearer_get_connected, NULL, NULL,
G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
+ { "Connectable", "b", bearer_get_connectable, NULL,
+ bearer_connectable_exists,
+ G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
{}
};
@@ -354,6 +382,16 @@ void btd_bearer_bonded(struct btd_bearer *bearer)
"Bonded");
}
+void btd_bearer_connectable(struct btd_bearer *bearer)
+{
+ if (!bearer || !bearer->path)
+ return;
+
+ g_dbus_emit_property_changed(btd_get_dbus_connection(), bearer->path,
+ bearer_interface(bearer->type),
+ "Connectable");
+}
+
void btd_bearer_connected(struct btd_bearer *bearer, int err)
{
DBusMessage *reply;
diff --git a/src/bearer.h b/src/bearer.h
index a201003..238d0a1 100644
--- a/src/bearer.h
+++ b/src/bearer.h
@@ -18,5 +18,6 @@ void btd_bearer_destroy(struct btd_bearer *bearer);
void btd_bearer_paired(struct btd_bearer *bearer);
void btd_bearer_bonded(struct btd_bearer *bearer);
+void btd_bearer_connectable(struct btd_bearer *bearer);
void btd_bearer_connected(struct btd_bearer *bearer, int err);
void btd_bearer_disconnected(struct btd_bearer *bearer, uint8_t reason);
diff --git a/src/device.c b/src/device.c
index dedab65..77744d0 100644
--- a/src/device.c
+++ b/src/device.c
@@ -3829,6 +3829,19 @@ bool btd_device_bdaddr_type_connected(struct btd_device *dev, uint8_t type)
return dev->le_state.connected;
}
+bool btd_device_bdaddr_type_connectable(struct btd_device *dev, uint8_t type)
+{
+ if (type == BDADDR_BREDR)
+ return true;
+
+ return dev->le_state.connectable;
+}
+
+bool btd_device_bdaddr_type_seen(struct btd_device *dev, uint8_t type)
+{
+ return get_state(dev, type)->last_seen != 0;
+}
+
static void clear_temporary_timer(struct btd_device *dev)
{
if (dev->temporary_timer) {
@@ -5372,8 +5385,10 @@ void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type,
struct bearer_state *state;
bool known = device_connectable_known(device);
bool was_connectable = device_is_connectable(device);
+ bool changed;
state = get_state(device, bdaddr_type);
+ changed = !state->last_seen || state->connectable != connectable;
state->last_seen = time(NULL);
state->connectable = connectable;
@@ -5383,6 +5398,9 @@ void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type,
g_dbus_emit_property_changed(dbus_conn, device->path,
DEVICE_INTERFACE, "Connectable");
+ if (changed && bdaddr_type != BDADDR_BREDR)
+ btd_bearer_connectable(device->le);
+
if (!device_is_temporary(device))
return;
diff --git a/src/device.h b/src/device.h
index fdc036e..597df74 100644
--- a/src/device.h
+++ b/src/device.h
@@ -127,6 +127,8 @@ void device_set_flags(struct btd_device *device, uint8_t flags);
bool btd_device_is_connected(struct btd_device *dev);
bool btd_device_bearer_is_connected(struct btd_device *dev);
bool btd_device_bdaddr_type_connected(struct btd_device *dev, uint8_t type);
+bool btd_device_bdaddr_type_connectable(struct btd_device *dev, uint8_t type);
+bool btd_device_bdaddr_type_seen(struct btd_device *dev, uint8_t type);
uint8_t btd_device_get_bdaddr_type(struct btd_device *dev);
bool device_is_retrying(struct btd_device *device);
void device_bonding_complete(struct btd_device *device, uint8_t bdaddr_type,
--
2.54.0 (Apple Git-157)
next prev parent reply other threads:[~2026-10-02 5:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 5:46 [PATCH BlueZ v2 0/6] Add Connectable property to org.bluez.Device Kevin Dewald
2026-10-02 5:46 ` [PATCH BlueZ v2 1/6] org.bluez.Device: Add Connectable property Kevin Dewald
2026-10-02 12:16 ` Add Connectable property to org.bluez.Device bluez.test.bot
2026-10-02 5:46 ` [PATCH BlueZ v2 2/6] org.bluez.Bearer: Add Connectable property Kevin Dewald
2026-10-02 5:46 ` [PATCH BlueZ v2 3/6] device: " Kevin Dewald
2026-10-02 5:46 ` Kevin Dewald [this message]
2026-10-02 5:46 ` [PATCH BlueZ v2 5/6] client: Print Connectable in info Kevin Dewald
2026-10-02 5:46 ` [PATCH BlueZ v2 6/6] client: Print discoverable broadcasters in red Kevin Dewald
2026-10-02 15:00 ` [PATCH BlueZ v2 0/6] Add Connectable property to org.bluez.Device patchwork-bot+bluetooth
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=20261002054618.30994-5-kevin@simpleble.org \
--to=kevin@simpleble.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox