diff --git a/debian/control b/debian/control index 62258bd4..6882da39 100644 --- a/debian/control +++ b/debian/control @@ -70,7 +70,8 @@ Depends: libqt5network5, libnymea1 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends} -Recommends: nymea-cli, +Recommends: nymea-cli, + nymea-data, network-manager, nymea-update-plugin-impl, nymea-system-plugin-impl, @@ -86,6 +87,22 @@ Description: An open source IoT server - daemon This package will install the daemon. +Package: nymea-data +Section: misc +Architecture: all +Depends: ${misc:Depends} +Recommends: nymea +Description: Optional data for extending functionality in nymea daemon + The nymea daemon is a plugin based IoT (Internet of Things) server. The + server works like a translator for devices, things and services and + allows them to interact. + With the powerful rule engine you are able to connect any device available + in the system and create individual scenes and behaviors for your environment. + . + This package provides the MAC address database for nymead and for the plugins in + order to get the manufacturer name for a given MAC address. + + Package: nymea-doc Section: doc Architecture: all diff --git a/debian/nymea-data.install b/debian/nymea-data.install new file mode 100644 index 00000000..2257e466 --- /dev/null +++ b/debian/nymea-data.install @@ -0,0 +1,2 @@ +data/mac-database/mac-addresses.db usr/share/nymea/ + diff --git a/libnymea/network/macaddressdatabase.cpp b/libnymea/network/macaddressdatabase.cpp index 4b652786..15ae6652 100644 --- a/libnymea/network/macaddressdatabase.cpp +++ b/libnymea/network/macaddressdatabase.cpp @@ -189,7 +189,7 @@ QString MacAddressDatabase::lookupMacAddressVendorInternal(const QString &macAdd // Found to many results, lets add a value until we find the matching vendor length += 1; - if (length > fullMacAddressString) + if (length > fullMacAddressString.length()) break; // Search with one addition digit diff --git a/libnymea/network/ping.cpp b/libnymea/network/ping.cpp index 54b66fdd..e7b51f1a 100644 --- a/libnymea/network/ping.cpp +++ b/libnymea/network/ping.cpp @@ -43,7 +43,6 @@ #include #include -#include NYMEA_LOGGING_CATEGORY(dcPing, "Ping") NYMEA_LOGGING_CATEGORY(dcPingTraffic, "PingTraffic") @@ -350,23 +349,15 @@ void Ping::onSocketReadyRead(int socketDescriptor) timeValueSubtract(&receiveTimeValue, &reply->m_startTime); reply->m_duration = qRound((receiveTimeValue.tv_sec * 1000 + (double)receiveTimeValue.tv_usec / 1000) * 100) / 100.0; - QHostInfo::lookupHost(senderAddress.toString(), this, [=](const QHostInfo &info){ - if (info.error() != QHostInfo::NoError) { - qCWarning(dcPing()) << "Failed to look up hostname after successfull ping" << senderAddress.toString() << info.error(); - } else { - qCDebug(dcPing()) << "********Looked up hostname after successfull ping" << senderAddress.toString() << info.hostName(); - if (info.hostName() != senderAddress.toString()) { - reply->m_hostName = info.hostName(); - } - } + // Note: due to a Qt bug < 5.9 we need to use old SLOT style and cannot make use of lambda here + int lookupId = QHostInfo::lookupHost(senderAddress.toString(), this, SLOT(onHostLookupFinished(const QHostInfo &info))); + m_pendingHostLookups.insert(lookupId, reply); - qCDebug(dcPingTraffic()) << "Received ICMP response" << reply->targetHostAddress().toString() << ICMP_PACKET_SIZE << "[Bytes]" - << "ID:" << QString("0x%1").arg(responsePacket->icmp_id, 4, 16, QChar('0')) - << "Sequence:" << htons(responsePacket->icmp_seq) - << "Time:" << reply->duration() << "[ms]" << info.hostName(); + qCDebug(dcPingTraffic()) << "Received ICMP response" << reply->targetHostAddress().toString() << ICMP_PACKET_SIZE << "[Bytes]" + << "ID:" << QString("0x%1").arg(responsePacket->icmp_id, 4, 16, QChar('0')) + << "Sequence:" << htons(responsePacket->icmp_seq) + << "Time:" << reply->duration() << "[ms]"; - finishReply(reply, PingReply::ErrorNoError); - }); } else if (responsePacket->icmp_type == ICMP_DEST_UNREACH) { // Get the sending package @@ -409,3 +400,23 @@ void Ping::onSocketReadyRead(int socketDescriptor) } } +void Ping::onHostLookupFinished(const QHostInfo &info) +{ + PingReply *reply = m_pendingHostLookups.value(info.lookupId()); + if (!reply) { + qCWarning(dcPing()) << "Could not find reply after host lookup."; + return; + } + + if (info.error() != QHostInfo::NoError) { + qCWarning(dcPing()) << "Failed to look up hostname after successfull ping" << reply->targetHostAddress().toString() << info.error(); + } else { + qCDebug(dcPing()) << "********Looked up hostname after successfull ping" << reply->targetHostAddress().toString() << info.hostName(); + if (info.hostName() != reply->targetHostAddress().toString()) { + reply->m_hostName = info.hostName(); + } + } + + finishReply(reply, PingReply::ErrorNoError); +} + diff --git a/libnymea/network/ping.h b/libnymea/network/ping.h index 3ce13f84..065b002d 100644 --- a/libnymea/network/ping.h +++ b/libnymea/network/ping.h @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -88,6 +89,7 @@ private: QQueue m_replyQueue; QTimer *m_queueTimer = nullptr; void sendNextReply(); + QHash m_pendingHostLookups; //Error performPing(const QString &address); void performPing(PingReply *reply); @@ -103,6 +105,7 @@ private: private slots: void onSocketReadyRead(int socketDescriptor); + void onHostLookupFinished(const QHostInfo &info); };