summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Wolff <oliver.wolff@qt.io>2017-07-07 13:15:51 +0200
committerOliver Wolff <oliver.wolff@qt.io>2017-08-02 05:56:17 +0000
commitaeeae7bc92f19778a73fb10a09b8949b2c384d39 (patch)
tree8a1b17552f1b70aa3832a0b9c7d1ebe9c09075b5
parent4849c1e95bb9521d08a7f8589c16c3b5849a7712 (diff)
winrt: Ensure that QLowEnergyController::RemoteHostClosedError is emitted
As there is no Windows API to disconnect from a BTLE device, we just set the internal state in QLowEnergyController::disconnectFromDevice. By removing the callback registration in disconnectFromDevice we can be sure, that every state change from connected to disconnected is caused by the remote host closing the connection and thus implement RemoteHostClosedError. Change-Id: I7dcacaffce68784cb297b02df2e9f9356bf14d9d Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r--src/bluetooth/qlowenergycontroller_winrt.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/bluetooth/qlowenergycontroller_winrt.cpp b/src/bluetooth/qlowenergycontroller_winrt.cpp
index d6fc4952..8d3d85d8 100644
--- a/src/bluetooth/qlowenergycontroller_winrt.cpp
+++ b/src/bluetooth/qlowenergycontroller_winrt.cpp
@@ -338,6 +338,7 @@ void QLowEnergyControllerPrivate::connectToDevice()
emit q->connected();
} else if (state == QLowEnergyController::ConnectedState
&& status == BluetoothConnectionStatus::BluetoothConnectionStatus_Disconnected) {
+ setError(QLowEnergyController::RemoteHostClosedError);
setState(QLowEnergyController::UnconnectedState);
emit q->disconnected();
}
@@ -419,6 +420,10 @@ void QLowEnergyControllerPrivate::disconnectFromDevice()
Q_Q(QLowEnergyController);
setState(QLowEnergyController::UnconnectedState);
emit q->disconnected();
+ if (mDevice && mStatusChangedToken.value) {
+ mDevice->remove_ConnectionStatusChanged(mStatusChangedToken);
+ mStatusChangedToken.value = 0;
+ }
}
ComPtr<IGattDeviceService> QLowEnergyControllerPrivate::getNativeService(const QBluetoothUuid &serviceUuid)