All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ]: adapter: Add Version and Manufacturer props to org.bluez.Adapter1.
@ 2023-09-19 12:17 vibhavp
  2023-09-19 12:24 ` [BlueZ] : " bluez.test.bot
  2023-09-19 20:10 ` [PATCH BlueZ]: " Luiz Augusto von Dentz
  0 siblings, 2 replies; 3+ messages in thread
From: vibhavp @ 2023-09-19 12:17 UTC (permalink / raw)
  To: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 3037 bytes --]

From: Vibhav Pant <vibhavp@gmail.com>

This allows DBus clients to find an adapter's version and
manufacturer company code without querying the management API.

Signed-off-by: Vibhav Pant <vibhavp@gmail.com>
---
 doc/adapter-api.txt | 11 +++++++++++
 src/adapter.c       | 28 ++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/doc/adapter-api.txt b/doc/adapter-api.txt
index d38ce7171..10c290c62 100644
--- a/doc/adapter-api.txt
+++ b/doc/adapter-api.txt
@@ -360,3 +360,14 @@ Properties	string Address [readonly]
 
 			List of 128-bit UUIDs that represents the
experimental
 			features currently enabled.
+
+		uint16 Manufacturer [readonly]
+
+			The manufacturer of the device, as a uint16
company
+			identifier defined by the Core Bluetooth
Specification.
+
+		byte Version [readonly]
+
+			The Bluetooth version supported by the device,
as a
+			core version code defined by the Core
Bluetooth
+			Specification.
diff --git a/src/adapter.c b/src/adapter.c
index 5ebfc4752..8f67a6826 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -260,6 +260,7 @@ struct btd_adapter {
 
 	bdaddr_t bdaddr;		/* controller Bluetooth
address */
 	uint8_t bdaddr_type;		/* address type */
+	uint8_t version;                /* controller core spec
version */
 	uint32_t dev_class;		/* controller class of device
*/
 	char *name;			/* controller device name */
 	char *short_name;		/* controller short name */
@@ -3540,6 +3541,29 @@ static gboolean
property_experimental_exists(const GDBusPropertyTable *property,
 	return !queue_isempty(adapter->exps);
 }
 
+static gboolean property_get_manufacturer(const GDBusPropertyTable
*property,
+					  DBusMessageIter *iter,
+					  void *user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	dbus_uint16_t val = adapter->manufacturer;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &val);
+
+	return TRUE;
+}
+
+static gboolean property_get_version(const GDBusPropertyTable
*property,
+				     DBusMessageIter *iter, void
*user_data)
+{
+	struct btd_adapter *adapter = user_data;
+	uint8_t val = adapter->version;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BYTE, &val);
+
+	return TRUE;
+}
+
 static DBusMessage *remove_device(DBusConnection *conn,
 					DBusMessage *msg, void
*user_data)
 {
@@ -3898,6 +3922,8 @@ static const GDBusPropertyTable
adapter_properties[] = {
 	{ "Roles", "as", property_get_roles },
 	{ "ExperimentalFeatures", "as", property_get_experimental,
NULL,
 					property_experimental_exists
},
+	{ "Manufacturer", "q", property_get_manufacturer },
+	{ "Version", "y", property_get_version },
 	{ }
 };
 
@@ -10162,6 +10188,8 @@ static void read_info_complete(uint8_t status,
uint16_t length,
 	adapter->supported_settings = btohl(rp->supported_settings);
 	adapter->current_settings = btohl(rp->current_settings);
 
+	adapter->version = rp->version;
+
 	clear_uuids(adapter);
 	clear_devices(adapter);
 
-- 
2.42.0




[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 512 bytes --]

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

end of thread, other threads:[~2023-09-19 20:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-19 12:17 [PATCH BlueZ]: adapter: Add Version and Manufacturer props to org.bluez.Adapter1 vibhavp
2023-09-19 12:24 ` [BlueZ] : " bluez.test.bot
2023-09-19 20:10 ` [PATCH BlueZ]: " Luiz Augusto von Dentz

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.