summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/lowenergyscanner/device.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/bluetooth/lowenergyscanner/device.cpp')
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/examples/bluetooth/lowenergyscanner/device.cpp b/examples/bluetooth/lowenergyscanner/device.cpp
index acab48c2..b8d61fe3 100644
--- a/examples/bluetooth/lowenergyscanner/device.cpp
+++ b/examples/bluetooth/lowenergyscanner/device.cpp
@@ -268,7 +268,15 @@ void Device::setUpdate(QString message)
void Device::disconnectFromDevice()
{
- controller->disconnectFromDevice();
+ // UI always expects disconnect() signal when calling this signal
+ // TODO what is really needed is to extend state() to a multi value
+ // and thus allowing UI to keep track of controller progress in addition to
+ // device scan progress
+
+ if (controller->state() != QLowEnergyController::UnconnectedState)
+ controller->disconnectFromDevice();
+ else
+ deviceDisconnected();
}
void Device::deviceDisconnected()
@@ -316,6 +324,13 @@ bool Device::state()
return m_deviceScanState;
}
+bool Device::hasControllerError() const
+{
+ if (controller && controller->error() != QLowEnergyController::NoError)
+ return true;
+ return false;
+}
+
bool Device::isRandomAddress() const
{
return randomAddress;