src/gatt-client: allow "command" even when property not set
PATCH 1/1 src/gatt-client: allow "command" even when property not set
This modifies the GATT client characteristic WriteValue D-Bus method to not check that the characteristic supports the requested type of write when the "type" option is set to "command".
Before this change, if the "type" option was used and it was set to "reliable" or "request", then BlueZ would attempt the write even if the characteristic does not support that write type. On the other hand, if "type" was set to "command" or was not specified, the method would return a org.bluez.Error.NotSupported error without attempting to write.
After this change, the WriteValue method will consistently always ignore the characteristic properties and attempt to write when the "type" option is used instead of having a different behavior for the "command" type.
---
Related discussion:
https://lore.kernel.org/linux-bluetooth/[email protected]
src/gatt-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
src/gatt-client.c +2 -2
@@ -1050,8 +1050,8 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,return NULL ; } -if ((type &&strcasecmp (type,"command" )) || offset || - !(chrc->props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP )) +if ((type &&strcasecmp (type,"command" )) || offset || (!type && + !(chrc->props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP ))) goto fail; supported = true;
Signature · 1 line
2.17.1
Hi David,
Quoted 40 lines · David Lechner
This modifies the GATT client characteristic WriteValue D-Bus method to not check that the characteristic supports the requested type of write when the "type" option is set to "command".
Before this change, if the "type" option was used and it was set to "reliable" or "request", then BlueZ would attempt the write even if the characteristic does not support that write type. On the other hand, if "type" was set to "command" or was not specified, the method would return a org.bluez.Error.NotSupported error without attempting to write.
After this change, the WriteValue method will consistently always ignore the characteristic properties and attempt to write when the "type" option is used instead of having a different behavior for the "command" type.
---Related discussion:
https://lore.kernel.org/linux-bluetooth/[email protected]src/gatt-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)src/gatt-client.c +2
-3@@ -1050,8 +1050,8 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,return NULL ; } -if ((type &&strcasecmp (type,"command" )) || offset || - !(chrc->props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP )) +if ((type &&strcasecmp (type,"command" )) || offset || (!type && + !(chrc->props &BT_GATT_CHRC_PROP_WRITE_WITHOUT_RESP ))) goto fail; supported = true; --
Quoted 1 line
2.17.1
Applied, thanks.
Signature · 1 line
Luiz Augusto von Dentz