From 878f727e1c3f1e3fd14bf9f28a7b3c58d9f503a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 8 Aug 2025 16:05:25 +0200 Subject: [PATCH] senic: Add Qt6 support --- senic/integrationpluginsenic.cpp | 24 +++++++++-------- senic/integrationpluginsenic.h | 13 +++++---- senic/nuimo.cpp | 45 ++++++++++++++++++++++++++++++++ senic/nuimo.h | 12 ++++----- senic/senic.pro | 4 +-- 5 files changed, 71 insertions(+), 27 deletions(-) diff --git a/senic/integrationpluginsenic.cpp b/senic/integrationpluginsenic.cpp index ceca3bcc..a9be9eca 100644 --- a/senic/integrationpluginsenic.cpp +++ b/senic/integrationpluginsenic.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,11 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ #include "integrationpluginsenic.h" -#include "integrations/thing.h" #include "plugininfo.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h" + +#include +#include +#include IntegrationPluginSenic::IntegrationPluginSenic() { @@ -240,7 +242,7 @@ void IntegrationPluginSenic::onButtonLongPressed() { Nuimo *nuimo = static_cast(sender()); Thing *thing = m_nuimos.value(nuimo); - emitEvent(Event(nuimoLongPressedEventTypeId, thing->id())); + emit emitEvent(Event(nuimoLongPressedEventTypeId, thing->id())); if (m_autoSymbolMode) { nuimo->showImage(Nuimo::MatrixTypeFilledCircle); @@ -248,23 +250,23 @@ void IntegrationPluginSenic::onButtonLongPressed() } -void IntegrationPluginSenic::onSwipeDetected(const Nuimo::SwipeDirection &direction) +void IntegrationPluginSenic::onSwipeDetected(Nuimo::SwipeDirection direction) { Nuimo *nuimo = static_cast(sender()); Thing *thing = m_nuimos.value(nuimo); switch (direction) { case Nuimo::SwipeDirectionLeft: - emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "←"))); + emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "←"))); break; case Nuimo::SwipeDirectionRight: - emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "→"))); + emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "→"))); break; case Nuimo::SwipeDirectionUp: - emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "↑"))); + emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "↑"))); break; case Nuimo::SwipeDirectionDown: - emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "↓"))); + emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "↓"))); break; } @@ -287,7 +289,7 @@ void IntegrationPluginSenic::onSwipeDetected(const Nuimo::SwipeDirection &direct } -void IntegrationPluginSenic::onRotationValueChanged(const uint &value) +void IntegrationPluginSenic::onRotationValueChanged(uint value) { Nuimo *nuimo = static_cast(sender()); Thing *thing = m_nuimos.value(nuimo); @@ -324,7 +326,7 @@ void IntegrationPluginSenic::onPluginConfigurationChanged(const ParamTypeId &par } } -void IntegrationPluginSenic::onBatteryValueChanged(const uint &percentage) +void IntegrationPluginSenic::onBatteryValueChanged(uint percentage) { Nuimo *nuimo = static_cast(sender()); Thing *thing = m_nuimos.value(nuimo); diff --git a/senic/integrationpluginsenic.h b/senic/integrationpluginsenic.h index 7fd6939b..4eaaced0 100644 --- a/senic/integrationpluginsenic.h +++ b/senic/integrationpluginsenic.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,9 +31,8 @@ #ifndef INTEGRATIONPLUGINSENIC_H #define INTEGRATIONPLUGINSENIC_H -#include "plugintimer.h" -#include "integrations/integrationplugin.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" +#include +#include #include "nuimo.h" @@ -65,11 +64,11 @@ private slots: void onReconnectTimeout(); void onConnectedChanged(bool connected); - void onBatteryValueChanged(const uint &percentage); + void onBatteryValueChanged(uint percentage); void onButtonPressed(); void onButtonLongPressed(); - void onSwipeDetected(const Nuimo::SwipeDirection &direction); - void onRotationValueChanged(const uint &value); + void onSwipeDetected(Nuimo::SwipeDirection direction); + void onRotationValueChanged(uint value); void onDeviceInformationChanged(const QString &firmwareRevision, const QString &hardwareRevision, const QString &softwareRevision); }; diff --git a/senic/nuimo.cpp b/senic/nuimo.cpp index b3a92b50..b0d81252 100644 --- a/senic/nuimo.cpp +++ b/senic/nuimo.cpp @@ -335,7 +335,11 @@ void Nuimo::onServiceDiscoveryFinished() { qCDebug(dcSenic()) << "Service scan finised"; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (!m_bluetoothDevice->serviceUuids().contains(QBluetoothUuid::ServiceClassUuid::DeviceInformation)) { +#else if (!m_bluetoothDevice->serviceUuids().contains(QBluetoothUuid::DeviceInformation)) { +#endif qCWarning(dcSenic()) << "Device Information service not found for device" << bluetoothDevice()->name() << bluetoothDevice()->address().toString(); emit deviceInitializationFinished(false); return; @@ -363,7 +367,11 @@ void Nuimo::onServiceDiscoveryFinished() // Device info service if (!m_deviceInfoService) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + m_deviceInfoService = m_bluetoothDevice->controller()->createServiceObject(QBluetoothUuid::ServiceClassUuid::DeviceInformation, this); +#else m_deviceInfoService = m_bluetoothDevice->controller()->createServiceObject(QBluetoothUuid::DeviceInformation, this); +#endif if (!m_deviceInfoService) { qCWarning(dcSenic()) << "Could not create thing info service."; emit deviceInitializationFinished(false); @@ -379,7 +387,11 @@ void Nuimo::onServiceDiscoveryFinished() // Battery service if (!m_batteryService) { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + m_batteryService = m_bluetoothDevice->controller()->createServiceObject(QBluetoothUuid::ServiceClassUuid::BatteryService, this); +#else m_batteryService = m_bluetoothDevice->controller()->createServiceObject(QBluetoothUuid::BatteryService, this); +#endif if (!m_batteryService) { qCWarning(dcSenic()) << "Could not create battery service."; @@ -441,9 +453,16 @@ void Nuimo::onDeviceInfoServiceStateChanged(const QLowEnergyService::ServiceStat qCDebug(dcSenic()) << "Device info service discovered."; printService(m_deviceInfoService); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QString firmware = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::CharacteristicType::FirmwareRevisionString).value()); + QString hardware = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::CharacteristicType::HardwareRevisionString).value()); + QString software = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::CharacteristicType::SoftwareRevisionString).value()); +#else QString firmware = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::FirmwareRevisionString).value()); QString hardware = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::HardwareRevisionString).value()); QString software = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::SoftwareRevisionString).value()); +#endif emit deviceInformationChanged(firmware, hardware, software); } @@ -458,14 +477,22 @@ void Nuimo::onBatteryServiceStateChanged(const QLowEnergyService::ServiceState & printService(m_batteryService); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + m_batteryCharacteristic = m_batteryService->characteristic(QBluetoothUuid::CharacteristicType::BatteryLevel); +#else m_batteryCharacteristic = m_batteryService->characteristic(QBluetoothUuid::BatteryLevel); +#endif if (!m_batteryCharacteristic.isValid()) { qCWarning(dcSenic()) << "Battery characteristc not found for thing " << bluetoothDevice()->name() << bluetoothDevice()->address().toString(); return; } // Enable notifications +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QLowEnergyDescriptor notificationDescriptor = m_batteryCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration); +#else QLowEnergyDescriptor notificationDescriptor = m_batteryCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); +#endif m_batteryService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); uint batteryPercentage = m_batteryCharacteristic.value().toHex().toUInt(nullptr, 16); @@ -497,7 +524,11 @@ void Nuimo::onInputServiceStateChanged(const QLowEnergyService::ServiceState &st return; } // Enable notifications +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QLowEnergyDescriptor notificationDescriptor = m_inputButtonCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration); +#else QLowEnergyDescriptor notificationDescriptor = m_inputButtonCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); +#endif m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); @@ -508,7 +539,11 @@ void Nuimo::onInputServiceStateChanged(const QLowEnergyService::ServiceState &st return; } // Enable notifications +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + notificationDescriptor = m_inputSwipeCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration); +#else notificationDescriptor = m_inputSwipeCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); +#endif m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); @@ -519,7 +554,11 @@ void Nuimo::onInputServiceStateChanged(const QLowEnergyService::ServiceState &st return; } // Enable notifications +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + notificationDescriptor = m_inputRotationCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration); +#else notificationDescriptor = m_inputRotationCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration); +#endif m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); } @@ -586,8 +625,14 @@ void Nuimo::onInputCharacteristicChanged(const QLowEnergyCharacteristic &charact void Nuimo::onLedMatrixServiceStateChanged(const QLowEnergyService::ServiceState &state) { // Only continue if discovered + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + if (state != QLowEnergyService::RemoteServiceDiscovered) + return; +#else if (state != QLowEnergyService::ServiceDiscovered) return; +#endif qCDebug(dcSenic()) << "Led matrix service discovered."; diff --git a/senic/nuimo.h b/senic/nuimo.h index 23b2f0f1..33b9f73a 100644 --- a/senic/nuimo.h +++ b/senic/nuimo.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. @@ -35,8 +35,8 @@ #include #include -#include "typeutils.h" -#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" +#include +#include class Nuimo : public QObject { @@ -99,9 +99,9 @@ signals: void connectedChanged(bool connected); void buttonPressed(); void buttonLongPressed(); - void batteryValueChanged(const uint &percentage); - void swipeDetected(const SwipeDirection &direction); - void rotationValueChanged(const uint &value); + void batteryValueChanged(uint percentage); + void swipeDetected(Nuimo::SwipeDirection direction); + void rotationValueChanged(uint value); void deviceInformationChanged(const QString &firmwareRevision, const QString &hardwareRevision, const QString &softwareRevision); void deviceInitializationFinished(bool success); diff --git a/senic/senic.pro b/senic/senic.pro index 3f735b53..20b6b66d 100644 --- a/senic/senic.pro +++ b/senic/senic.pro @@ -1,8 +1,6 @@ include(../plugins.pri) -QT += bluetooth - -TARGET = $$qtLibraryTarget(nymea_integrationpluginsenic) +QT *= bluetooth SOURCES += \ integrationpluginsenic.cpp \