diff options
Diffstat (limited to 'examples/bluetooth/heartrate-game/devicehandler.cpp')
-rw-r--r-- | examples/bluetooth/heartrate-game/devicehandler.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/examples/bluetooth/heartrate-game/devicehandler.cpp b/examples/bluetooth/heartrate-game/devicehandler.cpp index 3bbadd7e..83a4fbbe 100644 --- a/examples/bluetooth/heartrate-game/devicehandler.cpp +++ b/examples/bluetooth/heartrate-game/devicehandler.cpp @@ -56,9 +56,6 @@ DeviceHandler::DeviceHandler(QObject *parent) : BluetoothBaseClass(parent), - m_control(0), - m_service(0), - m_currentDevice(0), m_foundHeartRateService(false), m_measuring(false), m_currentValue(0), @@ -107,7 +104,7 @@ void DeviceHandler::setDevice(DeviceInfo *device) if (m_control) { m_control->disconnectFromDevice(); delete m_control; - m_control = 0; + m_control = nullptr; } // Create new controller and connect it if device available @@ -181,7 +178,7 @@ void DeviceHandler::serviceScanDone() // Delete old service if available if (m_service) { delete m_service; - m_service = 0; + m_service = nullptr; } //! [Filter HeartRate service 2] @@ -240,15 +237,15 @@ void DeviceHandler::updateHeartRateValue(const QLowEnergyCharacteristic &c, cons if (c.uuid() != QBluetoothUuid(QBluetoothUuid::HeartRateMeasurement)) return; - const quint8 *data = reinterpret_cast<const quint8 *>(value.constData()); - quint8 flags = data[0]; + auto data = reinterpret_cast<const quint8 *>(value.constData()); + quint8 flags = *data; //Heart Rate int hrvalue = 0; if (flags & 0x1) // HR 16 bit? otherwise 8 bit - hrvalue = (int)qFromLittleEndian<quint16>(data[1]); + hrvalue = static_cast<int>(qFromLittleEndian<quint16>(data[1])); else - hrvalue = (int)data[1]; + hrvalue = static_cast<int>(data[1]); addMeasurement(hrvalue); } @@ -276,7 +273,7 @@ void DeviceHandler::confirmedDescriptorWrite(const QLowEnergyDescriptor &d, cons //disabled notifications -> assume disconnect intent m_control->disconnectFromDevice(); delete m_service; - m_service = 0; + m_service = nullptr; } } @@ -293,7 +290,7 @@ void DeviceHandler::disconnectService() m_control->disconnectFromDevice(); delete m_service; - m_service = 0; + m_service = nullptr; } } |