flowercare: Add Qt6 support
parent
3e2dc2940a
commit
d46177e1eb
|
|
@ -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.
|
||||||
|
|
@ -89,7 +89,11 @@ void FlowerCare::onSensorServiceStateChanged(const QLowEnergyService::ServiceSta
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray value = batteryFirmwareCharacteristic.value();
|
QByteArray value = batteryFirmwareCharacteristic.value();
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
QDataStream stream(&value, QDataStream::ReadOnly);
|
||||||
|
#else
|
||||||
QDataStream stream(&value, QIODevice::ReadOnly);
|
QDataStream stream(&value, QIODevice::ReadOnly);
|
||||||
|
#endif
|
||||||
stream.setByteOrder(QDataStream::LittleEndian);
|
stream.setByteOrder(QDataStream::LittleEndian);
|
||||||
stream >> m_batteryLevel;
|
stream >> m_batteryLevel;
|
||||||
|
|
||||||
|
|
@ -110,7 +114,11 @@ void FlowerCare::onSensorServiceStateChanged(const QLowEnergyService::ServiceSta
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable notifications
|
// Enable notifications
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
QLowEnergyDescriptor notificationDescriptor = m_sensorDataCharacteristic.descriptor(QBluetoothUuid::DescriptorType::ClientCharacteristicConfiguration);
|
||||||
|
#else
|
||||||
QLowEnergyDescriptor notificationDescriptor = m_sensorDataCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
|
QLowEnergyDescriptor notificationDescriptor = m_sensorDataCharacteristic.descriptor(QBluetoothUuid::ClientCharacteristicConfiguration);
|
||||||
|
#endif
|
||||||
m_sensorService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
|
m_sensorService->writeDescriptor(notificationDescriptor, QByteArray::fromHex("0100"));
|
||||||
|
|
||||||
// Read the data manually
|
// Read the data manually
|
||||||
|
|
@ -122,7 +130,11 @@ void FlowerCare::onSensorServiceStateChanged(const QLowEnergyService::ServiceSta
|
||||||
|
|
||||||
void FlowerCare::onSensorServiceCharacteristicRead(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
void FlowerCare::onSensorServiceCharacteristicRead(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
qCDebug(dcFlowerCare()) << "Characteristic read" << characteristic.uuid().toString() << value.toHex();
|
||||||
|
#else
|
||||||
qCDebug(dcFlowerCare()) << "Characteristic read" << QString::number(characteristic.handle(), 16) << value.toHex();
|
qCDebug(dcFlowerCare()) << "Characteristic read" << QString::number(characteristic.handle(), 16) << value.toHex();
|
||||||
|
#endif
|
||||||
if (characteristic != m_sensorDataCharacteristic) {
|
if (characteristic != m_sensorDataCharacteristic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -131,7 +143,11 @@ void FlowerCare::onSensorServiceCharacteristicRead(const QLowEnergyCharacteristi
|
||||||
|
|
||||||
void FlowerCare::onSensorServiceCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
void FlowerCare::onSensorServiceCharacteristicChanged(const QLowEnergyCharacteristic &characteristic, const QByteArray &value)
|
||||||
{
|
{
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
qCDebug(dcFlowerCare()) << "Notification received" << characteristic.uuid().toString() << value.toHex();
|
||||||
|
#else
|
||||||
qCDebug(dcFlowerCare()) << "Notification received" << QString::number(characteristic.handle(), 16) << value.toHex();
|
qCDebug(dcFlowerCare()) << "Notification received" << QString::number(characteristic.handle(), 16) << value.toHex();
|
||||||
|
#endif
|
||||||
if (characteristic != m_sensorDataCharacteristic) {
|
if (characteristic != m_sensorDataCharacteristic) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -142,9 +158,17 @@ void FlowerCare::onSensorServiceCharacteristicChanged(const QLowEnergyCharacteri
|
||||||
void FlowerCare::printServiceDetails(QLowEnergyService *service) const
|
void FlowerCare::printServiceDetails(QLowEnergyService *service) const
|
||||||
{
|
{
|
||||||
foreach (const QLowEnergyCharacteristic &characteristic, service->characteristics()) {
|
foreach (const QLowEnergyCharacteristic &characteristic, service->characteristics()) {
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
qCDebug(dcFlowerCare()).nospace() << "C: --> " << characteristic.uuid().toString() << " (" << " Name: " << characteristic.name() << "): " << characteristic.value() << ", " << characteristic.value().toHex();
|
||||||
|
#else
|
||||||
qCDebug(dcFlowerCare()).nospace() << "C: --> " << characteristic.uuid().toString() << " (" << characteristic.handle() << " Name: " << characteristic.name() << "): " << characteristic.value() << ", " << characteristic.value().toHex();
|
qCDebug(dcFlowerCare()).nospace() << "C: --> " << characteristic.uuid().toString() << " (" << characteristic.handle() << " Name: " << characteristic.name() << "): " << characteristic.value() << ", " << characteristic.value().toHex();
|
||||||
|
#endif
|
||||||
foreach (const QLowEnergyDescriptor &descriptor, characteristic.descriptors()) {
|
foreach (const QLowEnergyDescriptor &descriptor, characteristic.descriptors()) {
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
qCDebug(dcFlowerCare()).nospace() << "D: --> " << descriptor.uuid().toString() << " (" << " Name: " << descriptor.name() << "): " << descriptor.value() << ", " << descriptor.value().toHex();
|
||||||
|
#else
|
||||||
qCDebug(dcFlowerCare()).nospace() << "D: --> " << descriptor.uuid().toString() << " (" << descriptor.handle() << " Name: " << descriptor.name() << "): " << descriptor.value() << ", " << descriptor.value().toHex();
|
qCDebug(dcFlowerCare()).nospace() << "D: --> " << descriptor.uuid().toString() << " (" << descriptor.handle() << " Name: " << descriptor.name() << "): " << descriptor.value() << ", " << descriptor.value().toHex();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +176,11 @@ void FlowerCare::printServiceDetails(QLowEnergyService *service) const
|
||||||
void FlowerCare::processSensorData(const QByteArray &data)
|
void FlowerCare::processSensorData(const QByteArray &data)
|
||||||
{
|
{
|
||||||
QByteArray copy = data;
|
QByteArray copy = data;
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||||
|
QDataStream stream(©, QDataStream::ReadOnly);
|
||||||
|
#else
|
||||||
QDataStream stream(©, QIODevice::ReadOnly);
|
QDataStream stream(©, QIODevice::ReadOnly);
|
||||||
|
#endif
|
||||||
stream.setByteOrder(QDataStream::LittleEndian);
|
stream.setByteOrder(QDataStream::LittleEndian);
|
||||||
qint16 temp;
|
qint16 temp;
|
||||||
stream >> temp;
|
stream >> temp;
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
|
#include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
|
||||||
|
|
||||||
static QBluetoothUuid sensorServiceUuid = QBluetoothUuid(QUuid("00001204-0000-1000-8000-00805f9b34fb"));
|
static QBluetoothUuid sensorServiceUuid = QBluetoothUuid(QUuid("00001204-0000-1000-8000-00805f9b34fb"));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += bluetooth
|
QT *= bluetooth
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationpluginflowercare)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginflowercare.cpp \
|
integrationpluginflowercare.cpp \
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
@ -37,8 +37,10 @@
|
||||||
* {0000fe95-0000-1000-8000-00805f9b34fb}
|
* {0000fe95-0000-1000-8000-00805f9b34fb}
|
||||||
* {0000fef5-0000-1000-8000-00805f9b34fb}
|
* {0000fef5-0000-1000-8000-00805f9b34fb}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <hardware/bluetoothlowenergy/bluetoothlowenergymanager.h>
|
||||||
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergymanager.h"
|
|
||||||
#include "integrationpluginflowercare.h"
|
#include "integrationpluginflowercare.h"
|
||||||
#include "flowercare.h"
|
#include "flowercare.h"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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,12 +31,12 @@
|
||||||
#ifndef INTEGRATIONPLUGINFLOWERCARE_H
|
#ifndef INTEGRATIONPLUGINFLOWERCARE_H
|
||||||
#define INTEGRATIONPLUGINFLOWERCARE_H
|
#define INTEGRATIONPLUGINFLOWERCARE_H
|
||||||
|
|
||||||
|
#include <integrations/integrationplugin.h>
|
||||||
|
#include <plugintimer.h>
|
||||||
|
#include <hardware/bluetoothlowenergy/bluetoothlowenergydevice.h>
|
||||||
|
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include "integrations/integrationplugin.h"
|
|
||||||
#include "plugintimer.h"
|
|
||||||
#include "hardware/bluetoothlowenergy/bluetoothlowenergydevice.h"
|
|
||||||
|
|
||||||
class FlowerCare;
|
class FlowerCare;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue