All of lore.kernel.org
 help / color / mirror / Atom feed
From: vibhavp@gmail.com
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ]: adapter: Add Version and Manufacturer props to org.bluez.Adapter1.
Date: Tue, 19 Sep 2023 17:47:47 +0530	[thread overview]
Message-ID: <89ceb9e5d67485c19d0f139ac0825cf008491ebb.camel@gmail.com> (raw)

[-- 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 --]

             reply	other threads:[~2023-09-19 12:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-19 12:17 vibhavp [this message]
2023-09-19 12:24 ` [BlueZ] : adapter: Add Version and Manufacturer props to org.bluez.Adapter1 bluez.test.bot
2023-09-19 20:10 ` [PATCH BlueZ]: " Luiz Augusto von Dentz

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=89ceb9e5d67485c19d0f139ac0825cf008491ebb.camel@gmail.com \
    --to=vibhavp@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /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 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.