elgato: Add Qt6 support

This commit is contained in:
Simon Stürz 2025-08-08 09:49:48 +02:00
parent 01137cc53e
commit 6acf92f22a
5 changed files with 41 additions and 18 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.
@ -68,7 +68,11 @@ bool AveaBulb::setPower(bool power)
// Power off // Power off
QByteArray command; QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly); QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian); stream.setByteOrder(QDataStream::LittleEndian);
quint8 commandId = static_cast<quint8>(ColorMessageColor); quint8 commandId = static_cast<quint8>(ColorMessageColor);
@ -108,7 +112,11 @@ bool AveaBulb::setColor(const QColor &color)
// Convert rgb to wrgb // Convert rgb to wrgb
QByteArray command; QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly); QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian); stream.setByteOrder(QDataStream::LittleEndian);
m_red = scaleColorValueUp(color.red()); m_red = scaleColorValueUp(color.red());
@ -133,7 +141,11 @@ bool AveaBulb::setBrightness(int percentage)
qCDebug(dcElgato()) << "Brightness value" << percentage << "% -->" << brightnessValue; qCDebug(dcElgato()) << "Brightness value" << percentage << "% -->" << brightnessValue;
QByteArray command; QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly); QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian); stream.setByteOrder(QDataStream::LittleEndian);
stream << static_cast<quint8>(ColorMessageBrightness); stream << static_cast<quint8>(ColorMessageBrightness);
stream << brightnessValue; stream << brightnessValue;
@ -216,7 +228,11 @@ bool AveaBulb::syncColor()
// Convert rgb to wrgb // Convert rgb to wrgb
QByteArray command; QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly); QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian); stream.setByteOrder(QDataStream::LittleEndian);
quint8 commandId = static_cast<quint8>(ColorMessageColor); quint8 commandId = static_cast<quint8>(ColorMessageColor);
@ -301,7 +317,11 @@ void AveaBulb::onColorServiceStateChanged(const QLowEnergyService::ServiceState
} }
// Enable notifications // Enable notifications
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QLowEnergyDescriptor notificationDescriptor = m_colorCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
#else
QLowEnergyDescriptor notificationDescriptor = m_colorCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); QLowEnergyDescriptor notificationDescriptor = m_colorCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
#endif
m_colorService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); m_colorService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
// Load current configuration // Load current configuration
@ -318,7 +338,11 @@ void AveaBulb::onColorServiceCharacteristicChanged(const QLowEnergyCharacteristi
qCDebug(dcElgato()) << "Color characteristic changed" << characteristic.uuid().toString() << value.toHex(); qCDebug(dcElgato()) << "Color characteristic changed" << characteristic.uuid().toString() << value.toHex();
QByteArray payload = value; QByteArray payload = value;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&payload, QDataStream::WriteOnly);
#else
QDataStream stream(&payload, QIODevice::ReadOnly); QDataStream stream(&payload, QIODevice::ReadOnly);
#endif
quint16 messageType; quint16 messageType;
stream.setByteOrder(QDataStream::LittleEndian); stream.setByteOrder(QDataStream::LittleEndian);
stream >> messageType; stream >> messageType;

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.
@ -35,9 +35,9 @@
#include <QQueue> #include <QQueue>
#include <QColor> #include <QColor>
#include "typeutils.h" #include <typeutils.h>
#include "integrations/thing.h" #include <integrations/thing.h>
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" #include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
static QBluetoothUuid colorServiceUuid = QBluetoothUuid(QUuid("f815e810-456c-6761-746f-4d756e696368")); static QBluetoothUuid colorServiceUuid = QBluetoothUuid(QUuid("f815e810-456c-6761-746f-4d756e696368"));
static QBluetoothUuid colorCharacteristicUuid = QBluetoothUuid(QUuid("f815e811-456c-6761-746f-4d756e696368")); static QBluetoothUuid colorCharacteristicUuid = QBluetoothUuid(QUuid("f815e811-456c-6761-746f-4d756e696368"));

View File

@ -1,16 +1,14 @@
include(../plugins.pri) include(../plugins.pri)
QT += bluetooth QT *= bluetooth gui
TARGET = $$qtLibraryTarget(nymea_integrationpluginelgato)
SOURCES += \ SOURCES += \
integrationpluginelgato.cpp \ integrationpluginelgato.cpp \
aveabulb.cpp \ aveabulb.cpp
HEADERS += \ HEADERS += \
integrationpluginelgato.h \ integrationpluginelgato.h \
aveabulb.h \ aveabulb.h

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.
@ -383,9 +383,9 @@
#include "integrationpluginelgato.h" #include "integrationpluginelgato.h"
#include "integrations/thing.h" #include <integrations/thing.h>
#include "plugininfo.h" #include <plugininfo.h>
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h" #include <hardware/bluetoothlowenergy/bluetoothlowenergymanager.h>
IntegrationPluginElgato::IntegrationPluginElgato() IntegrationPluginElgato::IntegrationPluginElgato()
{ {

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,10 +31,11 @@
#ifndef INTEGRATIONPLUGINELGATO_H #ifndef INTEGRATIONPLUGINELGATO_H
#define INTEGRATIONPLUGINELGATO_H #define INTEGRATIONPLUGINELGATO_H
#include <integrations/integrationplugin.h>
#include <plugintimer.h>
#include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
#include "aveabulb.h" #include "aveabulb.h"
#include "plugintimer.h"
#include "integrations/integrationplugin.h"
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
class IntegrationPluginElgato : public IntegrationPlugin class IntegrationPluginElgato : public IntegrationPlugin
{ {