From 2685fb1dc6dd66a5ac5516f7205ffa47dda8c1b9 Mon Sep 17 00:00:00 2001 From: Arnav Singh 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. Part-of: --- 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 01e93b851..58ccda038 100644 --- a/src/xrt/auxiliary/os/os_ble_dbus.c +++ b/src/xrt/auxiliary/os/os_ble_dbus.c @@ -613,10 +613,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; @@ -645,13 +645,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, ¬ifable); - if (ret <= 0 || !notifable) { + bool notifiable = false; + ret = gatt_iface_get_flag_notifiable(&iface_elm, ¬ifiable); + if (ret <= 0) { continue; } *out_path_str = path_str; + *out_notifiable = notifiable; return 1; } @@ -904,6 +905,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; @@ -911,8 +913,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, ¬ifiable); + if (ret <= 0 || !notifiable) { continue; } if (!starts_with_and_has_slash(char_path_str, dev_path_str)) { @@ -1135,6 +1137,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; @@ -1142,7 +1145,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, ¬ifiable); if (ret <= 0) { continue; }