senic: Add Qt6 support

This commit is contained in:
Simon Stürz 2025-08-08 16:05:25 +02:00
parent e157a9b64c
commit 878f727e1c
5 changed files with 71 additions and 27 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.
@ -29,9 +29,11 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "integrationpluginsenic.h" #include "integrationpluginsenic.h"
#include "integrations/thing.h"
#include "plugininfo.h" #include "plugininfo.h"
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h"
#include <integrations/thing.h>
#include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
#include <hardware/bluetoothlowenergy/bluetoothlowenergymanager.h>
IntegrationPluginSenic::IntegrationPluginSenic() IntegrationPluginSenic::IntegrationPluginSenic()
{ {
@ -240,7 +242,7 @@ void IntegrationPluginSenic::onButtonLongPressed()
{ {
Nuimo *nuimo = static_cast<Nuimo *>(sender()); Nuimo *nuimo = static_cast<Nuimo *>(sender());
Thing *thing = m_nuimos.value(nuimo); Thing *thing = m_nuimos.value(nuimo);
emitEvent(Event(nuimoLongPressedEventTypeId, thing->id())); emit emitEvent(Event(nuimoLongPressedEventTypeId, thing->id()));
if (m_autoSymbolMode) { if (m_autoSymbolMode) {
nuimo->showImage(Nuimo::MatrixTypeFilledCircle); 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<Nuimo *>(sender()); Nuimo *nuimo = static_cast<Nuimo *>(sender());
Thing *thing = m_nuimos.value(nuimo); Thing *thing = m_nuimos.value(nuimo);
switch (direction) { switch (direction) {
case Nuimo::SwipeDirectionLeft: case Nuimo::SwipeDirectionLeft:
emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, ""))); emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "")));
break; break;
case Nuimo::SwipeDirectionRight: case Nuimo::SwipeDirectionRight:
emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, ""))); emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "")));
break; break;
case Nuimo::SwipeDirectionUp: case Nuimo::SwipeDirectionUp:
emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, ""))); emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "")));
break; break;
case Nuimo::SwipeDirectionDown: case Nuimo::SwipeDirectionDown:
emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, ""))); emit emitEvent(Event(nuimoPressedEventTypeId, thing->id(), ParamList() << Param(nuimoPressedEventButtonNameParamTypeId, "")));
break; 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<Nuimo *>(sender()); Nuimo *nuimo = static_cast<Nuimo *>(sender());
Thing *thing = m_nuimos.value(nuimo); 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<Nuimo *>(sender()); Nuimo *nuimo = static_cast<Nuimo *>(sender());
Thing *thing = m_nuimos.value(nuimo); Thing *thing = m_nuimos.value(nuimo);

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,9 +31,8 @@
#ifndef INTEGRATIONPLUGINSENIC_H #ifndef INTEGRATIONPLUGINSENIC_H
#define INTEGRATIONPLUGINSENIC_H #define INTEGRATIONPLUGINSENIC_H
#include "plugintimer.h" #include <integrations/integrationplugin.h>
#include "integrations/integrationplugin.h" #include <plugintimer.h>
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
#include "nuimo.h" #include "nuimo.h"
@ -65,11 +64,11 @@ private slots:
void onReconnectTimeout(); void onReconnectTimeout();
void onConnectedChanged(bool connected); void onConnectedChanged(bool connected);
void onBatteryValueChanged(const uint &percentage); void onBatteryValueChanged(uint percentage);
void onButtonPressed(); void onButtonPressed();
void onButtonLongPressed(); void onButtonLongPressed();
void onSwipeDetected(const Nuimo::SwipeDirection &direction); void onSwipeDetected(Nuimo::SwipeDirection direction);
void onRotationValueChanged(const uint &value); void onRotationValueChanged(uint value);
void onDeviceInformationChanged(const QString &firmwareRevision, const QString &hardwareRevision, const QString &softwareRevision); void onDeviceInformationChanged(const QString &firmwareRevision, const QString &hardwareRevision, const QString &softwareRevision);
}; };

View File

