tplink: Add Qt6 support
This commit is contained in:
parent
1d629d50a6
commit
d2593bb465
@ -38,6 +38,7 @@
|
||||
#include <QJsonDocument>
|
||||
#include <QTimer>
|
||||
#include <QDataStream>
|
||||
#include <QRegularExpression>
|
||||
|
||||
// Related projects:
|
||||
|
||||
@ -138,19 +139,19 @@ void IntegrationPluginTPLink::discoverThings(ThingDiscoveryInfo *info)
|
||||
|
||||
qCWarning(dcTplink()) << qUtf8Printable(jsonDoc.toJson(QJsonDocument::Indented));
|
||||
|
||||
QRegExp modelFilter;
|
||||
QRegularExpression modelFilter;
|
||||
if (info->thingClassId() == kasaPlug100ThingClassId) {
|
||||
modelFilter = QRegExp("(HS100|HS103|HS105|KP100|KP105).*");
|
||||
modelFilter = QRegularExpression("(HS100|HS103|HS105|KP100|KP105).*");
|
||||
} else if (info->thingClassId() == kasaPlug110ThingClassId) {
|
||||
modelFilter = QRegExp("(HS110|KP115).*");
|
||||
modelFilter = QRegularExpression("(HS110|KP115).*");
|
||||
} else if (info->thingClassId() == kasaSwitch200ThingClassId) {
|
||||
modelFilter = QRegExp("HS200.*");
|
||||
modelFilter = QRegularExpression("HS200.*");
|
||||
} else if (info->thingClassId() == kasaPowerStrip300ThingClassId) {
|
||||
modelFilter = QRegExp("HS300.*");
|
||||
modelFilter = QRegularExpression("HS300.*");
|
||||
}
|
||||
QString model = sysInfo.value("model").toString();
|
||||
|
||||
if (modelFilter.exactMatch(model)) {
|
||||
if (modelFilter.match(model).hasMatch()) {
|
||||
ThingDescriptor descriptor(info->thingClassId(), sysInfo.value("alias").toString(), sysInfo.value("dev_name").toString());
|
||||
Param idParam = Param(idParamTypesMap.value(info->thingClassId()), sysInfo.value("deviceId").toString());
|
||||
descriptor.setParams(ParamList() << idParam);
|
||||
@ -363,7 +364,7 @@ void IntegrationPluginTPLink::executeAction(ThingActionInfo *info)
|
||||
job.data = data;
|
||||
job.actionInfo = info;
|
||||
m_jobQueue[targetThing].append(job);
|
||||
connect(info, &ThingActionInfo::aborted, this, [=](){
|
||||
connect(info, &ThingActionInfo::aborted, targetThing, [this, targetThing, job](){
|
||||
m_jobQueue[targetThing].removeAll(job);
|
||||
});
|
||||
|
||||
@ -422,8 +423,12 @@ void IntegrationPluginTPLink::connectToDevice(Thing *thing, const QHostAddress &
|
||||
fetchState(thing);
|
||||
});
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
|
||||
connect(socket, &QTcpSocket::errorOccurred, this, [](QAbstractSocket::SocketError error){
|
||||
#else
|
||||
typedef void (QTcpSocket:: *errorSignal)(QAbstractSocket::SocketError);
|
||||
connect(socket, static_cast<errorSignal>(&QTcpSocket::error), thing, [](QAbstractSocket::SocketError error) {
|
||||
#endif
|
||||
qCWarning(dcTplink()) << "Error in device connection:" << error;
|
||||
});
|
||||
|
||||
|
||||
@ -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,7 +31,7 @@
|
||||
#ifndef INTEGRATIONPLUGINTPLINK_H
|
||||
#define INTEGRATIONPLUGINTPLINK_H
|
||||
|
||||
#include "integrations/integrationplugin.h"
|
||||
#include <integrations/integrationplugin.h>
|
||||
|
||||
#include <QUdpSocket>
|
||||
|
||||
@ -49,7 +49,7 @@ class IntegrationPluginTPLink: public IntegrationPlugin
|
||||
|
||||
public:
|
||||
explicit IntegrationPluginTPLink();
|
||||
~IntegrationPluginTPLink();
|
||||
~IntegrationPluginTPLink() override;
|
||||
|
||||
void init() override;
|
||||
void discoverThings(ThingDiscoveryInfo *info) override;
|
||||
@ -73,18 +73,19 @@ private:
|
||||
int id = 0;
|
||||
QByteArray data;
|
||||
ThingActionInfo *actionInfo = nullptr;
|
||||
bool operator==(const Job &other) { return id == other.id; }
|
||||
bool operator==(const Job &other) const { return id == other.id; }
|
||||
};
|
||||
QHash<Thing*, Job> m_pendingJobs;
|
||||
QHash<Thing*, QList<Job>> m_jobQueue;
|
||||
QHash<Thing*, QTimer*> m_jobTimers;
|
||||
|
||||
QHash<Thing *, Job> m_pendingJobs;
|
||||
QHash<Thing *, QList<Job>> m_jobQueue;
|
||||
QHash<Thing *, QTimer *> m_jobTimers;
|
||||
int m_jobIdx = 0;
|
||||
|
||||
QUdpSocket *m_broadcastSocket = nullptr;
|
||||
QHash<Thing*, QTcpSocket*> m_sockets;
|
||||
QHash<ThingSetupInfo*, int> m_setupRetries;
|
||||
QHash<Thing *, QTcpSocket *> m_sockets;
|
||||
QHash<ThingSetupInfo *, int> m_setupRetries;
|
||||
|
||||
QHash<Thing*, QByteArray> m_inputBuffers;
|
||||
QHash<Thing *, QByteArray> m_inputBuffers;
|
||||
|
||||
PluginTimer *m_timer = nullptr;
|
||||
};
|
||||
|
||||
@ -3,10 +3,10 @@ include(../plugins.pri)
|
||||
QT += network
|
||||
|
||||
SOURCES += \
|
||||
integrationplugintplink.cpp \
|
||||
integrationplugintplink.cpp
|
||||
|
||||
HEADERS += \
|
||||
integrationplugintplink.h \
|
||||
integrationplugintplink.h
|
||||
|
||||
OTHER_FILES += \
|
||||
sampledata/HS200.txt \
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user