summaryrefslogtreecommitdiffstats
path: root/tradeshow/iot-sensortag/resources/small/MainSmall.qml
diff options
context:
space:
mode:
authorKari Hautamäki <kari.hautamaki@qt.io>2017-02-16 08:33:49 +0200
committerMaurice Kalinowski <maurice.kalinowski@qt.io>2017-02-28 13:16:09 +0000
commit35c1c07cd676b9c9afb23ad7266a67d5b6aef03a (patch)
treed43445955be5f1799ca9bb9db2c6e2cfd7915370 /tradeshow/iot-sensortag/resources/small/MainSmall.qml
parentdec3883a1d0d7d24c797cf517fa7fad85b24a1f2 (diff)
iot-sensortag: Allow reconnect after a failed connection attempt
A disconnected sensor tag can be tried to be reconnected by clicking on the chart area or starting rescan from the Sensor settings menu. During a (re)connection process a progress indicator is shown to the user. The user has a possibility to disconnect (and reconnect) a currently connect SensorDataProvider A new state, 'NotFound' is added in SensorTagDataProvider to distinguish between states when a Sensor Tag has not been discovered at all, and when it has already been discovered but is has been disconnected. Change-Id: I54eea72d8c92a67a5ccbb3bc192ac8f33ada1c39 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'tradeshow/iot-sensortag/resources/small/MainSmall.qml')
-rw-r--r--tradeshow/iot-sensortag/resources/small/MainSmall.qml47
1 files changed, 30 insertions, 17 deletions
diff --git a/tradeshow/iot-sensortag/resources/small/MainSmall.qml b/tradeshow/iot-sensortag/resources/small/MainSmall.qml
index df4a868..83835e3 100644
--- a/tradeshow/iot-sensortag/resources/small/MainSmall.qml
+++ b/tradeshow/iot-sensortag/resources/small/MainSmall.qml
@@ -54,25 +54,31 @@ import "../base"
Item {
id: main
+ function startRescan(sensor) {
+ if (sensor.state === SensorTagData.NotFound)
+ dataProviderPool.startScanning();
+ else if (sensor.state === SensorTagData.Scanning)
+ dataProviderPool.disconnectProvider(sensor.providerId)
+ else if (sensor.state !== SensorTagData.Connected)
+ sensor.startServiceScan();
+ }
+
anchors.fill: parent
Component.onCompleted: {
- dataProviderPool.startScanning()
- }
-
- Connections {
- target: dataProviderPool
- onScanFinished: {
- ambientTemp.sensor = dataProviderPool.getProvider(SensorTagData.AmbientTemperature);
- objectTemp.sensor = dataProviderPool.getProvider(SensorTagData.ObjectTemperature);
- humidity.sensor = dataProviderPool.getProvider(SensorTagData.Humidity);
- airPressure.sensor = dataProviderPool.getProvider(SensorTagData.AirPressure);
- light.sensor = dataProviderPool.getProvider(SensorTagData.Light);
- magnetometer.sensor = dataProviderPool.getProvider(SensorTagData.Magnetometer);
- rotation.sensor = dataProviderPool.getProvider(SensorTagData.Rotation);
- accelometer.sensor = dataProviderPool.getProvider(SensorTagData.Accelometer);
- rotationMain.sensor = dataProviderPool.getProvider(SensorTagData.Rotation);
- }
+ dataProviderPool.startScanning();
+
+ // UI gets information about the intended setup of the
+ // sensor even though they have not been really discovered yet
+ ambientTemp.sensor = dataProviderPool.getProvider(SensorTagData.AmbientTemperature);
+ objectTemp.sensor = dataProviderPool.getProvider(SensorTagData.ObjectTemperature);
+ humidity.sensor = dataProviderPool.getProvider(SensorTagData.Humidity);
+ airPressure.sensor = dataProviderPool.getProvider(SensorTagData.AirPressure);
+ light.sensor = dataProviderPool.getProvider(SensorTagData.Light);
+ magnetometer.sensor = dataProviderPool.getProvider(SensorTagData.Magnetometer);
+ rotation.sensor = dataProviderPool.getProvider(SensorTagData.Rotation);
+ accelometer.sensor = dataProviderPool.getProvider(SensorTagData.Accelometer);
+ rotationMain.sensor = dataProviderPool.getProvider(SensorTagData.Rotation);
}
Column {
@@ -92,6 +98,7 @@ Item {
width: leftPane.width
height: leftPane.indicatorHeight
+ onClicked: main.startRescan(sensor)
}
ObjectTemperatureChart {
@@ -99,6 +106,7 @@ Item {
width: leftPane.width
height: leftPane.indicatorHeight
+ onClicked: main.startRescan(sensor)
}
HumidityChart {
@@ -106,6 +114,7 @@ Item {
width: leftPane.width
height: leftPane.indicatorHeight
+ onClicked: main.startRescan(sensor)
}
AltitudeChart {
@@ -113,6 +122,7 @@ Item {
width: leftPane.width
height: leftPane.indicatorHeight
+ onClicked: main.startRescan(sensor)
}
}
@@ -131,6 +141,7 @@ Item {
width: rightPane.width
height: rightPane.height / 4
+ onClicked: main.startRescan(sensor)
}
MagnetometerChart {
@@ -138,6 +149,7 @@ Item {
width: rightPane.width
height: rightPane.height * 0.3 - 30
+ onClicked: main.startRescan(sensor)
}
GyroChart {
@@ -145,6 +157,7 @@ Item {
width: rightPane.width
height: rightPane.height * 0.3 - 60
+ onClicked: main.startRescan(sensor)
}
AccelChart {
@@ -152,6 +165,7 @@ Item {
width: rightPane.width
height: rightPane.height - light.height - magnetometer.height - rotation.height - 3 * rightPane.spacing
+ onClicked: main.startRescan(sensor)
}
}
@@ -167,7 +181,6 @@ Item {
onSensorChanged: if (sensor) sensor.recalibrate()
}
-
TopToolbar {
id: topToolbar