fixed udp init, polished debug output, fixed missing debian dependency
This commit is contained in:
parent
1c2c04f187
commit
238efba31c
1
debian/control
vendored
1
debian/control
vendored
@ -973,6 +973,7 @@ Depends: ${shlibs:Depends},
|
|||||||
${misc:Depends},
|
${misc:Depends},
|
||||||
nymea-plugins-translations,
|
nymea-plugins-translations,
|
||||||
nmap,
|
nmap,
|
||||||
|
arping,
|
||||||
Replaces: guh-plugin-keba
|
Replaces: guh-plugin-keba
|
||||||
Description: nymea.io plugin for keba
|
Description: nymea.io plugin for keba
|
||||||
The nymea daemon is a plugin based IoT (Internet of Things) server. The
|
The nymea daemon is a plugin based IoT (Internet of Things) server. The
|
||||||
|
|||||||
@ -109,7 +109,7 @@ void Discovery::discoveryFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||||||
QXmlStreamReader reader(data);
|
QXmlStreamReader reader(data);
|
||||||
|
|
||||||
int foundHosts = 0;
|
int foundHosts = 0;
|
||||||
|
qCDebug(dcKebaKeContact()) << "nmap finished network discovery:";
|
||||||
while (!reader.atEnd() && !reader.hasError()) {
|
while (!reader.atEnd() && !reader.hasError()) {
|
||||||
QXmlStreamReader::TokenType token = reader.readNext();
|
QXmlStreamReader::TokenType token = reader.readNext();
|
||||||
if(token == QXmlStreamReader::StartDocument)
|
if(token == QXmlStreamReader::StartDocument)
|
||||||
@ -143,7 +143,7 @@ void Discovery::discoveryFinished(int exitCode, QProcess::ExitStatus exitStatus)
|
|||||||
|
|
||||||
if (isUp) {
|
if (isUp) {
|
||||||
foundHosts++;
|
foundHosts++;
|
||||||
qCDebug(dcKebaKeContact()) << "Have host:" << address;
|
qCDebug(dcKebaKeContact()) << " - host:" << address;
|
||||||
|
|
||||||
Host *host = new Host();
|
Host *host = new Host();
|
||||||
host->setAddress(address);
|
host->setAddress(address);
|
||||||
@ -264,7 +264,7 @@ void Discovery::finishDiscovery()
|
|||||||
qDeleteAll(m_scanResults);
|
qDeleteAll(m_scanResults);
|
||||||
m_scanResults.clear();
|
m_scanResults.clear();
|
||||||
|
|
||||||
qCDebug(dcKebaKeContact()) << "Emitting device discovered for" << hosts.count() << "devices";
|
qCDebug(dcKebaKeContact()) << "Found" << hosts.count() << "network devices";
|
||||||
m_timeoutTimer.stop();
|
m_timeoutTimer.stop();
|
||||||
emit finished(hosts);
|
emit finished(hosts);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,11 +85,13 @@ void IntegrationPluginKeba::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
if (!host.hostName().contains("keba", Qt::CaseSensitivity::CaseInsensitive))
|
if (!host.hostName().contains("keba", Qt::CaseSensitivity::CaseInsensitive))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
qCDebug(dcKebaKeContact()) << " - Keba Wallbox" << host.address() << host.macAddress();
|
||||||
ThingDescriptor descriptor(wallboxThingClassId, "Wallbox", host.address() + " (" + host.macAddress() + ")");
|
ThingDescriptor descriptor(wallboxThingClassId, "Wallbox", host.address() + " (" + host.macAddress() + ")");
|
||||||
|
|
||||||
// Rediscovery
|
// Rediscovery
|
||||||
foreach (Thing *existingThing, myThings()) {
|
foreach (Thing *existingThing, myThings()) {
|
||||||
if (existingThing->paramValue(wallboxThingMacAddressParamTypeId).toString() == host.macAddress()) {
|
if (existingThing->paramValue(wallboxThingMacAddressParamTypeId).toString() == host.macAddress()) {
|
||||||
|
qCDebug(dcKebaKeContact()) << " - Device is already added";
|
||||||
descriptor.setThingId(existingThing->id());
|
descriptor.setThingId(existingThing->id());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -118,7 +120,7 @@ void IntegrationPluginKeba::setupThing(ThingSetupInfo *info)
|
|||||||
|
|
||||||
if(!m_udpSocket){
|
if(!m_udpSocket){
|
||||||
m_udpSocket = new QUdpSocket(this);
|
m_udpSocket = new QUdpSocket(this);
|
||||||
if (!m_udpSocket->bind(QHostAddress::AnyIPv4, 7090, QAbstractSocket::ShareAddress)) {
|
if (!m_udpSocket->bind(QHostAddress::AnyIPv4, 7090, QAbstractSocket::DefaultForPlatform)) {
|
||||||
qCWarning(dcKebaKeContact()) << "Cannot bind to port" << 7090;
|
qCWarning(dcKebaKeContact()) << "Cannot bind to port" << 7090;
|
||||||
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("Error opening network port."));
|
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("Error opening network port."));
|
||||||
}
|
}
|
||||||
@ -137,9 +139,8 @@ void IntegrationPluginKeba::setupThing(ThingSetupInfo *info)
|
|||||||
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("Error opening network port."));
|
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("Error opening network port."));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_kebaDevices.insert(thing->id(), keba);
|
|
||||||
keba->getReport1();
|
keba->getReport1();
|
||||||
connect(keba, &KeContact::reportOneReceived, info, [info] (const KeContact::ReportOne &report) {
|
connect(keba, &KeContact::reportOneReceived, info, [info, this, keba] (const KeContact::ReportOne &report) {
|
||||||
Thing *thing = info->thing();
|
Thing *thing = info->thing();
|
||||||
|
|
||||||
qCDebug(dcKebaKeContact()) << "Report one received for" << thing->name();
|
qCDebug(dcKebaKeContact()) << "Report one received for" << thing->name();
|
||||||
@ -152,12 +153,13 @@ void IntegrationPluginKeba::setupThing(ThingSetupInfo *info)
|
|||||||
thing->setStateValue(wallboxFirmwareStateTypeId, report.firmware);
|
thing->setStateValue(wallboxFirmwareStateTypeId, report.firmware);
|
||||||
thing->setStateValue(wallboxModelStateTypeId, report.product);
|
thing->setStateValue(wallboxModelStateTypeId, report.product);
|
||||||
thing->setStateValue(wallboxUptimeStateTypeId, report.seconds);
|
thing->setStateValue(wallboxUptimeStateTypeId, report.seconds);
|
||||||
|
|
||||||
|
m_kebaDevices.insert(thing->id(), keba);
|
||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
});
|
});
|
||||||
connect(info, &ThingSetupInfo::aborted, keba, &KeContact::deleteLater);
|
connect(info, &ThingSetupInfo::aborted, keba, &KeContact::deleteLater);
|
||||||
connect(keba, &KeContact::destroyed, this, [thing, keba, this]{
|
connect(keba, &KeContact::destroyed, this, [thing, this]{
|
||||||
m_kebaDevices.remove(thing->id());
|
m_kebaDevices.remove(thing->id());
|
||||||
keba->deleteLater();
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcKebaKeContact()) << "setupDevice, unhandled device class" << thing->thingClass();
|
qCWarning(dcKebaKeContact()) << "setupDevice, unhandled device class" << thing->thingClass();
|
||||||
@ -224,6 +226,11 @@ void IntegrationPluginKeba::thingRemoved(Thing *thing)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (myThings().empty()) {
|
if (myThings().empty()) {
|
||||||
|
qCDebug(dcKebaKeContact()) << "Closing UDP Ports";
|
||||||
|
m_udpSocket->close();
|
||||||
|
m_udpSocket->deleteLater();
|
||||||
|
m_udpSocket = nullptr;
|
||||||
|
|
||||||
qCDebug(dcKebaKeContact()) << "Stopping plugin timers";
|
qCDebug(dcKebaKeContact()) << "Stopping plugin timers";
|
||||||
hardwareManager()->pluginTimerManager()->unregisterTimer(m_reconnectTimer);
|
hardwareManager()->pluginTimerManager()->unregisterTimer(m_reconnectTimer);
|
||||||
m_reconnectTimer = nullptr;
|
m_reconnectTimer = nullptr;
|
||||||
|
|||||||
@ -142,7 +142,7 @@
|
|||||||
"displayNameAction": "Set maximal charging current",
|
"displayNameAction": "Set maximal charging current",
|
||||||
"type": "uint",
|
"type": "uint",
|
||||||
"unit": "MilliAmpere",
|
"unit": "MilliAmpere",
|
||||||
"defaultValue": 6000,
|
"defaultValue": 6,
|
||||||
"minValue": 6000,
|
"minValue": 6000,
|
||||||
"maxValue": 63000,
|
"maxValue": 63000,
|
||||||
"writable": true
|
"writable": true
|
||||||
@ -158,6 +158,15 @@
|
|||||||
"minValue": 0,
|
"minValue": 0,
|
||||||
"maxValue": 100
|
"maxValue": 100
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "08bb9872-8d63-49b0-a8ce-7a449341f13b",
|
||||||
|
"name": "maxPossibleChargingCurrent",
|
||||||
|
"displayName": "Maximum possible charging current",
|
||||||
|
"displayNameEvent": "Maximum possible charging current changed",
|
||||||
|
"type": "double",
|
||||||
|
"unit": "Ampere",
|
||||||
|
"defaultValue": 6.00
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "4a2d75d8-a3a0-4b40-9ca7-e8b6f11d0ef9",
|
"id": "4a2d75d8-a3a0-4b40-9ca7-e8b6f11d0ef9",
|
||||||
"name": "voltagePhase1",
|
"name": "voltagePhase1",
|
||||||
|
|||||||
@ -58,10 +58,6 @@ bool KeContact::init(){
|
|||||||
qCDebug(dcKebaKeContact()) << "Initializing Keba connection";
|
qCDebug(dcKebaKeContact()) << "Initializing Keba connection";
|
||||||
if(m_udpSocket){
|
if(m_udpSocket){
|
||||||
connect(m_udpSocket, &QUdpSocket::readyRead, this, &KeContact::readPendingDatagrams);
|
connect(m_udpSocket, &QUdpSocket::readyRead, this, &KeContact::readPendingDatagrams);
|
||||||
if (!m_udpSocket->bind(QHostAddress::AnyIPv4, m_port, QAbstractSocket::ShareAddress)) {
|
|
||||||
qCWarning(dcKebaKeContact()) << "Cannot bind to port" << m_port;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcKebaKeContact()) << "UDP socket not valid";
|
qCWarning(dcKebaKeContact()) << "UDP socket not valid";
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user