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: <https://gitlab.freedesktop.org/monado/monado/-/merge_requests/2269>
This commit is contained in:
Arnav Singh 2024-06-29 01:58:51 -07:00 committed by Marge Bot
parent bdd61330f7
commit 2685fb1dc6

View file

@ -613,10 +613,10 @@ gatt_iface_get_uuid(const DBusMessageIter *iface_elm, const char **out_str)
/*! /*!
* Returns positive value if the object implements the * Returns positive value if the object implements the
* `org.bluez.GattCharacteristic1` interface, its `UUID` matches the given @p * `org.bluez.GattCharacteristic1` interface, its `UUID` matches the given @p
* uuid and has the notify flag set. * uuid.
*/ */
static int 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 first_elm;
DBusMessageIter iface_elm; DBusMessageIter iface_elm;
@ -645,13 +645,14 @@ gatt_char_has_uuid_and_notify(const DBusMessageIter *dict, const char *uuid, con
continue; continue;
} }
bool notifable = false; bool notifiable = false;
ret = gatt_iface_get_flag_notifiable(&iface_elm, &notifable); ret = gatt_iface_get_flag_notifiable(&iface_elm, &notifiable);
if (ret <= 0 || !notifable) { if (ret <= 0) {
continue; continue;
} }
*out_path_str = path_str; *out_path_str = path_str;
*out_notifiable = notifiable;
return 1; return 1;
} }
@ -904,6 +905,7 @@ get_path_to_notify_char(
{ {
const char *dev_path_str; const char *dev_path_str;
const char *char_path_str; const char *char_path_str;
bool notifiable;
ret = device_has_uuid(&elm, dev_uuid, &dev_path_str); ret = device_has_uuid(&elm, dev_uuid, &dev_path_str);
if (ret <= 0) { if (ret <= 0) {
continue; continue;
@ -911,8 +913,8 @@ get_path_to_notify_char(
for_each(c, first_elm) 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) { if (ret <= 0 || !notifiable) {
continue; continue;
} }
if (!starts_with_and_has_slash(char_path_str, dev_path_str)) { 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 *dev_path_str;
const char *char_path_str; const char *char_path_str;
bool notifiable;
ret = device_has_uuid(&elm, service_uuid, &dev_path_str); ret = device_has_uuid(&elm, service_uuid, &dev_path_str);
if (ret <= 0) { if (ret <= 0) {
continue; continue;
@ -1142,7 +1145,7 @@ os_ble_broadcast_write_value(const char *service_uuid, const char *char_uuid, ui
for_each(c, first_elm) 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) { if (ret <= 0) {
continue; continue;
} }