eq-3: Add Qt6 support
parent
6acf92f22a
commit
da1d815894
|
|
@ -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 \
|
||||
|
|
|
|||
|
|
@ -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<quint8>(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<quint8>(now.date().year() - 2000);
|
||||
stream << static_cast<quint8>(now.date().month());
|
||||
|
|
|
|||
|
|
@ -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 <QObject>
|
||||
|
||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h"
|
||||
#include <hardware/bluetoothlowenergy/bluetoothlowenergymanager.h>
|
||||
|
||||
|
||||
class EqivaBluetooth : public QObject
|
||||
|
|
@ -145,7 +145,7 @@ private slots:
|
|||
void deviceDiscoveryDone();
|
||||
|
||||
signals:
|
||||
void finished(const QList<DiscoveryResult> &results);
|
||||
void finished(const QList<EqivaBluetoothDiscovery::DiscoveryResult> &results);
|
||||
|
||||
private:
|
||||
BluetoothLowEnergyManager *m_bluetoothManager = nullptr;
|
||||
|
|
|
|||
|
|
@ -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 <integrations/thing.h>
|
||||
#include <types/param.h>
|
||||
#include <hardwaremanager.h>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 <integrations/integrationplugin.h>
|
||||
#include <plugintimer.h>
|
||||
|
||||
#include <QHostAddress>
|
||||
|
||||
#include "eqivabluetooth.h"
|
||||
|
||||
class MaxCube;
|
||||
class QNetworkReply;
|
||||
|
||||
class IntegrationPluginEQ3: public IntegrationPlugin
|
||||
|
|
@ -70,7 +71,7 @@ private:
|
|||
QList<Param> m_config;
|
||||
QHash<MaxCube *, Thing *> m_cubes;
|
||||
|
||||
QHash<Thing*, EqivaBluetooth*> m_eqivaDevices;
|
||||
QHash<Thing *, EqivaBluetooth *> m_eqivaDevices;
|
||||
|
||||
private slots:
|
||||
void onPluginTimer();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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 <QDateTime>
|
||||
#include <QHostAddress>
|
||||
|
||||
#include "maxdevice.h"
|
||||
#include <integrations/integrationplugin.h>
|
||||
|
||||
#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<WallThermostat*> wallThermostatList();
|
||||
QList<RadiatorThermostat*> radiatorThermostatList();
|
||||
QList<WallThermostat *> wallThermostatList();
|
||||
QList<RadiatorThermostat *> radiatorThermostatList();
|
||||
|
||||
QList<Room*> 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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 <QHostAddress>
|
||||
#include <QTimer>
|
||||
|
||||
#include "maxcube.h"
|
||||
|
||||
class MaxCubeDiscovery : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
@ -60,11 +58,11 @@ private slots:
|
|||
void discoverTimeout();
|
||||
|
||||
signals:
|
||||
void cubesDetected(const QList<CubeInfo> &cubeList);
|
||||
void cubesDetected(const QList<MaxCubeDiscovery::CubeInfo> &cubeList);
|
||||
|
||||
private:
|
||||
QUdpSocket *m_udpSocket;
|
||||
QTimer *m_timeout;
|
||||
QUdpSocket *m_udpSocket = nullptr;
|
||||
QTimer *m_timeout = nullptr;
|
||||
|
||||
quint16 m_port;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 <QObject>
|
||||
|
||||
#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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -53,12 +53,6 @@ private:
|
|||
QString m_roomName;
|
||||
QByteArray m_groupRfAddress;
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // ROOM_H
|
||||
|
|
|
|||
Loading…
Reference in New Issue