From c24cf9e04a6e28baaabc4e4561db85eb311b25bf Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 18 Jul 2018 14:40:09 +0200 Subject: winrt: Only emit characteristicWritten if WriteWithResponse was set Winrt API does not distinguish, whether the gatt write was done with or without response but always runs into the callback while doing "the right thing" on a lower level. If WriteWithResponse was not specified, we should not emit characteristicWritten though. Change-Id: I4479296d2931635f6f9d0eb52eed78b394a43d66 Reviewed-by: Andy Shaw Reviewed-by: Alex Blasche --- src/bluetooth/qlowenergycontroller_winrt.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bluetooth/qlowenergycontroller_winrt.cpp b/src/bluetooth/qlowenergycontroller_winrt.cpp index 628f1195..917f3790 100644 --- a/src/bluetooth/qlowenergycontroller_winrt.cpp +++ b/src/bluetooth/qlowenergycontroller_winrt.cpp @@ -937,7 +937,7 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(const QSharedPointer< GattWriteOption option = writeWithResponse ? GattWriteOption_WriteWithResponse : GattWriteOption_WriteWithoutResponse; hr = characteristic->WriteValueWithOptionAsync(buffer.Get(), option, &writeOp); Q_ASSERT_SUCCEEDED(hr); - auto writeCompletedLambda =[charData, charHandle, newValue, service, this] + auto writeCompletedLambda =[charData, charHandle, newValue, service, writeWithResponse, this] (IAsyncOperation *op, AsyncStatus status) { if (status == AsyncStatus::Canceled || status == AsyncStatus::Error) { @@ -963,7 +963,8 @@ void QLowEnergyControllerPrivateWinRT::writeCharacteristic(const QSharedPointer< // empty. if (charData.properties & QLowEnergyCharacteristic::Read) updateValueOfCharacteristic(charHandle, newValue, false); - emit service->characteristicWritten(QLowEnergyCharacteristic(service, charHandle), newValue); + if (writeWithResponse) + emit service->characteristicWritten(QLowEnergyCharacteristic(service, charHandle), newValue); return S_OK; }; hr = writeOp->put_Completed(Callback>(writeCompletedLambda).Get()); -- cgit v1.2.3