From c73647c20eb6b51467e03dcc603d8bc40aed9d82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 8 Aug 2025 15:36:13 +0200 Subject: [PATCH] onewire: Add Qt6 support --- onewire/integrationpluginonewire.cpp | 7 ++++--- onewire/integrationpluginonewire.h | 11 ++++++----- onewire/onewire.pro | 6 +----- onewire/owfs.cpp | 25 ++++++++++++++----------- onewire/owfs.h | 6 ++---- onewire/w1.cpp | 4 ++-- 6 files changed, 29 insertions(+), 30 deletions(-) diff --git a/onewire/integrationpluginonewire.cpp b/onewire/integrationpluginonewire.cpp index 5ac02108..57419cfa 100644 --- a/onewire/integrationpluginonewire.cpp +++ b/onewire/integrationpluginonewire.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. @@ -29,9 +29,10 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "integrationpluginonewire.h" -#include "integrations/thing.h" #include "plugininfo.h" +#include + #include #include @@ -591,7 +592,7 @@ void IntegrationPluginOneWire::onOneWireDevicesDiscovered(QList +#include + +#include +#include #include "extern-plugininfo.h" diff --git a/onewire/onewire.pro b/onewire/onewire.pro index 8e786aba..18f29526 100644 --- a/onewire/onewire.pro +++ b/onewire/onewire.pro @@ -1,10 +1,6 @@ include(../plugins.pri) -TARGET = $$qtLibraryTarget(nymea_integrationpluginonewire) - -LIBS += \ - -low \ - -lowcapi \ +LIBS += -low -lowcapi SOURCES += \ integrationpluginonewire.cpp \ diff --git a/onewire/owfs.cpp b/onewire/owfs.cpp index 132e468d..6bab4983 100644 --- a/onewire/owfs.cpp +++ b/onewire/owfs.cpp @@ -29,8 +29,12 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "owfs.h" +#include "owcapi.h" + #include "extern-plugininfo.h" +#include + Owfs::Owfs(QObject *parent) : QObject(parent) { @@ -56,7 +60,7 @@ bool Owfs::init(const QByteArray &owfsInitArguments) //inifArguments.append("--w1"); if (OW_init(owfsInitArguments) < 0) { - qWarning(dcOneWire()) << "ERROR initialising one wire" << strerror(errno); + qCWarning(dcOneWire()) << "ERROR initialising one wire" << strerror(errno); return false; } m_path = "/"; @@ -69,10 +73,10 @@ bool Owfs::discoverDevices() size_t dirLength ; if (OW_get(m_path, &dirBuffer, &dirLength) < 0) { - qWarning(dcOneWire()) << "DIRECTORY ERROR" << strerror(errno); + qCWarning(dcOneWire()) << "DIRECTORY ERROR" << strerror(errno); return false; } - qDebug(dcOneWire()) << "Directory has members" << dirBuffer; + qCDebug(dcOneWire()) << "Directory has members" << dirBuffer; QList dirMembers ; dirMembers = QByteArray(dirBuffer, dirLength).split(','); @@ -95,7 +99,6 @@ bool Owfs::discoverDevices() int family = member.split('.').first().toInt(nullptr, 16); if (family != 0) { member.remove(member.indexOf('/'), 1); - QByteArray type; OwfsDevice thing; thing.family = family; thing.address = member; @@ -148,10 +151,10 @@ QByteArray Owfs::getValue(const QByteArray &address, const QByteArray &type) devicePath.append('\0'); if (OW_get(devicePath, &getBuffer, &getLength) < 0) { - qWarning(dcOneWire()) << "ERROR reading" << devicePath << strerror(errno); + qCWarning(dcOneWire()) << "ERROR reading" << devicePath << strerror(errno); } - qDebug(dcOneWire()) << "Device value" << devicePath << getBuffer; + qCDebug(dcOneWire()) << "Device value" << devicePath << getBuffer; QByteArray value = QByteArray(getBuffer, getLength); free(getBuffer); @@ -171,21 +174,21 @@ void Owfs::setValue(const QByteArray &address, const QByteArray &type, const QBy devicePath.append('\0'); if (OW_put(devicePath, value, value.length()) < 0) { - qWarning(dcOneWire()) << "ERROR reading" << devicePath << strerror(errno); + qCWarning(dcOneWire()) << "ERROR reading" << devicePath << strerror(errno); } } double Owfs::getTemperature(const QByteArray &address, bool *ok) { QByteArray temperature = getValue(address, "temperature"); - qDebug(dcOneWire()) << "Temperature" << temperature << temperature.replace(',','.').toDouble(); + qCDebug(dcOneWire()) << "Temperature" << temperature << temperature.replace(',','.').toDouble(); return temperature.toDouble(ok); } double Owfs::getHumidity(const QByteArray &address, bool *ok) { QByteArray humidity = getValue(address, "humidity"); - qDebug(dcOneWire()) << "Humidity" << humidity << humidity.replace(',','.').toDouble(); + qCDebug(dcOneWire()) << "Humidity" << humidity << humidity.replace(',','.').toDouble(); return humidity.toDouble(ok); } @@ -226,7 +229,7 @@ bool Owfs::getSwitchOutput(const QByteArray &address, SwitchChannel channel, boo break; } QByteArray state = getValue(address, c); - qDebug(dcOneWire()) << "Switch state" << state.toInt(); + qCDebug(dcOneWire()) << "Switch state" << state.toInt(); return state.toInt(ok); } @@ -261,7 +264,7 @@ bool Owfs::getSwitchInput(const QByteArray &address, SwitchChannel channel, bool break; } QByteArray state = getValue(address, c); - qDebug(dcOneWire()) << "Switch state" << state.toInt(); + qCDebug(dcOneWire()) << "Switch state" << state.toInt(); return state.toInt(ok); } diff --git a/onewire/owfs.h b/onewire/owfs.h index 1ef1937e..9eb642f6 100644 --- a/onewire/owfs.h +++ b/onewire/owfs.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,6 @@ #ifndef OWFS_H #define OWFS_H -#include "owcapi.h" - #include class Owfs : public QObject @@ -88,7 +86,7 @@ private: void setValue(const QByteArray &address, const QByteArray &deviceType, const QByteArray &value); signals: - void devicesDiscovered(QList devices); + void devicesDiscovered(QList devices); }; #endif // OWFS_H diff --git a/onewire/w1.cpp b/onewire/w1.cpp index ccd2ace1..a22631b8 100644 --- a/onewire/w1.cpp +++ b/onewire/w1.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. @@ -52,7 +52,7 @@ QStringList W1::discoverDevices() QFileInfoList list = w1SysFSDir.entryInfoList(); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); - if(fileInfo.fileName()[2] == '-') { + if(fileInfo.fileName().at(2) == '-') { qCDebug(dcOneWire()) << "Found one wire device" << fileInfo.filePath(); deviceList.append(fileInfo.fileName()); }