From 20d2b6c8977d86a1413fea8cf491aa99de16e50f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 11 Aug 2025 14:59:10 +0200 Subject: [PATCH] usbrelay: Add Qt6 support --- usbrelay/integrationpluginusbrelay.cpp | 11 ++++++----- usbrelay/integrationpluginusbrelay.h | 9 ++++----- usbrelay/rawhiddevicewatcher.cpp | 4 +--- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/usbrelay/integrationpluginusbrelay.cpp b/usbrelay/integrationpluginusbrelay.cpp index 6f6bddc9..738227e8 100644 --- a/usbrelay/integrationpluginusbrelay.cpp +++ b/usbrelay/integrationpluginusbrelay.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -28,8 +28,9 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -#include "plugininfo.h" #include "integrationpluginusbrelay.h" +#include "plugininfo.h" +#include "usbrelay.h" #include #include @@ -132,9 +133,9 @@ void IntegrationPluginUsbRelay::discoverThings(ThingDiscoveryInfo *info) quint16 releaseNumber = static_cast(currentDevice->release_number); quint16 productId = static_cast(currentDevice->product_id); quint16 vendorId = static_cast(currentDevice->vendor_id); - int relayCount = QString(product.at(product.count() -1)).toInt(); + int relayCount = QString(product.at(product.length() -1)).toInt(); - qCDebug(dcUsbRelay()) << path << manufacturer << product << serialnumber << "Relay count" << relayCount << QString("%1:%2").arg(QString::number(vendorId, 16)).arg(QString::number(productId, 16)) << releaseNumber; + qCDebug(dcUsbRelay()) << path << manufacturer << product << serialnumber << "Relay count" << relayCount << QString("%1:%2").arg(QString::number(vendorId, 16), QString::number(productId, 16)) << releaseNumber; // Open it to get more details hid_device *hidDevice = nullptr; @@ -161,7 +162,7 @@ void IntegrationPluginUsbRelay::discoverThings(ThingDiscoveryInfo *info) hid_close(hidDevice); - ThingDescriptor descriptor(usbRelayConnectorThingClassId, "USB Relay Connector", QString("%1 (%2)").arg(product).arg(path)); + ThingDescriptor descriptor(usbRelayConnectorThingClassId, "USB Relay Connector", QString("%1 (%2)").arg(product, path)); ParamList params; params.append(Param(usbRelayConnectorThingPathParamTypeId, path)); params.append(Param(usbRelayConnectorThingRelayCountParamTypeId, relayCount)); diff --git a/usbrelay/integrationpluginusbrelay.h b/usbrelay/integrationpluginusbrelay.h index 45d0ea6b..b576f237 100644 --- a/usbrelay/integrationpluginusbrelay.h +++ b/usbrelay/integrationpluginusbrelay.h @@ -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,8 +31,9 @@ #ifndef INTEGRATIONPLUGINUSBRELAY_H #define INTEGRATIONPLUGINUSBRELAY_H -#include "usbrelay.h" -#include "integrations/integrationplugin.h" +#include + +class UsbRelay; class IntegrationPluginUsbRelay: public IntegrationPlugin { @@ -41,7 +42,6 @@ class IntegrationPluginUsbRelay: public IntegrationPlugin Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginusbrelay.json") Q_INTERFACES(IntegrationPlugin) - public: explicit IntegrationPluginUsbRelay(); @@ -59,7 +59,6 @@ private: Thing *getRelayDevice(Thing *parentDevice, int relayNumber); UsbRelay *getRelayForDevice(Thing *relayDevice); -private slots: }; diff --git a/usbrelay/rawhiddevicewatcher.cpp b/usbrelay/rawhiddevicewatcher.cpp index 67b489d6..6100b243 100644 --- a/usbrelay/rawhiddevicewatcher.cpp +++ b/usbrelay/rawhiddevicewatcher.cpp @@ -1,6 +1,6 @@ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * -* Copyright 2013 - 2020, nymea GmbH +* Copyright 2013 - 2025, nymea GmbH * Contact: contact@nymea.io * * This file is part of nymea. @@ -81,7 +81,6 @@ RawHidDeviceWatcher::RawHidDeviceWatcher(QObject *parent) : QObject(parent) return; } - udev_enumerate_add_match_subsystem(enumerate, "hidraw"); udev_enumerate_scan_devices(enumerate); devices = udev_enumerate_get_list_entry(enumerate); @@ -96,7 +95,6 @@ RawHidDeviceWatcher::RawHidDeviceWatcher(QObject *parent) : QObject(parent) qCDebug(dcUsbRelay()) << "[+]" << devicePath; m_devicePaths.append(devicePath); - emit deviceAdded(devicePath); } udev_enumerate_unref(enumerate);