@ -335,7 +335,11 @@ void Nuimo::onServiceDiscoveryFinished()
{ {
qCDebug(dcSenic()) << "Service scan finised"; 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)) { if (!m_bluetoothDevice->serviceUuids().contains(QBluetoothUuid::DeviceInformation)) {
#endif
qCWarning(dcSenic()) << "Device Information service not found for device" << bluetoothDevice()->name() << bluetoothDevice()->address().toString(); qCWarning(dcSenic()) << "Device Information service not found for device" << bluetoothDevice()->name() << bluetoothDevice()->address().toString();
emit deviceInitializationFinished(false); emit deviceInitializationFinished(false);
return; return;
@ -363,7 +367,11 @@ void Nuimo::onServiceDiscoveryFinished()
// Device info service // Device info service
if (!m_deviceInfoService) { 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); m_deviceInfoService = m_bluetoothDevice->controller()->createServiceObject(QBluetoothUuid::DeviceInformation, this);
#endif
if (!m_deviceInfoService) { if (!m_deviceInfoService) {
qCWarning(dcSenic()) << "Could not create thing info service."; qCWarning(dcSenic()) << "Could not create thing info service.";
emit deviceInitializationFinished(false); emit deviceInitializationFinished(false);
@ -379,7 +387,11 @@ void Nuimo::onServiceDiscoveryFinished()
// Battery service // Battery service
if (!m_batteryService) { 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); m_batteryService = m_bluetoothDevice->controller()->createServiceObject(QBluetoothUuid::BatteryService, this);
#endif
if (!m_batteryService) { if (!m_batteryService) {
qCWarning(dcSenic()) << "Could not create battery service."; qCWarning(dcSenic()) << "Could not create battery service.";
@ -441,9 +453,16 @@ void Nuimo::onDeviceInfoServiceStateChanged(const QLowEnergyService::ServiceStat
qCDebug(dcSenic()) << "Device info service discovered."; qCDebug(dcSenic()) << "Device info service discovered.";
printService(m_deviceInfoService); 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 firmware = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::FirmwareRevisionString).value());
QString hardware = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::HardwareRevisionString).value()); QString hardware = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::HardwareRevisionString).value());
QString software = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::SoftwareRevisionString).value()); QString software = QString::fromUtf8(m_deviceInfoService->characteristic(QBluetoothUuid::SoftwareRevisionString).value());
#endif
emit deviceInformationChanged(firmware, hardware, software); emit deviceInformationChanged(firmware, hardware, software);
} }
@ -458,14 +477,22 @@ void Nuimo::onBatteryServiceStateChanged(const QLowEnergyService::ServiceState &
printService(m_batteryService); 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); m_batteryCharacteristic = m_batteryService->characteristic(QBluetoothUuid::BatteryLevel);
#endif
if (!m_batteryCharacteristic.isValid()) { if (!m_batteryCharacteristic.isValid()) {
qCWarning(dcSenic()) << "Battery characteristc not found for thing " << bluetoothDevice()->name() << bluetoothDevice()->address().toString(); qCWarning(dcSenic()) << "Battery characteristc not found for thing " << bluetoothDevice()->name() << bluetoothDevice()->address().toString();
return; return;
} }
// Enable notifications // 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); QLowEnergyDescriptor notificationDescriptor = m_batteryCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
#endif
m_batteryService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); m_batteryService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
uint batteryPercentage = m_batteryCharacteristic.value().toHex().toUInt(nullptr, 16); uint batteryPercentage = m_batteryCharacteristic.value().toHex().toUInt(nullptr, 16);
@ -497,7 +524,11 @@ void Nuimo::onInputServiceStateChanged(const QLowEnergyService::ServiceState &st
return; return;
} }
// Enable notifications // 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); QLowEnergyDescriptor notificationDescriptor = m_inputButtonCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
#endif
m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
@ -508,7 +539,11 @@ void Nuimo::onInputServiceStateChanged(const QLowEnergyService::ServiceState &st
return; return;
} }
// Enable notifications // 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); notificationDescriptor = m_inputSwipeCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
#endif
m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
@ -519,7 +554,11 @@ void Nuimo::onInputServiceStateChanged(const QLowEnergyService::ServiceState &st
return; return;
} }
// Enable notifications // 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); notificationDescriptor = m_inputRotationCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
#endif
m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100")); m_inputService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
} }
@ -586,8 +625,14 @@ void Nuimo::onInputCharacteristicChanged(const QLowEnergyCharacteristic &charact
void Nuimo::onLedMatrixServiceStateChanged(const QLowEnergyService::ServiceState &state) void Nuimo::onLedMatrixServiceStateChanged(const QLowEnergyService::ServiceState &state)
{ {
// Only continue if discovered // Only continue if discovered
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (state != QLowEnergyService::RemoteServiceDiscovered)
return;
#else
if (state != QLowEnergyService::ServiceDiscovered) if (state != QLowEnergyService::ServiceDiscovered)
return; return;
#endif
qCDebug(dcSenic()) << "Led matrix service discovered."; qCDebug(dcSenic()) << "Led matrix service discovered.";

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,8 +35,8 @@
#include <QTimer> #include <QTimer>
#include <QBluetoothUuid> #include <QBluetoothUuid>
#include "typeutils.h" #include <typeutils.h>
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h" #include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
class Nuimo : public QObject class Nuimo : public QObject
{ {
@ -99,9 +99,9 @@ signals:
void connectedChanged(bool connected); void connectedChanged(bool connected);
void buttonPressed(); void buttonPressed();
void buttonLongPressed(); void buttonLongPressed();
void batteryValueChanged(const uint &percentage); void batteryValueChanged(uint percentage);
void swipeDetected(const SwipeDirection &direction); void swipeDetected(Nuimo::SwipeDirection direction);
void rotationValueChanged(const uint &value); void rotationValueChanged(uint value);
void deviceInformationChanged(const QString &firmwareRevision, const QString &hardwareRevision, const QString &softwareRevision); void deviceInformationChanged(const QString &firmwareRevision, const QString &hardwareRevision, const QString &softwareRevision);
void deviceInitializationFinished(bool success); void deviceInitializationFinished(bool success);

View File

@ -1,8 +1,6 @@
include(../plugins.pri) include(../plugins.pri)
QT += bluetooth QT *= bluetooth
TARGET = $$qtLibraryTarget(nymea_integrationpluginsenic)
SOURCES += \ SOURCES += \
integrationpluginsenic.cpp \ integrationpluginsenic.cpp \