Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH 1/2] device: LastSeen property for D-Bus interface
@ 2016-08-02 15:40 andrey.zheregelya
  2016-08-02 15:40 ` [PATCH 2/2] doc/device-api.txt Information about D-Bus LastSeen property andrey.zheregelya
  0 siblings, 1 reply; 7+ messages in thread
From: andrey.zheregelya @ 2016-08-02 15:40 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Andrey Zheregelya

From: Andrey Zheregelya <andrey.zheregelya@dsr-company.com>

It returns le_seen or bredr_seen to caller. Marked as experimental.
Can be used to detect if device is still reachable.
---
 src/device.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/device.c b/src/device.c
index 264d599..7fe4d32 100644
--- a/src/device.c
+++ b/src/device.c
@@ -937,6 +937,17 @@ static gboolean dev_property_get_tx_power(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean dev_property_get_last_seen(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct btd_device *dev = data;
+	dbus_int64_t val = (dev->bredr_seen > dev->le_seen) ? dev->bredr_seen : dev->le_seen;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_INT64, &val);
+
+	return TRUE;
+}
+
 static gboolean dev_property_exists_tx_power(const GDBusPropertyTable *property,
 								void *data)
 {
@@ -2529,6 +2540,8 @@ static const GDBusPropertyTable device_properties[] = {
 	{ "TxPower", "n", dev_property_get_tx_power, NULL,
 					dev_property_exists_tx_power },
 	{ "ServicesResolved", "b", dev_property_get_svc_resolved, NULL, NULL },
+	{ "LastSeen", "x", dev_property_get_last_seen, NULL, NULL,
+					G_DBUS_PROPERTY_FLAG_EXPERIMENTAL },
 
 	{ }
 };
-- 
2.9.2


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

end of thread, other threads:[~2016-08-03 12:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-02 15:40 [PATCH 1/2] device: LastSeen property for D-Bus interface andrey.zheregelya
2016-08-02 15:40 ` [PATCH 2/2] doc/device-api.txt Information about D-Bus LastSeen property andrey.zheregelya
2016-08-02 15:57   ` Bastien Nocera
2016-08-02 16:55     ` Andrey Zheregelya
2016-08-03  9:48       ` Luiz Augusto von Dentz
2016-08-03 12:32         ` Andrey Zheregelya
2016-08-03 12:46           ` Luiz Augusto von Dentz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox