diff --git a/evbox/evbox.pro b/evbox/evbox.pro index e149ca78..9738dcb4 100644 --- a/evbox/evbox.pro +++ b/evbox/evbox.pro @@ -1,13 +1,11 @@ include(../plugins.pri) -QT += network serialport +QT *= network serialport SOURCES += \ - evboxdiscovery.cpp \ evboxport.cpp \ integrationpluginevbox.cpp \ HEADERS += \ - evboxdiscovery.h \ evboxport.h \ integrationpluginevbox.h \ diff --git a/evbox/evboxdiscovery.cpp b/evbox/evboxdiscovery.cpp deleted file mode 100644 index 72787fb5..00000000 --- a/evbox/evboxdiscovery.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* -* Copyright 2013 - 2023, nymea GmbH -* Contact: contact@nymea.io -* -* This file is part of nymea. -* This project including source code and documentation is protected by -* copyright law, and remains the property of nymea GmbH. All rights, including -* reproduction, publication, editing and translation, are reserved. The use of -* this project is subject to the terms of a license agreement to be concluded -* with nymea GmbH in accordance with the terms of use of nymea GmbH, available -* under https://nymea.io/license -* -* GNU Lesser General Public License Usage -* Alternatively, this project may be redistributed and/or modified under the -* terms of the GNU Lesser General Public License as published by the Free -* Software Foundation; version 3. This project is distributed in the hope that -* it will be useful, but WITHOUT ANY WARRANTY; without even the implied -* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this project. If not, see . -* -* For any further details and any questions please contact us under -* contact@nymea.io or see our FAQ/Licensing Information on -* https://nymea.io/license/faq -* -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#include "evboxdiscovery.h" - -EVBoxDiscovery::EVBoxDiscovery(EVBoxPort *evboxPort, QObject *parent) - : QObject{parent}, - m_port{evboxPort} -{ - -} - diff --git a/evbox/evboxdiscovery.h b/evbox/evboxdiscovery.h deleted file mode 100644 index edcffd14..00000000 --- a/evbox/evboxdiscovery.h +++ /dev/null @@ -1,51 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* -* Copyright 2013 - 2023, nymea GmbH -* Contact: contact@nymea.io -* -* This file is part of nymea. -* This project including source code and documentation is protected by -* copyright law, and remains the property of nymea GmbH. All rights, including -* reproduction, publication, editing and translation, are reserved. The use of -* this project is subject to the terms of a license agreement to be concluded -* with nymea GmbH in accordance with the terms of use of nymea GmbH, available -* under https://nymea.io/license -* -* GNU Lesser General Public License Usage -* Alternatively, this project may be redistributed and/or modified under the -* terms of the GNU Lesser General Public License as published by the Free -* Software Foundation; version 3. This project is distributed in the hope that -* it will be useful, but WITHOUT ANY WARRANTY; without even the implied -* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* Lesser General Public License for more details. -* -* You should have received a copy of the GNU Lesser General Public License -* along with this project. If not, see . -* -* For any further details and any questions please contact us under -* contact@nymea.io or see our FAQ/Licensing Information on -* https://nymea.io/license/faq -* -* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -#ifndef EVBOXDISCOVERY_H -#define EVBOXDISCOVERY_H - -#include -#include "evboxport.h" - -class EVBoxDiscovery : public QObject -{ - Q_OBJECT -public: - explicit EVBoxDiscovery(EVBoxPort *evboxPort, QObject *parent = nullptr); - -signals: - - -private: - EVBoxPort *m_port = nullptr; - -}; - -#endif // EVBOXDISCOVERY_H diff --git a/evbox/evboxport.cpp b/evbox/evboxport.cpp index 8c60a452..9f8114c5 100644 --- a/evbox/evboxport.cpp +++ b/evbox/evboxport.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2023, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -30,17 +30,14 @@ #include "evboxport.h" +#include #include #include "extern-plugininfo.h" - -#include - #define STX 0x02 #define ETX 0x03 - EVBoxPort::EVBoxPort(const QString &portName, QObject *parent) : QObject{parent} { @@ -51,8 +48,11 @@ EVBoxPort::EVBoxPort(const QString &portName, QObject *parent) m_serialPort->setParity(QSerialPort::NoParity); connect(m_serialPort, &QSerialPort::readyRead, this, &EVBoxPort::onReadyRead); - +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + connect(m_serialPort, &QSerialPort::errorOccurred, this, [this](){ +#else connect(m_serialPort, static_cast(&QSerialPort::error), this, [=](){ +#endif qCWarning(dcEVBox()) << "Serial Port error" << m_serialPort->error() << m_serialPort->errorString(); if (m_serialPort->error() != QSerialPort::NoError) { if (m_serialPort->isOpen()) { @@ -262,7 +262,7 @@ void EVBoxPort::processQueue() commandData += "80"; // Dst addr commandData += "A0"; // Sender address - commandData += QString::number(cmd.command); + commandData += QString::number(cmd.command).toUtf8(); qCDebug(dcEVBox()) << "Sending command" << cmd.command << "to" << cmd.serial << "MaxCurrent:" << cmd.maxChargingCurrent; @@ -272,7 +272,7 @@ void EVBoxPort::processQueue() processQueue(); return; } - commandData += cmd.serial; + commandData += cmd.serial.toUtf8(); // The content of the “information module” is 16 bytes in size and not defined. ¯\_(ツ)_/¯ commandData += "00112233445566778899AABBCCDDEEFF"; @@ -281,16 +281,16 @@ void EVBoxPort::processQueue() } - commandData += QString("%1").arg(cmd.maxChargingCurrent * 10, 4, 10, QChar('0')); - commandData += QString("%1").arg(cmd.maxChargingCurrent * 10, 4, 10, QChar('0')); - commandData += QString("%1").arg(cmd.maxChargingCurrent * 10, 4, 10, QChar('0')); - commandData += QString("%1").arg(cmd.timeout, 4, 10, QChar('0')); + commandData += QString("%1").arg(cmd.maxChargingCurrent * 10, 4, 10, QChar('0')).toUtf8(); + commandData += QString("%1").arg(cmd.maxChargingCurrent * 10, 4, 10, QChar('0')).toUtf8(); + commandData += QString("%1").arg(cmd.maxChargingCurrent * 10, 4, 10, QChar('0')).toUtf8(); + commandData += QString("%1").arg(cmd.timeout, 4, 10, QChar('0')).toUtf8(); // If we fail to refresh the wallbox after the timeout, it shall turn off, which is what we'll use as default // when we don't know what its set to (as we can't read it). // Hence we do *not* cache the power and maxChargingCurrent states for this one - commandData += QString("%1").arg(6, 4, 10, QChar('0')); - commandData += QString("%1").arg(6, 4, 10, QChar('0')); - commandData += QString("%1").arg(6, 4, 10, QChar('0')); + commandData += QString("%1").arg(6, 4, 10, QChar('0')).toUtf8(); + commandData += QString("%1").arg(6, 4, 10, QChar('0')).toUtf8(); + commandData += QString("%1").arg(6, 4, 10, QChar('0')).toUtf8(); commandData += createChecksum(commandData); diff --git a/evbox/integrationpluginevbox.cpp b/evbox/integrationpluginevbox.cpp index de807a91..94109a00 100644 --- a/evbox/integrationpluginevbox.cpp +++ b/evbox/integrationpluginevbox.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2022, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -28,10 +28,8 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - #include "integrationpluginevbox.h" #include "plugininfo.h" -#include "plugintimer.h" #include "evboxport.h" #include diff --git a/evbox/integrationpluginevbox.h b/evbox/integrationpluginevbox.h index c1df0234..2104b5e1 100644 --- a/evbox/integrationpluginevbox.h +++ b/evbox/integrationpluginevbox.h @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2022, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -31,11 +31,10 @@ #ifndef INTEGRATIONPLUGINEVBOX_H #define INTEGRATIONPLUGINEVBOX_H -#include "integrations/integrationplugin.h" - -#include "evboxport.h" +#include #include "extern-plugininfo.h" +#include "evboxport.h" #include #include @@ -63,9 +62,9 @@ private: void finishPendingAction(Thing *thing); private: - QHash m_ports; - QHash> m_pendingActions; - QHash m_waitingForResponses; + QHash m_ports; + QHash> m_pendingActions; + QHash m_waitingForResponses; PluginTimer *m_timer = nullptr; };