usbrelay: Add Qt6 support

This commit is contained in:
Simon Stürz 2025-08-11 14:59:10 +02:00
parent 673a25ef8d
commit 20d2b6c897
3 changed files with 11 additions and 13 deletions

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2025, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -28,8 +28,9 @@
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "plugininfo.h"
#include "integrationpluginusbrelay.h" #include "integrationpluginusbrelay.h"
#include "plugininfo.h"
#include "usbrelay.h"
#include <QTimer> #include <QTimer>
#include <hidapi/hidapi.h> #include <hidapi/hidapi.h>
@ -132,9 +133,9 @@ void IntegrationPluginUsbRelay::discoverThings(ThingDiscoveryInfo *info)
quint16 releaseNumber = static_cast<quint16>(currentDevice->release_number); quint16 releaseNumber = static_cast<quint16>(currentDevice->release_number);
quint16 productId = static_cast<quint16>(currentDevice->product_id); quint16 productId = static_cast<quint16>(currentDevice->product_id);
quint16 vendorId = static_cast<quint16>(currentDevice->vendor_id); quint16 vendorId = static_cast<quint16>(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 // Open it to get more details
hid_device *hidDevice = nullptr; hid_device *hidDevice = nullptr;
@ -161,7 +162,7 @@ void IntegrationPluginUsbRelay::discoverThings(ThingDiscoveryInfo *info)
hid_close(hidDevice); 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; ParamList params;
params.append(Param(usbRelayConnectorThingPathParamTypeId, path)); params.append(Param(usbRelayConnectorThingPathParamTypeId, path));
params.append(Param(usbRelayConnectorThingRelayCountParamTypeId, relayCount)); params.append(Param(usbRelayConnectorThingRelayCountParamTypeId, relayCount));

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2025, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -31,8 +31,9 @@
#ifndef INTEGRATIONPLUGINUSBRELAY_H #ifndef INTEGRATIONPLUGINUSBRELAY_H
#define INTEGRATIONPLUGINUSBRELAY_H #define INTEGRATIONPLUGINUSBRELAY_H
#include "usbrelay.h" #include <integrations/integrationplugin.h>
#include "integrations/integrationplugin.h"
class UsbRelay;
class IntegrationPluginUsbRelay: public IntegrationPlugin class IntegrationPluginUsbRelay: public IntegrationPlugin
{ {
@ -41,7 +42,6 @@ class IntegrationPluginUsbRelay: public IntegrationPlugin
Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginusbrelay.json") Q_PLUGIN_METADATA(IID "io.nymea.IntegrationPlugin" FILE "integrationpluginusbrelay.json")
Q_INTERFACES(IntegrationPlugin) Q_INTERFACES(IntegrationPlugin)
public: public:
explicit IntegrationPluginUsbRelay(); explicit IntegrationPluginUsbRelay();
@ -59,7 +59,6 @@ private:
Thing *getRelayDevice(Thing *parentDevice, int relayNumber); Thing *getRelayDevice(Thing *parentDevice, int relayNumber);
UsbRelay *getRelayForDevice(Thing *relayDevice); UsbRelay *getRelayForDevice(Thing *relayDevice);
private slots:
}; };

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* Copyright 2013 - 2020, nymea GmbH * Copyright 2013 - 2025, nymea GmbH
* Contact: contact@nymea.io * Contact: contact@nymea.io
* *
* This file is part of nymea. * This file is part of nymea.
@ -81,7 +81,6 @@ RawHidDeviceWatcher::RawHidDeviceWatcher(QObject *parent) : QObject(parent)
return; return;
} }
udev_enumerate_add_match_subsystem(enumerate, "hidraw"); udev_enumerate_add_match_subsystem(enumerate, "hidraw");
udev_enumerate_scan_devices(enumerate); udev_enumerate_scan_devices(enumerate);
devices = udev_enumerate_get_list_entry(enumerate); devices = udev_enumerate_get_list_entry(enumerate);
@ -96,7 +95,6 @@ RawHidDeviceWatcher::RawHidDeviceWatcher(QObject *parent) : QObject(parent)
qCDebug(dcUsbRelay()) << "[+]" << devicePath; qCDebug(dcUsbRelay()) << "[+]" << devicePath;
m_devicePaths.append(devicePath); m_devicePaths.append(devicePath);
emit deviceAdded(devicePath);
} }
udev_enumerate_unref(enumerate); udev_enumerate_unref(enumerate);