summaryrefslogtreecommitdiffstats
path: root/tradeshow
diff options
context:
space:
mode:
Diffstat (limited to 'tradeshow')
-rw-r--r--tradeshow/iot-sensortag/bluetoothdataprovider.cpp5
-rw-r--r--tradeshow/iot-sensortag/bluetoothdataprovider.h1
-rw-r--r--tradeshow/iot-sensortag/bluetoothdevice.cpp25
-rw-r--r--tradeshow/iot-sensortag/bluetoothdevice.h1
4 files changed, 22 insertions, 10 deletions
diff --git a/tradeshow/iot-sensortag/bluetoothdataprovider.cpp b/tradeshow/iot-sensortag/bluetoothdataprovider.cpp
index 0987d0d..06e9fd5 100644
--- a/tradeshow/iot-sensortag/bluetoothdataprovider.cpp
+++ b/tradeshow/iot-sensortag/bluetoothdataprovider.cpp
@@ -93,10 +93,7 @@ bool BluetoothDataProvider::startDataFetching()
this, &BluetoothDataProvider::lightIntensityReceived);
connect(m_btDevice, &BluetoothDevice::motionChanged,
this, &BluetoothDataProvider::motionReceived);
- timer.setInterval(1000);
- timer.setSingleShot(true);
- connect(&timer, &QTimer::timeout, this, &BluetoothDataProvider::startServiceScan);
- timer.start();
+ startServiceScan();
}
return true;
}
diff --git a/tradeshow/iot-sensortag/bluetoothdataprovider.h b/tradeshow/iot-sensortag/bluetoothdataprovider.h
index 691b94c..5f39b4f 100644
--- a/tradeshow/iot-sensortag/bluetoothdataprovider.h
+++ b/tradeshow/iot-sensortag/bluetoothdataprovider.h
@@ -90,7 +90,6 @@ private:
void updateState();
float countRotationDegrees(double degreesPerSecond, quint64 milliseconds);
BluetoothDevice *m_btDevice;
- QTimer timer;
int m_smaSamples;
int m_zeroAltitudeSamples;
float gyroscopeX_calibration;
diff --git a/tradeshow/iot-sensortag/bluetoothdevice.cpp b/tradeshow/iot-sensortag/bluetoothdevice.cpp
index 667e7a2..f2d3881 100644
--- a/tradeshow/iot-sensortag/bluetoothdevice.cpp
+++ b/tradeshow/iot-sensortag/bluetoothdevice.cpp
@@ -267,7 +267,7 @@ void BluetoothDevice::temperatureDetailsDiscovered(QLowEnergyService::ServiceSta
}
m_temperatureMeasurementStarted = true;
- m_serviceDetailsTimer->start();
+ updateServiceDetails();
}
}
@@ -306,7 +306,7 @@ void BluetoothDevice::barometerDetailsDiscovered(QLowEnergyService::ServiceState
}
m_barometerMeasurementStarted = true;
- m_serviceDetailsTimer->start();
+ updateServiceDetails();
}
}
@@ -346,7 +346,7 @@ void BluetoothDevice::humidityDetailsDiscovered(QLowEnergyService::ServiceState
}
m_humidityMeasurementStarted = true;
- m_serviceDetailsTimer->start();
+ updateServiceDetails();
}
}
@@ -386,7 +386,7 @@ void BluetoothDevice::lightIntensityDetailsDiscovered(QLowEnergyService::Service
}
m_lightIntensityMeasurementStarted = true;
- m_serviceDetailsTimer->start();
+ updateServiceDetails();
}
}
@@ -428,7 +428,7 @@ void BluetoothDevice::motionDetailsDiscovered(QLowEnergyService::ServiceState ne
m_motionService->writeCharacteristic(characteristic, QByteArray::fromHex(SENSORTAG_RAPID_TIMER_TIMEOUT_STR), QLowEnergyService::WriteWithResponse);
}
m_motionMeasurementStarted = true;
- m_serviceDetailsTimer->start();
+ updateServiceDetails();
}
}
@@ -486,6 +486,21 @@ bool BluetoothDevice::isDeviceReady() const
return false;
}
+void BluetoothDevice::updateServiceDetails()
+{
+ if (m_temperatureMeasurementStarted
+ && m_barometerMeasurementStarted
+ && m_humidityMeasurementStarted
+ && m_lightIntensityMeasurementStarted
+ && m_motionMeasurementStarted) {
+ qCDebug(boot2QtDemos) << "Service details timer stop. All service details found";
+ m_serviceDetailsTimer->stop();
+ setState(Connected);
+ } else {
+ m_serviceDetailsTimer->start();
+ }
+}
+
void BluetoothDevice::irTemperatureReceived(const QByteArray &value)
{
const unsigned int rawObjectTemperature = (((quint8)value.at(3)) << 8) + ((quint8)value.at(2));
diff --git a/tradeshow/iot-sensortag/bluetoothdevice.h b/tradeshow/iot-sensortag/bluetoothdevice.h
index 6a75a67..ed74866 100644
--- a/tradeshow/iot-sensortag/bluetoothdevice.h
+++ b/tradeshow/iot-sensortag/bluetoothdevice.h
@@ -167,6 +167,7 @@ private:
void motionReceived(const QByteArray &value);
double convertIrTemperatureAPIReadingToCelsius(quint16 rawReading);
bool isDeviceReady() const;
+ void updateServiceDetails();
QLowEnergyController *m_controller;
QLowEnergyService* m_irTemperatureService;