diff options
-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; |