Bluetooth: GATT: Fix calculation of max data allowed in write req

This patch fixes the calculation of maximum data that can be sent
by Write Request.
Maximum data is MTU reduced by size of handle and command opcode.

Change-Id: I2abeef9adffd65e24a2489ad084bfa3b810e4acf
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
Mariusz Skamra 2015-12-02 15:07:35 +01:00 committed by Anas Nashif
commit 65e917c9ab

View file

@ -1349,7 +1349,7 @@ int bt_gatt_write(struct bt_conn *conn, uint16_t handle, uint16_t offset,
}
/* Use Prepare Write if offset is set or Long Write is required */
if (offset || length > bt_att_get_mtu(conn) - 1) {
if (offset || length > (bt_att_get_mtu(conn) - sizeof(*req) - 1)) {
return gatt_prepare_write(conn, handle, offset, data, length,
func);
}