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 3/6] device: Add Connectable property
Date: Thu, 1 Oct 2026 22:46:14 -0700 [thread overview]
Message-ID: <20261002054618.30994-4-kevin@simpleble.org> (raw)
In-Reply-To: <20261002054618.30994-1-kevin@simpleble.org>
This implements Connectable property using device_is_connectable, which
reports whether the last advertising report on the device's bearer was
connectable, and emits PropertiesChanged from device_update_last_seen
when the value changes or first becomes known.
---
src/device.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/src/device.c b/src/device.c
index a8bd29b..dedab65 100644
--- a/src/device.c
+++ b/src/device.c
@@ -327,6 +327,14 @@ static struct bearer_state *get_state(struct btd_device *dev,
return &dev->le_state;
}
+static bool device_connectable_known(struct btd_device *dev)
+{
+ if (dev->bredr)
+ return true;
+
+ return get_state(dev, dev->bdaddr_type)->last_seen != 0;
+}
+
bool btd_device_is_initiator(struct btd_device *dev)
{
if (dev->le_state.connected)
@@ -1281,6 +1289,25 @@ static gboolean dev_property_exists_tx_power(const GDBusPropertyTable *property,
return TRUE;
}
+static gboolean
+dev_property_get_connectable(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *data)
+{
+ struct btd_device *dev = data;
+ dbus_bool_t val = device_is_connectable(dev);
+
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val);
+
+ return TRUE;
+}
+
+static gboolean
+dev_property_exists_connectable(const GDBusPropertyTable *property,
+ void *data)
+{
+ return device_connectable_known(data);
+}
+
static gboolean
dev_property_get_svc_resolved(const GDBusPropertyTable *property,
DBusMessageIter *iter, void *data)
@@ -3756,6 +3783,8 @@ static const GDBusPropertyTable device_properties[] = {
NULL, dev_property_service_data_exist },
{ "TxPower", "n", dev_property_get_tx_power, NULL,
dev_property_exists_tx_power },
+ { "Connectable", "b", dev_property_get_connectable, NULL,
+ dev_property_exists_connectable },
{ "ServicesResolved", "b", dev_property_get_svc_resolved, NULL, NULL },
{ "AdvertisingFlags", "ay", dev_property_get_flags, NULL,
dev_property_flags_exist },
@@ -5341,12 +5370,19 @@ void device_update_last_seen(struct btd_device *device, uint8_t bdaddr_type,
bool connectable)
{
struct bearer_state *state;
+ bool known = device_connectable_known(device);
+ bool was_connectable = device_is_connectable(device);
state = get_state(device, bdaddr_type);
state->last_seen = time(NULL);
state->connectable = connectable;
+ if (known != device_connectable_known(device) ||
+ was_connectable != device_is_connectable(device))
+ g_dbus_emit_property_changed(dbus_conn, device->path,
+ DEVICE_INTERFACE, "Connectable");
+
if (!device_is_temporary(device))
return;
--
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 ` Kevin Dewald [this message]
2026-10-02 5:46 ` [PATCH BlueZ v2 4/6] bearer: " Kevin Dewald
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-4-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