From: David Lechner <david@lechnology.com>
To: linux-bluetooth@vger.kernel.org
Cc: David Lechner <david@lechnology.com>
Subject: [PATCH BlueZ v2] src/gatt-client: always check properties in WriteValue
Date: Mon, 27 Apr 2020 10:01:53 -0500 [thread overview]
Message-ID: <20200427150153.17055-1-david@lechnology.com> (raw)
This modifies the GATT client characteristic WriteValue D-Bus method to
always check that the characteristic supports the requested type of
write by checking for the corresponding property before attempting to
write.
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 return
org.bluez.Error.NotSupported if the corresponding property flag is not
set for all types of writes.
---
v2 changes:
- remove extra check of test variable not NULL
- fix one line over 80 chars
src/gatt-client.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/gatt-client.c b/src/gatt-client.c
index a9bfc2802..f80742fbb 100644
--- a/src/gatt-client.c
+++ b/src/gatt-client.c
@@ -1016,8 +1016,8 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,
* - If value is larger than MTU - 3: long-write
* * "write-without-response" property set -> write command.
*/
- if ((!type && (chrc->ext_props & BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE))
- || (type && !strcasecmp(type, "reliable"))) {
+ if ((!type || !strcasecmp(type, "reliable")) && chrc->ext_props &
+ BT_GATT_CHRC_EXT_PROP_RELIABLE_WRITE) {
supported = true;
chrc->write_op = start_long_write(msg, chrc->value_handle, gatt,
true, value, value_len, offset,
@@ -1026,8 +1026,8 @@ static DBusMessage *characteristic_write_value(DBusConnection *conn,
return NULL;
}
- if ((!type && chrc->props & BT_GATT_CHRC_PROP_WRITE) ||
- (type && !strcasecmp(type, "request"))) {
+ if ((!type || !strcasecmp(type, "request")) && chrc->props &
+ BT_GATT_CHRC_PROP_WRITE) {
uint16_t mtu;
supported = true;
--
2.17.1
next reply other threads:[~2020-04-27 15:02 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-27 15:01 David Lechner [this message]
2020-04-27 16:28 ` [PATCH BlueZ v2] src/gatt-client: always check properties in WriteValue Luiz Augusto von Dentz
2020-04-28 14:39 ` David Lechner
2020-04-28 17:03 ` Luiz Augusto von Dentz
2020-04-28 17:19 ` David Lechner
2020-04-28 21:07 ` 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=20200427150153.17055-1-david@lechnology.com \
--to=david@lechnology.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox