summaryrefslogtreecommitdiffstats
path: root/examples/bluetooth/lowenergyscanner
diff options
context:
space:
mode:
Diffstat (limited to 'examples/bluetooth/lowenergyscanner')
-rw-r--r--examples/bluetooth/lowenergyscanner/assets/Services.qml10
-rw-r--r--examples/bluetooth/lowenergyscanner/device.cpp17
-rw-r--r--examples/bluetooth/lowenergyscanner/device.h2
3 files changed, 28 insertions, 1 deletions
diff --git a/examples/bluetooth/lowenergyscanner/assets/Services.qml b/examples/bluetooth/lowenergyscanner/assets/Services.qml
index e4e802d2..a433d445 100644
--- a/examples/bluetooth/lowenergyscanner/assets/Services.qml
+++ b/examples/bluetooth/lowenergyscanner/assets/Services.qml
@@ -45,6 +45,16 @@ Rectangle {
width: 300
height: 600
+ Component.onCompleted: {
+ // Loading this page may take longer than QLEController
+ // stopping with an error, go back and readjust this view
+ // based on controller errors
+ if (device.controllerError) {
+ info.visible = false;
+ menu.menuText = device.update
+ }
+ }
+
Header {
id: header
anchors.top: parent.top
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;
diff --git a/examples/bluetooth/lowenergyscanner/device.h b/examples/bluetooth/lowenergyscanner/device.h
index 09b32599..049d1c61 100644
--- a/examples/bluetooth/lowenergyscanner/device.h
+++ b/examples/bluetooth/lowenergyscanner/device.h
@@ -66,6 +66,7 @@ class Device: public QObject
Q_PROPERTY(QString update READ getUpdate NOTIFY updateChanged)
Q_PROPERTY(bool useRandomAddress READ isRandomAddress WRITE setRandomAddress NOTIFY randomAddressChanged)
Q_PROPERTY(bool state READ state NOTIFY stateChanged)
+ Q_PROPERTY(bool controllerError READ hasControllerError)
public:
Device();
~Device();
@@ -74,6 +75,7 @@ public:
QVariant getCharacteristics();
QString getUpdate();
bool state();
+ bool hasControllerError() const;
bool isRandomAddress() const;
void setRandomAddress(bool newValue);