diff options
author | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-07-18 13:56:14 +0200 |
---|---|---|
committer | Alex Blasche <alexander.blasche@theqtcompany.com> | 2016-07-19 11:08:58 +0000 |
commit | 8755a1f2460fa523782e27b6ca7a430a0176ac61 (patch) | |
tree | 697421644eb6883f21a1f5b5296655969cfe96a5 /src | |
parent | b00651a9e6ca00c31dd0601d3cdbe1db623c6204 (diff) |
Highlight incomplete handling of BTLE packet writes
Cases such as partial writes were silently ignored.
Since QLowEnergyController works in unbuffered mode such incomplete
writes are ignored. The ATT layer will automatically recover from such
packets on the line.
The EAGAIN case is a similar case as it effectively
means the BTLE connection is still ok but the packet can temporarily
not be written anyway. In fact, previously QBluetoothSocket reported such cases by
returning -1 as a result of QBLuetoothSocket::write(). This was even worse
as it caused a drop of the connection without justification.
These issues are reproducable when the BTLE connection is flooded
with lots of notifications.
Task-number: QTBUG-54475
Change-Id: I2b6be555ff676c440971981db0974be83c901eaa
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/qlowenergycontroller_bluez.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluez.cpp b/src/bluetooth/qlowenergycontroller_bluez.cpp index d4fe0232..e85fcb34 100644 --- a/src/bluetooth/qlowenergycontroller_bluez.cpp +++ b/src/bluetooth/qlowenergycontroller_bluez.cpp @@ -688,12 +688,19 @@ void QLowEnergyControllerPrivate::sendPacket(const QByteArray &packet) { qint64 result = l2cpSocket->write(packet.constData(), packet.size()); + // We ignore result == 0 which is likely to be caused by EAGAIN. + // This packet is effectively discarded but the controller can still recover + if (result == -1) { qCDebug(QT_BT_BLUEZ) << "Cannot write L2CP packet:" << hex << packet.toHex() << l2cpSocket->errorString(); setError(QLowEnergyController::NetworkError); + } else if (result < packet.size()) { + qCWarning(QT_BT_BLUEZ) << "L2CP write request incomplete:" + << result << "of" << packet.size(); } + } void QLowEnergyControllerPrivate::sendNextPendingRequest() |