[PATCH 2/8] adapter: add API to find an existing device by D-Bus path

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This allows us to get a btd_device from information passed in D-Bus
method calls or signals.
---
 src/adapter.c |   15 +++++++++++++++
 src/adapter.h |    2 ++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index acb845e..f817975 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3531,3 +3531,18 @@ int btd_adapter_remove_remote_oob_data(struct btd_adapter *adapter,
 {
 	return adapter_ops->remove_remote_oob_data(adapter->dev_id, bdaddr);
 }
+
+struct btd_device *adapter_get_device_by_path(struct btd_adapter *adapter,
+					      const char *path)
+{
+	GSList *l;
+
+	for (l = adapter->devices; l != NULL; l = g_slist_next(l))
+		if (g_strcmp0(device_get_path(l->data), path) == 0)
+			break;
+
+	if (!l)
+		return NULL;
+
+	return l->data;
+}
diff --git a/src/adapter.h b/src/adapter.h
index ceebb97..4933baf 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -294,3 +294,5 @@ int btd_adapter_remove_remote_oob_data(struct btd_adapter *adapter,
 
 int btd_adapter_gatt_server_start(struct btd_adapter *adapter);
 void btd_adapter_gatt_server_stop(struct btd_adapter *adapter);
+struct btd_device *adapter_get_device_by_path(struct btd_adapter *adapter,
+					      const char *path);
-- 
1.7.5.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux