From da1d8158940fb831c9114b0c33edbb1bbb76b456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 8 Aug 2025 10:02:28 +0200 Subject: [PATCH] eq-3: Add Qt6 support --- eq-3/eq-3.pro | 20 ++++++++-------- eq-3/eqivabluetooth.cpp | 42 ++++++++++++++++++++++++++++++---- eq-3/eqivabluetooth.h | 6 ++--- eq-3/integrationplugineq-3.cpp | 18 +++++++++------ eq-3/integrationplugineq-3.h | 13 ++++++----- eq-3/maxcube.cpp | 17 ++++++++------ eq-3/maxcube.h | 14 ++++++------ eq-3/maxcubediscovery.cpp | 4 ++-- eq-3/maxcubediscovery.h | 10 ++++---- eq-3/maxdevice.h | 8 +------ eq-3/radiatorthermostat.h | 6 +---- eq-3/room.h | 6 ----- 12 files changed, 92 insertions(+), 72 deletions(-) diff --git a/eq-3/eq-3.pro b/eq-3/eq-3.pro index 3e44bb00..5e266379 100644 --- a/eq-3/eq-3.pro +++ b/eq-3/eq-3.pro @@ -1,24 +1,22 @@ include(../plugins.pri) -QT += network bluetooth - -TARGET = $$qtLibraryTarget(nymea_integrationplugineq-3) +QT *= network bluetooth SOURCES += \ - integrationplugineq-3.cpp \ - maxcubediscovery.cpp \ - maxcube.cpp \ - maxdevice.cpp \ + integrationplugineq-3.cpp \ + maxcubediscovery.cpp \ + maxcube.cpp \ + maxdevice.cpp \ room.cpp \ wallthermostat.cpp \ radiatorthermostat.cpp \ eqivabluetooth.cpp HEADERS += \ - integrationplugineq-3.h \ - maxcubediscovery.h \ - maxcube.h \ - maxdevice.h \ + integrationplugineq-3.h \ + maxcubediscovery.h \ + maxcube.h \ + maxdevice.h \ room.h \ wallthermostat.h \ radiatorthermostat.h \ diff --git a/eq-3/eqivabluetooth.cpp b/eq-3/eqivabluetooth.cpp index e84c0ac6..e600d962 100644 --- a/eq-3/eqivabluetooth.cpp +++ b/eq-3/eqivabluetooth.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. @@ -166,7 +166,11 @@ bool EqivaBluetooth::locked() const int EqivaBluetooth::setLocked(bool locked) { QByteArray data; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&data, QDataStream::WriteOnly); +#else QDataStream stream(&data, QIODevice::WriteOnly); +#endif stream << commandLock; stream << (locked ? valueOn : valueOff); return enqueue("SetLocked", data); @@ -180,7 +184,11 @@ bool EqivaBluetooth::boostEnabled() const int EqivaBluetooth::setBoostEnabled(bool enabled) { QByteArray data; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&data, QDataStream::WriteOnly); +#else QDataStream stream(&data, QIODevice::WriteOnly); +#endif stream << commandBoost; stream << (enabled ? valueOn : valueOff); return enqueue("SetBoostEnabled", data); @@ -194,7 +202,11 @@ qreal EqivaBluetooth::targetTemperature() const int EqivaBluetooth::setTargetTemperature(qreal targetTemperature) { QByteArray data; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&data, QDataStream::WriteOnly); +#else QDataStream stream(&data, QIODevice::WriteOnly); +#endif stream << commandSetTemp; if (targetTemperature == 4.5) { stream << static_cast(4.5 * 2); // 4.5 degrees is off @@ -211,8 +223,12 @@ EqivaBluetooth::Mode EqivaBluetooth::mode() const int EqivaBluetooth::setMode(EqivaBluetooth::Mode mode) { - QByteArray data; + QByteArray data; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&data, QDataStream::WriteOnly); +#else QDataStream stream(&data, QIODevice::WriteOnly); +#endif stream << commandSetMode; switch (mode) { case ModeAuto: @@ -259,7 +275,7 @@ void EqivaBluetooth::controllerStateChanged(const QLowEnergyController::Controll if (state == QLowEnergyController::UnconnectedState) { int delay = qMin(m_reconnectAttempt, 30); - qWarning(dcEQ3()) << m_name << "Eqiva thing disconnected. Reconnecting in" << delay << "sec"; + qCWarning(dcEQ3()) << m_name << "Eqiva thing disconnected. Reconnecting in" << delay << "sec"; m_available = false; emit availableChanged(); @@ -312,7 +328,11 @@ void EqivaBluetooth::controllerStateChanged(const QLowEnergyController::Controll qCDebug(dcEQ3()) << m_name << "Characteristic read:" << info.name() << info.uuid() << value.toHex(); QByteArray data(value); - QDataStream stream(&data, QIODevice::ReadOnly); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&data, QDataStream::WriteOnly); +#else + QDataStream stream(&data, QIODevice::WriteOnly); +#endif quint8 header; stream >> header; quint8 notificationType; @@ -371,7 +391,11 @@ void EqivaBluetooth::serviceStateChanged(QLowEnergyService::ServiceState newStat // Enable notifications QLowEnergyCharacteristic characteristic = m_eqivaService->characteristic(notificationCharacteristicUuid); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QLowEnergyDescriptor notificationDescriptor = characteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration); +#else QLowEnergyDescriptor notificationDescriptor = characteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); +#endif m_eqivaService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); } @@ -384,7 +408,11 @@ void EqivaBluetooth::characteristicChanged(const QLowEnergyCharacteristic &info, m_refreshTimer.start(); QByteArray data(value); - QDataStream stream(&data, QIODevice::ReadOnly); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&data, QDataStream::WriteOnly); +#else + QDataStream stream(&data, QIODevice::WriteOnly); +#endif quint8 header; stream >> header; if (header == notifyHeader) { @@ -470,7 +498,11 @@ void EqivaBluetooth::sendDate() QDateTime now = QDateTime::currentDateTime(); QByteArray data; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QDataStream stream(&data, QDataStream::WriteOnly); +#else QDataStream stream(&data, QIODevice::WriteOnly); +#endif stream << commandSetDate; stream << static_cast(now.date().year() - 2000); stream << static_cast(now.date().month()); diff --git a/eq-3/eqivabluetooth.h b/eq-3/eqivabluetooth.h index da458e91..c1b67356 100644 --- a/eq-3/eqivabluetooth.h +++ b/eq-3/eqivabluetooth.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/bluetoothlowenergymanager.h" +#include class EqivaBluetooth : public QObject @@ -145,7 +145,7 @@ private slots: void deviceDiscoveryDone(); signals: - void finished(const QList &results); + void finished(const QList &results); private: BluetoothLowEnergyManager *m_bluetoothManager = nullptr; diff --git a/eq-3/integrationplugineq-3.cpp b/eq-3/integrationplugineq-3.cpp index 84357963..8a5df228 100644 --- a/eq-3/integrationplugineq-3.cpp +++ b/eq-3/integrationplugineq-3.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. @@ -29,12 +29,14 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "integrationplugineq-3.h" - -#include "integrations/thing.h" -#include "types/param.h" -#include "plugininfo.h" - +#include "maxcubediscovery.h" #include "eqivabluetooth.h" +#include "plugininfo.h" +#include "maxcube.h" + +#include +#include +#include #include @@ -169,7 +171,9 @@ void IntegrationPluginEQ3::setupThing(ThingSetupInfo *info) qCDebug(dcEQ3) << "Setup thing" << thing->params(); if(thing->thingClassId() == cubeThingClassId){ - MaxCube *cube = new MaxCube(this,thing->paramValue(cubeThingSerialParamTypeId).toString(),QHostAddress(thing->paramValue(cubeThingHostParamTypeId).toString()),thing->paramValue(cubeThingPortParamTypeId).toInt()); + MaxCube *cube = new MaxCube(this, thing->paramValue(cubeThingSerialParamTypeId).toString(), + QHostAddress(thing->paramValue(cubeThingHostParamTypeId).toString()), + thing->paramValue(cubeThingPortParamTypeId).toInt()); m_cubes.insert(cube,thing); connect(cube, &MaxCube::cubeConnectionStatusChanged, this, &IntegrationPluginEQ3::cubeConnectionStatusChanged); diff --git a/eq-3/integrationplugineq-3.h b/eq-3/integrationplugineq-3.h index f1bdab49..40ce7da5 100644 --- a/eq-3/integrationplugineq-3.h +++ b/eq-3/integrationplugineq-3.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,13 +31,14 @@ #ifndef INTEGRATIONPLUGINEQ3_H #define INTEGRATIONPLUGINEQ3_H -#include "integrations/integrationplugin.h" -#include "maxcubediscovery.h" -#include "plugintimer.h" -#include "eqivabluetooth.h" +#include +#include #include +#include "eqivabluetooth.h" + +class MaxCube; class QNetworkReply; class IntegrationPluginEQ3: public IntegrationPlugin @@ -70,7 +71,7 @@ private: QList m_config; QHash m_cubes; - QHash m_eqivaDevices; + QHash m_eqivaDevices; private slots: void onPluginTimer(); diff --git a/eq-3/maxcube.cpp b/eq-3/maxcube.cpp index 809fa262..e10da4ee 100644 --- a/eq-3/maxcube.cpp +++ b/eq-3/maxcube.cpp @@ -37,12 +37,15 @@ MaxCube::MaxCube(QObject *parent, QString serialNumber, QHostAddress hostAdress, m_cubeInitialized = false; - connect(this,SIGNAL(stateChanged(QAbstractSocket::SocketState)),this,SLOT(connectionStateChanged(QAbstractSocket::SocketState))); + connect(this, &MaxCube::stateChanged, this, &MaxCube::connectionStateChanged); + connect(this, &MaxCube::readyRead, this, &MaxCube::onReadyRead); + connect(this, &MaxCube::cubeDataAvailable, this, &MaxCube::processCubeData); +#if QT_VERSION >= QT_VERSION_CHECK(6,0,0) + connect(this, &MaxCube::errorOccurred, this, &MaxCube::onTcpError); +#else + connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(onTcpError(QAbstractSocket::SocketError))); +#endif - connect(this,SIGNAL(readyRead()),this,SLOT(onReadyRead())); - connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(error(QAbstractSocket::SocketError))); - - connect(this,SIGNAL(cubeDataAvailable(QByteArray)),this,SLOT(processCubeData(QByteArray))); } QString MaxCube::serialNumber() const @@ -698,7 +701,7 @@ quint8 MaxCube::generateCommandId() return cmd++; } -void MaxCube::connectionStateChanged(const QAbstractSocket::SocketState &socketState) +void MaxCube::connectionStateChanged(QAbstractSocket::SocketState socketState) { switch (socketState) { case QAbstractSocket::ConnectedState: @@ -715,7 +718,7 @@ void MaxCube::connectionStateChanged(const QAbstractSocket::SocketState &socketS } } -void MaxCube::error(QAbstractSocket::SocketError error) +void MaxCube::onTcpError(QAbstractSocket::SocketError error) { qCWarning(dcEQ3) << "connection error (" << m_serialNumber << "): " << error; emit cubeConnectionStatusChanged(false); diff --git a/eq-3/maxcube.h b/eq-3/maxcube.h index 749a21ed..4ea49725 100644 --- a/eq-3/maxcube.h +++ b/eq-3/maxcube.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. @@ -36,11 +36,11 @@ #include #include -#include "maxdevice.h" +#include + #include "room.h" #include "wallthermostat.h" #include "radiatorthermostat.h" -#include "integrations/integrationplugin.h" class MaxCube : public QTcpSocket { @@ -79,8 +79,8 @@ public: bool portalEnabeld() const; - QList wallThermostatList(); - QList radiatorThermostatList(); + QList wallThermostatList(); + QList radiatorThermostatList(); QList roomList(); @@ -120,8 +120,8 @@ signals: void commandActionFinished(bool succeeded, int commandId); private slots: - void connectionStateChanged(const QAbstractSocket::SocketState &socketState); - void error(QAbstractSocket::SocketError error); + void connectionStateChanged(SocketState socketState); + void onTcpError(QAbstractSocket::SocketError error); void onReadyRead(); void processCubeData(const QByteArray &data); diff --git a/eq-3/maxcubediscovery.cpp b/eq-3/maxcubediscovery.cpp index 855aa64a..33f04d51 100644 --- a/eq-3/maxcubediscovery.cpp +++ b/eq-3/maxcubediscovery.cpp @@ -42,8 +42,8 @@ MaxCubeDiscovery::MaxCubeDiscovery(QObject *parent) : m_timeout = new QTimer(this); m_timeout->setSingleShot(true); - connect(m_udpSocket,SIGNAL(readyRead()),this,SLOT(readData())); - connect(m_timeout,SIGNAL(timeout()),this,SLOT(discoverTimeout())); + connect(m_udpSocket, &QUdpSocket::readyRead, this, &MaxCubeDiscovery::readData); + connect(m_timeout, &QTimer::timeout, this, &MaxCubeDiscovery::discoverTimeout); } void MaxCubeDiscovery::detectCubes() diff --git a/eq-3/maxcubediscovery.h b/eq-3/maxcubediscovery.h index 46e41d76..71ba2e95 100644 --- a/eq-3/maxcubediscovery.h +++ b/eq-3/maxcubediscovery.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. @@ -36,8 +36,6 @@ #include #include -#include "maxcube.h" - class MaxCubeDiscovery : public QObject { Q_OBJECT @@ -60,11 +58,11 @@ private slots: void discoverTimeout(); signals: - void cubesDetected(const QList &cubeList); + void cubesDetected(const QList &cubeList); private: - QUdpSocket *m_udpSocket; - QTimer *m_timeout; + QUdpSocket *m_udpSocket = nullptr; + QTimer *m_timeout = nullptr; quint16 m_port; diff --git a/eq-3/maxdevice.h b/eq-3/maxdevice.h index af0d1430..03d974c5 100644 --- a/eq-3/maxdevice.h +++ b/eq-3/maxdevice.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,8 +33,6 @@ #include -#include "room.h" - class MaxDevice : public QObject { Q_OBJECT @@ -87,10 +85,6 @@ private: QString m_roomName; bool m_batteryOk; -signals: - -public slots: - }; #endif // MAXDEVICE_H diff --git a/eq-3/radiatorthermostat.h b/eq-3/radiatorthermostat.h index 2f6e5811..f603012a 100644 --- a/eq-3/radiatorthermostat.h +++ b/eq-3/radiatorthermostat.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. @@ -147,10 +147,6 @@ private: int m_valvePosition; double m_setpointTemperature; -signals: - -public slots: - }; #endif // RADIATORTHERMOSTAT_H diff --git a/eq-3/room.h b/eq-3/room.h index c0e33a8c..79320f41 100644 --- a/eq-3/room.h +++ b/eq-3/room.h @@ -53,12 +53,6 @@ private: QString m_roomName; QByteArray m_groupRfAddress; -signals: - - - -public slots: - }; #endif // ROOM_H