diff options
author | Anderson Lizardo <anderson.lizardo@openbossa.org> | 2013-07-19 13:34:09 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2013-07-24 08:41:47 -0700 |
commit | ccd0e3783dbfeedd70a94a404580daffac772323 (patch) | |
tree | 0991e58287d0f9596bad08fa7f182008a3e9d4a7 /attrib/gatt.c | |
parent | 1d4f111fae897e5bbee5733955dd2d75c815e659 (diff) | |
download | bluez-ccd0e3783dbfeedd70a94a404580daffac772323.tar.gz |
attrib: Do not use Write Command in gatt_write_char()
Previously, if no callback was given to gatt_write_char(), it was
assumed that a "Write Without Response" (which uses Write Command)
should be used instead of Write Request.
This "shortcut" is unnecessary (there is gatt_write_cmd() for the
situations where Write Without Response is required) and just duplicates
code.
This commit also fixes the few places where gatt_write_cmd() should be
used.
Diffstat (limited to 'attrib/gatt.c')
-rw-r--r-- | attrib/gatt.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/attrib/gatt.c b/attrib/gatt.c index d21dd392c..9de07e4e9 100644 --- a/attrib/gatt.c +++ b/attrib/gatt.c @@ -785,23 +785,21 @@ guint gatt_write_char(GAttrib *attrib, uint16_t handle, uint8_t *value, { uint8_t *buf; size_t buflen; - guint16 plen; struct write_long_data *long_write; buf = g_attrib_get_buffer(attrib, &buflen); - /* Only use Write Request/Command if payload fits on a single transfer, - * including 3 bytes for the header. */ + /* Use Write Request if payload fits on a single transfer, including 3 + * bytes for the header. */ if (vlen <= buflen - 3) { - if (func) - plen = enc_write_req(handle, value, vlen, buf, - buflen); - else - plen = enc_write_cmd(handle, value, vlen, buf, - buflen); - - return g_attrib_send(attrib, 0, buf, plen, func, - user_data, NULL); + uint16_t plen; + + plen = enc_write_req(handle, value, vlen, buf, buflen); + if (plen == 0) + return 0; + + return g_attrib_send(attrib, 0, buf, plen, func, user_data, + NULL); } /* Write Long Characteristic Values */ |