diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-11-27 09:17:57 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2015-11-27 11:48:19 +0000 |
commit | 2d9c73c35b99453f8f36f9dcc4a4f6a8856d7877 (patch) | |
tree | 3bbdddfe928eae5aae51f7c9f6d5296e89b5d596 | |
parent | cf8b244f94fdabf5c960d82c4bbcbf13c91c29b1 (diff) |
Enforce unbuffered L2CAP socket for GATT
The GATT protocol does not enforce a length indicator on each GATT
command. Usually this is not a problem because each request is followed
by a response and therefore we can assume the entire packet content is
a single response/request.
However the GATT WRITE_COMMAND does not have a response. Multiple
requests can be sent in quick follow-up. If buffering is utilized the
consecutive commands may be merged and received as single data blob on
the remote device. Since Write commands don't have a length indicator
they cannot be distinguished and ultimately the write command will set
the wrong value.
Change-Id: I02f3cd3cfaedfeae6a40272f5d22d3d88c39aa55
Task-number: QTBUG-49650
Reviewed-by: Christian Kandeler <christian.kandeler@theqtcompany.com>
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index 8906eb06..4cd3afe3 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -262,7 +262,9 @@ void QLowEnergyControllerPrivate::connectToDevice() } // connect - l2cpSocket->connectToService(remoteDevice, ATTRIBUTE_CHANNEL_ID); + // Unbuffered mode required to separate each GATT packet + l2cpSocket->connectToService(remoteDevice, ATTRIBUTE_CHANNEL_ID, + QIODevice::ReadWrite | QIODevice::Unbuffered); } void QLowEnergyControllerPrivate::l2cpConnected() |