diff options
author | Oliver Wolff <oliver.wolff@qt.io> | 2017-02-15 09:23:38 +0100 |
---|---|---|
committer | Kari Hautamäki <kari.hautamaki@qt.io> | 2017-02-15 08:28:21 +0000 |
commit | 973ba6d609c25011b937cb045aab891e13708ba6 (patch) | |
tree | ffd04fbc81815b27063e9b779ed6cef6e7f83415 /tradeshow | |
parent | 9c8d67cb260fae6504703afe3f24551f8733f31c (diff) |
iot-sensortag: "Fix" isDeviceReady
The name suggests a const function so we either have to come up
with a new name that describes the current functionality or
move the state change out of the function. Decided for the latter.
Change-Id: Ifab2689b8a3ec054222f40708e1eb2d1576a6a08
Reviewed-by: Kari Hautamäki <kari.hautamaki@qt.io>
Diffstat (limited to 'tradeshow')
-rw-r--r-- | tradeshow/iot-sensortag/bluetoothdevice.cpp | 26 | ||||
-rw-r--r-- | tradeshow/iot-sensortag/bluetoothdevice.h | 2 |
2 files changed, 16 insertions, 12 deletions
diff --git a/tradeshow/iot-sensortag/bluetoothdevice.cpp b/tradeshow/iot-sensortag/bluetoothdevice.cpp index 7be53d7..b44afab 100644 --- a/tradeshow/iot-sensortag/bluetoothdevice.cpp +++ b/tradeshow/iot-sensortag/bluetoothdevice.cpp @@ -263,7 +263,8 @@ void BluetoothDevice::temperatureDetailsDiscovered(QLowEnergyService::ServiceSta } m_temperatureMeasurementStarted = true; - isDeviceReady(); + if (isDeviceReady()) + setState(DeviceState::Connected); } } @@ -302,7 +303,8 @@ void BluetoothDevice::barometerDetailsDiscovered(QLowEnergyService::ServiceState } m_barometerMeasurementStarted = true; - isDeviceReady(); + if (isDeviceReady()) + setState(DeviceState::Connected); } } @@ -342,7 +344,8 @@ void BluetoothDevice::humidityDetailsDiscovered(QLowEnergyService::ServiceState } m_humidityMeasurementStarted = true; - isDeviceReady(); + if (isDeviceReady()) + setState(DeviceState::Connected); } } @@ -382,7 +385,8 @@ void BluetoothDevice::lightIntensityDetailsDiscovered(QLowEnergyService::Service } m_lightIntensityMeasurementStarted = true; - isDeviceReady(); + if (isDeviceReady()) + setState(DeviceState::Connected); } } @@ -424,7 +428,8 @@ void BluetoothDevice::motionDetailsDiscovered(QLowEnergyService::ServiceState ne motionService->writeCharacteristic(characteristic, QByteArray::fromHex(SENSORTAG_RAPID_TIMER_TIMEOUT_STR), QLowEnergyService::WriteWithResponse); } m_motionMeasurementStarted = true; - isDeviceReady(); + if (isDeviceReady()) + setState(DeviceState::Connected); } } @@ -470,13 +475,12 @@ double BluetoothDevice::convertIrTemperatureAPIReadingToCelsius(quint16 rawReadi return t * SCALE_LSB; } -void BluetoothDevice::isDeviceReady() +bool BluetoothDevice::isDeviceReady() const { - if (m_temperatureMeasurementStarted && - m_humidityMeasurementStarted && - m_lightIntensityMeasurementStarted && - m_motionMeasurementStarted) - setState(DeviceState::Connected); + return m_temperatureMeasurementStarted + && m_humidityMeasurementStarted + && m_lightIntensityMeasurementStarted + && m_motionMeasurementStarted; } void BluetoothDevice::irTemperatureReceived(const QByteArray &value) diff --git a/tradeshow/iot-sensortag/bluetoothdevice.h b/tradeshow/iot-sensortag/bluetoothdevice.h index 0c9ac1d..e6137e8 100644 --- a/tradeshow/iot-sensortag/bluetoothdevice.h +++ b/tradeshow/iot-sensortag/bluetoothdevice.h @@ -169,7 +169,7 @@ private: void lightIntensityReceived(const QByteArray &value); void motionReceived(const QByteArray &value); double convertIrTemperatureAPIReadingToCelsius(quint16 rawReading); - void isDeviceReady(); + bool isDeviceReady() const; QBluetoothDeviceDiscoveryAgent *discoveryAgent; QString m_previousAddress; |