improoved Max! cube decoding...current temperatur still missing
This commit is contained in:
parent
6efbf688ce
commit
58b8e13ef2
@ -34,6 +34,7 @@ StateTypeId dateTimeStateTypeId = StateTypeId("78aed123-ca8e-4e11-a823-52043c4a4
|
|||||||
DevicePluginEQ3::DevicePluginEQ3()
|
DevicePluginEQ3::DevicePluginEQ3()
|
||||||
{
|
{
|
||||||
m_cubeDiscovery = new MaxCubeDiscovery(this);
|
m_cubeDiscovery = new MaxCubeDiscovery(this);
|
||||||
|
|
||||||
connect(m_cubeDiscovery,SIGNAL(cubesDetected(QList<MaxCube*>)),this,SLOT(discoveryDone(QList<MaxCube*>)));
|
connect(m_cubeDiscovery,SIGNAL(cubesDetected(QList<MaxCube*>)),this,SLOT(discoveryDone(QList<MaxCube*>)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +117,6 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginEQ3::discoverDevices(cons
|
|||||||
return report(DeviceManager::DeviceErrorDeviceClassNotFound);
|
return report(DeviceManager::DeviceErrorDeviceClassNotFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginEQ3::setupDevice(Device *device)
|
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginEQ3::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
qDebug() << "setupDevice" << device->params();
|
qDebug() << "setupDevice" << device->params();
|
||||||
@ -129,15 +129,28 @@ QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginEQ3::setupDevice(De
|
|||||||
}
|
}
|
||||||
|
|
||||||
MaxCube *cube = new MaxCube(this,device->paramValue("serial number").toString(),QHostAddress(device->paramValue("host address").toString()),device->paramValue("port").toInt());
|
MaxCube *cube = new MaxCube(this,device->paramValue("serial number").toString(),QHostAddress(device->paramValue("host address").toString()),device->paramValue("port").toInt());
|
||||||
connect(cube,SIGNAL(cubeConnectionStatusChanged(bool)),this,SLOT(cubeConnectionStatusChanged(bool)));
|
|
||||||
|
|
||||||
m_cubes.insert(cube,device);
|
m_cubes.insert(cube,device);
|
||||||
|
|
||||||
|
connect(cube,SIGNAL(cubeConnectionStatusChanged(bool)),this,SLOT(cubeConnectionStatusChanged(bool)));
|
||||||
|
|
||||||
cube->connectToCube();
|
cube->connectToCube();
|
||||||
|
|
||||||
return reportDeviceSetup(DeviceManager::DeviceSetupStatusAsync);
|
return reportDeviceSetup(DeviceManager::DeviceSetupStatusAsync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DevicePluginEQ3::deviceRemoved(Device *device)
|
||||||
|
{
|
||||||
|
if (!m_cubes.values().contains(device)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
MaxCube *cube = m_cubes.key(device);
|
||||||
|
cube->disconnectFromCube();
|
||||||
|
qDebug() << "remove cube " << cube->serialNumber();
|
||||||
|
m_cubes.remove(cube);
|
||||||
|
cube->deleteLater();
|
||||||
|
}
|
||||||
|
|
||||||
void DevicePluginEQ3::guhTimer()
|
void DevicePluginEQ3::guhTimer()
|
||||||
{
|
{
|
||||||
foreach (MaxCube *cube, m_cubes.keys()) {
|
foreach (MaxCube *cube, m_cubes.keys()) {
|
||||||
@ -156,7 +169,7 @@ void DevicePluginEQ3::cubeConnectionStatusChanged(const bool &connected)
|
|||||||
MaxCube *cube = static_cast<MaxCube*>(sender());
|
MaxCube *cube = static_cast<MaxCube*>(sender());
|
||||||
Device *device;
|
Device *device;
|
||||||
if (m_cubes.contains(cube)) {
|
if (m_cubes.contains(cube)) {
|
||||||
device = m_cubes.take(cube);
|
device = m_cubes.value(cube);
|
||||||
device->setName("Max! Cube " + cube->serialNumber());
|
device->setName("Max! Cube " + cube->serialNumber());
|
||||||
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess, QString());
|
emit deviceSetupFinished(device, DeviceManager::DeviceSetupStatusSuccess, QString());
|
||||||
}
|
}
|
||||||
@ -173,7 +186,7 @@ void DevicePluginEQ3::discoveryDone(const QList<MaxCube *> &cubeList)
|
|||||||
params.append(hostParam);
|
params.append(hostParam);
|
||||||
Param portParam("port", cube->port());
|
Param portParam("port", cube->port());
|
||||||
params.append(portParam);
|
params.append(portParam);
|
||||||
Param firmwareParam("firmware version", QString::number(cube->firmware()));
|
Param firmwareParam("firmware version", cube->firmware());
|
||||||
params.append(firmwareParam);
|
params.append(firmwareParam);
|
||||||
Param serialNumberParam("serial number", cube->serialNumber());
|
Param serialNumberParam("serial number", cube->serialNumber());
|
||||||
params.append(serialNumberParam);
|
params.append(serialNumberParam);
|
||||||
|
|||||||
@ -47,6 +47,8 @@ public:
|
|||||||
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
QPair<DeviceManager::DeviceError, QString> discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||||
|
void deviceRemoved(Device *device) override;
|
||||||
|
|
||||||
|
|
||||||
void guhTimer() override;
|
void guhTimer() override;
|
||||||
|
|
||||||
|
|||||||
@ -9,12 +9,14 @@ SOURCES += \
|
|||||||
maxcubediscovery.cpp \
|
maxcubediscovery.cpp \
|
||||||
maxcube.cpp \
|
maxcube.cpp \
|
||||||
maxdevice.cpp \
|
maxdevice.cpp \
|
||||||
room.cpp \
|
room.cpp \
|
||||||
|
livemessage.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
deviceplugineq-3.h \
|
deviceplugineq-3.h \
|
||||||
maxcubediscovery.h \
|
maxcubediscovery.h \
|
||||||
maxcube.h \
|
maxcube.h \
|
||||||
maxdevice.h \
|
maxdevice.h \
|
||||||
room.h \
|
room.h \
|
||||||
|
livemessage.h
|
||||||
|
|
||||||
|
|||||||
170
plugins/deviceplugins/eq-3/livemessage.cpp
Normal file
170
plugins/deviceplugins/eq-3/livemessage.cpp
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
#include "livemessage.h"
|
||||||
|
|
||||||
|
LiveMessage::LiveMessage(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray LiveMessage::rfAddress() const
|
||||||
|
{
|
||||||
|
return m_rfAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setRfAddress(const QByteArray &rfAddress)
|
||||||
|
{
|
||||||
|
m_rfAddress = rfAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::informationValid() const
|
||||||
|
{
|
||||||
|
return m_informationValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setInformationValid(const bool &informationValid)
|
||||||
|
{
|
||||||
|
m_informationValid = informationValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::errorOccured() const
|
||||||
|
{
|
||||||
|
return m_errorOccured;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setErrorOccured(const bool &errorOccured)
|
||||||
|
{
|
||||||
|
m_errorOccured = errorOccured;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::isAnswereToCommand() const
|
||||||
|
{
|
||||||
|
return m_isAnswerToCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setIsAnswereToCommand(const bool &isAnswereToCommand)
|
||||||
|
{
|
||||||
|
m_isAnswerToCommand = isAnswereToCommand;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::initialized() const
|
||||||
|
{
|
||||||
|
return m_initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setInitialized(const bool &initialized)
|
||||||
|
{
|
||||||
|
m_initialized = initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::batteryLow() const
|
||||||
|
{
|
||||||
|
return m_batteryLow;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setBatteryLow(const bool &batteryLow)
|
||||||
|
{
|
||||||
|
m_batteryLow = batteryLow;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::linkStatusOK() const
|
||||||
|
{
|
||||||
|
return m_linkStatusOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setLinkStatusOK(const bool &linkStatusOK)
|
||||||
|
{
|
||||||
|
m_linkStatusOK = linkStatusOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::panelLocked() const
|
||||||
|
{
|
||||||
|
return m_panelLocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setPanelLocked(const bool &panelLocked)
|
||||||
|
{
|
||||||
|
m_panelLocked = panelLocked;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::gatewayKnown() const
|
||||||
|
{
|
||||||
|
return m_gatewayKnown;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setGatewayKnown(const bool &gatewayKnown)
|
||||||
|
{
|
||||||
|
m_gatewayKnown = gatewayKnown;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool LiveMessage::dtsActive() const
|
||||||
|
{
|
||||||
|
return m_dtsActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setDtsActive(const bool &dtsActive)
|
||||||
|
{
|
||||||
|
m_dtsActive = dtsActive;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LiveMessage::deviceMode() const
|
||||||
|
{
|
||||||
|
return m_deviceMode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setDeviceMode(const int &deviceMode)
|
||||||
|
{
|
||||||
|
m_deviceMode = deviceMode;
|
||||||
|
|
||||||
|
switch (deviceMode) {
|
||||||
|
case Auto:
|
||||||
|
m_deviceModeString = "Auto";
|
||||||
|
break;
|
||||||
|
case Manual:
|
||||||
|
m_deviceModeString = "Manuel";
|
||||||
|
break;
|
||||||
|
case Temporary:
|
||||||
|
m_deviceModeString = "Temporary";
|
||||||
|
break;
|
||||||
|
case Boost:
|
||||||
|
m_deviceModeString = "Boost";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
m_deviceModeString = "-";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
QString LiveMessage::deviceModeString() const
|
||||||
|
{
|
||||||
|
return m_deviceModeString;
|
||||||
|
}
|
||||||
|
|
||||||
|
int LiveMessage::valvePosition() const
|
||||||
|
{
|
||||||
|
return m_valvePosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setValvePosition(const int &valvePosition)
|
||||||
|
{
|
||||||
|
m_valvePosition = valvePosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
double LiveMessage::setpointTemperature() const
|
||||||
|
{
|
||||||
|
return m_setpointTemperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setSetpointTemperatre(const double &setpointTemperature)
|
||||||
|
{
|
||||||
|
m_setpointTemperature = setpointTemperature;
|
||||||
|
}
|
||||||
|
|
||||||
|
QDateTime LiveMessage::dateTime() const
|
||||||
|
{
|
||||||
|
return m_dateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LiveMessage::setDateTime(const QDateTime dateTime)
|
||||||
|
{
|
||||||
|
m_dateTime = dateTime;
|
||||||
|
}
|
||||||
89
plugins/deviceplugins/eq-3/livemessage.h
Normal file
89
plugins/deviceplugins/eq-3/livemessage.h
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
#ifndef LIVEMESSAGE_H
|
||||||
|
#define LIVEMESSAGE_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
class LiveMessage : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit LiveMessage(QObject *parent = 0);
|
||||||
|
|
||||||
|
enum DeviceMode{
|
||||||
|
Auto = 0,
|
||||||
|
Manual = 1,
|
||||||
|
Temporary = 2,
|
||||||
|
Boost = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
QByteArray rfAddress() const;
|
||||||
|
void setRfAddress(const QByteArray & rfAddress);
|
||||||
|
|
||||||
|
bool informationValid() const;
|
||||||
|
void setInformationValid(const bool &informationValid);
|
||||||
|
|
||||||
|
bool errorOccured() const;
|
||||||
|
void setErrorOccured(const bool &errorOccured);
|
||||||
|
|
||||||
|
bool isAnswereToCommand() const;
|
||||||
|
void setIsAnswereToCommand(const bool &isAnswereToCommand);
|
||||||
|
|
||||||
|
bool initialized() const;
|
||||||
|
void setInitialized(const bool &initialized);
|
||||||
|
|
||||||
|
bool batteryLow() const;
|
||||||
|
void setBatteryLow(const bool &batteryLow);
|
||||||
|
|
||||||
|
bool linkStatusOK() const;
|
||||||
|
void setLinkStatusOK(const bool &linkStatusOK);
|
||||||
|
|
||||||
|
bool panelLocked() const;
|
||||||
|
void setPanelLocked(const bool &panelLocked);
|
||||||
|
|
||||||
|
bool gatewayKnown() const;
|
||||||
|
void setGatewayKnown(const bool &gatewayKnown);
|
||||||
|
|
||||||
|
bool dtsActive() const;
|
||||||
|
void setDtsActive(const bool &dtsActive);
|
||||||
|
|
||||||
|
int deviceMode() const;
|
||||||
|
void setDeviceMode(const int &deviceMode);
|
||||||
|
|
||||||
|
QString deviceModeString() const;
|
||||||
|
|
||||||
|
int valvePosition() const;
|
||||||
|
void setValvePosition(const int &valvePosition);
|
||||||
|
|
||||||
|
double setpointTemperature() const;
|
||||||
|
void setSetpointTemperatre(const double &setpointTemperature);
|
||||||
|
|
||||||
|
QDateTime dateTime() const;
|
||||||
|
void setDateTime(const QDateTime dateTime);
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
QByteArray m_rfAddress;
|
||||||
|
bool m_informationValid;
|
||||||
|
bool m_errorOccured;
|
||||||
|
bool m_isAnswerToCommand;
|
||||||
|
bool m_initialized;
|
||||||
|
bool m_batteryLow;
|
||||||
|
bool m_linkStatusOK;
|
||||||
|
bool m_panelLocked;
|
||||||
|
bool m_gatewayKnown;
|
||||||
|
bool m_dtsActive;
|
||||||
|
int m_deviceMode;
|
||||||
|
QString m_deviceModeString;
|
||||||
|
int m_valvePosition;
|
||||||
|
double m_setpointTemperature;
|
||||||
|
QDateTime m_dateTime;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // LIVEMESSAGE_H
|
||||||
@ -21,6 +21,9 @@
|
|||||||
MaxCube::MaxCube(QObject *parent, QString serialNumber, QHostAddress hostAdress, quint16 port):
|
MaxCube::MaxCube(QObject *parent, QString serialNumber, QHostAddress hostAdress, quint16 port):
|
||||||
QTcpSocket(parent), m_serialNumber(serialNumber), m_hostAddress(hostAdress), m_port(port)
|
QTcpSocket(parent), m_serialNumber(serialNumber), m_hostAddress(hostAdress), m_port(port)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
m_cubeInitialized = false;
|
||||||
|
|
||||||
connect(this,SIGNAL(connected()),this,SLOT(connected()));
|
connect(this,SIGNAL(connected()),this,SLOT(connected()));
|
||||||
connect(this,SIGNAL(disconnected()),this,SLOT(disconnected()));
|
connect(this,SIGNAL(disconnected()),this,SLOT(disconnected()));
|
||||||
connect(this,SIGNAL(readyRead()),this,SLOT(readData()));
|
connect(this,SIGNAL(readyRead()),this,SLOT(readData()));
|
||||||
@ -29,76 +32,91 @@ MaxCube::MaxCube(QObject *parent, QString serialNumber, QHostAddress hostAdress,
|
|||||||
connect(this,SIGNAL(cubeDataAvailable(QByteArray)),this,SLOT(processCubeData(QByteArray)));
|
connect(this,SIGNAL(cubeDataAvailable(QByteArray)),this,SLOT(processCubeData(QByteArray)));
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaxCube::serialNumber()
|
QString MaxCube::serialNumber() const
|
||||||
{
|
{
|
||||||
return m_serialNumber;
|
return m_serialNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::setSerialNumber(QString serialNumber)
|
void MaxCube::setSerialNumber(const QString &serialNumber)
|
||||||
{
|
{
|
||||||
m_serialNumber = serialNumber;
|
m_serialNumber = serialNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray MaxCube::rfAddress()
|
QByteArray MaxCube::rfAddress() const
|
||||||
{
|
{
|
||||||
return m_rfAddress;
|
return m_rfAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::setRfAddress(QByteArray rfAddress)
|
void MaxCube::setRfAddress(const QByteArray &rfAddress)
|
||||||
{
|
{
|
||||||
m_rfAddress = rfAddress;
|
m_rfAddress = rfAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MaxCube::firmware()
|
int MaxCube::firmware() const
|
||||||
{
|
{
|
||||||
return m_firmware;
|
return m_firmware;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::setFirmware(int firmware)
|
void MaxCube::setFirmware(const int &firmware)
|
||||||
{
|
{
|
||||||
m_firmware = firmware;
|
m_firmware = firmware;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHostAddress MaxCube::hostAddress()
|
QHostAddress MaxCube::hostAddress() const
|
||||||
{
|
{
|
||||||
return m_hostAddress;
|
return m_hostAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::setHostAddress(QHostAddress hostAddress)
|
void MaxCube::setHostAddress(const QHostAddress &hostAddress)
|
||||||
{
|
{
|
||||||
m_hostAddress = hostAddress;
|
m_hostAddress = hostAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
quint16 MaxCube::port()
|
quint16 MaxCube::port() const
|
||||||
{
|
{
|
||||||
return m_port;
|
return m_port;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::setPort(quint16 port)
|
void MaxCube::setPort(const quint16 &port)
|
||||||
{
|
{
|
||||||
m_port = port;
|
m_port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray MaxCube::httpConnectionId()
|
QByteArray MaxCube::httpConnectionId() const
|
||||||
{
|
{
|
||||||
return m_httpConnectionId;
|
return m_httpConnectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::setHttpConnectionId(QByteArray httpConnectionId)
|
void MaxCube::setHttpConnectionId(const QByteArray &httpConnectionId)
|
||||||
{
|
{
|
||||||
m_httpConnectionId = httpConnectionId;
|
m_httpConnectionId = httpConnectionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MaxCube::freeMemorySlots()
|
int MaxCube::freeMemorySlots() const
|
||||||
{
|
{
|
||||||
return m_freeMemorySlots;
|
return m_freeMemorySlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::setFreeMemorySlots(int freeMemorySlots)
|
void MaxCube::setFreeMemorySlots(const int &freeMemorySlots)
|
||||||
{
|
{
|
||||||
m_freeMemorySlots = freeMemorySlots;
|
m_freeMemorySlots = freeMemorySlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QDateTime MaxCube::cubeDateTime() const
|
||||||
|
{
|
||||||
|
return m_cubeDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MaxCube::setCubeDateTime(const QDateTime &cubeDateTime)
|
||||||
|
{
|
||||||
|
m_cubeDateTime = cubeDateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MaxCube::portalEnabeld() const
|
||||||
|
{
|
||||||
|
return m_portalEnabeld;
|
||||||
|
}
|
||||||
|
|
||||||
QList<MaxDevice *> MaxCube::deviceList()
|
QList<MaxDevice *> MaxCube::deviceList()
|
||||||
{
|
{
|
||||||
return m_deviceList;
|
return m_deviceList;
|
||||||
@ -127,18 +145,20 @@ bool MaxCube::sendData(QByteArray data)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::parseHelloMessage(QByteArray data)
|
void MaxCube::decodeHelloMessage(QByteArray data)
|
||||||
{
|
{
|
||||||
|
|
||||||
QList<QByteArray> list = data.split(',');
|
QList<QByteArray> list = data.split(',');
|
||||||
m_cubeDateTime = calculateDateTime(list.at(7),list.at(8));
|
m_cubeDateTime = calculateDateTime(list.at(7),list.at(8));
|
||||||
|
|
||||||
|
m_rfAddress = list.at(1);
|
||||||
|
m_firmware = list.at(2).toInt();
|
||||||
|
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
qDebug() << "HELLO message:";
|
qDebug() << " HELLO message:";
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
qDebug() << " serial number | " << list.at(0);
|
qDebug() << " serial number | " << list.at(0);
|
||||||
qDebug() << " RF address (hex) | " << list.at(1);
|
qDebug() << " RF address (hex) | " << list.at(1);
|
||||||
qDebug() << " firmware | " << QString::number(list.at(2).toInt());
|
qDebug() << " firmware | " << QString::number(list.at(2).toInt());
|
||||||
qDebug() << " ? | " << list.at(3);
|
|
||||||
qDebug() << " HTTP connection id | " << list.at(4);
|
qDebug() << " HTTP connection id | " << list.at(4);
|
||||||
qDebug() << " duty cycle (hex) | " << list.at(5);
|
qDebug() << " duty cycle (hex) | " << list.at(5);
|
||||||
qDebug() << " free memory slots (hex) | " << list.at(6);
|
qDebug() << " free memory slots (hex) | " << list.at(6);
|
||||||
@ -148,19 +168,13 @@ void MaxCube::parseHelloMessage(QByteArray data)
|
|||||||
qDebug() << " NTP counter | " << list.at(10);
|
qDebug() << " NTP counter | " << list.at(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::parseMetadataMessage(QByteArray data)
|
void MaxCube::decodeMetadataMessage(QByteArray data)
|
||||||
{
|
{
|
||||||
QList<QByteArray> list = data.left(data.length()-2).split(',');
|
QList<QByteArray> list = data.left(data.length()-2).split(',');
|
||||||
QByteArray dataDecoded = QByteArray::fromBase64(list.at(2));
|
QByteArray dataDecoded = QByteArray::fromBase64(list.at(2));
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
qDebug() << "METADATA message:";
|
qDebug() << " METADATA message:";
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
// qDebug() << " Index | " << list.at(0);
|
|
||||||
// qDebug() << " Count | " << list.at(1);
|
|
||||||
// qDebug() << " Data Base64 encoded | " << list.at(2);
|
|
||||||
// qDebug() << " Data Base64 decoded | " << dataDecoded;
|
|
||||||
// qDebug() << " Data Base64 decoded hex | " << dataDecoded.toHex();
|
|
||||||
|
|
||||||
|
|
||||||
// parse room list
|
// parse room list
|
||||||
int roomCount = dataDecoded.toHex().mid(4,2).toInt(0,16);
|
int roomCount = dataDecoded.toHex().mid(4,2).toInt(0,16);
|
||||||
@ -200,8 +214,8 @@ void MaxCube::parseMetadataMessage(QByteArray data)
|
|||||||
int deviceNameLenght = deviceRawData.mid(28,2).toInt(0,16);
|
int deviceNameLenght = deviceRawData.mid(28,2).toInt(0,16);
|
||||||
device->setDeviceName(QByteArray::fromHex(deviceRawData.mid(30,deviceNameLenght*2)));
|
device->setDeviceName(QByteArray::fromHex(deviceRawData.mid(30,deviceNameLenght*2)));
|
||||||
device->setRoomId(deviceRawData.mid(30 + deviceNameLenght*2,2).toInt(0,16));
|
device->setRoomId(deviceRawData.mid(30 + deviceNameLenght*2,2).toInt(0,16));
|
||||||
deviceRawData = deviceRawData.right(deviceRawData.length() - (30 + deviceNameLenght*2));
|
|
||||||
//qDebug() << "rawdata left :" << deviceRawData;
|
deviceRawData = deviceRawData.right(deviceRawData.length() - (32 + deviceNameLenght*2));
|
||||||
m_deviceList.append(device);
|
m_deviceList.append(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,132 +228,292 @@ void MaxCube::parseMetadataMessage(QByteArray data)
|
|||||||
qDebug() << " Serial Number| " << device->serialNumber();
|
qDebug() << " Serial Number| " << device->serialNumber();
|
||||||
qDebug() << " Device Type String | " << device->deviceTypeString();
|
qDebug() << " Device Type String | " << device->deviceTypeString();
|
||||||
qDebug() << " RF address (hex) | " << device->rfAddress();
|
qDebug() << " RF address (hex) | " << device->rfAddress();
|
||||||
//qDebug() << " Device Type | " << device->deviceType();
|
|
||||||
qDebug() << " Room ID | " << device->roomId();
|
qDebug() << " Room ID | " << device->roomId();
|
||||||
qDebug() << "-------------------------|-------------------------";
|
qDebug() << "-------------------------|-------------------------";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set room data for each device
|
||||||
|
foreach (MaxDevice *device, m_deviceList) {
|
||||||
|
foreach (Room * room, m_roomList) {
|
||||||
|
if(device->roomId() == room->roomId()){
|
||||||
|
device->setRoomName(room->roomName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
emit deviceListReady(m_deviceList);
|
||||||
|
m_cubeInitialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::parseConfigMessage(QByteArray data)
|
void MaxCube::decodeConfigMessage(QByteArray data)
|
||||||
{
|
{
|
||||||
QList<QByteArray> list = data.split(',');
|
QList<QByteArray> list = data.split(',');
|
||||||
|
if(list.count() < 2){
|
||||||
|
return;
|
||||||
|
}
|
||||||
QByteArray rfAddress = list.at(0);
|
QByteArray rfAddress = list.at(0);
|
||||||
QByteArray dataRaw = QByteArray::fromBase64(list.at(1)).toHex();
|
QByteArray dataRaw = QByteArray::fromBase64(list.at(1)).toHex();
|
||||||
//int lengthData = dataRaw.left(2).toInt(0,16);
|
int lengthData = dataRaw.left(2).toInt(0,16);
|
||||||
//QByteArray rfAddress = dataRaw.mid(2,6);
|
if(rfAddress != dataRaw.mid(2,6)){
|
||||||
|
qDebug() << "ERROR: rf addresses not equal!";
|
||||||
|
}
|
||||||
int deviceType = dataRaw.mid(8,2).toInt(0,16);
|
int deviceType = dataRaw.mid(8,2).toInt(0,16);
|
||||||
int roomId = dataRaw.mid(10,2).toInt(0,16);
|
|
||||||
//QByteArray unknown = dataRaw.mid(12,6);
|
//QByteArray unknown = dataRaw.mid(12,6);
|
||||||
|
|
||||||
QByteArray serialNumber = QByteArray::fromHex(dataRaw.mid(16,20));
|
QByteArray serialNumber = QByteArray::fromHex(dataRaw.mid(16,20));
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
qDebug() << "CONFIG message:";
|
qDebug() << " CONFIG message:";
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
qDebug() << " device Type | " << deviceTypeString(deviceType);
|
|
||||||
qDebug() << " Serial Number | " << serialNumber;
|
qDebug() << " Serial Number | " << serialNumber;
|
||||||
|
qDebug() << " device Type | " << deviceTypeString(deviceType);
|
||||||
qDebug() << " RF address (hex) | " << rfAddress;
|
qDebug() << " RF address (hex) | " << rfAddress;
|
||||||
qDebug() << " Room ID | " << roomId;
|
qDebug() << " data length | " << lengthData;
|
||||||
qDebug() << "-------------------------|-------------------------";
|
qDebug() << "-------------------------|-------------------------";
|
||||||
|
|
||||||
switch (deviceType) {
|
switch (deviceType) {
|
||||||
case MaxDevice::DeviceCube:{
|
case MaxDevice::DeviceCube:{
|
||||||
qDebug() << QByteArray::fromHex(dataRaw.mid(dataRaw.length() - 32));
|
|
||||||
|
m_portalEnabeld = (bool)dataRaw.mid(36,2).toInt(0,16);
|
||||||
|
|
||||||
|
qDebug() << " portal enabled | " << m_portalEnabeld;
|
||||||
|
qDebug() << " portal URL | " << QString(QByteArray::fromHex(dataRaw.mid(170,68)));
|
||||||
|
qDebug() << " time zone | " << QString(QByteArray::fromHex(dataRaw.mid(428,6)));
|
||||||
|
qDebug() << " summer/winter time | " << QString(QByteArray::fromHex(dataRaw.mid(452,8)));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MaxDevice::DeviceEcoButton:
|
|
||||||
break;
|
|
||||||
case MaxDevice::DeviceWallThermostat:
|
|
||||||
break;
|
|
||||||
case MaxDevice::DeviceRadiatorThermostatPlus:
|
|
||||||
break;
|
|
||||||
case MaxDevice::DeviceRadiatorThermostat:{
|
case MaxDevice::DeviceRadiatorThermostat:{
|
||||||
double confortTemp = dataRaw.mid(36,2).toInt(0,16)/2;
|
int roomId = dataRaw.mid(10,2).toInt(0,16);
|
||||||
double ecoTemp = dataRaw.mid(38,2).toInt(0,16)/2;
|
int firmware = dataRaw.mid(12,2).toInt(0,16);
|
||||||
double maxSetPointTemp = dataRaw.mid(40,2).toInt(0,16)/2;
|
double confortTemp = (double)dataRaw.mid(36,2).toInt(0,16) / 2.0;
|
||||||
double minSetPointTemp = dataRaw.mid(42,2).toInt(0,16)/2;
|
double ecoTemp = (double)dataRaw.mid(38,2).toInt(0,16) / 2.0;
|
||||||
double offsetTemp = (dataRaw.mid(44,2).toInt(0,16) / 2 ) - 3.5;
|
double maxSetPointTemp = (double)dataRaw.mid(40,2).toInt(0,16) / 2.0;
|
||||||
double windowOpenTemp = dataRaw.mid(46,2).toInt(0,16)/2;
|
double minSetPointTemp = (double)dataRaw.mid(42,2).toInt(0,16) / 2.0;
|
||||||
|
double offsetTemp = (double)(dataRaw.mid(44,2).toInt(0,16) / 2.0 ) - 3.5;
|
||||||
|
double windowOpenTemp = (double)dataRaw.mid(46,2).toInt(0,16)/2.0;
|
||||||
int windowOpenDuration = dataRaw.mid(48,2).toInt(0,16);
|
int windowOpenDuration = dataRaw.mid(48,2).toInt(0,16);
|
||||||
// boost code
|
// boost code
|
||||||
QByteArray boostDurationCode = QByteArray::number(dataRaw.mid(50,2).toInt(0,16),2);
|
QByteArray boostDurationCode = fillBin(QByteArray::number(dataRaw.mid(50,2).toInt(0,16),2),8);
|
||||||
qDebug() << boostDurationCode;
|
int boostDuration = boostDurationCode.left(3).toInt(0,2) * 5;
|
||||||
int boostDuration = boostDurationCode.left(3).toInt(0,2);
|
int valveValue = boostDurationCode.right(5).toInt(0,2) * 5;
|
||||||
if(boostDuration = 7){
|
|
||||||
boostDuration = 30;
|
|
||||||
}else{
|
|
||||||
boostDuration *= 5;
|
|
||||||
}
|
|
||||||
int valveValue = boostDurationCode.right(5).toInt(0,2);
|
|
||||||
// day of week an time
|
|
||||||
QByteArray dowTime = QByteArray::number(dataRaw.mid(52,2).toInt(0,16),2);
|
|
||||||
double valveMaximumSettings = dataRaw.mid(54,2).toInt(0,16)*(double)100/255;
|
|
||||||
double valveOffset = dataRaw.mid(56,2).toInt(0,16)*(double)100/255;
|
|
||||||
|
|
||||||
qDebug() << " Serial Number | " << serialNumber;
|
// day of week an time
|
||||||
qDebug() << " Confort Temp. | " << confortTemp;
|
QByteArray dowTime = fillBin(QByteArray::number(dataRaw.mid(52,2).toInt(0,16),2),8);
|
||||||
qDebug() << " Eco Temp. | " << ecoTemp;
|
QString weekDay = weekDayString(dowTime.left(3).toInt(0,2));
|
||||||
qDebug() << " Max. Set Point Temp. | " << maxSetPointTemp;
|
QTime time = QTime(dowTime.right(5).toInt(0,2),0);
|
||||||
qDebug() << " Min. Set Point Temp. | " << minSetPointTemp;
|
|
||||||
qDebug() << " Temp. Offset | " << offsetTemp;
|
double valveMaximumSettings = (double)dataRaw.mid(54,2).toInt(0,16)*(double)100.0/255.0;
|
||||||
qDebug() << " Window Open Temp. | " << windowOpenTemp;
|
double valveOffset = (double)dataRaw.mid(56,2).toInt(0,16)*100.0/255.0;
|
||||||
qDebug() << " Window Open Duration | " << windowOpenDuration;
|
|
||||||
|
qDebug() << " Room ID | " << roomId;
|
||||||
|
qDebug() << " firmware | " << firmware;
|
||||||
|
qDebug() << " Confort Temp. | " << confortTemp << "C";
|
||||||
|
qDebug() << " Eco Temp. | " << ecoTemp << "C";
|
||||||
|
qDebug() << " Max. Set Point Temp. | " << maxSetPointTemp << "C";
|
||||||
|
qDebug() << " Min. Set Point Temp. | " << minSetPointTemp << "C";
|
||||||
|
qDebug() << " Temp. Offset | " << offsetTemp << "C";
|
||||||
|
qDebug() << " Window Open Temp. | " << windowOpenTemp << "C";
|
||||||
|
qDebug() << " Window Open Duration | " << windowOpenDuration << "min";
|
||||||
|
qDebug() << " Boost code | " << boostDurationCode;
|
||||||
qDebug() << " Boost Duration | " << boostDuration << "min";
|
qDebug() << " Boost Duration | " << boostDuration << "min";
|
||||||
qDebug() << " Valve value | " << valveValue << "%";
|
qDebug() << " Valve value | " << valveValue << "%";
|
||||||
qDebug() << " Day of week and time | " << dowTime;
|
qDebug() << " dow code | " << dowTime;
|
||||||
|
qDebug() << " disclaiming run day | " << weekDay;
|
||||||
|
qDebug() << " disclaiming run time | " << time.toString("HH:mm");
|
||||||
qDebug() << " Valve Maximum Settings | " << valveMaximumSettings << "%";
|
qDebug() << " Valve Maximum Settings | " << valveMaximumSettings << "%";
|
||||||
qDebug() << " Valve Offset | " << valveOffset << "%";
|
qDebug() << " Valve Offset | " << valveOffset << "%";
|
||||||
parseWeeklyProgram(dataRaw.right(dataRaw.length() - 58));
|
parseWeeklyProgram(dataRaw.right(dataRaw.length() - 58));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MaxDevice::DeviceRadiatorThermostatPlus:
|
||||||
|
break;
|
||||||
|
case MaxDevice::DeviceWallThermostat:{
|
||||||
|
int roomId = dataRaw.mid(10,2).toInt(0,16);
|
||||||
|
int firmware = dataRaw.mid(12,2).toInt(0,16);
|
||||||
|
double confortTemp = (double)dataRaw.mid(36,2).toInt(0,16) / 2.0;
|
||||||
|
double ecoTemp = (double)dataRaw.mid(38,2).toInt(0,16)/2.0;
|
||||||
|
double maxSetPointTemp = (double)dataRaw.mid(40,2).toInt(0,16)/2.0;
|
||||||
|
double minSetPointTemp = (double)dataRaw.mid(42,2).toInt(0,16)/2.0;
|
||||||
|
|
||||||
|
qDebug() << " Room ID | " << roomId;
|
||||||
|
qDebug() << " firmware | " << firmware;
|
||||||
|
qDebug() << " Confort Temp. | " << confortTemp;
|
||||||
|
qDebug() << " Eco Temp. | " << ecoTemp;
|
||||||
|
qDebug() << " Max. Set Point Temp. | " << maxSetPointTemp;
|
||||||
|
qDebug() << " Min. Set Point Temp. | " << minSetPointTemp;
|
||||||
|
|
||||||
|
parseWeeklyProgram(dataRaw.right(dataRaw.length() - 44));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MaxDevice::DeviceEcoButton:
|
||||||
|
break;
|
||||||
|
case MaxDevice::DeviceWindowContact:
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning() << "unknown device type: " << deviceType;
|
qWarning() << "unknown device type: " << deviceType;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::parseDevicelistMessage(QByteArray data)
|
void MaxCube::decodeDevicelistMessage(QByteArray data)
|
||||||
{
|
{
|
||||||
QList<QByteArray> list = data.split(',');
|
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
qDebug() << "DEVICELIST message:";
|
qDebug() << " LIVE message:";
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
foreach (const QByteArray &code, list) {
|
//qDebug() << data;
|
||||||
QByteArray rawData = QByteArray::fromBase64(code).toHex();
|
QByteArray rawDataAll = QByteArray::fromBase64(data).toHex();
|
||||||
qDebug() << " Code | " << rawData.toBase64();
|
qDebug() << rawDataAll;
|
||||||
qDebug() << " Code (Hex) | " << rawData;
|
|
||||||
qDebug() << " Length of data | " << rawData.left(2).toInt(0,16);
|
QList<QByteArray> deviceMessageList = splitMessage(rawDataAll);
|
||||||
qDebug() << " RF address (hex) | " << rawData.mid(2,6);
|
|
||||||
qDebug() << " Initialization | " << QByteArray::number(rawData.mid(10,2).toInt(0,16),2);
|
foreach (QByteArray rawData, deviceMessageList) {
|
||||||
qDebug() << " Battery, ... , | " << QByteArray::number(rawData.mid(12,2).toInt(0,16),2);
|
|
||||||
qDebug() << " Valve Position | " << QByteArray::number(rawData.mid(14,2).toInt(0,16),2) << "%";
|
LiveMessage message;
|
||||||
qDebug() << " Temperatur Setpoint | " << (double)rawData.mid(16,2).toInt(0,16) / 2.0 << "%";
|
message.setRfAddress(rawData.mid(0,6));
|
||||||
QDateTime dateTime = calculateDateTime(rawData.mid(18,4), rawData.mid(22,2));
|
|
||||||
qDebug() << " Cube date | " << dateTime.date().toString("dd.MM.yyyy");
|
MaxDevice *device = getDeviceTypeFromRFAddress(message.rfAddress());
|
||||||
qDebug() << " Cube time | " << dateTime.time().toString("HH:mm");
|
|
||||||
|
switch (device->deviceType()) {
|
||||||
|
case MaxDevice::DeviceWallThermostat:{
|
||||||
|
QByteArray unknown = rawData.mid(6,2);
|
||||||
|
|
||||||
|
QByteArray initCode = fillBin(QByteArray::number(rawData.mid(8,2).toInt(0,16),2),8);
|
||||||
|
message.setInformationValid((bool)initCode.mid(3,1).toInt());
|
||||||
|
message.setErrorOccured((bool)initCode.mid(4,1).toInt());
|
||||||
|
message.setIsAnswereToCommand((bool)initCode.mid(5,1).toInt());
|
||||||
|
message.setInitialized((bool)initCode.mid(6,1).toInt());
|
||||||
|
|
||||||
|
QByteArray statusCode = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8);
|
||||||
|
message.setBatteryLow((bool)statusCode.mid(0,1).toInt());
|
||||||
|
message.setLinkStatusOK(!(bool)statusCode.mid(1,1).toInt());
|
||||||
|
message.setPanelLocked((bool)statusCode.mid(2,1).toInt());
|
||||||
|
message.setGatewayKnown((bool)statusCode.mid(3,1).toInt());
|
||||||
|
message.setDtsActive((bool)statusCode.mid(4,1).toInt());
|
||||||
|
message.setDeviceMode(statusCode.right(2).toInt(0,2));
|
||||||
|
|
||||||
|
message.setValvePosition((double)rawData.mid(12,2).toInt(0,16));
|
||||||
|
message.setSetpointTemperatre((double)rawData.mid(14,2).toInt(0,16)/ 2.0);
|
||||||
|
message.setDateTime(calculateDateTime(rawData.mid(18,4), rawData.mid(22,2)));
|
||||||
|
|
||||||
|
qDebug() << " raw data | " << rawData;
|
||||||
|
qDebug() << " device type | " << device->deviceTypeString();
|
||||||
|
qDebug() << " device name | " << device->deviceName();
|
||||||
|
qDebug() << " RF address (hex) | " << message.rfAddress();
|
||||||
|
qDebug() << " unknown | " << unknown;
|
||||||
|
qDebug() << " initCode | " << initCode;
|
||||||
|
qDebug() << " information valid | " << message.informationValid();
|
||||||
|
qDebug() << " error occured | " << message.errorOccured();
|
||||||
|
qDebug() << " is answere to a command | " << message.isAnswereToCommand();
|
||||||
|
qDebug() << " initialized | " << message.initialized();
|
||||||
|
qDebug() << " statusCode | " << statusCode;
|
||||||
|
qDebug() << " battery low | " << message.batteryLow();
|
||||||
|
qDebug() << " link status OK | " << message.linkStatusOK();
|
||||||
|
qDebug() << " panel locked | " << message.panelLocked();
|
||||||
|
qDebug() << " gateway known | " << message.gatewayKnown();
|
||||||
|
qDebug() << " DST settings active | " << message.dtsActive();
|
||||||
|
qDebug() << " device mode | " << message.deviceModeString();
|
||||||
|
qDebug() << " unknown | " << rawData.right(rawData.length() - 12);
|
||||||
|
qDebug() << " measured temp. 0b | " << fillBin(QByteArray::number(rawData.left(2).toInt(0,16),2),8);
|
||||||
|
qDebug() << "-------------------------|-------------------------";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
emit liveMessageReady(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MaxDevice::DeviceRadiatorThermostat:{
|
||||||
|
QByteArray unknown = rawData.mid(6,2);
|
||||||
|
|
||||||
|
QByteArray initCode = fillBin(QByteArray::number(rawData.mid(8,2).toInt(0,16),2),8);
|
||||||
|
message.setInformationValid((bool)initCode.mid(3,1).toInt());
|
||||||
|
message.setErrorOccured((bool)initCode.mid(4,1).toInt());
|
||||||
|
message.setIsAnswereToCommand((bool)initCode.mid(5,1).toInt());
|
||||||
|
message.setInitialized((bool)initCode.mid(6,1).toInt());
|
||||||
|
|
||||||
|
QByteArray statusCode = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8);
|
||||||
|
message.setBatteryLow((bool)statusCode.mid(0,1).toInt());
|
||||||
|
message.setLinkStatusOK(!(bool)statusCode.mid(1,1).toInt());
|
||||||
|
message.setPanelLocked((bool)statusCode.mid(2,1).toInt());
|
||||||
|
message.setGatewayKnown((bool)statusCode.mid(3,1).toInt());
|
||||||
|
message.setDtsActive((bool)statusCode.mid(4,1).toInt());
|
||||||
|
message.setDeviceMode(statusCode.right(2).toInt(0,2));
|
||||||
|
|
||||||
|
message.setValvePosition((double)rawData.mid(12,2).toInt(0,16));
|
||||||
|
message.setSetpointTemperatre((double)rawData.mid(14,2).toInt(0,16)/ 2.0);
|
||||||
|
message.setDateTime(calculateDateTime(rawData.mid(18,4), rawData.mid(22,2)));
|
||||||
|
|
||||||
|
qDebug() << " raw data | " << rawData;
|
||||||
|
qDebug() << " device type | " << device->deviceTypeString();
|
||||||
|
qDebug() << " device name | " << device->deviceName();
|
||||||
|
qDebug() << " RF address (hex) | " << message.rfAddress();
|
||||||
|
qDebug() << " unknown | " << unknown;
|
||||||
|
qDebug() << " information valid | " << message.informationValid();
|
||||||
|
qDebug() << " error occured | " << message.errorOccured();
|
||||||
|
qDebug() << " is answere to a command | " << message.isAnswereToCommand();
|
||||||
|
qDebug() << " initialized | " << message.initialized();
|
||||||
|
qDebug() << " battery low | " << message.batteryLow();
|
||||||
|
qDebug() << " link status OK | " << message.linkStatusOK();
|
||||||
|
qDebug() << " panel locked | " << message.panelLocked();
|
||||||
|
qDebug() << " gateway known | " << message.gatewayKnown();
|
||||||
|
qDebug() << " DST settings active | " << message.dtsActive();
|
||||||
|
qDebug() << " device mode | " << message.deviceModeString();
|
||||||
|
qDebug() << " valve position | " << message.valvePosition() << "%";
|
||||||
|
qDebug() << " Temperatur Setpoint | " << message.setpointTemperature() << " deg C";
|
||||||
|
qDebug() << " unknown | " << rawData.right(rawData.length() - 12);
|
||||||
|
qDebug() << "-------------------------|-------------------------";
|
||||||
|
|
||||||
|
emit liveMessageReady(message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MaxDevice::DeviceWindowContact:{
|
||||||
|
QByteArray windowOpenRawData = fillBin(QByteArray::number(rawData.mid(10,2).toInt(0,16),2),8);
|
||||||
|
bool windowOpen = (bool)windowOpenRawData.mid(5,1).toInt();
|
||||||
|
|
||||||
|
qDebug() << " raw data | " << rawData;
|
||||||
|
qDebug() << " device type | " << device->deviceTypeString();
|
||||||
|
qDebug() << " device name | " << device->deviceName();
|
||||||
|
qDebug() << " RF address (hex) | " << message.rfAddress();
|
||||||
|
qDebug() << " window open code | " << windowOpenRawData;
|
||||||
|
qDebug() << " window open | " << windowOpen;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::parseWeeklyProgram(QByteArray data)
|
void MaxCube::parseWeeklyProgram(QByteArray data)
|
||||||
{
|
{
|
||||||
for(int i=0; i<7; i++){
|
for(int i=0; i < 7; i++){
|
||||||
QByteArray dayData = data.left(52);
|
QByteArray dayData = data.left(52);
|
||||||
qDebug() << dayData;
|
//qDebug() << weekDayString(i);
|
||||||
|
for(int i = 0; i < 52; i+=4){
|
||||||
|
QByteArray element = fillBin(QByteArray::number(dayData.mid(i,4).toInt(0,16),2),16);
|
||||||
|
int minutes = element.right(9).toInt(0,2) * 5;
|
||||||
|
int hours = (minutes / 60) % 24;
|
||||||
|
minutes = minutes % 60;
|
||||||
|
QTime time = QTime(hours,minutes);
|
||||||
|
//qDebug() << (double)element.left(7).toInt(0,2) / 2 << "\t" << "deg. until" << "\t" << time.toString("HH:mm");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
data = data.right(data.length() - 52);
|
data = data.right(data.length() - 52);
|
||||||
}
|
}
|
||||||
qDebug() << "data left" << data;
|
if(!data.isEmpty()){
|
||||||
|
qDebug() << " ? | " << data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::parseNewDeviceFoundMessage(QByteArray data)
|
void MaxCube::decodeNewDeviceFoundMessage(QByteArray data)
|
||||||
{
|
{
|
||||||
if(data.isEmpty()){
|
if(data.isEmpty()){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
qDebug() << "NEW DEVICE message:";
|
qDebug() << " NEW DEVICE message:";
|
||||||
qDebug() << "====================================================";
|
qDebug() << "====================================================";
|
||||||
|
|
||||||
qDebug() << " Serial Number | " << QByteArray::fromBase64(data);
|
qDebug() << " Serial Number | " << QByteArray::fromBase64(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -385,9 +559,70 @@ QString MaxCube::deviceTypeString(int deviceType)
|
|||||||
return deviceTypeString;
|
return deviceTypeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString MaxCube::weekDayString(int weekDay)
|
||||||
|
{
|
||||||
|
QString weekDayString;
|
||||||
|
|
||||||
|
switch (weekDay) {
|
||||||
|
case Monday:
|
||||||
|
weekDayString = "Monday";
|
||||||
|
break;
|
||||||
|
case Tuesday:
|
||||||
|
weekDayString = "Tuesday";
|
||||||
|
break;
|
||||||
|
case Wednesday:
|
||||||
|
weekDayString = "Wednesday";
|
||||||
|
break;
|
||||||
|
case Thursday:
|
||||||
|
weekDayString = "Thursday";
|
||||||
|
break;
|
||||||
|
case Friday:
|
||||||
|
weekDayString = "Friday";
|
||||||
|
break;
|
||||||
|
case Saturday:
|
||||||
|
weekDayString = "Saturday";
|
||||||
|
break;
|
||||||
|
case Sunday:
|
||||||
|
weekDayString = "Sunday";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
weekDayString = "-";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return weekDayString;
|
||||||
|
}
|
||||||
|
|
||||||
QByteArray MaxCube::fillBin(QByteArray data, int dataLength)
|
QByteArray MaxCube::fillBin(QByteArray data, int dataLength)
|
||||||
{
|
{
|
||||||
|
QByteArray zeros;
|
||||||
|
for(int i = 0; i < dataLength - data.length(); i++){
|
||||||
|
zeros.append("0");
|
||||||
|
}
|
||||||
|
data = zeros.append(data);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QByteArray> MaxCube::splitMessage(QByteArray data)
|
||||||
|
{
|
||||||
|
QList<QByteArray> messageList;
|
||||||
|
while(!data.isEmpty()){
|
||||||
|
int length = data.left(2).toInt(0,16)*2;
|
||||||
|
messageList.append(data.mid(2,length));
|
||||||
|
data = data.right(data.length() - (length+2));
|
||||||
|
}
|
||||||
|
qDebug() << messageList;
|
||||||
|
return messageList;
|
||||||
|
}
|
||||||
|
|
||||||
|
MaxDevice *MaxCube::getDeviceTypeFromRFAddress(QByteArray rfAddress)
|
||||||
|
{
|
||||||
|
foreach (MaxDevice *device, m_deviceList){
|
||||||
|
if(device->rfAddress() == rfAddress){
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxCube::connected()
|
void MaxCube::connected()
|
||||||
@ -398,6 +633,7 @@ void MaxCube::connected()
|
|||||||
|
|
||||||
void MaxCube::disconnected()
|
void MaxCube::disconnected()
|
||||||
{
|
{
|
||||||
|
m_cubeInitialized = false;
|
||||||
qDebug() << "-> disconnected from cube " << m_serialNumber << m_hostAddress.toString();
|
qDebug() << "-> disconnected from cube " << m_serialNumber << m_hostAddress.toString();
|
||||||
emit cubeConnectionStatusChanged(false);
|
emit cubeConnectionStatusChanged(false);
|
||||||
}
|
}
|
||||||
@ -422,28 +658,35 @@ void MaxCube::processCubeData(const QByteArray &data)
|
|||||||
{
|
{
|
||||||
//qDebug() << "data" << data;
|
//qDebug() << "data" << data;
|
||||||
if(data.startsWith("H")){
|
if(data.startsWith("H")){
|
||||||
parseHelloMessage(data.right(data.length() -2 ));
|
decodeHelloMessage(data.right(data.length() -2 ));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// METADATA message
|
// METADATA message
|
||||||
if(data.startsWith("M")){
|
if(data.startsWith("M")){
|
||||||
parseMetadataMessage(data.right(data.length() -2 ));
|
decodeMetadataMessage(data.right(data.length() -2 ));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// CONFIG message
|
// CONFIG message
|
||||||
if(data.startsWith("C")){
|
if(data.startsWith("C")){
|
||||||
parseConfigMessage(data.right(data.length() -2 ));
|
QList<QByteArray> dataList = data.split('\r');
|
||||||
|
foreach (QByteArray dataElement, dataList) {
|
||||||
|
if(dataElement.startsWith("C")){
|
||||||
|
decodeConfigMessage(dataElement.right(dataElement.length() -2 ));
|
||||||
|
}
|
||||||
|
if(dataElement.startsWith("\nC")){
|
||||||
|
decodeConfigMessage(dataElement.right(dataElement.length() -3 ));
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// DEVICELIST message
|
// LIVE message
|
||||||
if(data.startsWith("L")){
|
if(data.startsWith("L")){
|
||||||
//customRequest("g:");
|
decodeDevicelistMessage(data.right(data.length() -2 ));
|
||||||
parseDevicelistMessage(data.right(data.length() -2 ));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// NEWDEVICEFOUND message
|
// NEWDEVICEFOUND message
|
||||||
if(data.startsWith("N")){
|
if(data.startsWith("N")){
|
||||||
parseNewDeviceFoundMessage(data.right(data.length() -2));
|
decodeNewDeviceFoundMessage(data.right(data.length() -2));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// ACK message
|
// ACK message
|
||||||
@ -469,11 +712,8 @@ void MaxCube::disablePairingMode()
|
|||||||
|
|
||||||
void MaxCube::refresh()
|
void MaxCube::refresh()
|
||||||
{
|
{
|
||||||
qDebug() << "refresh cube " << m_serialNumber;
|
if(m_cubeInitialized){
|
||||||
if(isWritable()){
|
|
||||||
write("l:\r\n");
|
write("l:\r\n");
|
||||||
}else{
|
|
||||||
qDebug() << "ERROR: could not send to " << m_hostAddress.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include "maxdevice.h"
|
#include "maxdevice.h"
|
||||||
#include "room.h"
|
#include "room.h"
|
||||||
|
#include "livemessage.h"
|
||||||
|
|
||||||
class MaxCube : public QTcpSocket
|
class MaxCube : public QTcpSocket
|
||||||
{
|
{
|
||||||
@ -33,30 +34,42 @@ class MaxCube : public QTcpSocket
|
|||||||
public:
|
public:
|
||||||
MaxCube(QObject *parent = 0, QString serialNumber = QString(), QHostAddress hostAdress = QHostAddress(), quint16 port = 0);
|
MaxCube(QObject *parent = 0, QString serialNumber = QString(), QHostAddress hostAdress = QHostAddress(), quint16 port = 0);
|
||||||
|
|
||||||
|
enum WeekDay{
|
||||||
|
Saturday = 0,
|
||||||
|
Sunday = 1,
|
||||||
|
Monday = 2,
|
||||||
|
Tuesday = 3,
|
||||||
|
Wednesday = 4,
|
||||||
|
Thursday = 5,
|
||||||
|
Friday = 6
|
||||||
|
};
|
||||||
|
|
||||||
// cube data access functions
|
// cube data access functions
|
||||||
QString serialNumber();
|
QString serialNumber() const;
|
||||||
void setSerialNumber(QString serialNumber);
|
void setSerialNumber(const QString &serialNumber);
|
||||||
|
|
||||||
QByteArray rfAddress();
|
QByteArray rfAddress() const;
|
||||||
void setRfAddress(QByteArray rfAddress);
|
void setRfAddress(const QByteArray &rfAddress);
|
||||||
|
|
||||||
int firmware();
|
int firmware() const;
|
||||||
void setFirmware(int firmware);
|
void setFirmware(const int &firmware);
|
||||||
|
|
||||||
QHostAddress hostAddress();
|
QHostAddress hostAddress() const;
|
||||||
void setHostAddress(QHostAddress hostAddress);
|
void setHostAddress(const QHostAddress &hostAddress);
|
||||||
|
|
||||||
quint16 port();
|
quint16 port() const;
|
||||||
void setPort(quint16 port);
|
void setPort(const quint16 &port);
|
||||||
|
|
||||||
QByteArray httpConnectionId();
|
QByteArray httpConnectionId() const;
|
||||||
void setHttpConnectionId(QByteArray httpConnectionId);
|
void setHttpConnectionId(const QByteArray &httpConnectionId);
|
||||||
|
|
||||||
int freeMemorySlots();
|
int freeMemorySlots() const;
|
||||||
void setFreeMemorySlots(int freeMemorySlots);
|
void setFreeMemorySlots(const int &freeMemorySlots);
|
||||||
|
|
||||||
QDateTime cubeDateTime();
|
QDateTime cubeDateTime() const;
|
||||||
void setCubeDateTime(QDateTime cubeDateTime);
|
void setCubeDateTime(const QDateTime &cubeDateTime);
|
||||||
|
|
||||||
|
bool portalEnabeld() const;
|
||||||
|
|
||||||
QList<MaxDevice*> deviceList();
|
QList<MaxDevice*> deviceList();
|
||||||
QList<Room*> roomList();
|
QList<Room*> roomList();
|
||||||
@ -65,6 +78,7 @@ public:
|
|||||||
void disconnectFromCube();
|
void disconnectFromCube();
|
||||||
bool sendData(QByteArray data);
|
bool sendData(QByteArray data);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// cube data
|
// cube data
|
||||||
QString m_serialNumber;
|
QString m_serialNumber;
|
||||||
@ -75,25 +89,34 @@ private:
|
|||||||
QByteArray m_httpConnectionId;
|
QByteArray m_httpConnectionId;
|
||||||
int m_freeMemorySlots;
|
int m_freeMemorySlots;
|
||||||
QDateTime m_cubeDateTime;
|
QDateTime m_cubeDateTime;
|
||||||
|
bool m_portalEnabeld;
|
||||||
|
|
||||||
QList<Room*> m_roomList;
|
QList<Room*> m_roomList;
|
||||||
QList<MaxDevice*> m_deviceList;
|
QList<MaxDevice*> m_deviceList;
|
||||||
|
|
||||||
void parseHelloMessage(QByteArray data);
|
bool m_cubeInitialized;
|
||||||
void parseMetadataMessage(QByteArray data);
|
|
||||||
void parseConfigMessage(QByteArray data);
|
void decodeHelloMessage(QByteArray data);
|
||||||
void parseDevicelistMessage(QByteArray data);
|
void decodeMetadataMessage(QByteArray data);
|
||||||
|
void decodeConfigMessage(QByteArray data);
|
||||||
|
void decodeDevicelistMessage(QByteArray data);
|
||||||
void parseWeeklyProgram(QByteArray data);
|
void parseWeeklyProgram(QByteArray data);
|
||||||
void parseNewDeviceFoundMessage(QByteArray data);
|
void decodeNewDeviceFoundMessage(QByteArray data);
|
||||||
|
|
||||||
QDateTime calculateDateTime(QByteArray dateRaw, QByteArray timeRaw);
|
QDateTime calculateDateTime(QByteArray dateRaw, QByteArray timeRaw);
|
||||||
QString deviceTypeString(int deviceType);
|
QString deviceTypeString(int deviceType);
|
||||||
|
QString weekDayString(int weekDay);
|
||||||
|
|
||||||
QByteArray fillBin(QByteArray data, int dataLength);
|
QByteArray fillBin(QByteArray data, int dataLength);
|
||||||
|
QList<QByteArray> splitMessage(QByteArray data);
|
||||||
|
MaxDevice *getDeviceTypeFromRFAddress(QByteArray rfAddress);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void cubeDataAvailable(const QByteArray &data);
|
void cubeDataAvailable(const QByteArray &data);
|
||||||
void cubeACK();
|
void cubeACK();
|
||||||
void cubeConnectionStatusChanged(const bool &connected);
|
void cubeConnectionStatusChanged(const bool &connected);
|
||||||
|
void deviceListReady(QList<MaxDevice*> maxDeviceList);
|
||||||
|
void liveMessageReady(const LiveMessage &liveMessage);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void connected();
|
void connected();
|
||||||
|
|||||||
@ -35,14 +35,10 @@ MaxCubeDiscovery::MaxCubeDiscovery(QObject *parent) :
|
|||||||
|
|
||||||
void MaxCubeDiscovery::detectCubes()
|
void MaxCubeDiscovery::detectCubes()
|
||||||
{
|
{
|
||||||
qDebug() << "====================================================";
|
|
||||||
qDebug() << " searching for cubes....";
|
|
||||||
|
|
||||||
m_cubeList.clear();
|
m_cubeList.clear();
|
||||||
|
|
||||||
// broadcast the hello message, every cube should respond with a 26 byte message
|
// broadcast the hello message, every cube should respond with a 26 byte message
|
||||||
m_udpSocket->writeDatagram("eQ3Max*.**********I", QHostAddress::Broadcast, m_port);
|
m_udpSocket->writeDatagram("eQ3Max*.**********I", QHostAddress::Broadcast, m_port);
|
||||||
|
|
||||||
m_timeout->start(1500);
|
m_timeout->start(1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +59,7 @@ void MaxCubeDiscovery::readData()
|
|||||||
QByteArray rfAddress = data.mid(21,3).toHex();
|
QByteArray rfAddress = data.mid(21,3).toHex();
|
||||||
int firmware = data.mid(24,2).toHex().toInt();
|
int firmware = data.mid(24,2).toHex().toInt();
|
||||||
qint16 port;
|
qint16 port;
|
||||||
|
|
||||||
// set port depending on the firmware
|
// set port depending on the firmware
|
||||||
if(firmware < 109){
|
if(firmware < 109){
|
||||||
port= 80;
|
port= 80;
|
||||||
@ -72,16 +69,6 @@ void MaxCubeDiscovery::readData()
|
|||||||
|
|
||||||
MaxCube *cube = new MaxCube(this, serialNumber, sender, port);
|
MaxCube *cube = new MaxCube(this, serialNumber, sender, port);
|
||||||
cube->setRfAddress(rfAddress);
|
cube->setRfAddress(rfAddress);
|
||||||
qDebug() << "====================================================";
|
|
||||||
qDebug() << " cube detected...";
|
|
||||||
qDebug() << "====================================================";
|
|
||||||
qDebug() << " serial number | " << cube->serialNumber();
|
|
||||||
qDebug() << " host address | " << cube->hostAddress().toString();
|
|
||||||
qDebug() << " port | " << QString::number(cube->port());
|
|
||||||
qDebug() << " rf address | " << cube->rfAddress();
|
|
||||||
qDebug() << " firmware | " << QString::number(cube->firmware());
|
|
||||||
qDebug() << "====================================================";
|
|
||||||
|
|
||||||
m_cubeList.append(cube);
|
m_cubeList.append(cube);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,12 +23,12 @@ MaxDevice::MaxDevice(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int MaxDevice::deviceType()
|
int MaxDevice::deviceType() const
|
||||||
{
|
{
|
||||||
return m_deviceType;
|
return m_deviceType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxDevice::setDeviceType(int deviceType)
|
void MaxDevice::setDeviceType(const int &deviceType)
|
||||||
{
|
{
|
||||||
m_deviceType = deviceType;
|
m_deviceType = deviceType;
|
||||||
|
|
||||||
@ -57,58 +57,58 @@ void MaxDevice::setDeviceType(int deviceType)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaxDevice::deviceTypeString()
|
QString MaxDevice::deviceTypeString() const
|
||||||
{
|
{
|
||||||
return m_deviceTypeString;
|
return m_deviceTypeString;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray MaxDevice::rfAddress()
|
QByteArray MaxDevice::rfAddress() const
|
||||||
{
|
{
|
||||||
return m_rfAddress;
|
return m_rfAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxDevice::setRfAddress(QByteArray rfAddress)
|
void MaxDevice::setRfAddress(const QByteArray &rfAddress)
|
||||||
{
|
{
|
||||||
m_rfAddress = rfAddress;
|
m_rfAddress = rfAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaxDevice::serialNumber()
|
QString MaxDevice::serialNumber() const
|
||||||
{
|
{
|
||||||
return m_serialNumber;
|
return m_serialNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxDevice::setSerialNumber(QString serialNumber)
|
void MaxDevice::setSerialNumber(const QString &serialNumber)
|
||||||
{
|
{
|
||||||
m_serialNumber = serialNumber;
|
m_serialNumber = serialNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString MaxDevice::deviceName()
|
QString MaxDevice::deviceName() const
|
||||||
{
|
{
|
||||||
return m_deviceName;
|
return m_deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxDevice::setDeviceName(QString deviceName)
|
void MaxDevice::setDeviceName(const QString &deviceName)
|
||||||
{
|
{
|
||||||
m_deviceName = deviceName;
|
m_deviceName = deviceName;
|
||||||
}
|
}
|
||||||
|
|
||||||
int MaxDevice::roomId()
|
int MaxDevice::roomId() const
|
||||||
{
|
{
|
||||||
return m_roomId;
|
return m_roomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxDevice::setRoomId(int roomId)
|
void MaxDevice::setRoomId(const int &roomId)
|
||||||
{
|
{
|
||||||
m_roomId = roomId;
|
m_roomId = roomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
Room *MaxDevice::room()
|
QString MaxDevice::roomName() const
|
||||||
{
|
{
|
||||||
return m_room;
|
return m_roomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MaxDevice::setRoom(Room *room)
|
void MaxDevice::setRoomName(const QString &roomName)
|
||||||
{
|
{
|
||||||
m_room = room;
|
m_roomName = roomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -38,25 +38,26 @@ public:
|
|||||||
DeviceEcoButton = 5
|
DeviceEcoButton = 5
|
||||||
};
|
};
|
||||||
|
|
||||||
int deviceType();
|
int deviceType() const;
|
||||||
void setDeviceType(int deviceType);
|
void setDeviceType(const int &deviceType);
|
||||||
|
|
||||||
QString deviceTypeString();
|
QString deviceTypeString() const;
|
||||||
|
|
||||||
QByteArray rfAddress();
|
QByteArray rfAddress() const;
|
||||||
void setRfAddress(QByteArray rfAddress);
|
void setRfAddress(const QByteArray &rfAddress);
|
||||||
|
|
||||||
QString serialNumber();
|
QString serialNumber() const;
|
||||||
void setSerialNumber(QString serialNumber);
|
void setSerialNumber(const QString &serialNumber);
|
||||||
|
|
||||||
QString deviceName();
|
QString deviceName() const;
|
||||||
void setDeviceName(QString deviceName);
|
void setDeviceName(const QString &deviceName);
|
||||||
|
|
||||||
int roomId();
|
int roomId() const;
|
||||||
void setRoomId(int roomId);
|
void setRoomId(const int &roomId);
|
||||||
|
|
||||||
|
QString roomName() const;
|
||||||
|
void setRoomName(const QString &roomName);
|
||||||
|
|
||||||
Room *room();
|
|
||||||
void setRoom(Room *room);
|
|
||||||
private:
|
private:
|
||||||
int m_deviceType;
|
int m_deviceType;
|
||||||
QString m_deviceTypeString;
|
QString m_deviceTypeString;
|
||||||
@ -64,7 +65,7 @@ private:
|
|||||||
QString m_serialNumber;
|
QString m_serialNumber;
|
||||||
QString m_deviceName;
|
QString m_deviceName;
|
||||||
int m_roomId;
|
int m_roomId;
|
||||||
Room *m_room;
|
QString m_roomName;
|
||||||
bool m_batteryOk;
|
bool m_batteryOk;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@ -23,32 +23,32 @@ Room::Room(QObject *parent) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int Room::roomId()
|
int Room::roomId() const
|
||||||
{
|
{
|
||||||
return m_roomId;
|
return m_roomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::setRoomId(int roomId)
|
void Room::setRoomId(const int &roomId)
|
||||||
{
|
{
|
||||||
m_roomId = roomId;
|
m_roomId = roomId;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Room::roomName()
|
QString Room::roomName() const
|
||||||
{
|
{
|
||||||
return m_roomName;
|
return m_roomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::setRoomName(QString roomName)
|
void Room::setRoomName(const QString &roomName)
|
||||||
{
|
{
|
||||||
m_roomName = roomName;
|
m_roomName = roomName;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray Room::groupRfAddress()
|
QByteArray Room::groupRfAddress() const
|
||||||
{
|
{
|
||||||
return m_groupRfAddress;
|
return m_groupRfAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Room::setGroupRfAddress(QByteArray groupRfAddress)
|
void Room::setGroupRfAddress(const QByteArray &groupRfAddress)
|
||||||
{
|
{
|
||||||
m_groupRfAddress = groupRfAddress;
|
m_groupRfAddress = groupRfAddress;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,14 +27,14 @@ class Room : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit Room(QObject *parent = 0);
|
explicit Room(QObject *parent = 0);
|
||||||
|
|
||||||
int roomId();
|
int roomId() const;
|
||||||
void setRoomId(int roomId);
|
void setRoomId(const int &roomId);
|
||||||
|
|
||||||
QString roomName();
|
QString roomName() const;
|
||||||
void setRoomName(QString roomName);
|
void setRoomName(const QString &roomName);
|
||||||
|
|
||||||
QByteArray groupRfAddress();
|
QByteArray groupRfAddress() const;
|
||||||
void setGroupRfAddress(QByteArray groupRfAddress);
|
void setGroupRfAddress(const QByteArray &groupRfAddress);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int m_roomId;
|
int m_roomId;
|
||||||
|
|||||||
@ -447,8 +447,15 @@ QPair<DeviceManager::DeviceError, QString> DevicePluginOpenweathermap::discoverD
|
|||||||
|
|
||||||
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginOpenweathermap::setupDevice(Device *device)
|
QPair<DeviceManager::DeviceSetupStatus, QString> DevicePluginOpenweathermap::setupDevice(Device *device)
|
||||||
{
|
{
|
||||||
|
foreach (Device *deviceListDevice, deviceManager()->findConfiguredDevices(openweathermapDeviceClassId)) {
|
||||||
|
if(deviceListDevice->paramValue("id").toString() == device->paramValue("id").toString()){
|
||||||
|
return reportDeviceSetup(DeviceManager::DeviceSetupStatusFailure,QString("Location " + device->paramValue("location").toString() + "allready in added"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_openweaher->update(device->paramValue("id").toString());
|
m_openweaher->update(device->paramValue("id").toString());
|
||||||
return reportDeviceSetup();
|
|
||||||
|
return reportDeviceSetup(DeviceManager::DeviceSetupStatusSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
DeviceManager::HardwareResources DevicePluginOpenweathermap::requiredHardware() const
|
DeviceManager::HardwareResources DevicePluginOpenweathermap::requiredHardware() const
|
||||||
@ -514,6 +521,7 @@ void DevicePluginOpenweathermap::weatherDataReady(const QByteArray &data)
|
|||||||
|
|
||||||
foreach (Device *device, deviceManager()->findConfiguredDevices(openweathermapDeviceClassId)) {
|
foreach (Device *device, deviceManager()->findConfiguredDevices(openweathermapDeviceClassId)) {
|
||||||
if(device->paramValue("id").toString() == dataMap.value("id").toString()){
|
if(device->paramValue("id").toString() == dataMap.value("id").toString()){
|
||||||
|
device->setName("Weather from openweathermap.org for " + device->paramValue("location").toString());
|
||||||
|
|
||||||
if(dataMap.contains("clouds")){
|
if(dataMap.contains("clouds")){
|
||||||
int cloudiness = dataMap.value("clouds").toMap().value("all").toInt();
|
int cloudiness = dataMap.value("clouds").toMap().value("all").toInt();
|
||||||
|
|||||||
Reference in New Issue
Block a user