usbrelay: Add Qt6 support

master
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
*
* This file is part of nymea.
@ -28,8 +28,9 @@
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "plugininfo.h"
#include "integrationpluginusbrelay.h"
#include "plugininfo.h"
#include "usbrelay.h"
#include <QTimer>
#include <hidapi/hidapi.h>
@ -132,9 +133,9 @@ void IntegrationPluginUsbRelay::discoverThings(ThingDiscoveryInfo *info)
quint16 releaseNumber = static_cast<quint16>(currentDevice->release_number);
quint16 productId = static_cast<quint16>(currentDevice->product_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
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));

View File

@ -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 <integrations/integrationplugin.h>
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:
};

View File

@ -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);