diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2018-07-18 14:40:09 +0200 |
---|---|---|
committer | Oliver Wolff <oliver.wolff@qt.io> | 2018-07-18 13:34:10 +0000 |
commit | c24cf9e04a6e28baaabc4e4561db85eb311b25bf (patch) | |
tree | 33ff18f35c23410964b29869fee2856c95b435ce | |
parent | 0df6eb94d989246dd0516a474266b9f562fca2f3 (diff) |
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 <andy.shaw@qt.io>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r-- | src/bluetooth/qlowenergycontroller_winrt.cpp | 5 |
1 files 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<GattCommunicationStatus> *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<IAsyncOperationCompletedHandler<GattCommunicationStatus>>(writeCompletedLambda).Get()); |