elgato: Add Qt6 support

master
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
*
* This file is part of nymea.
@ -68,7 +68,11 @@ bool AveaBulb::setPower(bool power)
// Power off
QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian);
quint8 commandId = static_cast<quint8>(ColorMessageColor);
@ -108,7 +112,11 @@ bool AveaBulb::setColor(const QColor &color)
// Convert rgb to wrgb
QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian);
m_red = scaleColorValueUp(color.red());
@ -133,7 +141,11 @@ bool AveaBulb::setBrightness(int percentage)
qCDebug(dcElgato()) << "Brightness value" << percentage << "% -->" << brightnessValue;
QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian);
stream << static_cast<quint8>(ColorMessageBrightness);
stream << brightnessValue;
@ -216,7 +228,11 @@ bool AveaBulb::syncColor()
// Convert rgb to wrgb
QByteArray command;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&command, QDataStream::WriteOnly);
#else
QDataStream stream(&command, QIODevice::WriteOnly);
#endif
stream.setByteOrder(QDataStream::LittleEndian);
quint8 commandId = static_cast<quint8>(ColorMessageColor);
@ -301,7 +317,11 @@ void AveaBulb::onColorServiceStateChanged(const QLowEnergyService::ServiceState
}
// 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);
#endif
m_colorService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
// Load current configuration
@ -318,7 +338,11 @@ void AveaBulb::onColorServiceCharacteristicChanged(const QLowEnergyCharacteristi
qCDebug(dcElgato()) << "Color characteristic changed" << characteristic.uuid().toString() << value.toHex();
QByteArray payload = value;
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDataStream stream(&payload, QDataStream::WriteOnly);
#else
QDataStream stream(&payload, QIODevice::ReadOnly);
#endif
quint16 messageType;
stream.setByteOrder(QDataStream::LittleEndian);
stream >> messageType;

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

View File

@ -1,16 +1,14 @@
include(../plugins.pri)
QT += bluetooth
TARGET = $$qtLibraryTarget(nymea_integrationpluginelgato)
QT *= bluetooth gui
SOURCES += \
integrationpluginelgato.cpp \
aveabulb.cpp \
aveabulb.cpp
HEADERS += \
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
*
* This file is part of nymea.
@ -383,9 +383,9 @@
#include "integrationpluginelgato.h"
#include "integrations/thing.h"
#include "plugininfo.h"
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h"
#include <integrations/thing.h>
#include <plugininfo.h>
#include <hardware/bluetoothlowenergy/bluetoothlowenergymanager.h>
IntegrationPluginElgato::IntegrationPluginElgato()
{

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