summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/plugins/sensors/sensors.pro9
-rw-r--r--src/plugins/sensors/sensortag/Sensors.conf13
-rw-r--r--src/plugins/sensors/sensortag/main.cpp113
-rw-r--r--src/plugins/sensors/sensortag/plugin.json1
-rw-r--r--src/plugins/sensors/sensortag/sensortag.pri22
-rw-r--r--src/plugins/sensors/sensortag/sensortag.pro11
-rw-r--r--src/plugins/sensors/sensortag/sensortagaccelerometer.cpp82
-rw-r--r--src/plugins/sensors/sensortag/sensortagaccelerometer.h68
-rw-r--r--src/plugins/sensors/sensortag/sensortagals.cpp97
-rw-r--r--src/plugins/sensors/sensortag/sensortagals.h68
-rw-r--r--src/plugins/sensors/sensortag/sensortagbase.cpp600
-rw-r--r--src/plugins/sensors/sensortag/sensortagbase.h252
-rw-r--r--src/plugins/sensors/sensortag/sensortaggyroscope.cpp84
-rw-r--r--src/plugins/sensors/sensortag/sensortaggyroscope.h67
-rw-r--r--src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp74
-rw-r--r--src/plugins/sensors/sensortag/sensortaghumiditysensor.h62
-rw-r--r--src/plugins/sensors/sensortag/sensortaglightsensor.cpp78
-rw-r--r--src/plugins/sensors/sensortag/sensortaglightsensor.h66
-rw-r--r--src/plugins/sensors/sensortag/sensortagmagnetometer.cpp80
-rw-r--r--src/plugins/sensors/sensortag/sensortagmagnetometer.h69
-rw-r--r--src/plugins/sensors/sensortag/sensortagpressuresensor.cpp73
-rw-r--r--src/plugins/sensors/sensortag/sensortagpressuresensor.h65
-rw-r--r--src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp73
-rw-r--r--src/plugins/sensors/sensortag/sensortagtemperaturesensor.h62
-rw-r--r--src/sensors/doc/src/compatmap.qdoc21
25 files changed, 2210 insertions, 0 deletions
diff --git a/src/plugins/sensors/sensors.pro b/src/plugins/sensors/sensors.pro
index 76989335..7fce2071 100644
--- a/src/plugins/sensors/sensors.pro
+++ b/src/plugins/sensors/sensors.pro
@@ -25,6 +25,14 @@ linux {
isEmpty(SENSORS_PLUGINS): SENSORS_PLUGINS = linux iio-sensor-proxy generic
}
+contains(CONFIG, sensortag) {
+ qtHaveModule(bluetooth) {
+ SENSORS_PLUGINS = sensortag generic
+ } else {
+ message("You have configured for sensortag, but Qt Bluetooth module was not found.")
+ }
+}
+
contains(SENSORS_PLUGINS, dummy):SUBDIRS += dummy
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, generic):SUBDIRS += generic
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, simulator):qtHaveModule(simulator):SUBDIRS += simulator
@@ -32,5 +40,6 @@ isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, linux):linux:SUBDIRS += linux
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, iio-sensor-proxy):linux:qtHaveModule(dbus):SUBDIRS += iio-sensor-proxy
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, android):android:SUBDIRS += android
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, sensorfw):sensorfw:SUBDIRS += sensorfw
+isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, sensortag):linux:SUBDIRS += sensortag
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, ios):darwin:SUBDIRS += ios
isEmpty(SENSORS_PLUGINS)|contains(SENSORS_PLUGINS, winrt):winrt:SUBDIRS += winrt
diff --git a/src/plugins/sensors/sensortag/Sensors.conf b/src/plugins/sensors/sensortag/Sensors.conf
new file mode 100644
index 00000000..b8d79752
--- /dev/null
+++ b/src/plugins/sensors/sensortag/Sensors.conf
@@ -0,0 +1,13 @@
+[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
new file mode 100644
index 00000000..e6dc54e5
--- /dev/null
+++ b/src/plugins/sensors/sensortag/main.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** 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()
+ {
+ if (!QSensorManager::isBackendRegistered(QAccelerometer::type, SensorTagAccelerometer::id))
+ QSensorManager::registerBackend(QAccelerometer::type, SensorTagAccelerometer::id, this);
+
+ if (!QSensorManager::isBackendRegistered(QAmbientLightSensor::type, SensorTagAls::id))
+ QSensorManager::registerBackend(QAmbientLightSensor::type, SensorTagAls::id, this);
+
+ if (!QSensorManager::isBackendRegistered(QLightSensor::type, SensorTagLightSensor::id))
+ QSensorManager::registerBackend(QLightSensor::type, SensorTagLightSensor::id, this);
+
+ if (!QSensorManager::isBackendRegistered(QAmbientTemperatureSensor::type, SensorTagTemperatureSensor::id))
+ QSensorManager::registerBackend(QAmbientTemperatureSensor::type, SensorTagTemperatureSensor::id, this);
+
+ if (!QSensorManager::isBackendRegistered(QHumiditySensor::type, SensorTagHumiditySensor::id))
+ QSensorManager::registerBackend(QHumiditySensor::type, SensorTagHumiditySensor::id, this);
+
+ if (!QSensorManager::isBackendRegistered(QPressureSensor::type, SensorTagPressureSensor::id))
+ QSensorManager::registerBackend(QPressureSensor::type, SensorTagPressureSensor::id, this);
+
+ if (!QSensorManager::isBackendRegistered(QGyroscope::type, SensorTagGyroscope::id))
+ QSensorManager::registerBackend(QGyroscope::type, SensorTagGyroscope::id, this);
+
+ if (!QSensorManager::isBackendRegistered(QMagnetometer::type, SensorTagMagnetometer::id))
+ QSensorManager::registerBackend(QMagnetometer::type, SensorTagMagnetometer::id, this);
+ }
+
+ QSensorBackend *createBackend(QSensor *sensor)
+ {
+ 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
new file mode 100644
index 00000000..9a0f4d52
--- /dev/null
+++ b/src/plugins/sensors/sensortag/plugin.json
@@ -0,0 +1 @@
+{ "Keys": [ "sensortag" ] }
diff --git a/src/plugins/sensors/sensortag/sensortag.pri b/src/plugins/sensors/sensortag/sensortag.pri
new file mode 100644
index 00000000..d1d60cb1
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortag.pri
@@ -0,0 +1,22 @@
+# 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/sensortag.pro b/src/plugins/sensors/sensortag/sensortag.pro
new file mode 100644
index 00000000..42252970
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortag.pro
@@ -0,0 +1,11 @@
+TARGET = qtsensors_sensortag
+QT = core sensors-private bluetooth
+CONFIG += c++11
+
+include(sensortag.pri)
+
+OTHER_FILES = plugin.json
+
+PLUGIN_TYPE = sensors
+PLUGIN_CLASS_NAME = SensortagSensorPlugin
+load(qt_plugin)
diff --git a/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp b/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp
new file mode 100644
index 00000000..b5b582a9
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagaccelerometer.cpp
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..39ad47f6
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagaccelerometer.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..3fe2de4c
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagals.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..3ef1b928
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagals.h
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..322a86d7
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagbase.cpp
@@ -0,0 +1,600 @@
+/****************************************************************************
+**
+** 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, QOverload<QBluetoothDeviceDiscoveryAgent::Error>::of(&QBluetoothDeviceDiscoveryAgent::error),
+ 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;
+
+ if ((!watchForAddress.isNull() && watchForAddress == device.address()) ||
+ (!watchForId.isNull() && watchForId == device.deviceUuid())) {
+ ok = true;
+ }
+ if (ok || device.name().contains("SensorTag")) {
+
+ m_deviceDiscoveryAgent->stop();
+
+ m_control = new QLowEnergyController(device.address(), this);
+
+ connect(m_control, &QLowEnergyController::discoveryFinished,
+ this, &SensorTagBasePrivate::serviceDiscoveryFinished);
+ connect(m_control, &QLowEnergyController::serviceDiscovered,
+ this, &SensorTagBasePrivate::serviceDiscovered);
+ connect(m_control, QOverload<QLowEnergyController::Error>::of(&QLowEnergyController::error),
+ 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::DiscoveryRequired) {
+ service->discoverDetails();
+ } else if (!enabledServiceUuids.isEmpty()
+ && enabledServiceUuids.contains(service->serviceUuid())) {
+ enableService(service->serviceUuid());
+ }
+ }
+}
+
+void SensorTagBasePrivate::serviceStateChanged(QLowEnergyService::ServiceState newState)
+{
+ if (newState != QLowEnergyService::ServiceDiscovered)
+ 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
new file mode 100644
index 00000000..5d61aacf
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagbase.h
@@ -0,0 +1,252 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..136d1433
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortaggyroscope.cpp
@@ -0,0 +1,84 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..af3cfe41
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortaggyroscope.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..77b4585c
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortaghumiditysensor.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..5511bf05
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortaghumiditysensor.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..9e4038b3
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortaglightsensor.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..edff8263
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortaglightsensor.h
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..d5d46221
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagmagnetometer.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..424727a2
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagmagnetometer.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..7d2c8f93
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagpressuresensor.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..5f8b0cfd
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagpressuresensor.h
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..ab8c4a2f
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagtemperaturesensor.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** 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
new file mode 100644
index 00000000..c4c45d58
--- /dev/null
+++ b/src/plugins/sensors/sensortag/sensortagtemperaturesensor.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** 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
diff --git a/src/sensors/doc/src/compatmap.qdoc b/src/sensors/doc/src/compatmap.qdoc
index be199602..d91c0c55 100644
--- a/src/sensors/doc/src/compatmap.qdoc
+++ b/src/sensors/doc/src/compatmap.qdoc
@@ -59,6 +59,7 @@
<td><b>Universal Windows Platform</b></td>
<td><b>Generic</b></td>
<td><b>Sensorfw</b></td>
+ <td><b>TI Sensor Tag</b></td>
</tr>
<tr>
<td nowrap="nowrap">Accelerometer</td>
@@ -68,6 +69,7 @@
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Altimeter</td>
@@ -77,6 +79,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Ambient Light Sensor</td>
@@ -86,6 +89,7 @@
<td bgcolor="green"></td>
<td bgcolor="green"></td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Ambient Temperature Sensor</td>
@@ -95,6 +99,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Compass</td>
@@ -104,6 +109,7 @@
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Distance</td>
@@ -113,6 +119,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Gyroscope</td>
@@ -122,6 +129,7 @@
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Holster Sensor</td>
@@ -131,6 +139,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Humidity Sensor</td>
@@ -140,6 +149,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">IR Proximity Sensor</td>
@@ -149,6 +159,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Lid Sensor</td>
@@ -158,6 +169,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Light Sensor</td>
@@ -167,6 +179,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Magnetometer</td>
@@ -176,6 +189,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Orientation Sensor</td>
@@ -185,6 +199,7 @@
<td bgcolor="green"></td>
<td bgcolor="green"></td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Pressure Sensor</td>
@@ -194,6 +209,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="green"></td>
</tr>
<tr>
<td nowrap="nowrap">Proximity Sensor</td>
@@ -203,6 +219,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Rotation Sensor</td>
@@ -212,6 +229,7 @@
<td bgcolor="green"></td>
<td bgcolor="green"></td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Tap Sensor</td>
@@ -221,6 +239,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Tilt Sensor</td>
@@ -230,6 +249,7 @@
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
<td bgcolor="gray"></td>
+ <td bgcolor="gray"></td>
</tr>
<tr>
<td nowrap="nowrap">Sensor Gestures</td>
@@ -239,6 +259,7 @@
<td bgcolor="gray"></td>
<td bgcolor="gray"></td>
<td bgcolor="green"></td>
+ <td bgcolor="gray"></td>
</tr>
</table>