File 0001-aux-os-ble_dbus-Don-t-require-power-management-chara.patch of Package monado

From b1c0ad2f415fec740a98b630518552c4456fc487 Mon Sep 17 00:00:00 2001
From: Arnav Singh <me@arnavion.dev>
Date: Sat, 29 Jun 2024 01:58:51 -0700
Subject: [PATCH] aux/os/ble_dbus: Don't require power management
 characteristic to be notifiable.

At least the SteamVR 2.0 lighthouses have a power management characteristic
that does not have the "notify" flag, only "write". So before this change,
the command would not find any valid characteristics to write to and be
a no-op. The power management code path does not require it to be notifiable
in the first place, so this change just ignores that flag.
---
 src/xrt/auxiliary/os/os_ble_dbus.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/src/xrt/auxiliary/os/os_ble_dbus.c b/src/xrt/auxiliary/os/os_ble_dbus.c
index 99b1d16a..2d766b27 100644
--- a/src/xrt/auxiliary/os/os_ble_dbus.c
+++ b/src/xrt/auxiliary/os/os_ble_dbus.c
@@ -614,10 +614,10 @@ gatt_iface_get_uuid(const DBusMessageIter *iface_elm, const char **out_str)
 /*!
  * Returns positive value if the object implements the
  * `org.bluez.GattCharacteristic1` interface, its `UUID` matches the given @p
- * uuid and has the notify flag set.
+ * uuid.
  */
 static int
-gatt_char_has_uuid_and_notify(const DBusMessageIter *dict, const char *uuid, const char **out_path_str)
+gatt_char_has_uuid(const DBusMessageIter *dict, const char *uuid, const char **out_path_str, bool *out_notifiable)
 {
 	DBusMessageIter first_elm;
 	DBusMessageIter iface_elm;
@@ -646,13 +646,14 @@ gatt_char_has_uuid_and_notify(const DBusMessageIter *dict, const char *uuid, con
 			continue;
 		}
 
-		bool notifable = false;
-		ret = gatt_iface_get_flag_notifiable(&iface_elm, &notifable);
-		if (ret <= 0 || !notifable) {
+		bool notifiable = false;
+		ret = gatt_iface_get_flag_notifiable(&iface_elm, &notifiable);
+		if (ret <= 0) {
 			continue;
 		}
 
 		*out_path_str = path_str;
+		*out_notifiable = notifiable;
 		return 1;
 	}
 
@@ -905,6 +906,7 @@ get_path_to_notify_char(
 	{
 		const char *dev_path_str;
 		const char *char_path_str;
+		bool notifiable;
 		ret = device_has_uuid(&elm, dev_uuid, &dev_path_str);
 		if (ret <= 0) {
 			continue;
@@ -912,8 +914,8 @@ get_path_to_notify_char(
 
 		for_each(c, first_elm)
 		{
-			ret = gatt_char_has_uuid_and_notify(&c, char_uuid, &char_path_str);
-			if (ret <= 0) {
+			ret = gatt_char_has_uuid(&c, char_uuid, &char_path_str, &notifiable);
+			if (ret <= 0 || !notifiable) {
 				continue;
 			}
 			if (!starts_with_and_has_slash(char_path_str, dev_path_str)) {
@@ -1136,6 +1138,7 @@ os_ble_broadcast_write_value(const char *service_uuid, const char *char_uuid, ui
 	{
 		const char *dev_path_str;
 		const char *char_path_str;
+		bool notifiable;
 		ret = device_has_uuid(&elm, service_uuid, &dev_path_str);
 		if (ret <= 0) {
 			continue;
@@ -1143,7 +1146,7 @@ os_ble_broadcast_write_value(const char *service_uuid, const char *char_uuid, ui
 
 		for_each(c, first_elm)
 		{
-			ret = gatt_char_has_uuid_and_notify(&c, char_uuid, &char_path_str);
+			ret = gatt_char_has_uuid(&c, char_uuid, &char_path_str, &notifiable);
 			if (ret <= 0) {
 				continue;
 			}
-- 
2.45.2

openSUSE Build Service is sponsored by