diff --git a/flowercare/flowercare.cpp b/flowercare/flowercare.cpp index 7e51b328..954633ea 100644 --- a/flowercare/flowercare.cpp +++ b/flowercare/flowercare.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -89,7 +89,11 @@ void FlowerCare::onSensorServiceStateChanged(const QLowEnergyService::ServiceSta } QByteArray value = batteryFirmwareCharacteristic.value(); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&value, QDataStream::ReadOnly); +#else QDataStream stream(&value, QIODevice::ReadOnly); +#endif stream.setByteOrder(QDataStream::LittleEndian); stream >> m_batteryLevel; @@ -110,7 +114,11 @@ void FlowerCare::onSensorServiceStateChanged(const QLowEnergyService::ServiceSta } // Enable notifications +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QLowEnergyDescriptor notificationDescriptor = m_sensorDataCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration); +#else QLowEnergyDescriptor notificationDescriptor = m_sensorDataCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); +#endif m_sensorService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); // Read the data manually @@ -122,7 +130,11 @@ void FlowerCare::onSensorServiceStateChanged(const QLowEnergyService::ServiceSta void FlowerCare::onSensorServiceCharacteristicRead(const QLowEnergyCharacteristic &characteristic, const QByteArray &value) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qCDebug(dcFlowerCare()) << "Characteristic read" << characteristic.uuid().toString() << value.toHex(); +#else qCDebug(dcFlowerCare()) << "Characteristic read" << QString::number(characteristic.handle(), 16) << value.toHex(); +#endif if (characteristic != m_sensorDataCharacteristic) { return; } @@ -131,7 +143,11 @@ void FlowerCare::onSensorServiceCharacteristicRead(const QLowEnergyCharacteristi void FlowerCare::onSensorServiceCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qCDebug(dcFlowerCare()) << "Notification received" << characteristic.uuid().toString() << value.toHex(); +#else qCDebug(dcFlowerCare()) << "Notification received" << QString::number(characteristic.handle(), 16) << value.toHex(); +#endif if (characteristic != m_sensorDataCharacteristic) { return; } @@ -142,9 +158,17 @@ void FlowerCare::onSensorServiceCharacteristicChanged(const QLowEnergyCharacteri void FlowerCare::printServiceDetails(QLowEnergyService *service) const { foreach (const QLowEnergyCharacteristic &characteristic, service->characteristics()) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qCDebug(dcFlowerCare()).nospace() << "C: --> " << characteristic.uuid().toString() << " (" << " Name: " << characteristic.name() << "): " << characteristic.value() << ", " << characteristic.value().toHex(); +#else qCDebug(dcFlowerCare()).nospace() << "C: --> " << characteristic.uuid().toString() << " (" << characteristic.handle() << " Name: " << characteristic.name() << "): " << characteristic.value() << ", " << characteristic.value().toHex(); +#endif foreach (const QLowEnergyDescriptor &descriptor, characteristic.descriptors()) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + qCDebug(dcFlowerCare()).nospace() << "D: --> " << descriptor.uuid().toString() << " (" << " Name: " << descriptor.name() << "): " << descriptor.value() << ", " << descriptor.value().toHex(); +#else qCDebug(dcFlowerCare()).nospace() << "D: --> " << descriptor.uuid().toString() << " (" << descriptor.handle() << " Name: " << descriptor.name() << "): " << descriptor.value() << ", " << descriptor.value().toHex(); +#endif } } } @@ -152,7 +176,11 @@ void FlowerCare::printServiceDetails(QLowEnergyService *service) const void FlowerCare::processSensorData(const QByteArray &data) { QByteArray copy = data; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(©, QDataStream::ReadOnly); +#else QDataStream stream(©, QIODevice::ReadOnly); +#endif stream.setByteOrder(QDataStream::LittleEndian); qint16 temp; stream >> temp; diff --git a/flowercare/flowercare.h b/flowercare/flowercare.h index 2652fa1a..e4c1ec26 100644 --- a/flowercare/flowercare.h +++ b/flowercare/flowercare.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -33,7 +33,7 @@ #include -#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" +#include static QBluetoothUuid sensorServiceUuid = QBluetoothUuid(QUuid("00001204-0000-1000-8000-00805f9b34fb")); diff --git a/flowercare/flowercare.pro b/flowercare/flowercare.pro index da4459f9..8ca79bdd 100644 --- a/flowercare/flowercare.pro +++ b/flowercare/flowercare.pro @@ -1,8 +1,6 @@ include(../plugins.pri) -QT += bluetooth - -TARGET = $$qtLibraryTarget(nymea_integrationpluginflowercare) +QT *= bluetooth SOURCES += \ integrationpluginflowercare.cpp \ diff --git a/flowercare/integrationpluginflowercare.cpp b/flowercare/integrationpluginflowercare.cpp index 4f9c1271..46757251 100644 --- a/flowercare/integrationpluginflowercare.cpp +++ b/flowercare/integrationpluginflowercare.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -37,8 +37,10 @@ * {0000fe95-0000-1000-8000-00805f9b34fb} * {0000fef5-0000-1000-8000-00805f9b34fb} */ + +#include + #include "plugininfo.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h" #include "integrationpluginflowercare.h" #include "flowercare.h" diff --git a/flowercare/integrationpluginflowercare.h b/flowercare/integrationpluginflowercare.h index 96184d83..589f909e 100644 --- a/flowercare/integrationpluginflowercare.h +++ b/flowercare/integrationpluginflowercare.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -31,12 +31,12 @@ #ifndef INTEGRATIONPLUGINFLOWERCARE_H #define INTEGRATIONPLUGINFLOWERCARE_H +#include +#include +#include #include #include -#include "integrations/integrationplugin.h" -#include "plugintimer.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" class FlowerCare;