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
*
* 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 <integrations/thing.h>
#include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
#include <hardware/bluetoothlowenergy/bluetoothlowenergymanager.h>
IntegrationPluginSenic::IntegrationPluginSenic()
{
@ -240,7 +242,7 @@ void IntegrationPluginSenic::onButtonLongPressed()
{
Nuimo *nuimo = static_cast<Nuimo *>(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<Nuimo *>(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<Nuimo *>(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<Nuimo *>(sender());
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
*
* 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 <integrations/integrationplugin.h>
#include <plugintimer.h>
#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);
};

View File

@ -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.";

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,8 +35,8 @@
#include <QTimer>
#include <QBluetoothUuid>
#include "typeutils.h"
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
#include <typeutils.h>
#include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
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);

View File

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