summaryrefslogtreecommitdiffstats
path: root/src/bluetooth
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2020-03-02 13:42:43 +0100
committerAlex Blasche <alexander.blasche@qt.io>2020-03-03 10:07:34 +0100
commit6d18706c7ceb09b5ec5bc57dbde508c8329c1785 (patch)
tree25fe82eb63d373890bd78faeee79e1e0c7a54299 /src/bluetooth
parent0282c2fc4ae437cb4f549f25f3e748a90e64f864 (diff)
Support characteristic Write Without Response on BlueZ 5.50+
BlueZ 5.50 adds support for this feature. This patch was provided by David Lechner via QTBUG-81696. Fixes: QTBUG-81696 Change-Id: I2a73b173821e36534b3848f7d0e35df16f118011 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/bluetooth')
-rw-r--r--src/bluetooth/qlowenergycontroller_bluezdbus.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
index 5dde8774..d69fb6cd 100644
--- a/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
+++ b/src/bluetooth/qlowenergycontroller_bluezdbus.cpp
@@ -851,7 +851,7 @@ void QLowEnergyControllerPrivateBluezDBus::onCharWriteFinished(QDBusPendingCallW
updateValueOfCharacteristic(nextJob.handle, nextJob.value, false);
QLowEnergyCharacteristic ch(service, nextJob.handle);
- // write without respone implies zero feedback
+ // write without response implies zero feedback
if (nextJob.writeMode == QLowEnergyService::WriteWithResponse) {
qCDebug(QT_BT_BLUEZ) << "Written Char:" << charData.uuid << nextJob.value.toHex();
emit service->characteristicWritten(ch, nextJob.value);
@@ -971,7 +971,12 @@ void QLowEnergyControllerPrivateBluezDBus::scheduleNextJob()
if (charData.uuid != QBluetoothUuid(gattChar.characteristic->uUID()))
continue;
- QDBusPendingReply<> reply = gattChar.characteristic->WriteValue(nextJob.value, QVariantMap());
+ QVariantMap options;
+ // The "type" option only works with BlueZ >= 5.50, older versions always write with response
+ options[QStringLiteral("type")] = nextJob.writeMode == QLowEnergyService::WriteWithoutResponse ?
+ QStringLiteral("command") : QStringLiteral("request");
+ QDBusPendingReply<> reply = gattChar.characteristic->WriteValue(nextJob.value, options);
+
QDBusPendingCallWatcher* watcher = new QDBusPendingCallWatcher(reply, this);
connect(watcher, &QDBusPendingCallWatcher::finished,
this, &QLowEnergyControllerPrivateBluezDBus::onCharWriteFinished);