diff options
Diffstat (limited to 'src/plugins')
24 files changed, 0 insertions, 2203 deletions
diff --git a/src/plugins/sensors/CMakeLists.txt b/src/plugins/sensors/CMakeLists.txt index 7b0644c4..bf42ae8d 100644 --- a/src/plugins/sensors/CMakeLists.txt +++ b/src/plugins/sensors/CMakeLists.txt @@ -26,14 +26,6 @@ if(LINUX AND TARGET Qt::DBus AND NOT SENSORS_PLUGINS OR "iio-sensor-proxy" IN_LI add_subdirectory(iio-sensor-proxy) endif() -if(LINUX AND TARGET Qt::Bluetooth AND NOT SENSORS_PLUGINS OR "sensortag" IN_LIST SENSORS_PLUGINS) - if (TARGET Qt::Bluetooth) - add_subdirectory(sensortag) - else() - message(WARNING "You have configured for sensortag, but Qt Bluetooth module was not found.") - endif() -endif() - if(NOT SENSORS_PLUGINS OR "dummy" IN_LIST SENSORS_PLUGINS) add_subdirectory(dummy) endif() diff --git a/src/plugins/sensors/sensortag/CMakeLists.txt b/src/plugins/sensors/sensortag/CMakeLists.txt deleted file mode 100644 index 4f70d76c..00000000 --- a/src/plugins/sensors/sensortag/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -##################################################################### -## SensortagSensorPlugin Plugin: -##################################################################### - -qt_internal_add_plugin(SensortagSensorPlugin - OUTPUT_NAME qtsensors_sensortag - TYPE sensors - SOURCES - main.cpp - sensortagaccelerometer.cpp sensortagaccelerometer.h - sensortagals.cpp sensortagals.h - sensortagbase.cpp sensortagbase.h - sensortaggyroscope.cpp sensortaggyroscope.h - sensortaghumiditysensor.cpp sensortaghumiditysensor.h - sensortaglightsensor.cpp sensortaglightsensor.h - sensortagmagnetometer.cpp sensortagmagnetometer.h - sensortagpressuresensor.cpp sensortagpressuresensor.h - sensortagtemperaturesensor.cpp sensortagtemperaturesensor.h - PUBLIC_LIBRARIES - Qt::Bluetooth - Qt::Core - Qt::SensorsPrivate -) - -#### Keys ignored in scope 1:.:.:sensortag.pro:<TRUE>: -# OTHER_FILES = "plugin.json" diff --git a/src/plugins/sensors/sensortag/Sensors.conf b/src/plugins/sensors/sensortag/Sensors.conf deleted file mode 100644 index b8d79752..00000000 --- a/src/plugins/sensors/sensortag/Sensors.conf +++ /dev/null @@ -1,13 +0,0 @@ -[Default] -QAccelerometer=sensortag.accelerometer -QAmbientLightSensor=sensortag.als -QCompass=sensortag.compass -QMagnetometer=sensortag.magnetometer -QOrientationSensor=sensortag.orientationsensor -QProximitySensor=sensortag.proximitysensor -QRotationSensor=sensortag.rotationsensor -QTapSensor=sensortag.tapsensor -QLightSensor=sensortag.lightsensor -QIRProximitySensor=sensortag.irproximitysensor -QGyroscope=sensortag.gyroscope -QLidSensor=sensortag.lidsensor diff --git a/src/plugins/sensors/sensortag/main.cpp b/src/plugins/sensors/sensortag/main.cpp deleted file mode 100644 index e8ab477a..00000000 --- a/src/plugins/sensors/sensortag/main.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagaccelerometer.h" -#include "sensortagals.h" -#include "sensortagbase.h" -#include "sensortaggyroscope.h" -#include "sensortaghumiditysensor.h" -#include "sensortaglightsensor.h" -#include "sensortagmagnetometer.h" -#include "sensortagpressuresensor.h" -#include "sensortagtemperaturesensor.h" - -#include <QtSensors/qsensorplugin.h> -#include <QtSensors/qsensorbackend.h> -#include <QtSensors/qsensormanager.h> -#include <QSettings> - -class SensortagSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorBackendFactory -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json") - Q_INTERFACES(QSensorPluginInterface) - -public: - - void registerSensors() override - { - if (!QSensorManager::isBackendRegistered(QAccelerometer::sensorType, SensorTagAccelerometer::id)) - QSensorManager::registerBackend(QAccelerometer::sensorType, SensorTagAccelerometer::id, this); - - if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::sensorType, SensorTagAls::id)) - QSensorManager::registerBackend(QAmbientLightSensor::sensorType, SensorTagAls::id, this); - - if (!QSensorManager::isBackendRegistered(QLightSensor::sensorType, SensorTagLightSensor::id)) - QSensorManager::registerBackend(QLightSensor::sensorType, SensorTagLightSensor::id, this); - - if (!QSensorManager::isBackendRegistered(QAmbientTemperatureSensor::sensorType, SensorTagTemperatureSensor::id)) - QSensorManager::registerBackend(QAmbientTemperatureSensor::sensorType, SensorTagTemperatureSensor::id, this); - - if (!QSensorManager::isBackendRegistered(QHumiditySensor::sensorType, SensorTagHumiditySensor::id)) - QSensorManager::registerBackend(QHumiditySensor::sensorType, SensorTagHumiditySensor::id, this); - - if (!QSensorManager::isBackendRegistered(QPressureSensor::sensorType, SensorTagPressureSensor::id)) - QSensorManager::registerBackend(QPressureSensor::sensorType, SensorTagPressureSensor::id, this); - - if (!QSensorManager::isBackendRegistered(QGyroscope::sensorType, SensorTagGyroscope::id)) - QSensorManager::registerBackend(QGyroscope::sensorType, SensorTagGyroscope::id, this); - - if (!QSensorManager::isBackendRegistered(QMagnetometer::sensorType, SensorTagMagnetometer::id)) - QSensorManager::registerBackend(QMagnetometer::sensorType, SensorTagMagnetometer::id, this); - } - - QSensorBackend *createBackend(QSensor *sensor) override - { - if (sensor->identifier() == SensorTagAccelerometer::id) - return new SensorTagAccelerometer(sensor); - if (sensor->identifier() == SensorTagAls::id) - return new SensorTagAls(sensor); - if (sensor->identifier() == SensorTagLightSensor::id) - return new SensorTagLightSensor(sensor); - if (sensor->identifier() == SensorTagTemperatureSensor::id) - return new SensorTagTemperatureSensor(sensor); - if (sensor->identifier() == SensorTagHumiditySensor::id) - return new SensorTagHumiditySensor(sensor); - if (sensor->identifier() == SensorTagPressureSensor::id) - return new SensorTagPressureSensor(sensor); - if (sensor->identifier() == SensorTagGyroscope::id) - return new SensorTagGyroscope(sensor); - if (sensor->identifier() == SensorTagMagnetometer::id) - return new SensorTagMagnetometer(sensor); - return nullptr; - } -}; - -#include "main.moc" diff --git a/src/plugins/sensors/sensortag/plugin.json b/src/plugins/sensors/sensortag/plugin.json deleted file mode 100644 index 9a0f4d52..00000000 --- a/src/plugins/sensors/sensortag/plugin.json +++ /dev/null @@ -1 +0,0 @@ -{ "Keys": [ "sensortag" ] } diff --git a/src/plugins/sensors/sensortag/sensortag.pri b/src/plugins/sensors/sensortag/sensortag.pri deleted file mode 100644 index d1d60cb1..00000000 --- a/src/plugins/sensors/sensortag/sensortag.pri +++ /dev/null @@ -1,22 +0,0 @@ -# Input -HEADERS += sensortagaccelerometer.h \ - sensortagals.h \ - sensortagbase.h \ - sensortaggyroscope.h \ - sensortaghumiditysensor.h \ - sensortaglightsensor.h \ - sensortagmagnetometer.h \ - sensortagpressuresensor.h \ - sensortagtemperaturesensor.h - -SOURCES += main.cpp \ - sensortagaccelerometer.cpp \ - sensortagals.cpp \ - sensortagbase.cpp \ - sensortaggyroscope.cpp \ - sensortaghumiditysensor.cpp \ - sensortaglightsensor.cpp \ - sensortagmagnetometer.cpp \ - sensortagpressuresensor.cpp \ - sensortagtemperaturesensor.cpp - diff --git a/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp b/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp deleted file mode 100644 index b5b582a9..00000000 --- a/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagaccelerometer.h" -#include <QtSensors/qsensorbackend.h> - -char const * const SensorTagAccelerometer::id("sensortag.accelerometer"); - -SensorTagAccelerometer::SensorTagAccelerometer(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setDescription(QLatin1String("x, y, and z axes accelerations in m/s^2")); - setReading<QAccelerometerReading>(&m_reading); - sensor->setDataRate(50);//set a default rate -} - -void SensorTagAccelerometer::slotDataAvailable(const QAccelerometerReading &data) -{ - m_reading.setX(data.x()); - m_reading.setY(data.y()); - m_reading.setZ(data.z()); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagAccelerometer::init() -{ - m_initDone = false; -} - -void SensorTagAccelerometer::start() -{ - QObject::connect(this, &SensorTagBase::accelDataAvailable, - this, &SensorTagAccelerometer::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_ACCELEROMETER_SERVICE); -} - -void SensorTagAccelerometer::stop() -{ - QObject::disconnect(this, &SensorTagBase::accelDataAvailable, - this, &SensorTagAccelerometer::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_ACCELEROMETER_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortagaccelerometer.h b/src/plugins/sensors/sensortag/sensortagaccelerometer.h deleted file mode 100644 index 39ad47f6..00000000 --- a/src/plugins/sensors/sensortag/sensortagaccelerometer.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGACCELEROMETER_H -#define SENSORTAGACCELEROMETER_H - -#include "sensortagbase.h" -#include <QtSensors/qaccelerometer.h> - -class SensorTagAccelerometer : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagAccelerometer(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - QAccelerometerReading m_reading; - bool m_initDone = false; - -private slots: - void slotDataAvailable(const QAccelerometerReading &data); -}; - -#endif -// SENSORTAGACCELEROMETER_H diff --git a/src/plugins/sensors/sensortag/sensortagals.cpp b/src/plugins/sensors/sensortag/sensortagals.cpp deleted file mode 100644 index 3fe2de4c..00000000 --- a/src/plugins/sensors/sensortag/sensortagals.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagals.h" -#include "sensortagbase.h" -#include <QDebug> - -char const * const SensorTagAls::id("sensortag.als"); - -SensorTagAls::SensorTagAls(QSensor *sensor) - : SensorTagBase(sensor) - , m_initDone(false) -{ - init(); - setReading<QAmbientLightReading>(&m_reading); - setDescription(QLatin1String("ambient light intensity given as 5 pre-defined levels")); -} - -void SensorTagAls::start() -{ - QObject::connect(this, &SensorTagBase::luxDataAvailable, this, &SensorTagAls::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_LIGHT_SERVICE); -} - -void SensorTagAls::stop() -{ - QObject::disconnect(this, &SensorTagBase::luxDataAvailable, this, &SensorTagAls::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_LIGHT_SERVICE); -} - -void SensorTagAls::slotDataAvailable(qreal data) -{ - QAmbientLightReading::LightLevel level = getLightLevel(data); - if (level != m_reading.lightLevel()) { - m_reading.setLightLevel(level); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); - } -} - -QAmbientLightReading::LightLevel SensorTagAls::getLightLevel(int lux) -{ - if (lux < 0) - return QAmbientLightReading::Undefined; - if (lux < 10) - return QAmbientLightReading::Dark; - if (lux < 80) - return QAmbientLightReading::Twilight; - if (lux < 400) - return QAmbientLightReading::Light; - if (lux < 2500) - return QAmbientLightReading::Bright; - return QAmbientLightReading::Sunny; -} - -void SensorTagAls::init() -{ - m_initDone = false; -} diff --git a/src/plugins/sensors/sensortag/sensortagals.h b/src/plugins/sensors/sensortag/sensortagals.h deleted file mode 100644 index 3ef1b928..00000000 --- a/src/plugins/sensors/sensortag/sensortagals.h +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGALS_H -#define SENSORTAGALS_H - -#include "sensortagbase.h" -#include <QtSensors/qambientlightsensor.h> - -class SensorTagAls : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagAls(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - QAmbientLightReading m_reading; - bool m_initDone = false; -private slots: - void slotDataAvailable(qreal data); - static QAmbientLightReading::LightLevel getLightLevel(int lux); -}; - -#endif -//SENSORTAGALS_H diff --git a/src/plugins/sensors/sensortag/sensortagbase.cpp b/src/plugins/sensors/sensortag/sensortagbase.cpp deleted file mode 100644 index f873c8d3..00000000 --- a/src/plugins/sensors/sensortag/sensortagbase.cpp +++ /dev/null @@ -1,600 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagbase.h" - -#include <QLowEnergyCharacteristic> -#include <QtMath> -#include <QTimer> -#include <QDeadlineTimer> - -Q_GLOBAL_STATIC(SensorTagBasePrivate, sensortagBasePrivate) - -SensorTagBasePrivate::SensorTagBasePrivate(QObject *parent) - : QObject(parent) -{ - QTimer::singleShot(50, this, &SensorTagBasePrivate::deviceSearch); -} - -void SensorTagBasePrivate::deviceSearch() -{ - m_deviceDiscoveryAgent = new QBluetoothDeviceDiscoveryAgent(this); - - connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::deviceDiscovered, - this, &SensorTagBasePrivate::deviceFound); - connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::errorOccurred, - this, &SensorTagBasePrivate::deviceScanError); - connect(m_deviceDiscoveryAgent, &QBluetoothDeviceDiscoveryAgent::finished, - this, &SensorTagBasePrivate::scanFinished); - - QTimer::singleShot(20000, this, &SensorTagBasePrivate::deviceSearchTimeout); //make sure to timeout - m_deviceDiscoveryAgent->start(QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); -} - -void SensorTagBasePrivate::deviceSearchTimeout() -{ - if (m_deviceDiscoveryAgent->isActive() && m_control == nullptr) { - m_deviceDiscoveryAgent->stop(); - qWarning("No Sensor Tag devices found"); - } -} - -void SensorTagBasePrivate::deviceFound(const QBluetoothDeviceInfo &device) -{ - if (device.coreConfigurations() & QBluetoothDeviceInfo::LowEnergyCoreConfiguration) { - const QString idString = QString::fromLatin1(qgetenv("QT_SENSORTAG_ID")); - - const QBluetoothAddress watchForAddress(idString); - //mac uses deviceUuid - const QUuid watchForId(idString); - - bool ok(false); - - if ((!watchForAddress.isNull() && watchForAddress == device.address()) || - (!watchForId.isNull() && QBluetoothUuid(watchForId) == device.deviceUuid())) { - ok = true; - } - if (ok || device.name().contains("SensorTag")) { - - m_deviceDiscoveryAgent->stop(); - - m_control = QLowEnergyController::createCentral(device, this); - - connect(m_control, &QLowEnergyController::discoveryFinished, - this, &SensorTagBasePrivate::serviceDiscoveryFinished); - connect(m_control, &QLowEnergyController::serviceDiscovered, - this, &SensorTagBasePrivate::serviceDiscovered); - connect(m_control, &QLowEnergyController::errorOccurred, - this, &SensorTagBasePrivate::controllerError); - connect(m_control, &QLowEnergyController::connected, - this, &SensorTagBasePrivate::sensortagDeviceConnected); - connect(m_control, &QLowEnergyController::disconnected, - this, &SensorTagBasePrivate::deviceDisconnected); - - m_control->connectToDevice(); - } - } -} - -void SensorTagBasePrivate::serviceDiscoveryFinished() -{ - discoveryDone = true; -} - -void SensorTagBasePrivate::scanFinished() -{ - if (m_control == nullptr) - qWarning("No Sensor Tag devices found"); -} - -void SensorTagBasePrivate::deviceScanError(QBluetoothDeviceDiscoveryAgent::Error error) -{ - switch (error) { - case QBluetoothDeviceDiscoveryAgent::PoweredOffError: - qWarning("The Bluetooth adaptor is powered off, power it on before doing discovery."); - break; - case QBluetoothDeviceDiscoveryAgent::InputOutputError: - qWarning("Writing or reading from the device resulted in an error."); - break; - default: - qWarning("An unknown error has occurred."); - break; - }; -} - -void SensorTagBasePrivate::serviceError(QLowEnergyService::ServiceError e) -{ - switch (e) { - case QLowEnergyService::DescriptorWriteError: - qWarning("Cannot obtain SensorTag notifications"); - break; - default: - case QLowEnergyService::CharacteristicWriteError: - qWarning() << "SensorTag service error:" << e; - break; - }; -} - -void SensorTagBasePrivate::controllerError(QLowEnergyController::Error error) -{ - qWarning("Cannot connect to remote device."); - qWarning() << "Controller Error:" << error; -} - -void SensorTagBasePrivate::sensortagDeviceConnected() -{ - m_control->discoverServices(); -} - -void SensorTagBasePrivate::deviceDisconnected() -{ - if (q_ptr && q_ptr->sensor()->isActive()) - q_ptr->sensorStopped(); -} - -void SensorTagBasePrivate::serviceDiscovered(const QBluetoothUuid &gatt) -{ - if (enabledServiceUuids.contains(gatt)) { - - if (gatt == TI_SENSORTAG_LIGHT_SERVICE) { - lightService = m_control->createServiceObject(gatt, this); - doConnections(lightService); - } else if (gatt == TI_SENSORTAG_TEMPERATURE_SERVICE) { - temperatureService = m_control->createServiceObject(gatt, this); - doConnections(temperatureService); - } else if (gatt == TI_SENSORTAG_BAROMETER_SERVICE) { - barometerService = m_control->createServiceObject(gatt, this); - doConnections(barometerService); - } else if (gatt == TI_SENSORTAG_HUMIDTIY_SERVICE) { - humidityService = m_control->createServiceObject(gatt, this); - doConnections(humidityService); - } else if (gatt == TI_SENSORTAG_INFO_SERVICE) { - infoService = m_control->createServiceObject(gatt, this); - doConnections(infoService); - } else if (gatt == TI_SENSORTAG_ACCELEROMETER_SERVICE) { - acceleratorService = m_control->createServiceObject(gatt, this); - doConnections(acceleratorService); - } else if (gatt == TI_SENSORTAG_GYROSCOPE_SERVICE) { - gyroscopeService = m_control->createServiceObject(gatt, this); - doConnections(gyroscopeService); - } else if (gatt == TI_SENSORTAG_MAGNETOMETER_SERVICE) { - magnetometerService = m_control->createServiceObject(gatt, this); - doConnections(magnetometerService); - } else if (movementService == nullptr) { - if (gatt == TI_SENSORTAG_MOVEMENT_SERVICE) { - movementService = m_control->createServiceObject(gatt, this); - doConnections(movementService); - } - } - } -} - -void SensorTagBasePrivate::doConnections(QLowEnergyService *service) -{ - if (service) { - connect(service, &QLowEnergyService::stateChanged, - this, &SensorTagBasePrivate::serviceStateChanged); - - connect(service, &QLowEnergyService::characteristicChanged, - this, &SensorTagBasePrivate::updateCharacteristic); - - connect(service,SIGNAL(error(QLowEnergyService::ServiceError)), - this,SLOT(serviceError(QLowEnergyService::ServiceError))); - - if (service->state() == QLowEnergyService::RemoteService) { - service->discoverDetails(); - } else if (!enabledServiceUuids.isEmpty() - && enabledServiceUuids.contains(service->serviceUuid())) { - enableService(service->serviceUuid()); - } - } -} - -void SensorTagBasePrivate::serviceStateChanged(QLowEnergyService::ServiceState newState) -{ - if (newState != QLowEnergyService::RemoteServiceDiscovered) - return; - - QLowEnergyService *m_service = qobject_cast<QLowEnergyService *>(sender()); - - if (!m_service) - return; - - if (!enabledServiceUuids.isEmpty() - && enabledServiceUuids.contains(m_service->serviceUuid())) { - enableService(m_service->serviceUuid()); - } -} - -void SensorTagBasePrivate::enableLight(bool on) -{ - if (!lightService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_LIGHT_SERVICE); - if (!lightService) - return; - - const QLowEnergyCharacteristic hrChar = lightService->characteristic(TI_SENSORTAG_LIGHT_CONTROL); - lightService->writeCharacteristic(hrChar, on ? enableSensorCharacteristic : disableSensorCharacteristic); - - const QLowEnergyCharacteristic hrChar2 = lightService->characteristic(TI_SENSORTAG_LIGHT_DATA); - - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - lightService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableTemp(bool on) -{ - if (!temperatureService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_TEMPERATURE_SERVICE); - - if (!temperatureService) - return; - - const QLowEnergyCharacteristic hrChar = temperatureService->characteristic(TI_SENSORTAG_IR_TEMPERATURE_CONTROL); - temperatureService->writeCharacteristic(hrChar,on ? enableSensorCharacteristic : disableSensorCharacteristic); - - const QLowEnergyCharacteristic hrChar2 = temperatureService->characteristic(TI_SENSORTAG_IR_TEMPERATURE_DATA); - - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - temperatureService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enablePressure(bool on) -{ - if (!barometerService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_BAROMETER_SERVICE); - if (!barometerService) - return; - - const QLowEnergyCharacteristic hrChar = barometerService->characteristic(TI_SENSORTAG_BAROMETER_CONTROL); - barometerService->writeCharacteristic(hrChar, on ? enableSensorCharacteristic : disableSensorCharacteristic); - - const QLowEnergyCharacteristic hrChar2 = barometerService->characteristic(TI_SENSORTAG_BAROMETER_DATA); - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - - barometerService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableHumidity(bool on) -{ - if (!humidityService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_HUMIDTIY_SERVICE); - if (!humidityService) - return; - - const QLowEnergyCharacteristic hrChar = humidityService->characteristic(TI_SENSORTAG_HUMIDTIY_CONTROL); - humidityService->writeCharacteristic(hrChar, on ? enableSensorCharacteristic : disableSensorCharacteristic); - const QLowEnergyCharacteristic hrChar2 = humidityService->characteristic(TI_SENSORTAG_HUMIDTIY_DATA); - if (hrChar2.descriptors().count() > 0) { - const QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - humidityService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableMovement(bool on) -{ - if (!movementService && discoveryDone) - serviceDiscovered(TI_SENSORTAG_MOVEMENT_SERVICE); - if (!movementService) - return; - - QByteArray controlCharacteristic; - - int movementControl = 0; - //movement service has different syntax here - if (on) { - if (gyroscopeEnabled) - movementControl += 7; - if (accelerometerEnabled) - movementControl += 56; - if (magnetometerEnabled) - movementControl += 64; - - controlCharacteristic = QByteArray::number(movementControl, 16); - controlCharacteristic.append("04"); - - } else { - controlCharacteristic = "00"; - } - - const QLowEnergyCharacteristic hrChar = movementService->characteristic(TI_SENSORTAG_MOVEMENT_CONTROL); - movementService->writeCharacteristic(hrChar, QByteArray::fromHex(controlCharacteristic)); - - const QLowEnergyCharacteristic hrChar2 = movementService->characteristic(TI_SENSORTAG_MOVEMENT_DATA); - if (hrChar2.descriptors().count() > 0) { - QLowEnergyDescriptor m_notificationDesc = hrChar2.descriptors().at(0); - - movementService->writeDescriptor(m_notificationDesc, - on ? enableNotificationsCharacteristic : disableNotificationsCharacteristic); - } -} - -void SensorTagBasePrivate::enableService(const QBluetoothUuid &uuid) -{ - if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE - || uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE - || uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) { - - if ((uuid != TI_SENSORTAG_MOVEMENT_SERVICE) - && (accelerometerEnabled || magnetometerEnabled || gyroscopeEnabled)) - return; - - if (!enabledServiceUuids.contains(TI_SENSORTAG_MOVEMENT_SERVICE)) - enabledServiceUuids.append(TI_SENSORTAG_MOVEMENT_SERVICE); - - if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE) - accelerometerEnabled = true; - else if (uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE) - magnetometerEnabled = true; - else if (uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) - gyroscopeEnabled = true; - - } else if (!enabledServiceUuids.contains(uuid)) - enabledServiceUuids.append(uuid); - - if (discoveryDone) { - - if (uuid == TI_SENSORTAG_LIGHT_SERVICE) - enableLight(true); - else if (uuid == TI_SENSORTAG_TEMPERATURE_SERVICE) - enableTemp(true); - else if (uuid == TI_SENSORTAG_BAROMETER_SERVICE) - enablePressure(true); - else if (uuid == TI_SENSORTAG_HUMIDTIY_SERVICE) - enableHumidity(true); - else if (uuid == TI_SENSORTAG_MOVEMENT_SERVICE) - enableMovement(true); - else if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE) - enableMovement(true); - else if (uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE) - enableMovement(true); - else if (uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) - enableMovement(true); - } -} - -void SensorTagBasePrivate::disableService(const QBluetoothUuid &uuid) -{ - enabledServiceUuids.removeOne(uuid); - - if (uuid == TI_SENSORTAG_LIGHT_SERVICE) { - enableLight(false); - } else if (uuid == TI_SENSORTAG_TEMPERATURE_SERVICE) { - enableTemp(false); - } else if (uuid == TI_SENSORTAG_BAROMETER_SERVICE) { - enablePressure(false); - } else if (uuid == TI_SENSORTAG_HUMIDTIY_SERVICE) { - enableHumidity(false); - } else if (uuid == TI_SENSORTAG_MOVEMENT_SERVICE) { - enableMovement(false); - } else if (uuid == TI_SENSORTAG_ACCELEROMETER_SERVICE) { - enableMovement(false); - accelerometerEnabled = false; - } else if (uuid == TI_SENSORTAG_MAGNETOMETER_SERVICE) { - enableMovement(false); - magnetometerEnabled = false; - } else if (uuid == TI_SENSORTAG_GYROSCOPE_SERVICE) { - enableMovement(false); - gyroscopeEnabled = false; - } -} - -void SensorTagBasePrivate::updateCharacteristic(const QLowEnergyCharacteristic &c, - const QByteArray &value) -{ - if (c.uuid() == TI_SENSORTAG_LIGHT_DATA) { - convertLux(value); - } else if (c.uuid()== TI_SENSORTAG_IR_TEMPERATURE_DATA) { - convertTemperature(value); - } else if (c.uuid() == TI_SENSORTAG_BAROMETER_DATA) { - convertBarometer(value); - } else if (c.uuid()== TI_SENSORTAG_HUMIDTIY_DATA) { - convertHumidity(value); - } else if (c.uuid()== TI_SENSORTAG_BAROMETER_DATA) { - convertBarometer(value); - } else if ((c.uuid() == TI_SENSORTAG_ACCELEROMETER_DATA - || c.uuid() == TI_SENSORTAG_MOVEMENT_DATA) && accelerometerEnabled) { - convertAccelerometer(value); - } else if ((c.uuid() == TI_SENSORTAG_MAGNETOMETER_DATA - || c.uuid()== TI_SENSORTAG_MOVEMENT_DATA) && magnetometerEnabled) { - convertMagnetometer(value); - } else if ((c.uuid() == TI_SENSORTAG_GYROSCOPE_DATA - || c.uuid() == TI_SENSORTAG_MOVEMENT_DATA) && gyroscopeEnabled) { - convertGyroscope(value); - } -} - -void SensorTagBasePrivate::convertLux(const QByteArray &bytes) -{ - if (bytes.size() < 1) - return; - - quint16 dat = ((quint16)bytes[1] & 0xFF) << 8; - dat |= (quint16)(bytes[0] & 0xFF); - - qreal lux = dat * .01; - - emit luxDataAvailable(lux); -} - -void SensorTagBasePrivate::convertTemperature(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - qint16 objTemp = ((bytes[0] & 0xff) | ((bytes[1] << 8) & 0xff00)); - objTemp >>= 2; - qreal objectTemperature = objTemp * 0.03125; - // change to this if you want to use the ambient/die temp sensor - // qreal ambientTemperature = ambTemp / 128.0; - - emit tempDataAvailable(objectTemperature); -} - -void SensorTagBasePrivate::convertHumidity(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - quint16 rawH = (bytes[2] & 0xff) | ((bytes[3] << 8) & 0xff00); - qreal rHumidity = (qreal)(rawH / 65535) * 100.0; - - emit humidityDataAvailable(rHumidity); -} - -void SensorTagBasePrivate::convertBarometer(const QByteArray &bytes) -{ - if (bytes.size() < 5) - return; - quint32 pressure = (bytes[3] & 0xff) | ((bytes[4] << 8) & 0xff00) | ((bytes[5] << 16) & 0xff0000); - - qreal mbars = (qreal)pressure / 100.0; - emit pressureDataAvailable(mbars); -} - -void SensorTagBasePrivate::convertAccelerometer(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - int range = 8; - - qint16 X = (qint16)((bytes[8]) + ((bytes[9] << 8))); - qint16 Y = (qint16)((bytes[6]) + ((bytes[7] << 8))); - qint16 Z = (qint16)((bytes[10]) + ((bytes[11] << 8))); - - accelReading.setX((qreal)(X * 1.0) / (32768 / range) * 9.80665); - accelReading.setY(-(qreal)(Y * 1.0) / (32768 / range) * 9.80665); - accelReading.setZ((qreal)(Z * 1.0) / (32768 / range) * 9.80665); - // TODO needs calibration - - emit accelDataAvailable(accelReading); -} - -void SensorTagBasePrivate::convertMagnetometer(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - qreal scale = 6.67100977199; // 32768 / 4912; - qint16 X = (qint16)((bytes[12]) + ((bytes[13] << 8))); - qint16 Y = (qint16)((bytes[14]) + ((bytes[15] << 8))); - qint16 Z = (qint16)((bytes[16]) + ((bytes[17] << 8))); - // TODO needs calibration - - magReading.setX((qreal)(X / scale)); - magReading.setY((qreal)(Y / scale)); - magReading.setZ((qreal)(Z / scale)); - - emit magDataAvailable(magReading); -} - -void SensorTagBasePrivate::convertGyroscope(const QByteArray &bytes) -{ - if (bytes.size() < 3) - return; - - qreal scale = 128.0; - qint16 X = (qint16)((bytes[2]) + ((bytes[3] << 8))); - qint16 Y = (qint16)((bytes[0]) + ((bytes[1] << 8))); - qint16 Z = (qint16)((bytes[4]) + ((bytes[5] << 8))); - - gyroReading.setX((qreal)(X / scale)); - gyroReading.setY((qreal)(Y / scale)); - gyroReading.setZ((qreal)(Z / scale)); - - emit gyroDataAvailable(gyroReading); -} - -SensorTagBasePrivate * SensorTagBasePrivate::instance() -{ - SensorTagBasePrivate *priv = sensortagBasePrivate(); - return priv; -} - -SensorTagBase::SensorTagBase(QSensor *sensor) - : QSensorBackend(sensor), - leService(nullptr), - serviceId(nullptr), - d_ptr(SensorTagBasePrivate::instance()) -{ - connect(d_ptr, &SensorTagBasePrivate::luxDataAvailable, - this, &SensorTagBase::luxDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::tempDataAvailable, - this, &SensorTagBase::tempDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::humidityDataAvailable, - this, &SensorTagBase::humidityDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::pressureDataAvailable, - this, &SensorTagBase::pressureDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::accelDataAvailable, - this, &SensorTagBase::accelDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::gyroDataAvailable, - this, &SensorTagBase::gyroDataAvailable); - connect(d_ptr, &SensorTagBasePrivate::magDataAvailable, - this, &SensorTagBase::magDataAvailable); -} - -SensorTagBase::~SensorTagBase() -{ -} - -void SensorTagBase::start() -{ -} - -void SensorTagBase::stop() -{ -} - -quint64 SensorTagBase::produceTimestamp() -{ - return QDeadlineTimer::current().deadlineNSecs() / 1000; -} - - diff --git a/src/plugins/sensors/sensortag/sensortagbase.h b/src/plugins/sensors/sensortag/sensortagbase.h deleted file mode 100644 index 5d61aacf..00000000 --- a/src/plugins/sensors/sensortag/sensortagbase.h +++ /dev/null @@ -1,252 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGBASEPRIVATE_H -#define SENSORTAGBASEPRIVATE_H - -#include <QObject> -#include <QSensorBackend> - -#include <QBluetoothDeviceDiscoveryAgent> -#include <QBluetoothDeviceInfo> -#include <QLowEnergyController> -#include <QLowEnergyService> - -#include <QAccelerometerReading> -#include <QGyroscopeReading> -#include <QMagnetometerReading> - -class SensorTagBase; - -class SensorTagBasePrivate : public QObject -{ - Q_OBJECT - Q_DECLARE_PUBLIC(SensorTagBase) -public: - explicit SensorTagBasePrivate(QObject *parent = 0); - - QLowEnergyService *lightService = nullptr; - QLowEnergyService *temperatureService = nullptr; - QLowEnergyService *barometerService = nullptr; - QLowEnergyService *humidityService = nullptr; - QLowEnergyService *movementService = nullptr; - QLowEnergyService *acceleratorService = nullptr; - QLowEnergyService *magnetometerService = nullptr; - QLowEnergyService *gyroscopeService = nullptr; - - void enableService(const QBluetoothUuid &uuid); - void disableService(const QBluetoothUuid &uuid); - - static SensorTagBasePrivate *instance(); - -signals: - void accelDataAvailable(const QAccelerometerReading &); - void gyroDataAvailable(const QGyroscopeReading &); - void magDataAvailable(const QMagnetometerReading &); - - void luxDataAvailable(qreal); - void tempDataAvailable(qreal); - void humidityDataAvailable(qreal); - void pressureDataAvailable(qreal); - void compassDataAvailable(qreal); - -public slots: - void enableLight(bool); - void enableTemp(bool); - void enablePressure(bool); - void enableHumidity(bool); - void enableMovement(bool); - - void deviceFound(const QBluetoothDeviceInfo&); - void scanFinished(); - - void deviceScanError(QBluetoothDeviceDiscoveryAgent::Error); - void serviceDiscovered(const QBluetoothUuid &); - - void controllerError(QLowEnergyController::Error); - - void sensortagDeviceConnected(); - void deviceDisconnected(); - - void serviceStateChanged(QLowEnergyService::ServiceState s); - void updateCharacteristic(const QLowEnergyCharacteristic &c, - const QByteArray &value); - void serviceError(QLowEnergyService::ServiceError e); - void doConnections(QLowEnergyService *service); - -private slots: - void deviceSearch(); - void serviceDiscoveryFinished(); - void deviceSearchTimeout(); - -private: - - void convertLux(const QByteArray &value); - void convertTemperature(const QByteArray &value); - void convertBarometer(const QByteArray &value); - void convertHumidity(const QByteArray &value); - void convertAccelerometer(const QByteArray &value); - void convertMagnetometer(const QByteArray &value); - void convertGyroscope(const QByteArray &value); - - QBluetoothDeviceDiscoveryAgent *m_deviceDiscoveryAgent = nullptr; - QLowEnergyDescriptor m_notificationDesc; - - QLowEnergyController *m_control = nullptr; - QLowEnergyService *infoService = nullptr; - - QAccelerometerReading accelReading; - QGyroscopeReading gyroReading; - QMagnetometerReading magReading; - - bool discoveryDone = false; - QList <QBluetoothUuid> enabledServiceUuids; - SensorTagBase *q_ptr; - - bool accelerometerEnabled = false; - bool gyroscopeEnabled = false; - bool magnetometerEnabled = false; - - const QByteArray enableSensorCharacteristic = QByteArrayLiteral("\x01"); - const QByteArray disableSensorCharacteristic = QByteArrayLiteral("\x00"); - - const QByteArray enableNotificationsCharacteristic = QByteArrayLiteral("\x01\x00"); - const QByteArray disableNotificationsCharacteristic = QByteArrayLiteral("\x00\x00"); -}; - -const QBluetoothUuid TI_SENSORTAG_TEMPERATURE_SERVICE(QUuid("{f000aa00-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IR_TEMPERATURE_DATA(QUuid("{f000aa01-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IR_TEMPERATURE_CONTROL(QUuid("{f000aa02-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IR_TEMPERATURE_PERIOD(QUuid("{f000aa03-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_SERVICE(QUuid("{f000aa10-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_DATA(QUuid("{f000aa11-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_CONTROL(QUuid("{f000aa12-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_ACCELEROMETER_PERIOD(QUuid("{f000aa13-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_SERVICE(QUuid("{f000aa20-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_DATA(QUuid("{f000aa21-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_CONTROL(QUuid("{f000aa22-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_HUMIDTIY_PERIOD(QUuid("{f000aa23-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_SERVICE(QUuid("{f000aa30-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_DATA(QUuid("{f000aa31-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_CONTROL(QUuid("{f000aa32-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MAGNETOMETER_PERIOD(QUuid("{f000aa33-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_BAROMETER_SERVICE(QUuid("{f000aa40-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_DATA(QUuid("{f000aa41-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_CONTROL(QUuid("{f000aa42-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_CALIBRATION(QUuid("{f000aa43-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_BAROMETER_PERIOD(QUuid("{f000aa44-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_SERVICE(QUuid("{f000aa50-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_DATA(QUuid("{f000aa51-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_CONTROL(QUuid("{f000aa52-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_GYROSCOPE_PERIOD(QUuid("{f000aa53-0451-4000-b000-000000000000}")); - -// test service "{f000aa60-0451-4000-b000-000000000000}" - -const QBluetoothUuid TI_SENSORTAG_IO_SERVICE(QUuid("{f000aa64-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IO_DATA(QUuid("{f000aa65-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_IO_CONTROL(QUuid("{f000aa66-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_LIGHT_SERVICE(QUuid("{f000aa70-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_LIGHT_DATA(QUuid("{f000aa71-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_LIGHT_CONTROL(QUuid("{f000aa72-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_LIGHT_PERIOD(QUuid("{f000aa73-0451-4000-b000-000000000000}")); - -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_SERVICE(QUuid("{f000aa80-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_DATA(QUuid("{f000aa81-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_CONTROL(QUuid("{f000aa82-0451-4000-b000-000000000000}")); -const QBluetoothUuid TI_SENSORTAG_MOVEMENT_PERIOD(QUuid("{f000aa83-0451-4000-b000-000000000000}")); - -// keypress "{f000ffe0-0000-1000-8000-00805f9b34fb" - -// Connection Control Service "{f000ccc0-0451-4000-b000-000000000000}" -// OAD (over air download) Service "{f000ffc0-0451-4000-b000-000000000000}" - -const QBluetoothUuid TI_SENSORTAG_INFO_SERVICE(QUuid("{0000180a-0000-1000-8000-00805f9b34fb}")); -//we might want to use these somehow -//const QBluetoothUuid TI_SENSORTAG_BATTERY_SERVICE "180F" -//const QBluetoothUuid TI_SENSORTAG_BATTERY_BATTERY_LEVEL "2A19" - -// {00001800-0000-1000-8000-00805f9b34fb} //Generic Access Service -// {00001801-0000-1000-8000-00805f9b34fb} //Generic Attribute Service - -class SensorTagBase : public QSensorBackend -{ - Q_OBJECT - Q_DECLARE_PRIVATE(SensorTagBase) -public: - SensorTagBase(QSensor *sensor); - virtual ~SensorTagBase(); - - quint64 produceTimestamp(); -signals: - void accelDataAvailable(const QAccelerometerReading &); - void luxDataAvailable(qreal); - void tempDataAvailable(qreal); - void humidityDataAvailable(qreal); - void pressureDataAvailable(qreal); - void gyroDataAvailable(const QGyroscopeReading &); - void magDataAvailable(const QMagnetometerReading &); - -protected: - void start() override; - void stop() override; - QLowEnergyService *leService; - QBluetoothUuid *serviceId; - -private: - SensorTagBasePrivate *d_ptr; - friend class SensorTagTemperatureSensor; - friend class SensorTagAls; - friend class SensorTagHumiditySensor; - friend class SensorTagLightSensor; - - friend class SensorTagPressureSensor; - friend class SensorTagAccelerometer; - - friend class SensorTagGyroscope; - friend class SensorTagMagnetometer; -}; - -#endif // SENSORTAGBASEPRIVATE_H diff --git a/src/plugins/sensors/sensortag/sensortaggyroscope.cpp b/src/plugins/sensors/sensortag/sensortaggyroscope.cpp deleted file mode 100644 index 136d1433..00000000 --- a/src/plugins/sensors/sensortag/sensortaggyroscope.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortaggyroscope.h" - -char const * const SensorTagGyroscope::id("sensortag.gyroscope"); -const float SensorTagGyroscope::MILLI = 0.001; - -SensorTagGyroscope::SensorTagGyroscope(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setDescription(QLatin1String("angular velocities around x, y, and z axis in degrees per second")); - setReading<QGyroscopeReading>(&m_reading); - sensor->setDataRate(50);//set a default rate -} - -void SensorTagGyroscope::slotDataAvailable(const QGyroscopeReading& data) -{ - m_reading.setX(data.x()); - m_reading.setY(data.y()); - m_reading.setZ(data.z()); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagGyroscope::init() -{ - m_initDone = false; -} - -void SensorTagGyroscope::start() -{ - QObject::connect(this, &SensorTagBase::gyroDataAvailable, - this, &SensorTagGyroscope::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_GYROSCOPE_SERVICE); -} - - -void SensorTagGyroscope::stop() -{ - QObject::disconnect(this, &SensorTagBase::gyroDataAvailable, - this, &SensorTagGyroscope::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_GYROSCOPE_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortaggyroscope.h b/src/plugins/sensors/sensortag/sensortaggyroscope.h deleted file mode 100644 index af3cfe41..00000000 --- a/src/plugins/sensors/sensortag/sensortaggyroscope.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGGYROSCOPE_H -#define SENSORTAGGYROSCOPE_H - -#include "sensortagbase.h" -#include <QtSensors/qgyroscope.h> - -class SensorTagGyroscope : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagGyroscope(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - QGyroscopeReading m_reading; - bool m_initDone = false; - static const float MILLI; -private slots: - void slotDataAvailable(const QGyroscopeReading &data); -}; - -#endif // SENSORTAGGYROSCOPE_H diff --git a/src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp b/src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp deleted file mode 100644 index 77b4585c..00000000 --- a/src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "sensortaghumiditysensor.h" -#include "sensortagbase.h" - -char const * const SensorTagHumiditySensor::id("sensortag.humidity"); - -SensorTagHumiditySensor::SensorTagHumiditySensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - setReading<QHumidityReading>(&m_reading); -} - - -void SensorTagHumiditySensor::humidityChanged(qreal value) -{ - m_reading.setRelativeHumidity(value); - - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagHumiditySensor::start() -{ - QObject::connect(this, &SensorTagBase::humidityDataAvailable, - this, &SensorTagHumiditySensor::humidityChanged); - d_ptr->enableService(TI_SENSORTAG_HUMIDTIY_SERVICE); -} - -void SensorTagHumiditySensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::humidityDataAvailable, - this, &SensorTagHumiditySensor::humidityChanged); - d_ptr->disableService(TI_SENSORTAG_HUMIDTIY_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortaghumiditysensor.h b/src/plugins/sensors/sensortag/sensortaghumiditysensor.h deleted file mode 100644 index 5511bf05..00000000 --- a/src/plugins/sensors/sensortag/sensortaghumiditysensor.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGHUMIDITYSENSOR_H -#define SENSORTAGHUMIDITYSENSOR_H - -#include "sensortagbase.h" -#include <QHumidityReading> - -class SensorTagHumiditySensor : public SensorTagBase -{ - Q_OBJECT -public: - SensorTagHumiditySensor(QSensor *sensor); - static char const * const id; -protected: - void start() override; - void stop() override; -private slots: - void humidityChanged(qreal value); -private: - QHumidityReading m_reading; -}; - -#endif // SENSORTAGHUMIDITYSENSOR_H diff --git a/src/plugins/sensors/sensortag/sensortaglightsensor.cpp b/src/plugins/sensors/sensortag/sensortaglightsensor.cpp deleted file mode 100644 index 9e4038b3..00000000 --- a/src/plugins/sensors/sensortag/sensortaglightsensor.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortaglightsensor.h" - -char const * const SensorTagLightSensor::id("sensortag.lightsensor"); - -SensorTagLightSensor::SensorTagLightSensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setReading<QLightReading>(&m_reading); - sensor->setDataRate(10);//set a default rate -} - -void SensorTagLightSensor::slotDataAvailable(qreal data) -{ - m_reading.setLux(data); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagLightSensor::init() -{ - m_initDone = false; -} - -void SensorTagLightSensor::start() -{ - QObject::connect(this, &SensorTagBase::luxDataAvailable, - this, &SensorTagLightSensor::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_LIGHT_SERVICE); -} - -void SensorTagLightSensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::luxDataAvailable, - this, &SensorTagLightSensor::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_LIGHT_SERVICE); -} diff --git a/src/plugins/sensors/sensortag/sensortaglightsensor.h b/src/plugins/sensors/sensortag/sensortaglightsensor.h deleted file mode 100644 index edff8263..00000000 --- a/src/plugins/sensors/sensortag/sensortaglightsensor.h +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGLIGHTSENSOR_H -#define SENSORTAGLIGHTSENSOR_H - -#include "sensortagbase.h" -#include <QtSensors/qlightsensor.h> - -class SensorTagLightSensor : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagLightSensor(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); -private: - QLightReading m_reading; - bool m_initDone = false; -private slots: - void slotDataAvailable(qreal data); -}; - -#endif -//SENSORTAGLIGHTSENSOR_H diff --git a/src/plugins/sensors/sensortag/sensortagmagnetometer.cpp b/src/plugins/sensors/sensortag/sensortagmagnetometer.cpp deleted file mode 100644 index d5d46221..00000000 --- a/src/plugins/sensors/sensortag/sensortagmagnetometer.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#include "sensortagmagnetometer.h" - -char const * const SensorTagMagnetometer::id("sensortag.magnetometer"); -const float SensorTagMagnetometer::NANO = 0.000000001; - -SensorTagMagnetometer::SensorTagMagnetometer(QSensor *sensor) - : SensorTagBase(sensor) -{ - init(); - setDescription(QLatin1String("magnetic flux density in teslas (T)")); - setReading<QMagnetometerReading>(&m_reading); -} - -void SensorTagMagnetometer::start() -{ - QObject::connect(this, &SensorTagBase::magDataAvailable, - this, &SensorTagMagnetometer::slotDataAvailable); - d_ptr->enableService(TI_SENSORTAG_MAGNETOMETER_SERVICE); -} - -void SensorTagMagnetometer::stop() -{ - QObject::disconnect(this, &SensorTagBase::magDataAvailable, - this, &SensorTagMagnetometer::slotDataAvailable); - d_ptr->disableService(TI_SENSORTAG_MAGNETOMETER_SERVICE); -} - -void SensorTagMagnetometer::slotDataAvailable(const QMagnetometerReading &data) -{ - m_reading.setX(data.x()); - m_reading.setY(data.y()); - m_reading.setZ(data.z()); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagMagnetometer::init() -{ - m_initDone = false; -} diff --git a/src/plugins/sensors/sensortag/sensortagmagnetometer.h b/src/plugins/sensors/sensortag/sensortagmagnetometer.h deleted file mode 100644 index 424727a2..00000000 --- a/src/plugins/sensors/sensortag/sensortagmagnetometer.h +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGMAGNETOMETER_H -#define SENSORTAGMAGNETOMETER_H - -#include "sensortagbase.h" -#include <QtSensors/qmagnetometer.h> - -class SensorTagMagnetometer : public SensorTagBase -{ - Q_OBJECT - -public: - static char const * const id; - SensorTagMagnetometer(QSensor *sensor); -protected: - void start() override; - void stop() override; - virtual void init(); - -private: - static const float NANO; - QMagnetometerReading m_reading; - bool m_initDone = false; - -private slots: - void slotDataAvailable(const QMagnetometerReading &data); -}; - -#endif -//SENSORTAGMAGNETOMETER_H diff --git a/src/plugins/sensors/sensortag/sensortagpressuresensor.cpp b/src/plugins/sensors/sensortag/sensortagpressuresensor.cpp deleted file mode 100644 index 7d2c8f93..00000000 --- a/src/plugins/sensors/sensortag/sensortagpressuresensor.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagpressuresensor.h" -#include "sensortagbase.h" - -char const * const SensorTagPressureSensor::id("sensortag.pressure"); - -SensorTagPressureSensor::SensorTagPressureSensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - setReading<QPressureReading>(&m_reading); -} - -void SensorTagPressureSensor::pressureChanged(qreal value) -{ - m_reading.setPressure(value); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagPressureSensor::start() -{ - QObject::connect(this, &SensorTagBase::pressureDataAvailable, - this, &SensorTagPressureSensor::pressureChanged); - d_ptr->enableService(TI_SENSORTAG_BAROMETER_SERVICE); -} - -void SensorTagPressureSensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::pressureDataAvailable, - this, &SensorTagPressureSensor::pressureChanged); - d_ptr->disableService(TI_SENSORTAG_BAROMETER_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortagpressuresensor.h b/src/plugins/sensors/sensortag/sensortagpressuresensor.h deleted file mode 100644 index 5f8b0cfd..00000000 --- a/src/plugins/sensors/sensortag/sensortagpressuresensor.h +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGPRESSURESENSOR_H -#define SENSORTAGPRESSURESENSOR_H - -#include "sensortagbase.h" -#include <QObject> -#include <QPressureReading> - -class SensorTagPressureSensor : public SensorTagBase -{ - Q_OBJECT -public: - SensorTagPressureSensor(QSensor *sensor); - static char const * const id; - -protected: - void start() override; - void stop() override; - -private slots: - void pressureChanged(qreal value); -private: - QPressureReading m_reading; -}; - -#endif // SENSORTAGPRESSURESENSOR_H diff --git a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp b/src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp deleted file mode 100644 index ab8c4a2f..00000000 --- a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2016 Canonical, Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensortagtemperaturesensor.h" -#include "sensortagbase.h" - -char const * const SensorTagTemperatureSensor::id("sensortag.temperature"); - -SensorTagTemperatureSensor::SensorTagTemperatureSensor(QSensor *sensor) - : SensorTagBase(sensor) -{ - setReading<QAmbientTemperatureReading>(&m_reading); -} - -void SensorTagTemperatureSensor::temperatureChanged(qreal value) -{ - m_reading.setTemperature(value); - m_reading.setTimestamp(produceTimestamp()); - newReadingAvailable(); -} - -void SensorTagTemperatureSensor::start() -{ - QObject::connect(this, &SensorTagBase::tempDataAvailable, - this, &SensorTagTemperatureSensor::temperatureChanged); - d_ptr->enableService(TI_SENSORTAG_TEMPERATURE_SERVICE); -} - -void SensorTagTemperatureSensor::stop() -{ - QObject::disconnect(this, &SensorTagBase::tempDataAvailable, - this, &SensorTagTemperatureSensor::temperatureChanged); - d_ptr->disableService(TI_SENSORTAG_TEMPERATURE_SERVICE); -} - diff --git a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.h b/src/plugins/sensors/sensortag/sensortagtemperaturesensor.h deleted file mode 100644 index c4c45d58..00000000 --- a/src/plugins/sensors/sensortag/sensortagtemperaturesensor.h +++ /dev/null @@ -1,62 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 Lorn Potter -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef SENSORTAGTEMPERATURESENSOR_H -#define SENSORTAGTEMPERATURESENSOR_H - -#include "sensortagbase.h" -#include <QAmbientTemperatureReading> - -class SensorTagTemperatureSensor : public SensorTagBase -{ - Q_OBJECT -public: - SensorTagTemperatureSensor(QSensor *sensor); - static char const * const id; -protected: - void start() override; - void stop() override; -private slots: - void temperatureChanged(qreal value); -private: - QAmbientTemperatureReading m_reading; -}; - -#endif // SENSORTAGTEMPERATURESENSOR_H |