[-]
[+]
|
Changed |
_service:tar_git:sensorfw.changes
|
|
[-]
[+]
|
Changed |
_service:tar_git:sensorfw-qt5-hybris.spec
^
|
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/TODO
^
|
@@ -0,0 +1,8 @@
+Just a rough todo for myself:
+
+sensorfw needs new sensors:
+
+* humidity
+* holster (hal)
+* ir distance
+* pressure (w/altitude property)
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/adaptors.pro
^
|
@@ -7,8 +7,10 @@
SUBDIRS += hybrisalsadaptor
SUBDIRS += hybrisgyroscopeadaptor
SUBDIRS += hybrismagnetometeradaptor
+ SUBDIRS += hybrispressureadaptor
SUBDIRS += hybrisproximityadaptor
SUBDIRS += hybrisorientationadaptor
+ SUBDIRS += hybrisstepcounteradaptor
} else {
@@ -30,22 +32,30 @@
mrstaccelerometer \
gyroscopeadaptor \
gyroscopeadaptor-evdev
+
SUDBIRS += oemtabletmagnetometeradaptor
-SUBDIRS += pegatronaccelerometeradaptor
+SUBDIRS += pegatronaccelerometeradaptor
SUBDIRS += oemtabletalsadaptor-ascii
SUBDIRS += oaktrailaccelerometer
SUBDIRS += oemtabletaccelerometer
SUDBIRS += oemtabletgyroscopeadaptor
SUBDIRS += steaccelerometeradaptor
SUBDIRS += mpu6050accelerometer
+SUBDIRS += lidsensoradaptor-evdev
+SUBDIRS += iioadaptor
+SUBDIRS += humidityadaptor
+SUBDIRS += pressureadaptor
+SUBDIRS += temperatureadaptor
config_hybris {
SUBDIRS += hybrisaccelerometer
SUBDIRS += hybrisalsadaptor
SUBDIRS += hybrisgyroscopeadaptor
SUBDIRS += hybrismagnetometeradaptor
+ SUBDIRS += hybrispressureadaptor
SUBDIRS += hybrisproximityadaptor
SUBDIRS += hybrisorientationadaptor
+ SUBDIRS += hybrisstepcounteradaptor
}
}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/humidityadaptor/humidityadaptor.cpp
^
|
@@ -0,0 +1,142 @@
+/**
+ @file humidityadaptor.cpp
+ @brief Contains HumidityAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "humidityadaptor.h"
+#include "config.h"
+#include "logging.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <unistd.h>
+#include <QMap>
+
+#include "datatypes/utils.h"
+
+HumidityAdaptor::HumidityAdaptor(const QString& id) :
+ InputDevAdaptor(id, 1)
+{
+ humidityBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
+ setAdaptedSensor("humidity", "Relative Humidity values", humidityBuffer_);
+ setDescription("Input device humidity adaptor");
+ powerStatePath_ = Config::configuration()->value("humidity/powerstate_path").toByteArray();
+ introduceAvailableDataRange(DataRange(0, 4095, 1));
+ setDefaultInterval(10);
+}
+
+HumidityAdaptor::~HumidityAdaptor()
+{
+}
+
+void HumidityAdaptor::interpretEvent(int src, struct input_event *ev)
+{
+ Q_UNUSED(src);
+
+ switch (ev->type) {
+ case EV_ABS:
+ switch (ev->code) {
+ case ABS_X:
+ case ABS_MISC:
+ humidityValue_ = ev->value;
+ break;
+ }
+ break;
+ }
+}
+
+void HumidityAdaptor::interpretSync(int src, struct input_event *ev)
+{
+ Q_UNUSED(src);
+ commitOutput(ev);
+}
+
+void HumidityAdaptor::commitOutput(struct input_event *ev)
+{
+ TimedUnsigned* rh = humidityBuffer_->nextSlot();
+ rh->value_ = humidityValue_;
+
+ rh->timestamp_ = Utils::getTimeStamp(&(ev->time));
+
+ humidityBuffer_->commit();
+ humidityBuffer_->wakeUpReaders();
+}
+
+unsigned int HumidityAdaptor::evaluateIntervalRequests(int& sessionId) const
+{
+ unsigned int highestValue = 0;
+ int winningSessionId = -1;
+
+ if (m_intervalMap.size() == 0) {
+ sessionId = winningSessionId;
+ return defaultInterval();
+ }
+
+ // Get the smallest positive request, 0 is reserved for HW wakeup
+ QMap<int, unsigned int>::const_iterator it;
+ it = m_intervalMap.begin();
+ highestValue = it.value();
+ winningSessionId = it.key();
+
+ for (++it; it != m_intervalMap.constEnd(); ++it) {
+ if ((it.value() < highestValue) && (it.value() > 0)) {
+ highestValue = it.value();
+ winningSessionId = it.key();
+ }
+ }
+
+ sessionId = winningSessionId;
+ return highestValue > 0 ? highestValue : defaultInterval();
+}
+
+bool HumidityAdaptor::startSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ writeToFile(powerStatePath_, "1");
+ }
+ if (SysfsAdaptor::startSensor()) {
+ return true;
+ }
+ return false;
+}
+
+void HumidityAdaptor::stopSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ writeToFile(powerStatePath_, "0");
+ }
+
+ SysfsAdaptor::stopSensor();
+}
+
+bool HumidityAdaptor::standby()
+{
+ stopSensor();
+ return true;
+}
+
+bool HumidityAdaptor::resume()
+{
+ startSensor();
+ return true;
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/humidityadaptor/humidityadaptor.h
^
|
@@ -0,0 +1,79 @@
+/**
+ @file humidityadaptor.h
+ @brief Contains HumidityAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+#ifndef HUMIDITYADAPTOR_H
+#define HUMIDITYADAPTOR_H
+
+#include "inputdevadaptor.h"
+#include "deviceadaptorringbuffer.h"
+#include "datatypes/orientationdata.h"
+#include <QTime>
+
+class HumidityAdaptor : public InputDevAdaptor
+{
+ Q_OBJECT
+public:
+ /**
+ * Factory method for gaining a new instance of AccelerometerAdaptor class.
+ * @param id Identifier for the adaptor.
+ */
+ static DeviceAdaptor* factoryMethod(const QString& id)
+ {
+ return new HumidityAdaptor(id);
+ }
+
+ virtual bool startSensor();
+
+ virtual void stopSensor();
+
+ virtual bool standby();
+
+ virtual bool resume();
+
+protected:
+ /**
+ * Constructor.
+ * @param id Identifier for the adaptor.
+ */
+ HumidityAdaptor(const QString& id);
+ ~HumidityAdaptor();
+
+ /**
+ * Reimplement to allow for 0 interval to be the slowest entry.
+ */
+ virtual unsigned int evaluateIntervalRequests(int& sessionId) const;
+
+private:
+ DeviceAdaptorRingBuffer<TimedUnsigned>* humidityBuffer_;
+
+ unsigned humidityValue_;
+
+ void interpretEvent(int src, struct input_event *ev);
+ void commitOutput(struct input_event *ev);
+ void interpretSync(int src, struct input_event *ev);
+ QByteArray powerStatePath_;
+
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/humidityadaptor/humidityadaptor.pro
^
|
@@ -0,0 +1,9 @@
+TARGET = humidityadaptor
+
+HEADERS += humidityadaptor.h \
+ humidityadaptorplugin.h
+
+SOURCES += humidityadaptor.cpp \
+ humidityadaptorplugin.cpp
+
+include( ../adaptor-config.pri )
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/humidityadaptor/humidityadaptorplugin.cpp
^
|
@@ -0,0 +1,40 @@
+/**
+ @file humidityadaptorplugin.cpp
+ @brief Plugin for HumidityAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "humidityadaptorplugin.h"
+#include "humidityadaptor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void HumidityAdaptorPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering humidityadaptor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<HumidityAdaptor>("humidityadaptor");
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(humidityadaptor, HumidityAdaptorPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/humidityadaptor/humidityadaptorplugin.h
^
|
@@ -0,0 +1,42 @@
+/**
+ @file humidityadaptorplugin.h
+ @brief Plugin for HumidityAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef HUMIDITYADAPTOR_PLUGIN_H
+#define HUMIDITYADAPTOR_PLUGIN_H
+
+#include "plugin.h"
+
+class HumidityAdaptorPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+
+private:
+ void Register(class Loader& l);
+};
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.cpp
^
|
@@ -22,6 +22,7 @@
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
+#include "config.h"
#define GRAVITY_RECIPROCAL_THOUSANDS 101.971621298
@@ -32,6 +33,7 @@
setAdaptedSensor("accelerometer", "Internal accelerometer coordinates", buffer);
setDescription("Hybris accelerometer");
+ powerStatePath = Config::configuration()->value("accelerometer/powerstate_path").toByteArray();
// setDefaultInterval(50);
}
@@ -42,6 +44,8 @@
bool HybrisAccelerometerAdaptor::startSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
@@ -51,6 +55,8 @@
void HybrisAccelerometerAdaptor::stopSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
sensordLogD() << "Hybris AccelAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisaccelerometer/hybrisaccelerometeradaptor.h
^
|
@@ -57,6 +57,7 @@
private:
DeviceAdaptorRingBuffer<AccelerationData>* buffer;
int sensorType;
+ QByteArray powerStatePath;
};
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisalsadaptor/hybrisalsadaptor.cpp
^
|
@@ -25,6 +25,7 @@
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
+#include "config.h"
#include <fcntl.h>
#include <unistd.h>
@@ -36,6 +37,12 @@
buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
setAdaptedSensor("als", "Internal ambient light sensor lux values", buffer);
setDescription("Hybris als");
+ powerStatePath = Config::configuration()->value("als/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
}
HybrisAlsAdaptor::~HybrisAlsAdaptor()
@@ -45,6 +52,8 @@
bool HybrisAlsAdaptor::startSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
@@ -86,7 +95,7 @@
if ((fd = open(inputDev.toLatin1(), O_RDONLY)) > -1) {
if (!ioctl(fd, EVIOCGABS(ABS_MISC), &absinfo)) {
- if (absinfo.value != lastLightValue)
+ if (absinfo.value != (signed)lastLightValue)
lastLightValue = absinfo.value;
TimedUnsigned *d = buffer->nextSlot();
@@ -111,6 +120,8 @@
void HybrisAlsAdaptor::stopSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
sensordLogD() << "Hybris HybrisAlsAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisalsadaptor/hybrisalsadaptor.h
^
|
@@ -62,6 +62,7 @@
private:
DeviceAdaptorRingBuffer<TimedUnsigned>* buffer;
unsigned lastLightValue;
+ QByteArray powerStatePath;
};
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.cpp
^
|
@@ -22,6 +22,7 @@
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
+#include "config.h"
#include <math.h>
#define RADIANS_TO_DEGREESECONDS 57295.7795
@@ -34,6 +35,12 @@
setAdaptedSensor("gyroscopeadaptor", "Internal gyroscope coordinates", buffer);
setDescription("Hybris gyroscope");
+ powerStatePath = Config::configuration()->value("gyroscope/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
setDefaultInterval(50);
}
@@ -44,6 +51,8 @@
bool HybrisGyroscopeAdaptor::startSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
@@ -53,6 +62,8 @@
void HybrisGyroscopeAdaptor::stopSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
sensordLogD() << "HybrisGyroscopeAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisgyroscopeadaptor/hybrisgyroscopeadaptor.h
^
|
@@ -57,5 +57,7 @@
private:
DeviceAdaptorRingBuffer<TimedXyzData>* buffer;
int sensorType;
+ QByteArray powerStatePath;
+
};
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.cpp
^
|
@@ -18,11 +18,11 @@
**
****************************************************************************/
-#include "config.h"
#include "hybrismagnetometeradaptor.h"
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
+#include "config.h"
HybrisMagnetometerAdaptor::HybrisMagnetometerAdaptor(const QString& id) :
HybrisAdaptor(id,SENSOR_TYPE_MAGNETIC_FIELD)
@@ -31,6 +31,12 @@
setAdaptedSensor("magnetometer", "Internal magnetometer coordinates", buffer);
setDescription("Hybris magnetometer");
+ powerStatePath = Config::configuration()->value("magnetometer/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
//setStandbyOverride(false);
setDefaultInterval(50);
}
@@ -42,14 +48,19 @@
bool HybrisMagnetometerAdaptor::startSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
+
sensordLogD() << "HybrisMagnetometerAdaptor start\n";
return true;
}
void HybrisMagnetometerAdaptor::stopSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
sensordLogD() << "HybrisMagnetometerAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrismagnetometeradaptor/hybrismagnetometeradaptor.h
^
|
@@ -57,6 +57,7 @@
private:
DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>* buffer;
int sensorType;
+ QByteArray powerStatePath;
};
#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.cpp
^
|
@@ -22,6 +22,7 @@
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
+#include "config.h"
/*
* azimuth: angle between the magnetic north direction and the Y axis, around
@@ -47,6 +48,12 @@
setAdaptedSensor("hybrisorientation", "Internal orientation coordinates", buffer);
setDescription("Hybris orientation");
+ powerStatePath = Config::configuration()->value("orientation/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
// setDefaultInterval(50);
}
@@ -57,6 +64,8 @@
bool HybrisOrientationAdaptor::startSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
@@ -66,6 +75,8 @@
void HybrisOrientationAdaptor::stopSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
sensordLogD() << "Hybris OrientationAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisorientationadaptor/hybrisorientationadaptor.h
^
|
@@ -55,6 +55,7 @@
private:
DeviceAdaptorRingBuffer<CompassData>* buffer;
int sensorType;
+ QByteArray powerStatePath;
};
#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrispressureadaptor/hybrispressureadaptor.cpp
^
|
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2017 Matti Lehtimäki
+** Contact: matti.lehtimaki@gmail.com
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QFile>
+#include <QTextStream>
+
+#include "hybrispressureadaptor.h"
+#include "logging.h"
+#include "datatypes/utils.h"
+#include <hardware/sensors.h>
+#include "config.h"
+
+HybrisPressureAdaptor::HybrisPressureAdaptor(const QString& id) :
+ HybrisAdaptor(id,SENSOR_TYPE_PRESSURE)
+{
+ buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
+ setAdaptedSensor("pressure", "Internal ambient pressure sensor values", buffer);
+ setDescription("Hybris pressure");
+ powerStatePath = Config::configuration()->value("pressure/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
+}
+
+HybrisPressureAdaptor::~HybrisPressureAdaptor()
+{
+ delete buffer;
+}
+
+bool HybrisPressureAdaptor::startSensor()
+{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
+ if (!(HybrisAdaptor::startSensor()))
+ return false;
+
+ sensordLogD() << "Hybris HybrisPressureAdaptor start\n";
+ return true;
+}
+
+void HybrisPressureAdaptor::stopSensor()
+{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
+ HybrisAdaptor::stopSensor();
+ sensordLogD() << "Hybris HybrisPressureAdaptor stop\n";
+}
+
+void HybrisPressureAdaptor::processSample(const sensors_event_t& data)
+{
+ TimedUnsigned *d = buffer->nextSlot();
+ d->timestamp_ = quint64(data.timestamp * .001);
+ d->value_ = data.pressure * 100;//From hPa to Pa
+ buffer->commit();
+ buffer->wakeUpReaders();
+}
+
+void HybrisPressureAdaptor::init()
+{
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrispressureadaptor/hybrispressureadaptor.h
^
|
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2017 Matti Lehtimäki
+** Contact: matti.lehtimaki@gmail.com
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HYBRISPRESSUREADAPTOR_H
+#define HYBRISPRESSUREADAPTOR_H
+#include "hybrisadaptor.h"
+
+#include <QString>
+#include <QStringList>
+#include <linux/input.h>
+#include "datatypes/timedunsigned.h"
+#include "deviceadaptorringbuffer.h"
+#include <QTime>
+
+/**
+ * @brief Adaptor for hybris pressure sensor.
+ *
+ * Adaptor for internal pressure sensor. Provides the amount of ambient
+ * pressure detected by the device. Uses hybris sensor daemon driver interface.
+ *
+ * Value output frequency depends on driver decision - only changed values
+ * are pushed out of driver.
+ *
+ */
+class HybrisPressureAdaptor : public HybrisAdaptor
+{
+ Q_OBJECT
+
+public:
+ static DeviceAdaptor* factoryMethod(const QString& id) {
+ return new HybrisPressureAdaptor(id);
+ }
+ HybrisPressureAdaptor(const QString& id);
+ ~HybrisPressureAdaptor();
+
+ bool startSensor();
+ void stopSensor();
+
+protected:
+ void processSample(const sensors_event_t& data);
+ void init();
+
+private:
+ DeviceAdaptorRingBuffer<TimedUnsigned>* buffer;
+ QByteArray powerStatePath;
+
+};
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrispressureadaptor/hybrispressureadaptor.pro
^
|
@@ -0,0 +1,13 @@
+TARGET = hybrispressureadaptor
+
+HEADERS += hybrispressureadaptor.h \
+ hybrispressureadaptorplugin.h
+
+SOURCES += hybrispressureadaptor.cpp \
+ hybrispressureadaptorplugin.cpp
+LIBS+= -L../../core -lhybrissensorfw-qt5
+
+include(../adaptor-config.pri )
+config_hybris {
+ INCLUDEPATH+=/usr/include/android
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrispressureadaptor/hybrispressureadaptorplugin.cpp
^
|
@@ -0,0 +1,37 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2017 Matti Lehtimäki
+** Contact: matti.lehtimaki@gmail.com
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "hybrispressureadaptorplugin.h"
+#include "hybrispressureadaptor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void HybrisPressureAdaptorPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering hybrispressureadaptor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<HybrisPressureAdaptor>("pressureadaptor");
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(hybrispressureadaptor, HybrisPressureAdaptorPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrispressureadaptor/hybrispressureadaptorplugin.h
^
|
@@ -0,0 +1,39 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2017 Matti Lehtimäki
+** Contact: matti.lehtimaki@gmail.com
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HYBRISPRESSUREADAPTORPLUGIN_H
+#define HYBRISPRESSUREADAPTORPLUGIN_H
+
+#include "plugin.h"
+
+class HybrisPressureAdaptorPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+
+private:
+ void Register(class Loader& l);
+};
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.cpp
^
|
@@ -26,6 +26,7 @@
#include "logging.h"
#include "datatypes/utils.h"
#include <hardware/sensors.h>
+#include "config.h"
#include <fcntl.h>
#include <unistd.h>
@@ -38,6 +39,12 @@
setAdaptedSensor("proximity", "Internal proximity coordinates", buffer);
setDescription("Hybris proximity");
+ powerStatePath = Config::configuration()->value("proximity/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
}
}
@@ -50,6 +57,8 @@
bool HybrisProximityAdaptor::startSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
if (!(HybrisAdaptor::startSensor()))
return false;
sensordLogD() << "HybrisProximityAdaptor start\n";
@@ -118,6 +127,8 @@
void HybrisProximityAdaptor::stopSensor()
{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
HybrisAdaptor::stopSensor();
sensordLogD() << "HybrisProximityAdaptor stop\n";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisproximityadaptor/hybrisproximityadaptor.h
^
|
@@ -62,5 +62,7 @@
DeviceAdaptorRingBuffer<ProximityData>* buffer;
int sensorType;
int lastNearValue;
+ QByteArray powerStatePath;
+
};
#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.cpp
^
|
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2016 kimmoli
+** Contact: kimmo.lindholm@eke.fi
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "hybrisstepcounteradaptor.h"
+#include "logging.h"
+#include "datatypes/utils.h"
+#include <hardware/sensors.h>
+#include "config.h"
+
+#ifndef SENSOR_TYPE_STEP_COUNTER
+#define SENSOR_TYPE_STEP_COUNTER (19)
+/* If hardware/sensors.h does not define SENSOR_TYPE_STEP_COUNTER, assume
+ * a) the event structure is missing u64 union too, and b) u64.step_counter
+ * would be located at the same address as non-u64 data array. */
+#define NO_SENSORS_EVENT_U64
+#endif
+
+HybrisStepCounterAdaptor::HybrisStepCounterAdaptor(const QString& id) :
+ HybrisAdaptor(id, SENSOR_TYPE_STEP_COUNTER)
+{
+ buffer = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
+ setAdaptedSensor("stepcounter", "Internal step counter steps since reboot", buffer);
+ setDescription("Hybris step counter");
+ powerStatePath = Config::configuration()->value("stepcounter/powerstate_path").toByteArray();
+ if (!powerStatePath.isEmpty() && !QFile::exists(powerStatePath))
+ {
+ sensordLogW() << "Path does not exists: " << powerStatePath;
+ powerStatePath.clear();
+ }
+}
+
+HybrisStepCounterAdaptor::~HybrisStepCounterAdaptor()
+{
+ delete buffer;
+}
+
+bool HybrisStepCounterAdaptor::startSensor()
+{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "1");
+ if (!(HybrisAdaptor::startSensor()))
+ return false;
+
+ sensordLogD() << "Hybris HybrisStepCounterAdaptor start\n";
+ return true;
+}
+
+void HybrisStepCounterAdaptor::sendInitialData()
+{
+ sensordLogW() << "No initial data for step counter";
+}
+
+void HybrisStepCounterAdaptor::stopSensor()
+{
+ if(!powerStatePath.isEmpty())
+ writeToFile(powerStatePath, "0");
+ HybrisAdaptor::stopSensor();
+ sensordLogD() << "Hybris HybrisStepCounterAdaptor stop\n";
+}
+
+void HybrisStepCounterAdaptor::processSample(const sensors_event_t& data)
+{
+ TimedUnsigned *d = buffer->nextSlot();
+ d->timestamp_ = quint64(data.timestamp * .001);
+#ifdef NO_SENSORS_EVENT_U64
+ uint64_t value = 0;
+ memcpy(&value, data.data, sizeof value);
+ d->value_ = value;
+#else
+ d->value_ = data.u64.step_counter;
+#endif
+ buffer->commit();
+ buffer->wakeUpReaders();
+}
+
+void HybrisStepCounterAdaptor::init()
+{
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.h
^
|
@@ -0,0 +1,70 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2016 kimmoli
+** Contact: kimmo.lindholm@eke.fi
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HYBRISSTEPCOUNTERADAPTOR_H
+#define HYBRISSTEPCOUNTERADAPTOR_H
+#include "hybrisadaptor.h"
+
+#include <QString>
+#include <QStringList>
+#include <linux/input.h>
+#include "deviceadaptorringbuffer.h"
+#include "datatypes/orientationdata.h"
+#include <QTime>
+
+/**
+ * @brief Adaptor for hybris step counter sensor.
+ *
+ * Adaptor for step counter sensor.
+ *
+ * Returns the number of steps taken by the user since
+ * the last reboot while activated. The value is returned as a uint64_t and is
+ * reset to zero only on a system reboot.
+ *
+ */
+class HybrisStepCounterAdaptor : public HybrisAdaptor
+{
+ Q_OBJECT
+
+public:
+ static DeviceAdaptor* factoryMethod(const QString& id) {
+ return new HybrisStepCounterAdaptor(id);
+ }
+ HybrisStepCounterAdaptor(const QString& id);
+ ~HybrisStepCounterAdaptor();
+
+ bool startSensor();
+ void stopSensor();
+
+ void sendInitialData();
+
+protected:
+ void processSample(const sensors_event_t& data);
+ void init();
+
+private:
+ DeviceAdaptorRingBuffer<TimedUnsigned>* buffer;
+ QByteArray powerStatePath;
+
+};
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptor.pro
^
|
@@ -0,0 +1,13 @@
+TARGET = hybrisstepcounteradaptor
+
+HEADERS += hybrisstepcounteradaptor.h \
+ hybrisstepcounteradaptorplugin.h
+
+SOURCES += hybrisstepcounteradaptor.cpp \
+ hybrisstepcounteradaptorplugin.cpp
+LIBS+= -L../../core -lhybrissensorfw-qt5
+
+include(../adaptor-config.pri )
+config_hybris {
+ INCLUDEPATH+=/usr/include/android
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptorplugin.cpp
^
|
@@ -0,0 +1,38 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2016 kimmoli
+** Contact: kimmo.lindholm@eke.fi
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "hybrisstepcounteradaptorplugin.h"
+#include "hybrisstepcounteradaptor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void HybrisStepCounterAdaptorPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering hybrisstepcounteradaptor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<HybrisStepCounterAdaptor>("stepcounteradaptor");
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(hybrisstepcounteradaptor, HybrisStepCounterAdaptorPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/hybrisstepcounteradaptor/hybrisstepcounteradaptorplugin.h
^
|
@@ -0,0 +1,40 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Jolla Ltd
+** Contact: lorn.potter@jollamobile.com
+**
+** Copyright (C) 2016 kimmoli
+** Contact: kimmo.lindholm@eke.fi
+**
+**
+** $QT_BEGIN_LICENSE:LGPL$
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef HYBRISSTEPCOUNTERADAPTORPLUGIN_H
+#define HYBRISSTEPCOUNTERADAPTORPLUGIN_H
+
+#include "plugin.h"
+
+class HybrisStepCounterAdaptorPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+
+private:
+ void Register(class Loader& l);
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/iioadaptor/README.md
^
|
@@ -0,0 +1,9 @@
+sensorfw-iioadaptor
+===================
+
+Industrial I/O plugin for SensorFW
+
+WIP.
+ * working accelerometer
+ - data is wrong
+
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/iioadaptor/iioadaptor.cpp
^
|
@@ -0,0 +1,522 @@
+/**
+
+// http://www.apache.org/licenses/LICENSE-2.0
+
+ @file iioadaptor.cpp
+ @brief IioAdaptor based on SysfsAdaptor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2012 Tuomas Kulve
+ Copyright (C) 2012 Srdjan Markovic
+ Copyright (C) 2016 Canonical
+
+ @author Tuomas Kulve <tuomas@kulve.fi>
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+#include <errno.h>
+
+#include <libudev.h>
+
+#include <logging.h>
+#include <config.h>
+#include <datatypes/utils.h>
+#include <unistd.h>
+#include <time.h>
+
+#include "iioadaptor.h"
+#include <sysfsadaptor.h>
+#include <deviceadaptorringbuffer.h>
+#include <QTextStream>
+#include <QDir>
+#include <QTimer>
+#include <QDirIterator>
+#include <qmath.h>
+
+#include <deviceadaptor.h>
+#include "datatypes/orientationdata.h"
+
+#define GRAVITY 9.80665
+#define REV_GRAVITY 0.101936799
+
+/* Conversion of acceleration data to SI units (m/s^2) */
+#define CONVERT_A_X(x) ((float(x) / 1000) * (GRAVITY * -1.0))
+#define CONVERT_A_Y(x) ((float(x) / 1000) * (GRAVITY * 1.0))
+#define CONVERT_A_Z(x) ((float(x) / 1000) * (GRAVITY * 1.0))
+
+IioAdaptor::IioAdaptor(const QString &id) :
+ SysfsAdaptor(id, SysfsAdaptor::IntervalMode, true),
+ deviceId(id)
+{
+ sensordLogD() << "Creating IioAdaptor with id: " << id;
+ setup();
+}
+
+IioAdaptor::~IioAdaptor()
+{
+ if (iioXyzBuffer_)
+ delete iioXyzBuffer_;
+ if (alsBuffer_)
+ delete alsBuffer_;
+ if (magnetometerBuffer_)
+ delete magnetometerBuffer_;
+}
+
+void IioAdaptor::setup()
+{
+ qDebug() << Q_FUNC_INFO << deviceId;
+
+ if (deviceId.startsWith("accel")) {
+ const QString name = "accelerometer";
+ const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+ qDebug() << "input_match" << inputMatch;
+
+ devNodeNumber = findSensor(inputMatch);
+ if (devNodeNumber!= -1) {
+ const QString desc = "Industrial I/O accelerometer (" + iioDevice.name +")";
+ qDebug() << Q_FUNC_INFO << "Accelerometer found";
+ iioXyzBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(1);
+ setAdaptedSensor(name, desc, iioXyzBuffer_);
+
+ iioDevice.sensorType = IioAdaptor::IIO_ACCELEROMETER;
+ }
+ }
+ else if (deviceId.startsWith("gyro")) {
+ const QString name = "gyroscope";
+ const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+ qDebug() << "input_match" << inputMatch;
+
+ devNodeNumber = findSensor(inputMatch);
+ if (devNodeNumber!= -1) {
+ const QString desc = "Industrial I/O gyroscope (" + iioDevice.name +")";
+ iioXyzBuffer_ = new DeviceAdaptorRingBuffer<TimedXyzData>(1);
+ setAdaptedSensor(name, desc, iioXyzBuffer_);
+
+ iioDevice.sensorType = IioAdaptor::IIO_GYROSCOPE;
+ }
+ }
+ else if (deviceId.startsWith("mag")) {
+ const QString name = "magnetometer";
+ const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+ qDebug() << "input_match" << inputMatch;
+
+ devNodeNumber = findSensor(inputMatch);
+
+ if (devNodeNumber!= -1) {
+ const QString desc = "Industrial I/O magnetometer (" + iioDevice.name +")";
+ magnetometerBuffer_ = new DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>(1);
+ setAdaptedSensor(name, desc, magnetometerBuffer_);
+
+ iioDevice.sensorType = IioAdaptor::IIO_MAGNETOMETER;
+ }
+ }
+ else if (deviceId.startsWith("als")) {
+ const QString name = "als";
+ const QString inputMatch = Config::configuration()->value<QString>(name + "/input_match");
+
+ devNodeNumber = findSensor(inputMatch);
+ if (devNodeNumber!= -1) {
+ QString desc = "Industrial I/O light sensor (" + iioDevice.name +")";
+ qDebug() << desc;
+ alsBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
+ setAdaptedSensor(name, desc, alsBuffer_);
+ iioDevice.sensorType = IioAdaptor::IIO_ALS;
+ }
+ }
+
+ if (devNodeNumber == -1) {
+ qDebug() << Q_FUNC_INFO << "sensor is invalid";
+// setValid(false);
+ return;
+ }
+ iioDevice.channels = scanElementsEnable(devNodeNumber,1);
+ scanElementsEnable(devNodeNumber,0);
+
+ introduceAvailableDataRange(DataRange(0, 65535, 1));
+ introduceAvailableInterval(DataRange(0, 586, 0));
+ setDefaultInterval(10);
+}
+
+int IioAdaptor::findSensor(const QString &sensorName)
+{
+ udev_list_entry *devices;
+ udev_list_entry *dev_list_entry;
+ udev_device *dev = 0;
+ struct udev *udevice = 0;
+ struct udev_enumerate *enumerate = 0;
+
+ if (!udevice)
+ udevice = udev_new();
+
+ enumerate = udev_enumerate_new(udevice);
+ udev_enumerate_add_match_subsystem(enumerate, "iio");
+
+ udev_enumerate_scan_devices(enumerate);
+ devices = udev_enumerate_get_list_entry(enumerate);
+
+ bool ok2;
+
+ udev_list_entry_foreach(dev_list_entry, devices) {
+ const char *path;
+ path = udev_list_entry_get_name(dev_list_entry);
+
+ dev = udev_device_new_from_syspath(udevice, path);
+ if (qstrcmp(udev_device_get_subsystem(dev), "iio") == 0) {
+ iioDevice.name = QString::fromLatin1(udev_device_get_sysattr_value(dev,"name"));
+ if (iioDevice.name == sensorName) {
+ struct udev_list_entry *sysattr;
+ int j = 0;
+ QString eventName = QString::fromLatin1(udev_device_get_sysname(dev));
+ iioDevice.devicePath = QString::fromLatin1(udev_device_get_syspath(dev)) +"/";
+ iioDevice.index = eventName.right(1).toInt(&ok2);
+ qDebug() << Q_FUNC_INFO << "syspath" << iioDevice.devicePath;
+
+ udev_list_entry_foreach(sysattr, udev_device_get_sysattr_list_entry(dev)) {
+ const char *name;
+ const char *value;
+ bool ok;
+ name = udev_list_entry_get_name(sysattr);
+ value = udev_device_get_sysattr_value(dev, name);
+ if (value == NULL)
+ continue;
+ qDebug() << "attr" << name << value;
+
+ QString attributeName(name);
+ if (attributeName.endsWith("scale")) {
+ iioDevice.scale = QString(value).toDouble(&ok);
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/iioadaptor/iioadaptor.h
^
|
@@ -0,0 +1,148 @@
+/**
+ @file iioadaptor.h
+ @brief IioAdaptor based on SysfsAdaptor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2012 Tuomas Kulve
+ Copyright (C) 2016 Canonical
+
+ @author Tuomas Kulve <tuomas@kulve.fi>
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef IIOADAPTOR_H
+#define IIOADAPTOR_H
+
+#include <sysfsadaptor.h>
+#include <datatypes/orientationdata.h>
+
+// FIXME: shouldn't assume any number of channels per device
+#define IIO_MAX_DEVICE_CHANNELS 20
+
+// FIXME: no idea what would be reasonable length
+#define IIO_BUFFER_LEN 256
+
+/**
+ * @brief Adaptor for Industrial I/O.
+ *
+ * Adaptor for Industrial I/O. Uses SysFs driver interface in
+ * polling mode, i.e. values are read with given constant interval.
+ *
+ * Driver interface is located in @e /sys/bus/iio/devices/iio:deviceX/ .
+ * <ul><li>@e angular_rate filehandle provides measurement values.</li></ul>
+ * No other filehandles are currently in use by this adaptor.
+ */
+class IioAdaptor : public SysfsAdaptor
+{
+ Q_OBJECT
+ enum IioSensorType {
+ IIO_ACCELEROMETER = 1, // accel_3d
+ IIO_GYROSCOPE, // gyro_3d
+ IIO_MAGNETOMETER, // magn_3d
+ IIO_ROTATION, // dev_rotation, quaternion
+ IIO_ALS, // als
+ IIO_TILT // incli_3d
+ };
+
+ struct iio_device {
+ QString name;
+ int channels;
+ int channel_bytes[IIO_MAX_DEVICE_CHANNELS];
+ qreal scale;
+ qreal offset;
+ int frequency;
+ QString devicePath;
+ int index;
+ IioSensorType sensorType;
+ };
+
+public:
+ /**
+ * Factory method for gaining a new instance of this adaptor class.
+ *
+ * @param id Identifier for the adaptor.
+ * @return A pointer to created adaptor with base class type.
+ */
+ static DeviceAdaptor *factoryMethod(const QString& id)
+ {
+ return new IioAdaptor(id);
+ }
+
+ virtual bool startSensor();
+ virtual void stopSensor();
+// virtual bool standby();
+// virtual bool resume();
+
+protected:
+
+ /**
+ * Constructor. Protected to force externals to use factory method.
+ *
+ * @param id Identifier for the adaptor.
+ */
+ IioAdaptor(const QString &id);
+
+ /**
+ * Destructor.
+ */
+ ~IioAdaptor();
+
+
+ bool setInterval(const unsigned int value, const int sessionId);
+ // unsigned int interval() const;
+
+private:
+
+ /**
+ * Read and process data. Run when sysfsadaptor has detected new
+ * available data.
+ *
+ * @param pathId PathId for the file that had event.
+ * @param fd Open file descriptor with new data. See
+ * #SysfsAdaptor::processSample()
+ */
+ void processSample(int pathId, int fd);
+
+ int findSensor(const QString &name);
+ bool deviceEnable(int device, int enable);
+
+ bool sysfsWriteInt(QString filename, int val);
+ QString sysfsReadString(QString filename);
+ int sysfsReadInt(QString filename);
+ int scanElementsEnable(int device, int enable);
+ int deviceChannelParseBytes(QString filename);
+
+ // Device number for the sensor (-1 if not found)
+ int devNodeNumber;
+
+ DeviceAdaptorRingBuffer<TimedXyzData>* iioXyzBuffer_;
+ DeviceAdaptorRingBuffer<TimedUnsigned>* alsBuffer_;
+ DeviceAdaptorRingBuffer<CalibratedMagneticFieldData>* magnetometerBuffer_;
+
+ iio_device iioDevice;
+
+ QString deviceId;
+
+ TimedXyzData* timedData;
+ CalibratedMagneticFieldData *calData;
+ TimedUnsigned *uData;
+
+private slots:
+ void setup();
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/iioadaptor/iioadaptor.pro
^
|
@@ -0,0 +1,16 @@
+TARGET = iioaccelerometeradaptor
+#TARGET = iiosensorsadaptor
+
+HEADERS += iioadaptor.h \
+ iioadaptorplugin.h
+
+SOURCES += iioadaptor.cpp \
+ iioadaptorplugin.cpp
+
+CONFIG += qt debug warn_on link_prl link_pkgconfig plugin
+
+CONFIG += link_pkgconfig
+PKGCONFIG += udev
+LIBS += -ludev
+
+include( ../adaptor-config.pri )
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/iioadaptor/iioadaptorplugin.cpp
^
|
@@ -0,0 +1,43 @@
+/**
+ @file iioadaptorplugin.cpp
+ @brief Plugin for IioAdaptor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2012 Tuomas Kulve
+ Copyright (C) 2016 Canonical
+
+ @author Tuomas Kulve <tuomas@kulve.fi>
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "iioadaptorplugin.h"
+#include "iioadaptor.h"
+#include <sensormanager.h>
+
+void IioAdaptorPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering iioaccelerometeradaptor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<IioAdaptor>("accelerometeradaptor");
+ sm.registerDeviceAdaptor<IioAdaptor>("gyroscopeadaptor");
+ sm.registerDeviceAdaptor<IioAdaptor>("magnetometeradaptor");
+ sm.registerDeviceAdaptor<IioAdaptor>("alsadaptor");
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(iioadaptor, IioAdaptorPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/iioadaptor/iioadaptorplugin.h
^
|
@@ -0,0 +1,43 @@
+/**
+ @file iioadaptorplugin.h
+ @brief Plugin for IioAdaptor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2012 Tuomas Kulve
+ Copyright (C) 2016 Canonical
+
+ @author Tuomas Kulve <tuomas@kulve.fi>
+ @author Lorn Potte
+r <lorn.potter@canonical.com>
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef IIOADAPTORPLUGIN_H
+#define IIOADAPTORPLUGIN_H
+
+#include <plugin.h>
+
+class IioAdaptorPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+
+private:
+ void Register(class Loader& l);
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdev.cpp
^
|
@@ -0,0 +1,172 @@
+/**
+ @file lidsensoradaptor-evdev.cpp
+ @brief LidSensorAdaptor utilizing evdev kernel interface
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <string.h>
+#include <logging.h>
+#include "datatypes/utils.h"
+#include "config.h"
+
+#include "lidsensoradaptor-evdev.h"
+
+#define SELFDEF_SW_LID 0
+#define SELFDEF_EV_SW 5
+#define SELFDEF_EV_DISTANCE 25
+
+LidSensorAdaptorEvdev::LidSensorAdaptorEvdev(const QString& id) :
+ InputDevAdaptor(id, 2),
+ currentType_(LidData::UnknownLid),
+ lastType(LidData::UnknownLid),
+ currentValue_(-1),
+ lastValue(-1),
+ usingFront(false)
+{
+ lidBuffer_ = new DeviceAdaptorRingBuffer<LidData>(1);
+ setAdaptedSensor("lidsensor", "Lid state", lidBuffer_);
+ powerStatePath_ = Config::configuration()->value("lidsensor/powerstate_path").toByteArray();
+
+}
+
+LidSensorAdaptorEvdev::~LidSensorAdaptorEvdev()
+{
+ delete lidBuffer_;
+}
+
+/* Dell event0 Lid Switch
+ * type EV_SW code EV_LID value 1 closed
+ * */
+
+/* Dell event8 Virtual Button Driver (happens with front lid too)
+ * back closed:
+ * type (4) EV_MSC code (4) MSC_SCAN value cb
+ * EV_MSC MSC_SCAN value cc
+ *
+ * back open:
+ * EV_MSC MSC_SCAN value ca
+ * EV_MSC MSC_SCAN value cd
+ *
+ *
+ * */
+
+// there can be two lid sensors, so try and use both
+void LidSensorAdaptorEvdev::init()
+{
+ qDebug() << Q_FUNC_INFO << name();
+ QStringList strList = Config::configuration()->value<QStringList>(name() + "/input_match");
+ qDebug() << strList;
+ foreach (const QString str, strList) {
+ if (!getInputDevices(str)) {
+ sensordLogW() << "Input device not found.";
+ SysfsAdaptor::init();
+ }
+ }
+}
+
+void LidSensorAdaptorEvdev::interpretEvent(int src, struct input_event *ev)
+{
+ Q_UNUSED(src);
+
+ if (ev->type == SELFDEF_EV_SW && ev->code == SELFDEF_SW_LID) {
+ currentValue_ = ev->value;
+ currentType_ = LidData::FrontLid;
+ if (currentValue_ == 1)
+ usingFront = true;
+ else
+ usingFront = false;
+ }
+ if (ev->type == EV_MSC && ev->code == MSC_SCAN && !usingFront) {
+
+ switch (ev->value) {
+ case 0xCC: // closed
+ currentValue_ = 1;
+ break;
+ case 0xCD: // open
+ currentValue_ = 0;
+ break;
+ };
+ currentType_ = LidData::BackLid;
+ }
+}
+
+void LidSensorAdaptorEvdev::interpretSync(int /*src*/, struct input_event *ev)
+{
+ commitOutput(ev);
+}
+
+void LidSensorAdaptorEvdev::commitOutput(struct input_event *ev)
+{
+ if (lastValue != currentValue_
+ && ((currentType_ == LidData::FrontLid)
+ || (!usingFront && currentType_ == LidData::BackLid))) {
+
+ LidData *lidData = lidBuffer_->nextSlot();
+
+ lidData->timestamp_ = Utils::getTimeStamp(&(ev->time));
+ lidData->value_ = currentValue_;
+ lidData->type_ = currentType_;
+ sensordLogD() << "Lid state change detected: "
+ << (currentType_ == 0 ? "front" : "back")
+ << (currentValue_ == 0 ? "OPEN": "CLOSED");
+
+ lidBuffer_->commit();
+ lidBuffer_->wakeUpReaders();
+ lastValue = currentValue_;
+ lastType = currentType_;
+ }
+}
+
+bool LidSensorAdaptorEvdev::startSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ // writeToFile(powerStatePath_, "1");
+ }
+ if (SysfsAdaptor::startSensor()) {
+ return true;
+ }
+ return false;
+}
+
+void LidSensorAdaptorEvdev::stopSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ // writeToFile(powerStatePath_, "0");
+ }
+
+ SysfsAdaptor::stopSensor();
+}
+
+bool LidSensorAdaptorEvdev::standby()
+{
+ stopSensor();
+ return true;
+}
+
+bool LidSensorAdaptorEvdev::resume()
+{
+ startSensor();
+ return true;
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdev.h
^
|
@@ -0,0 +1,90 @@
+/**
+ @file lidsensoradaptor-evdev.h
+ @brief LidSensorAdaptor utilizing evdev kernel interface
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef LIDADAPTOR_EVDEV_H
+#define LIDADAPTOR_EVDEV_H
+
+#include "inputdevadaptor.h"
+#include "deviceadaptorringbuffer.h"
+#include "datatypes/liddata.h"
+
+/**
+ * @brief Adaptor for lid sensor.
+ *
+ * Events are received through @e evdev kernel interface.
+ *
+ * Listening clients are notified whenever the state has changed.
+ */
+class LidSensorAdaptorEvdev : public InputDevAdaptor
+{
+ Q_OBJECT
+public:
+// /* Enumerates the possible states for proximity */
+// enum ProximityState {
+// ProximityStateUnknown = -1, /**< Proximity state unknown */
+// ProximityStateOpen = 0, /**< Proximity open (no target detected)*/
+// ProximityStateClosed = 1 /**< Proximity closed (target nearby)*/
+// };
+
+ /**
+ * Factory method for gaining a new instance of LidsensorAdaptorEvdev class.
+ * @param id Identifier for the adaptor.
+ */
+ static DeviceAdaptor* factoryMethod(const QString& id)
+ {
+ return new LidSensorAdaptorEvdev(id);
+ }
+ virtual bool startSensor();
+
+ virtual void stopSensor();
+
+ virtual bool standby();
+
+ virtual bool resume();
+ virtual void init();
+protected:
+ /**
+ * Constructor.
+ * @param id Identifier for the adaptor.
+ */
+ LidSensorAdaptorEvdev(const QString& id);
+ ~LidSensorAdaptorEvdev();
+
+private:
+
+ DeviceAdaptorRingBuffer<LidData> *lidBuffer_;
+ LidData::Type currentType_;
+ LidData::Type lastType;
+ qreal currentValue_;
+ qreal lastValue;
+ bool usingFront;
+
+ void interpretEvent(int src, struct input_event *ev);
+ void commitOutput(struct input_event *ev);
+ void interpretSync(int src, struct input_event *ev);
+ QByteArray powerStatePath_;
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdev.pro
^
|
@@ -0,0 +1,9 @@
+TARGET = lidsensoradaptor-evdev
+
+HEADERS += lidsensoradaptor-evdev.h \
+ lidsensoradaptor-evdevplugin.h
+
+SOURCES += lidsensoradaptor-evdev.cpp \
+ lidsensoradaptor-evdevplugin.cpp
+
+include( ../adaptor-config.pri )
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdev.pro.user
^
|
@@ -0,0 +1,270 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE QtCreatorProject>
+<!-- Written by QtCreator 3.4.1, 2016-10-26T11:47:56. -->
+<qtcreator>
+ <data>
+ <variable>EnvironmentId</variable>
+ <value type="QByteArray">{272d5cea-eec6-4d5f-9f49-7f2059a976c7}</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.ActiveTarget</variable>
+ <value type="int">0</value>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.EditorSettings</variable>
+ <valuemap type="QVariantMap">
+ <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
+ <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
+ <value type="bool" key="EditorConfiguration.CamelCaseNavigation">true</value>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
+ <value type="QString" key="language">Cpp</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QByteArray" key="CurrentPreferences">CppGlobal</value>
+ </valuemap>
+ </valuemap>
+ <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
+ <value type="QString" key="language">QmlJS</value>
+ <valuemap type="QVariantMap" key="value">
+ <value type="QByteArray" key="CurrentPreferences">QmlJSGlobal</value>
+ </valuemap>
+ </valuemap>
+ <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
+ <value type="QByteArray" key="EditorConfiguration.Codec">UTF-8</value>
+ <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
+ <value type="int" key="EditorConfiguration.IndentSize">4</value>
+ <value type="bool" key="EditorConfiguration.KeyboardTooltips">false</value>
+ <value type="int" key="EditorConfiguration.MarginColumn">80</value>
+ <value type="bool" key="EditorConfiguration.MouseHiding">true</value>
+ <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
+ <value type="int" key="EditorConfiguration.PaddingMode">1</value>
+ <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
+ <value type="bool" key="EditorConfiguration.ShowMargin">false</value>
+ <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">0</value>
+ <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
+ <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
+ <value type="int" key="EditorConfiguration.TabSize">8</value>
+ <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
+ <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
+ <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
+ <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
+ <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
+ <value type="bool" key="EditorConfiguration.inEntireDocument">true</value>
+ </valuemap>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.PluginSettings</variable>
+ <valuemap type="QVariantMap"/>
+ </data>
+ <data>
+ <variable>ProjectExplorer.Project.Target.0</variable>
+ <valuemap type="QVariantMap">
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.2 GCC 64bit</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.2 GCC 64bit</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.gcc_64_kit</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
+ <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
+ <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lpotter/builds/build-lidsensoradaptor-evdev-Desktop_Qt_5_4_2_GCC_64bit-Debug</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+ <value type="QString">-w</value>
+ <value type="QString">-r</value>
+ </valuelist>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+ <value type="QString">-w</value>
+ <value type="QString">-r</value>
+ </valuelist>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Debug</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">2</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
+ <value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/home/lpotter/builds/build-lidsensoradaptor-evdev-Desktop_Qt_5_4_2_GCC_64bit-Release</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">qmake</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">QtProjectManager.QMakeBuildStep</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibrary">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
+ <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
+ <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+ <value type="QString">-w</value>
+ <value type="QString">-r</value>
+ </valuelist>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">false</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments"></value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">2</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
+ </valuemap>
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
+ <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.MakeStep</value>
+ <valuelist type="QVariantList" key="Qt4ProjectManager.MakeStep.AutomaticallyAddedMakeArguments">
+ <value type="QString">-w</value>
+ <value type="QString">-r</value>
+ </valuelist>
+ <value type="bool" key="Qt4ProjectManager.MakeStep.Clean">true</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeArguments">clean</value>
+ <value type="QString" key="Qt4ProjectManager.MakeStep.MakeCommand"></value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
+ <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
+ <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Release</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4BuildConfiguration</value>
+ <value type="int" key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration">0</value>
+ <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">2</value>
+ <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
+ <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
+ <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
+ </valuemap>
+ <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy locally</value>
+ <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdevplugin.cpp
^
|
@@ -0,0 +1,40 @@
+/**
+ @file lidsensoradaptor-evdevplugin.cpp
+ @brief Plugin for LidSensorAdaptorEvdev
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "lidsensoradaptor-evdevplugin.h"
+#include "lidsensoradaptor-evdev.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void LidsensorAdaptorEvdevPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering lidsensoradaptor-evdev";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<LidSensorAdaptorEvdev>("lidsensoradaptor");
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(lidsensoradaptor-evdev, LidsensorAdaptorEvdevPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdevplugin.h
^
|
@@ -0,0 +1,41 @@
+/**
+ @file lidsensoradaptor-evdevplugin.h
+ @brief Plugin for LidSensorAdaptorEvdev
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef LIDADAPTOR_EVDEVPLUGIN_H
+#define LIDADAPTOR_EVDEVPLUGIN_H
+
+#include "plugin.h"
+
+class LidsensorAdaptorEvdevPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+private:
+ void Register(class Loader& l);
+};
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/magnetometeradaptor-evdev/magnetometerevdevadaptor.h
^
|
@@ -1,5 +1,5 @@
/**
- @file magnetometeradaptor-evdevplugin.cpp
+ @file magnetometerevdevadaptor.h
@brief Contains MagnetometerAdaptorEvdevPlugin.
<p>
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/magnetometeradaptor-ncdk/magnetometeradaptor-ncdk.cpp
^
|
@@ -66,18 +66,14 @@
int bytesRead = 0;
bool isOK = (bytesRead = read(fd, &buf, sizeof(buf))) > 0;
- switch (isOK)
- {
- case true:
+ if (isOK) {
strList = QByteArray(buf, bytesRead).split(':');
- if (strList.size() == 3)
- {
+ if (strList.size() == 3) {
x = adjustPos(strList.at(0).toInt(), x_adj);
y = adjustPos(strList.at(1).toInt(), y_adj);
z = adjustPos(strList.at(2).toInt(), z_adj);
- break;
}
- case false:
+ } else {
sensordLogW() << "Reading magnetometer error: " << strerror(errno);
return;
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/magnetometeradaptor/magnetometeradaptor.cpp
^
|
@@ -93,7 +93,7 @@
{
if(intervalCompensation_)
{
- return SysfsAdaptor::setInterval(value > intervalCompensation_ ? value - intervalCompensation_ : 0, sessionId);
+ return SysfsAdaptor::setInterval((signed)value >intervalCompensation_ ? value - intervalCompensation_ : 0, sessionId);
}
return SysfsAdaptor::setInterval(value, sessionId);
}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/pressureadaptor/pressureadaptor.cpp
^
|
@@ -0,0 +1,142 @@
+/**
+ @file pressureadaptor.cpp
+ @brief Contains PressureAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "pressureadaptor.h"
+#include "config.h"
+#include "logging.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <unistd.h>
+#include <QMap>
+
+#include "datatypes/utils.h"
+
+PressureAdaptor::PressureAdaptor(const QString& id) :
+ InputDevAdaptor(id, 1)
+{
+ pressureBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
+ setAdaptedSensor("pressure", "Pressure values", pressureBuffer_);
+ setDescription("Input device pressure adaptor");
+ powerStatePath_ = Config::configuration()->value("pressure/powerstate_path").toByteArray();
+ introduceAvailableDataRange(DataRange(0, 4095, 1));
+ setDefaultInterval(10);
+}
+
+PressureAdaptor::~PressureAdaptor()
+{
+}
+
+void PressureAdaptor::interpretEvent(int src, struct input_event *ev)
+{
+ Q_UNUSED(src);
+
+ switch (ev->type) {
+ case EV_ABS:
+ switch (ev->code) {
+ case ABS_X:
+ case ABS_MISC:
+ pressureValue_ = ev->value;
+ break;
+ }
+ break;
+ }
+}
+
+void PressureAdaptor::interpretSync(int src, struct input_event *ev)
+{
+ Q_UNUSED(src);
+ commitOutput(ev);
+}
+
+void PressureAdaptor::commitOutput(struct input_event *ev)
+{
+ TimedUnsigned* lux = pressureBuffer_->nextSlot();
+ lux->value_ = pressureValue_;
+
+ lux->timestamp_ = Utils::getTimeStamp(&(ev->time));
+
+ pressureBuffer_->commit();
+ pressureBuffer_->wakeUpReaders();
+}
+
+unsigned int PressureAdaptor::evaluateIntervalRequests(int& sessionId) const
+{
+ unsigned int highestValue = 0;
+ int winningSessionId = -1;
+
+ if (m_intervalMap.size() == 0) {
+ sessionId = winningSessionId;
+ return defaultInterval();
+ }
+
+ // Get the smallest positive request, 0 is reserved for HW wakeup
+ QMap<int, unsigned int>::const_iterator it;
+ it = m_intervalMap.begin();
+ highestValue = it.value();
+ winningSessionId = it.key();
+
+ for (++it; it != m_intervalMap.constEnd(); ++it) {
+ if ((it.value() < highestValue) && (it.value() > 0)) {
+ highestValue = it.value();
+ winningSessionId = it.key();
+ }
+ }
+
+ sessionId = winningSessionId;
+ return highestValue > 0 ? highestValue : defaultInterval();
+}
+
+bool PressureAdaptor::startSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ writeToFile(powerStatePath_, "1");
+ }
+ if (SysfsAdaptor::startSensor()) {
+ return true;
+ }
+ return false;
+}
+
+void PressureAdaptor::stopSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ writeToFile(powerStatePath_, "0");
+ }
+
+ SysfsAdaptor::stopSensor();
+}
+
+bool PressureAdaptor::standby()
+{
+ stopSensor();
+ return true;
+}
+
+bool PressureAdaptor::resume()
+{
+ startSensor();
+ return true;
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/pressureadaptor/pressureadaptor.h
^
|
@@ -0,0 +1,79 @@
+/**
+ @file pressureadaptor.h
+ @brief Contains PressureAdaptor.
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+#ifndef PRESSUREADAPTOR_H
+#define PRESSUREADAPTOR_H
+
+#include "inputdevadaptor.h"
+#include "deviceadaptorringbuffer.h"
+#include "datatypes/orientationdata.h"
+#include <QTime>
+
+class PressureAdaptor : public InputDevAdaptor
+{
+ Q_OBJECT
+public:
+ /**
+ * Factory method for gaining a new instance of AccelerometerAdaptor class.
+ * @param id Identifier for the adaptor.
+ */
+ static DeviceAdaptor* factoryMethod(const QString& id)
+ {
+ return new PressureAdaptor(id);
+ }
+
+ virtual bool startSensor();
+
+ virtual void stopSensor();
+
+ virtual bool standby();
+
+ virtual bool resume();
+
+protected:
+ /**
+ * Constructor.
+ * @param id Identifier for the adaptor.
+ */
+ PressureAdaptor(const QString& id);
+ ~PressureAdaptor();
+
+ /**
+ * Reimplement to allow for 0 interval to be the slowest entry.
+ */
+ virtual unsigned int evaluateIntervalRequests(int& sessionId) const;
+
+private:
+ DeviceAdaptorRingBuffer<TimedUnsigned>* pressureBuffer_;
+
+ unsigned pressureValue_;
+
+ void interpretEvent(int src, struct input_event *ev);
+ void commitOutput(struct input_event *ev);
+ void interpretSync(int src, struct input_event *ev);
+ QByteArray powerStatePath_;
+
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/pressureadaptor/pressureadaptor.pro
^
|
@@ -0,0 +1,9 @@
+TARGET = pressureadaptor
+
+HEADERS += pressureadaptor.h \
+ pressureadaptorplugin.h
+
+SOURCES += pressureadaptor.cpp \
+ pressureadaptorplugin.cpp
+
+include( ../adaptor-config.pri )
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/pressureadaptor/pressureadaptorplugin.cpp
^
|
@@ -0,0 +1,43 @@
+/**
+ @file pressureadaptorplugin.cpp
+ @brief Plugin for PressureAdaptor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2015 Jolla
+
+ @author Lorn Potter <lorn.potter@jolla.com>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Markus Lehtonen <markus.lehtonen@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "pressureadaptorplugin.h"
+#include "pressureadaptor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void PressureAdaptorPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering pressureadaptor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<PressureAdaptor>("pressureadaptor");
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(pressureadaptor, PressureAdaptorPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/pressureadaptor/pressureadaptorplugin.h
^
|
@@ -0,0 +1,42 @@
+/**
+ @file pressureadaptorplugin.h
+ @brief Plugin for PressureAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef PRESSUREADAPTOR_PLUGIN_H
+#define PRESSUREADAPTOR_PLUGIN_H
+
+#include "plugin.h"
+
+class PressureAdaptorPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+
+private:
+ void Register(class Loader& l);
+};
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/proximityadaptor-evdev/proximityadaptor-evdev.cpp
^
|
@@ -57,8 +57,8 @@
void ProximityAdaptorEvdev::interpretEvent(int src, struct input_event *ev)
{
Q_UNUSED(src);
- if (ev->type == EV_SW && ev->code == SW_FRONT_PROXIMITY ||
- ev->type == EV_ABS && ev->code == ABS_DISTANCE) {
+ if ((ev->type == EV_SW && ev->code == SW_FRONT_PROXIMITY) ||
+ (ev->type == EV_ABS && ev->code == ABS_DISTANCE)) {
if (ev->value == 0) {
currentState_ = ProximityStateClosed;
} else if (ev->value == 1) {
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/proximityadaptor/proximityadaptor.cpp
^
|
@@ -136,7 +136,7 @@
return;
}
sscanf(buffer, "%d", &rawdata);
- if ( rawdata > threshold_ ) {
+ if ( (signed)rawdata > threshold_ ) {
ret = 1;
}
sensordLogT() << "Proximity value: " << rawdata;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/steaccelerometeradaptor/steaccelerometeradaptor.cpp
^
|
@@ -47,31 +47,6 @@
powerStatePath = Config::configuration()->value("accelerometer/mode_path").toByteArray();
frequency = Config::configuration()->value("accelerometer/frequency_mode").toInt();
-
- int interval;
- switch(frequency) {
- case 0:
- interval = 0; //off
- case 1:
- interval = 1;
- break;
- case 2:
- interval = 10;
- break;
- case 3:
- interval = 25;
- break;
- case 4:
- interval = 50;
- break;
- case 6:
- interval = 200;
- break;
- case 7:
- interval = 400;
- break;
- };
-
setDescription("ste accelerometer");
}
@@ -102,9 +77,9 @@
void SteAccelAdaptor::processSample(int pathId, int fd)
{
+ Q_UNUSED(pathId);
char buf[32];
int x, y, z;
- qlonglong ts;
// if (pathId != devId) {
// sensordLogW () << "Wrong pathId" << pathId;
@@ -122,7 +97,6 @@
x = line.section(":",0,0).toInt();
y = line.section(":",1,1).toInt();
z = line.section(":",2,2).toInt();
- ts = line.section(":",3,3).toLongLong();
AccelerationData *d = buffer->nextSlot();
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/temperatureadaptor/temperatureadaptor.cpp
^
|
@@ -0,0 +1,142 @@
+/**
+ @file temperatureadaptor.cpp
+ @brief Contains TemperatureAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "temperatureadaptor.h"
+#include "config.h"
+#include "logging.h"
+#include <errno.h>
+#include <fcntl.h>
+#include <linux/input.h>
+#include <unistd.h>
+#include <QMap>
+
+#include "datatypes/utils.h"
+
+TemperatureAdaptor::TemperatureAdaptor(const QString& id) :
+ InputDevAdaptor(id, 1)
+{
+ temperatureBuffer_ = new DeviceAdaptorRingBuffer<TimedUnsigned>(1);
+ setAdaptedSensor("temperature", "Temperature values", temperatureBuffer_);
+ setDescription("Input device temperature adaptor");
+ powerStatePath_ = Config::configuration()->value("temperature/powerstate_path").toByteArray();
+ introduceAvailableDataRange(DataRange(0, 4095, 1));
+ setDefaultInterval(10);
+}
+
+TemperatureAdaptor::~TemperatureAdaptor()
+{
+}
+
+void TemperatureAdaptor::interpretEvent(int src, struct input_event *ev)
+{
+ Q_UNUSED(src);
+
+ switch (ev->type) {
+ case EV_ABS:
+ switch (ev->code) {
+ case ABS_X:
+ case ABS_MISC:
+ temperatureValue_ = ev->value;
+ break;
+ }
+ break;
+ }
+}
+
+void TemperatureAdaptor::interpretSync(int src, struct input_event *ev)
+{
+ Q_UNUSED(src);
+ commitOutput(ev);
+}
+
+void TemperatureAdaptor::commitOutput(struct input_event *ev)
+{
+ TimedUnsigned* temp = temperatureBuffer_->nextSlot();
+ temp->value_ = temperatureValue_;
+
+ temp->timestamp_ = Utils::getTimeStamp(&(ev->time));
+
+ temperatureBuffer_->commit();
+ temperatureBuffer_->wakeUpReaders();
+}
+
+unsigned int TemperatureAdaptor::evaluateIntervalRequests(int& sessionId) const
+{
+ unsigned int highestValue = 0;
+ int winningSessionId = -1;
+
+ if (m_intervalMap.size() == 0) {
+ sessionId = winningSessionId;
+ return defaultInterval();
+ }
+
+ // Get the smallest positive request, 0 is reserved for HW wakeup
+ QMap<int, unsigned int>::const_iterator it;
+ it = m_intervalMap.begin();
+ highestValue = it.value();
+ winningSessionId = it.key();
+
+ for (++it; it != m_intervalMap.constEnd(); ++it) {
+ if ((it.value() < highestValue) && (it.value() > 0)) {
+ highestValue = it.value();
+ winningSessionId = it.key();
+ }
+ }
+
+ sessionId = winningSessionId;
+ return highestValue > 0 ? highestValue : defaultInterval();
+}
+
+bool TemperatureAdaptor::startSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ writeToFile(powerStatePath_, "1");
+ }
+ if (SysfsAdaptor::startSensor()) {
+ return true;
+ }
+ return false;
+}
+
+void TemperatureAdaptor::stopSensor()
+{
+ if (!powerStatePath_.isEmpty()) {
+ writeToFile(powerStatePath_, "0");
+ }
+
+ SysfsAdaptor::stopSensor();
+}
+
+bool TemperatureAdaptor::standby()
+{
+ stopSensor();
+ return true;
+}
+
+bool TemperatureAdaptor::resume()
+{
+ startSensor();
+ return true;
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/temperatureadaptor/temperatureadaptor.h
^
|
@@ -0,0 +1,78 @@
+/**
+ @file temperatureadaptor.h
+ @brief Contains TemperatureAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+#ifndef TEMPERATUREADAPTOR_H
+#define TEMPERATUREADAPTOR_H
+
+#include "inputdevadaptor.h"
+#include "deviceadaptorringbuffer.h"
+#include "datatypes/orientationdata.h"
+#include <QTime>
+
+class TemperatureAdaptor : public InputDevAdaptor
+{
+ Q_OBJECT
+public:
+ /**
+ * Factory method for gaining a new instance of AccelerometerAdaptor class.
+ * @param id Identifier for the adaptor.
+ */
+ static DeviceAdaptor* factoryMethod(const QString& id)
+ {
+ return new TemperatureAdaptor(id);
+ }
+
+ virtual bool startSensor();
+
+ virtual void stopSensor();
+
+ virtual bool standby();
+
+ virtual bool resume();
+
+protected:
+ /**
+ * Constructor.
+ * @param id Identifier for the adaptor.
+ */
+ TemperatureAdaptor(const QString& id);
+ ~TemperatureAdaptor();
+
+ /**
+ * Reimplement to allow for 0 interval to be the slowest entry.
+ */
+ virtual unsigned int evaluateIntervalRequests(int& sessionId) const;
+
+private:
+ DeviceAdaptorRingBuffer<TimedUnsigned>* temperatureBuffer_;
+
+ unsigned temperatureValue_;
+
+ void interpretEvent(int src, struct input_event *ev);
+ void commitOutput(struct input_event *ev);
+ void interpretSync(int src, struct input_event *ev);
+ QByteArray powerStatePath_;
+
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/temperatureadaptor/temperatureadaptor.pro
^
|
@@ -0,0 +1,9 @@
+TARGET = temperatureadaptor
+
+HEADERS += temperatureadaptor.h \
+ temperatureadaptorplugin.h
+
+SOURCES += temperatureadaptor.cpp \
+ temperatureadaptorplugin.cpp
+
+include( ../adaptor-config.pri )
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/temperatureadaptor/temperatureadaptorplugin.cpp
^
|
@@ -0,0 +1,40 @@
+/**
+ @file temperatureadaptorplugin.cpp
+ @brief Plugin for TemperatureAdaptor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#include "temperatureadaptorplugin.h"
+#include "temperatureadaptor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void TemperatureAdaptorPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering temperatureadaptor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerDeviceAdaptor<TemperatureAdaptor>("temperatureadaptor");
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(temperatureadaptor, TemperatureAdaptorPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/adaptors/temperatureadaptor/temperatureadaptorplugin.h
^
|
@@ -0,0 +1,45 @@
+/**
+ @file temperatureadaptorplugin.h
+ @brief Plugin for TemperatureAdaptor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2015 Jolla
+
+ @author Lorn Potter <lorn.potter@jolla.com>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Markus Lehtonen <markus.lehtonen@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+*/
+
+#ifndef TEMPERATUREADAPTOR_PLUGIN_H
+#define TEMPERATUREADAPTOR_PLUGIN_H
+
+#include "plugin.h"
+
+class TemperatureAdaptorPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+
+private:
+ void Register(class Loader& l);
+};
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/config/sensord-hybris.conf
^
|
@@ -5,6 +5,8 @@
magnetometeradaptor = hybrismagnetometeradaptor
gyroscopeadaptor = hybrisgyroscopeadaptor
orientationadaptor = hybrisorientationadaptor
+stepcounteradaptor = hybrisstepcounteradaptor
+pressureadaptor = hybrispressureadaptor
[magnetometer]
scale_coefficient = 1
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/config/sensord-ubuntu.conf
^
|
@@ -0,0 +1,17 @@
+[plugins]
+accelerometeradaptor = iioaccelerometeradaptor
+#alsadaptor = iioaccelerometeradaptor
+#proximityadaptor = iioaccelerometeradaptor
+#magnetometeradaptor = iioaccelerometeradaptor
+#gyroscopeadaptor = iioaccelerometeradaptor
+lidadaptor = lidsensoradaptor-evdev
+
+[lidsensor]
+input_match = Lid,Virtual Button
+#poll_file = /sys/bus/i2c/devices/3-000f/poll
+#powerstate_path = /sys/bus/i2c/devices/3-0068/enable
+
+
+[global]
+device_sys_path = /dev/input/event%1
+#device_poll_file_path = /sys/class/input/input%1/poll
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/core.pro
^
|
@@ -2,10 +2,10 @@
TEMPLATE = lib
TARGET = sensorfw
-
include( ../common-config.pri )
CONFIG += link_pkgconfig
+VERSION = 0.9.0
SENSORFW_INCLUDEPATHS = .. \
../include \
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/deviceadaptor.cpp
^
|
@@ -111,6 +111,7 @@
RingBufferBase* DeviceAdaptor::findBuffer(const QString& name) const
{
+ Q_UNUSED(name)
AdaptedSensorEntry* entry = getAdaptedSensor();
if ( !entry )
return NULL;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/hybrisadaptor.cpp
^
|
@@ -28,6 +28,10 @@
#include <hardware/hardware.h>
#include <hardware/sensors.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
+
#ifndef SENSOR_TYPE_ACCELEROMETER
#define SENSOR_TYPE_ACCELEROMETER (1)
#endif
@@ -72,25 +76,11 @@
//#define SENSOR_TYPE_GYROSCOPE_UNCALIBRATED (16)
//#define SENSOR_TYPE_SIGNIFICANT_MOTION (17)
//#define SENSOR_TYPE_STEP_DETECTOR (18)
-//#define SENSOR_TYPE_STEP_COUNTER (19)
+#ifndef SENSOR_TYPE_STEP_COUNTER
+#define SENSOR_TYPE_STEP_COUNTER (19)
+#endif
//#define SENSOR_TYPE_GEOMAGNETIC_ROTATION_VECTOR (20)
-static QHash<QString,int> HybrisAdaptor_sensorTypes()
-{
- QHash<QString,int> types;
- types["accelerometer"] = SENSOR_TYPE_ACCELEROMETER;
- types["magnetomoter"] = SENSOR_TYPE_MAGNETIC_FIELD;
- types["orientation"] = SENSOR_TYPE_ORIENTATION;
- types["gyroscope"] = SENSOR_TYPE_GYROSCOPE;
- types["light"] = SENSOR_TYPE_LIGHT;
- types["pressure"] = SENSOR_TYPE_PRESSURE;
- types["temperature"] = SENSOR_TYPE_TEMPERATURE;
- types["proximity"] = SENSOR_TYPE_PROXIMITY;
- types["gravity"] = SENSOR_TYPE_GRAVITY;
- types["lacceration"] = SENSOR_TYPE_LINEAR_ACCELERATION;
- return types;
-}
-
Q_GLOBAL_STATIC(HybrisManager, hybrisManager)
HybrisManager::HybrisManager(QObject *parent)
@@ -133,11 +123,29 @@
sensorsCount = module->get_sensors_list(module, &sensorList);
for (int i = 0 ; i < sensorsCount ; i++) {
+ bool use = true;
+ // Assumption: The primary sensor variants that we want to
+ // use are listed before the secondary ones that we want
+ // to ignore -> Use the 1st entry found for each sensor type.
+ if( sensorMap.contains(sensorList[i].type) ) {
+ use = false;
+ }
+
// some devices have compass and compass raw,
// ignore compass raw. compass has range 360
- if (sensorList[i].type != SENSOR_TYPE_ORIENTATION
- || sensorList[i].maxRange == 360)
- sensorMap.insert(sensorList[i].type, i);
+ if (sensorList[i].type == SENSOR_TYPE_ORIENTATION &&
+ sensorList[i].maxRange != 360) {
+ use = false;
+ }
+
+ sensordLogW() << Q_FUNC_INFO
+ << (use ? "SELECT" : "IGNORE")
+ << "type:" << sensorList[i].type
+ << "name:" << (sensorList[i].name ?: "n/a");
+
+ if (use) {
+ sensorMap.insert(sensorList[i].type, i);
+ }
}
}
@@ -563,6 +571,26 @@
return highestValue > 0 ? highestValue : defaultInterval();
}
+bool HybrisAdaptor::writeToFile(const QByteArray& path, const QByteArray& content)
+{
+ sensordLogT() << "Writing to '" << path << ": " << content;
+ QFile file(path);
+ if (!file.open(QIODevice::WriteOnly))
+ {
+ sensordLogW() << "Failed to open '" << path << "': " << file.errorString();
+ return false;
+ }
+ if (file.write(content.constData(), content.size()) == -1)
+ {
+ sensordLogW() << "Failed to write to '" << path << "': " << file.errorString();
+ file.close();
+ return false;
+ }
+
+ file.close();
+ return true;
+}
+
/*/////////////////////////////////////////////////////////////////////
/// \brief HybrisAdaptorReader::HybrisAdaptorReader
/// \param parent
@@ -593,6 +621,29 @@
start();
}
+static void ObtainTemporaryWakeLock()
+{
+ static bool triedToOpen = false;
+ static int wakeLockFd = -1;
+
+ if (!triedToOpen) {
+ triedToOpen = true;
+ wakeLockFd = ::open("/sys/power/wake_lock", O_RDWR);
+ if (wakeLockFd == -1) {
+ sensordLogW() << "wake locks not available:" << ::strerror(errno);
+ }
+ }
+
+ if (wakeLockFd != -1) {
+ sensordLogD() << "wake lock to guard sensor data io";
+ static const char m[] = "sensorfwd_pass_data 1000000000\n";
+ if( ::write(wakeLockFd, m, sizeof m - 1) == -1 ) {
+ sensordLogW() << "wake locking failed:" << ::strerror(errno);
+ ::close(wakeLockFd), wakeLockFd = -1;
+ }
+ }
+}
+
void HybrisAdaptorReader::run()
{
int err = 0;
@@ -604,6 +655,7 @@
sensordLogW() << "poll() failed" << strerror(-err);
QThread::msleep(1000);
} else {
+ bool blockSuspend = false;
bool errorInInput = false;
for (int i = 0; i < numberOfEvents; i++) {
@@ -613,9 +665,17 @@
sensordLogW()<< QString("incorrect event version (version=%1, expected=%2").arg(data.version).arg(sizeof(sensors_event_t));
errorInInput = true;
}
+ if (data.type == SENSOR_TYPE_PROXIMITY) {
+ blockSuspend = true;
+ }
hybrisManager()->processSample(data);
}
+
+ if (blockSuspend) {
+ ObtainTemporaryWakeLock();
+ }
+
if (errorInInput)
QThread::msleep(50);
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/hybrisadaptor.h
^
|
@@ -24,6 +24,7 @@
#include <QObject>
#include <QThread>
#include <QTimer>
+#include <QFile>
#include "deviceadaptor.h"
#include <hardware/sensors.h>
@@ -130,6 +131,7 @@
virtual unsigned int interval() const;
virtual bool setInterval(const unsigned int value, const int sessionId);
virtual unsigned int evaluateIntervalRequests(int& sessionId) const;
+ static bool writeToFile(const QByteArray& path, const QByteArray& content);
private:
void stopReaderThread();
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/inputdevadaptor.cpp
^
|
@@ -74,10 +74,12 @@
++deviceCount_;
} else if(deviceSysPathString.contains("%1")) {
const int MAX_EVENT_DEV = 16;
+qDebug() << deviceNumber << deviceCount_ << maxDeviceCount_;
// No configuration for this device, try find the device from the device system path
while (deviceNumber < MAX_EVENT_DEV && deviceCount_ < maxDeviceCount_) {
deviceName = deviceSysPathString.arg(deviceNumber);
+ qDebug() << Q_FUNC_INFO << deviceName;
if (checkInputDevice(deviceName, typeName)) {
addPath(deviceName, deviceCount_);
++deviceCount_;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/loader.cpp
^
|
@@ -54,7 +54,13 @@
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
QString pluginPath = QString::fromLatin1("/usr/lib/sensord/lib%1.so").arg(name);
#else
- QString pluginPath = QString::fromLatin1("/usr/lib/sensord-qt5/lib%1-qt5.so").arg(name);
+ QString pluginPath;
+ QByteArray env = qgetenv("SENSORFW_LIBRARY_PATH");
+ if (env.isEmpty())
+ pluginPath = QString::fromLatin1("/usr/lib/sensord-qt5/lib%1-qt5.so").arg(name);
+ else
+ pluginPath = QString::fromLatin1(env+"/usr/lib/sensord-qt5/lib%1-qt5.so").arg(name);
+
#endif
QPluginLoader qpl(pluginPath);
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/sensormanager.cpp
^
|
@@ -108,7 +108,13 @@
pipeNotifier_(0),
deviation(0)
{
+ QString pluginPath;
const char* SOCKET_NAME = "/var/run/sensord.sock";
+ QByteArray env = qgetenv("SENSORFW_SOCKET_PATH");
+ if (!env.isEmpty()) {
+ env += SOCKET_NAME;
+ SOCKET_NAME = env;
+ }
new SensorManagerAdaptor(this);
@@ -316,8 +322,10 @@
clearError();
QString cleanId = getCleanId(id);
- QMap<QString, SensorInstanceEntry>::iterator entryIt = sensorInstanceMap_.find(cleanId);
+ qDebug() << sensorInstanceMap_.keys();
+
+ QMap<QString, SensorInstanceEntry>::iterator entryIt = sensorInstanceMap_.find(cleanId);
if ( entryIt == sensorInstanceMap_.end() )
{
setError(SmIdNotRegistered, QString(tr("requested sensor id '%1' not registered")).arg(cleanId));
@@ -479,7 +487,7 @@
if( id.contains(';') ) // no parameter passing in release
{
setError( SmIdNotRegistered, QString(tr("unknown adaptor id '%1'").arg(id)) );
- return NULL;
+ return Q_NULLPTR;
}
DeviceAdaptor* da = NULL;
@@ -619,9 +627,9 @@
void SensorManager::sensorDataHandler(int)
{
PipeData pipeData;
- read(pipefds_[0], &pipeData, sizeof(pipeData));
+ ssize_t bytesRead = read(pipefds_[0], &pipeData, sizeof(pipeData));
- if (!socketHandler_->write(pipeData.id, pipeData.buffer, pipeData.size)) {
+ if (!bytesRead || !socketHandler_->write(pipeData.id, pipeData.buffer, pipeData.size)) {
sensordLogW() << "Failed to write data to socket.";
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/sensormanager.h
^
|
@@ -464,6 +464,7 @@
template<class SENSOR_TYPE>
void SensorManager::registerSensor(const QString& sensorName)
{
+ qDebug() << Q_FUNC_INFO << sensorName;
if (sensorInstanceMap_.contains(sensorName)) {
sensordLogW() << QString("<%1> Sensor is already present!").arg(sensorName);
return;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/core/sysfsadaptor.cpp
^
|
@@ -67,6 +67,8 @@
bool SysfsAdaptor::addPath(const QString& path, const int id)
{
+ qDebug() << Q_FUNC_INFO << path;
+
if (!QFile::exists(path)) {
return false;
}
@@ -300,7 +302,9 @@
{
if (mode_ == SelectMode) {
quint64 dummy = 1;
- write(pipeDescriptors_[1], &dummy, 8);
+ ssize_t bytesWritten = write(pipeDescriptors_[1], &dummy, 8);
+ if (!bytesWritten)
+ qWarning() << "Could not write pipe descriptors";
}
else
reader_.stopReader();
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/datatypes/datatypes.pro
^
|
@@ -23,14 +23,17 @@
posedata.h \
tapdata.h \
touchdata.h \
- proximity.h
+ proximity.h \
+ lid.h \
+ liddata.h
SOURCES += xyz.cpp \
orientation.cpp \
unsigned.cpp \
compass.cpp \
utils.cpp \
- tap.cpp
+ tap.cpp \
+ lid.cpp
include(../common-install.pri)
publicheaders.path = $${publicheaders.path}/datatypes
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/datatypes/lid.cpp
^
|
@@ -0,0 +1,36 @@
+/**
+ @file lid.cpp
+ @brief QObject based datatype for LidData
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "lid.h"
+
+Lid::Lid(const LidData& lidData)
+ : QObject(), data_(lidData.timestamp_, lidData.type_, lidData.value_)
+{
+}
+
+Lid::Lid(const Lid& lid)
+ : QObject(), data_(lid.lidData().timestamp_, lid.lidData().type_, lid.lidData().value_)
+{
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/datatypes/lid.h
^
|
@@ -0,0 +1,120 @@
+/**
+ @file lid.h
+ @brief QObject based datatype for LidData
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef LID_H
+#define LID_H
+
+#include <QDBusArgument>
+
+#include <datatypes/liddata.h>
+
+/**
+ * QObject facade for #LidData.
+ */
+class Lid : public QObject
+{
+ Q_OBJECT
+
+ // Q_PROPERTY(uint value READ value)
+ Q_PROPERTY(int type READ type)
+
+public:
+ /**
+ * Default constructor.
+ */
+ Lid() {}
+
+ /**
+ * Constructor.
+ *
+ * @param lidData Source object.
+ */
+ Lid(const LidData& lidData);
+
+ /**
+ * Copy constructor.
+ *
+ * @param lid Source object.
+ */
+ Lid(const Lid& lid);
+
+ /**
+ * Returns the contained #LidData.
+ * @return LidData
+ */
+ const LidData& lidData() const { return data_; }
+
+ /**
+ * Returns Lid type.
+ * @return Lid type.
+ */
+ LidData::Type type() const { return data_.type_; }
+
+ unsigned value_;
+
+private:
+ LidData data_; /**< Contained Lid data */
+
+ friend const QDBusArgument &operator>>(const QDBusArgument &argument, Lid& lid);
+};
+
+Q_DECLARE_METATYPE( Lid )
+
+/**
+ * Marshall the Lid data into a D-Bus argument
+ *
+ * @param argument dbus argument.
+ * @param lid data to marshall.
+ * @return dbus argument.
+ */
+inline QDBusArgument &operator<<(QDBusArgument &argument, const Lid &lid)
+{
+ argument.beginStructure();
+ argument << lid.lidData().timestamp_ << (int)(lid.lidData().value_) << (int)(lid.lidData().type_);
+ argument.endStructure();
+ return argument;
+}
+
+/**
+ * Unmarshall Lid data from the D-Bus argument
+ *
+ * @param argument dbus argument.
+ * @param lid unmarshalled data.
+ * @return dbus argument.
+ */
+inline const QDBusArgument &operator>>(const QDBusArgument &argument, Lid &lid)
+{
+ int tmp;
+ argument.beginStructure();
+ argument >> lid.data_.timestamp_;
+ argument >> tmp;
+ lid.data_.value_ = (unsigned)tmp;
+ argument >> tmp;
+ lid.data_.type_ = (LidData::Type)tmp;
+ argument.endStructure();
+ return argument;
+}
+
+#endif // LID_H
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/datatypes/liddata.h
^
|
@@ -0,0 +1,67 @@
+/**
+ @file liddata.h
+ @brief Datatype for device tap events
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef LIDDATA_H
+#define LIDDATA_H
+
+#include <datatypes/genericdata.h>
+
+/**
+ * @brief Datatype for device lid events.
+ *
+ * Contains enumerated values for different types of lid events.
+ */
+class LidData : public TimedData {
+public:
+
+ /**
+ * Type of lid.
+ */
+ enum Type {
+ UnknownLid = -1,
+ FrontLid = 0, /**< Front lid. */
+ BackLid /**< Back lid. */
+ };
+
+ LidData::Type type_; /**< Type of lid */
+ unsigned value_; /**< Measurement value. */
+
+ /**
+ * Constructor.
+ */
+ LidData() : TimedData(0), type_(FrontLid), value_(0) {}
+
+ /**
+ * Constructor.
+ * @param timestamp Timestamp of lid event.
+ * @param type Type of lid.
+ * @param value Initial value to use
+ */
+ LidData(const quint64& timestamp, Type type, unsigned value) :
+ TimedData(timestamp), type_(type), value_(value) {}
+};
+
+Q_DECLARE_METATYPE(LidData)
+#endif // LidData_H
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/debian/changelog
^
|
@@ -1,3 +1,9 @@
+sensorfw-qt5 (0.7.4) unstable; urgency=medium
+
+ * add lid sensor
+
+ -- Lorn Potter <lpotter@lpotter-Inspiron-2350> Wed, 26 Oct 2016 09:58:21 +1000
+
sensorfw-qt5 (0.7.3) unstable; urgency=low
[Lorn Potter]
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/debian/control
^
|
@@ -3,7 +3,7 @@
Priority: optional
Maintainer: Lorn Potter <lorn.potter@gmail.com>
Uploaders:
-Build-Depends: debhelper (>=5), qt5-default
+Build-Depends: debhelper (>=5), qt5-default, libudev-dev
Standards-Version: 3.7.3
Package: sensorfw-qt5
@@ -18,7 +18,7 @@
Section: misc
Priority: extra
Architecture: any
-Depends: sensorfw-qt5 (= ${binary:Version}), ${misc:Depends}, libqt5core5a
+Depends: sensorfw-qt5 (= ${binary:Version}), ${misc:Depends}, libqt5core5a, udev
Description: Sensor framework daemon and libraries plugins
Platform plugins for sensorfw.
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/humiditysensor_i.cpp
^
|
@@ -0,0 +1,76 @@
+/**
+ @file humiditysensor_i.cpp
+ @brief Interface for HumiditySensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "sensormanagerinterface.h"
+#include "humiditysensor_i.h"
+#include "socketreader.h"
+
+const char* HumiditySensorChannelInterface::staticInterfaceName = "local.HumiditySensor";
+
+AbstractSensorChannelInterface* HumiditySensorChannelInterface::factoryMethod(const QString& id, int sessionId)
+{
+ return new HumiditySensorChannelInterface(OBJECT_PATH + "/" + id, sessionId);
+}
+
+HumiditySensorChannelInterface::HumiditySensorChannelInterface(const QString& path, int sessionId)
+ : AbstractSensorChannelInterface(path, HumiditySensorChannelInterface::staticInterfaceName, sessionId)
+{
+}
+
+const HumiditySensorChannelInterface* HumiditySensorChannelInterface::listenInterface(const QString& id)
+{
+ return dynamic_cast<const HumiditySensorChannelInterface*> (interface(id));
+}
+
+HumiditySensorChannelInterface* HumiditySensorChannelInterface::controlInterface(const QString& id)
+{
+ return interface(id);
+}
+
+
+HumiditySensorChannelInterface* HumiditySensorChannelInterface::interface(const QString& id)
+{
+ SensorManagerInterface& sm = SensorManagerInterface::instance();
+ if ( !sm.registeredAndCorrectClassName( id, HumiditySensorChannelInterface::staticMetaObject.className())) {
+ return 0;
+ }
+
+ return dynamic_cast<HumiditySensorChannelInterface*>(sm.interface(id));
+}
+
+bool HumiditySensorChannelInterface::dataReceivedImpl()
+{
+ QVector<TimedUnsigned> values;
+ if(!read<TimedUnsigned>(values))
+ return false;
+ foreach(const TimedUnsigned& data, values)
+ emit relativeHumidityChanged(data);
+ return true;
+}
+
+Unsigned HumiditySensorChannelInterface::relativeHumidity()
+{
+ return getAccessor<Unsigned>("relativeHumidity");
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/humiditysensor_i.h
^
|
@@ -0,0 +1,118 @@
+/**
+ @file humiditysensor_i.h
+ @brief Interface for HumiditySensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef HUMIDITYSENSOR_I_H
+#define HUMIDITYSENSOR_I_H
+
+#include <QtDBus/QtDBus>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_i.h"
+
+/**
+ * Client interface for accessing ambient light sensor.
+ * Provides signal on change of measured ambient light intensity level.
+ * Previous measured intensity level can be queried any time. Provided
+ * values are in \e lux.
+ */
+class HumiditySensorChannelInterface : public AbstractSensorChannelInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HumiditySensorChannelInterface)
+ Q_PROPERTY(Unsigned relativeHumidity READ relativeHumidity NOTIFY relativeHumidityChanged)
+
+public:
+ /**
+ * Name of the D-Bus interface for this class.
+ */
+ static const char* staticInterfaceName;
+
+ /**
+ * Create new instance of the class.
+ *
+ * @param id Sensor ID.
+ * @param sessionId Session ID.
+ * @return Pointer to new instance of the class.
+ */
+ static AbstractSensorChannelInterface* factoryMethod(const QString& id, int sessionId);
+
+ /**
+ * Get latest relative humidity reading from sensor daemon.
+ *
+ * @return relative humidity reading.
+ */
+ Unsigned relativeHumidity();
+
+ /**
+ * Constructor.
+ *
+ * @param path path.
+ * @param sessionId session ID.
+ */
+ HumiditySensorChannelInterface(const QString& path, int sessionId);
+
+ /**
+ * Request a listening interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static const HumiditySensorChannelInterface* listenInterface(const QString& id);
+
+ /**
+ * Request a control interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static HumiditySensorChannelInterface* controlInterface(const QString& id);
+
+ /**
+ * Request an interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ */
+ static HumiditySensorChannelInterface* interface(const QString& id);
+
+protected:
+ virtual bool dataReceivedImpl();
+
+Q_SIGNALS:
+ /**
+ * Sent when measured relative humidity has changed.
+ *
+ * @param value relative humidity reading.
+ */
+ void relativeHumidityChanged(const Unsigned& value);
+};
+
+namespace local {
+ typedef ::HumiditySensorChannelInterface HumiditySensor;
+}
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/lidsensor_i.cpp
^
|
@@ -0,0 +1,76 @@
+/**
+ @file lidsensor_i.cpp
+ @brief Interface for LidSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "sensormanagerinterface.h"
+#include "lidsensor_i.h"
+#include "socketreader.h"
+
+const char* LidSensorChannelInterface::staticInterfaceName = "local.LidSensor";
+
+AbstractSensorChannelInterface* LidSensorChannelInterface::factoryMethod(const QString& id, int sessionId)
+{
+ return new LidSensorChannelInterface(OBJECT_PATH + "/" + id, sessionId);
+}
+
+LidSensorChannelInterface::LidSensorChannelInterface(const QString& path, int sessionId)
+ : AbstractSensorChannelInterface(path, LidSensorChannelInterface::staticInterfaceName, sessionId)
+{
+}
+
+const LidSensorChannelInterface* LidSensorChannelInterface::listenInterface(const QString& id)
+{
+ return dynamic_cast<const LidSensorChannelInterface*> (interface(id));
+}
+
+LidSensorChannelInterface* LidSensorChannelInterface::controlInterface(const QString& id)
+{
+ return interface(id);
+}
+
+
+LidSensorChannelInterface* LidSensorChannelInterface::interface(const QString& id)
+{
+ SensorManagerInterface& sm = SensorManagerInterface::instance();
+ if (!sm.registeredAndCorrectClassName(id, LidSensorChannelInterface::staticMetaObject.className())) {
+ return 0;
+ }
+
+ return dynamic_cast<LidSensorChannelInterface*>(sm.interface(id));
+}
+
+bool LidSensorChannelInterface::dataReceivedImpl()
+{
+ QVector<LidData> values;
+ if (!read<LidData>(values))
+ return false;
+ foreach(const LidData &data, values)
+ emit lidChanged(data);
+ return true;
+}
+
+LidData LidSensorChannelInterface::closed()
+{
+ return getAccessor<LidData>("closed");
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/lidsensor_i.h
^
|
@@ -0,0 +1,115 @@
+/**
+ @file alssensor_i.h
+ @brief Interface for ALSSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef LIDSENSOR_I_H
+#define LIDSENSOR_I_H
+
+#include <QtDBus/QtDBus>
+
+#include "datatypes/liddata.h"
+#include "abstractsensor_i.h"
+
+/**
+ * Client interface for listening to lid sensor state changes.
+ */
+class LidSensorChannelInterface : public AbstractSensorChannelInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(LidSensorChannelInterface)
+ Q_PROPERTY(LidData closed READ closed)
+
+public:
+ /**
+ * Name of the D-Bus interface for this class.
+ */
+ static const char* staticInterfaceName;
+
+ /**
+ * Create new instance of the class.
+ *
+ * @param id Sensor ID.
+ * @param sessionId Session ID.
+ * @return Pointer to new instance of the class.
+ */
+ static AbstractSensorChannelInterface* factoryMethod(const QString& id, int sessionId);
+
+ /**
+ * Get latest lid reading from sensor daemon.
+ *
+ * @return lid reading.
+ */
+ LidData closed();
+
+ /**
+ * Constructor.
+ *
+ * @param path path.
+ * @param sessionId session ID.
+ */
+ LidSensorChannelInterface(const QString& path, int sessionId);
+
+ /**
+ * Request a listening interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static const LidSensorChannelInterface* listenInterface(const QString& id);
+
+ /**
+ * Request a control interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static LidSensorChannelInterface* controlInterface(const QString& id);
+
+ /**
+ * Request an interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ */
+ static LidSensorChannelInterface* interface(const QString& id);
+
+protected:
+ virtual bool dataReceivedImpl();
+
+Q_SIGNALS:
+ /**
+ * Sent when measured ambient light intensity has changed.
+ *
+ * @param value ambient light reading.
+ */
+ void lidChanged(const LidData& value);
+};
+
+namespace local {
+ typedef ::LidSensorChannelInterface LidSensor;
+}
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/pressuresensor_i.cpp
^
|
@@ -0,0 +1,76 @@
+/**
+ @file pressuresensor_i.cpp
+ @brief Interface for PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "sensormanagerinterface.h"
+#include "pressuresensor_i.h"
+#include "socketreader.h"
+
+const char* PressureSensorChannelInterface::staticInterfaceName = "local.PressureSensor";
+
+AbstractSensorChannelInterface* PressureSensorChannelInterface::factoryMethod(const QString& id, int sessionId)
+{
+ return new PressureSensorChannelInterface(OBJECT_PATH + "/" + id, sessionId);
+}
+
+PressureSensorChannelInterface::PressureSensorChannelInterface(const QString& path, int sessionId)
+ : AbstractSensorChannelInterface(path, PressureSensorChannelInterface::staticInterfaceName, sessionId)
+{
+}
+
+const PressureSensorChannelInterface* PressureSensorChannelInterface::listenInterface(const QString& id)
+{
+ return dynamic_cast<const PressureSensorChannelInterface*> (interface(id));
+}
+
+PressureSensorChannelInterface* PressureSensorChannelInterface::controlInterface(const QString& id)
+{
+ return interface(id);
+}
+
+
+PressureSensorChannelInterface* PressureSensorChannelInterface::interface(const QString& id)
+{
+ SensorManagerInterface& sm = SensorManagerInterface::instance();
+ if ( !sm.registeredAndCorrectClassName( id, PressureSensorChannelInterface::staticMetaObject.className())) {
+ return 0;
+ }
+
+ return dynamic_cast<PressureSensorChannelInterface*>(sm.interface(id));
+}
+
+bool PressureSensorChannelInterface::dataReceivedImpl()
+{
+ QVector<TimedUnsigned> values;
+ if(!read<TimedUnsigned>(values))
+ return false;
+ foreach(const TimedUnsigned& data, values)
+ emit pressureChanged(data);
+ return true;
+}
+
+Unsigned PressureSensorChannelInterface::pressure()
+{
+ return getAccessor<Unsigned>("pressure");
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/pressuresensor_i.h
^
|
@@ -0,0 +1,118 @@
+/**
+ @file pressuresensor_i.h
+ @brief Interface for PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef PRESSURESENSOR_I_H
+#define PRESSURESENSOR_I_H
+
+#include <QtDBus/QtDBus>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_i.h"
+
+/**
+ * Client interface for accessing pressure sensor.
+ * Provides signal on change of measured pressure level.
+ * Previous measured pressure level can be queried any time. Provided
+ * values are in \e pascals.
+ */
+class PressureSensorChannelInterface : public AbstractSensorChannelInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(PressureSensorChannelInterface)
+ Q_PROPERTY(Unsigned pressure READ pressure NOTIFY pressureChanged)
+
+public:
+ /**
+ * Name of the D-Bus interface for this class.
+ */
+ static const char* staticInterfaceName;
+
+ /**
+ * Create new instance of the class.
+ *
+ * @param id Sensor ID.
+ * @param sessionId Session ID.
+ * @return Pointer to new instance of the class.
+ */
+ static AbstractSensorChannelInterface* factoryMethod(const QString& id, int sessionId);
+
+ /**
+ * Get latest pressure from sensor daemon.
+ *
+ * @return pressure reading.
+ */
+ Unsigned pressure();
+
+ /**
+ * Constructor.
+ *
+ * @param path path.
+ * @param sessionId session ID.
+ */
+ PressureSensorChannelInterface(const QString& path, int sessionId);
+
+ /**
+ * Request a listening interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static const PressureSensorChannelInterface* listenInterface(const QString& id);
+
+ /**
+ * Request a control interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static PressureSensorChannelInterface* controlInterface(const QString& id);
+
+ /**
+ * Request an interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ */
+ static PressureSensorChannelInterface* interface(const QString& id);
+
+protected:
+ virtual bool dataReceivedImpl();
+
+Q_SIGNALS:
+ /**
+ * Sent when measured ambient light intensity has changed.
+ *
+ * @param value ambient light reading.
+ */
+ void pressureChanged(const Unsigned& value);
+};
+
+namespace local {
+ typedef ::PressureSensorChannelInterface PressureSensor;
+}
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/qt-api.pro
^
|
@@ -17,7 +17,12 @@
proximitysensor_i.cpp \
rotationsensor_i.cpp \
magnetometersensor_i.cpp \
- gyroscopesensor_i.cpp
+ gyroscopesensor_i.cpp \
+ lidsensor_i.cpp \
+ humiditysensor_i.cpp \
+ pressuresensor_i.cpp \
+ temperaturesensor_i.cpp \
+ stepcountersensor_i.cpp
HEADERS += sensormanagerinterface.h \
sensormanager_i.h \
@@ -31,7 +36,12 @@
proximitysensor_i.h \
rotationsensor_i.h \
magnetometersensor_i.h \
- gyroscopesensor_i.h
+ gyroscopesensor_i.h \
+ lidsensor_i.h \
+ humiditysensor_i.h \
+ pressuresensor_i.h \
+ temperaturesensor_i.h \
+ stepcountersensor_i.h
SENSORFW_INCLUDEPATHS = .. \
../include \
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/socketreader.cpp
^
|
@@ -50,7 +50,14 @@
}
socket_ = new QLocalSocket(this);
- socket_->connectToServer("/var/run/sensord.sock", QIODevice::ReadWrite);
+ const char* SOCKET_NAME = "/var/run/sensord.sock";
+ QByteArray env = qgetenv("SENSORFW_SOCKET_PATH");
+ if (!env.isEmpty()) {
+ env += SOCKET_NAME;
+ SOCKET_NAME = env;
+ }
+
+ socket_->connectToServer(SOCKET_NAME, QIODevice::ReadWrite);
if (!(socket_->serverName().size())) {
qDebug() << socket_->errorString();
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/stepcountersensor_i.cpp
^
|
@@ -0,0 +1,80 @@
+/**
+ @file stepcountersensor_i.cpp
+ @brief Interface for stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Antti Virtanen <antti.i.virtanen@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "sensormanagerinterface.h"
+#include "stepcountersensor_i.h"
+#include "socketreader.h"
+
+const char* StepCounterSensorChannelInterface::staticInterfaceName = "local.StepCounterSensor";
+
+AbstractSensorChannelInterface* StepCounterSensorChannelInterface::factoryMethod(const QString& id, int sessionId)
+{
+ return new StepCounterSensorChannelInterface(OBJECT_PATH + "/" + id, sessionId);
+}
+
+StepCounterSensorChannelInterface::StepCounterSensorChannelInterface(const QString& path, int sessionId)
+ : AbstractSensorChannelInterface(path, StepCounterSensorChannelInterface::staticInterfaceName, sessionId)
+{
+}
+
+const StepCounterSensorChannelInterface* StepCounterSensorChannelInterface::listenInterface(const QString& id)
+{
+ return dynamic_cast<const StepCounterSensorChannelInterface*> (interface(id));
+}
+
+StepCounterSensorChannelInterface* StepCounterSensorChannelInterface::controlInterface(const QString& id)
+{
+ return interface(id);
+}
+
+
+StepCounterSensorChannelInterface* StepCounterSensorChannelInterface::interface(const QString& id)
+{
+ SensorManagerInterface& sm = SensorManagerInterface::instance();
+ if ( !sm.registeredAndCorrectClassName( id, StepCounterSensorChannelInterface::staticMetaObject.className() ) )
+ {
+ return 0;
+ }
+
+ return dynamic_cast<StepCounterSensorChannelInterface*>(sm.interface(id));
+}
+
+bool StepCounterSensorChannelInterface::dataReceivedImpl()
+{
+ QVector<TimedUnsigned> values;
+ if(!read<TimedUnsigned>(values))
+ return false;
+ foreach(const TimedUnsigned& data, values)
+ emit StepCounterChanged(data);
+ return true;
+}
+
+Unsigned StepCounterSensorChannelInterface::steps()
+{
+ return getAccessor<Unsigned>("steps");
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/stepcountersensor_i.h
^
|
@@ -0,0 +1,121 @@
+/**
+ @file stepcountersensor_i.h
+ @brief Interface for stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Antti Virtanen <antti.i.virtanen@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef STEPCOUNTERSENSOR_I_H
+#define STEPCOUNTERSENSOR_I_H
+
+#include <QtDBus/QtDBus>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_i.h"
+
+/**
+ * Client interface for accessing stepcounter sensor.
+ * Provides signal on change of counted steps.
+ * Previous counted steps can be queried any time. Provided
+ * values are in \e steps.
+ */
+class StepCounterSensorChannelInterface : public AbstractSensorChannelInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(StepCounterSensorChannelInterface)
+ Q_PROPERTY(Unsigned steps READ steps)
+
+public:
+ /**
+ * Name of the D-Bus interface for this class.
+ */
+ static const char* staticInterfaceName;
+
+ /**
+ * Create new instance of the class.
+ *
+ * @param id Sensor ID.
+ * @param sessionId Session ID.
+ * @return Pointer to new instance of the class.
+ */
+ static AbstractSensorChannelInterface* factoryMethod(const QString& id, int sessionId);
+
+ /**
+ * Get latest step count from sensor daemon.
+ *
+ * @return step counts since reboot.
+ */
+ Unsigned steps();
+
+ /**
+ * Constructor.
+ *
+ * @param path path.
+ * @param sessionId session ID.
+ */
+ StepCounterSensorChannelInterface(const QString& path, int sessionId);
+
+ /**
+ * Request a listening interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static const StepCounterSensorChannelInterface* listenInterface(const QString& id);
+
+ /**
+ * Request a control interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static StepCounterSensorChannelInterface* controlInterface(const QString& id);
+
+ /**
+ * Request an interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ */
+ static StepCounterSensorChannelInterface* interface(const QString& id);
+
+protected:
+ virtual bool dataReceivedImpl();
+
+Q_SIGNALS:
+ /**
+ * Sent when measured step count has changed.
+ *
+ * @param value step count reading.
+ */
+ void StepCounterChanged(const Unsigned& value);
+};
+
+namespace local {
+ typedef ::StepCounterSensorChannelInterface StepCounterSensor;
+}
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/temperaturesensor_i.cpp
^
|
@@ -0,0 +1,76 @@
+/**
+ @file temperaturesensor_i.cpp
+ @brief Interface for TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "sensormanagerinterface.h"
+#include "temperaturesensor_i.h"
+#include "socketreader.h"
+
+const char* TemperatureSensorChannelInterface::staticInterfaceName = "local.TemperatureSensor";
+
+AbstractSensorChannelInterface* TemperatureSensorChannelInterface::factoryMethod(const QString& id, int sessionId)
+{
+ return new TemperatureSensorChannelInterface(OBJECT_PATH + "/" + id, sessionId);
+}
+
+TemperatureSensorChannelInterface::TemperatureSensorChannelInterface(const QString& path, int sessionId)
+ : AbstractSensorChannelInterface(path, TemperatureSensorChannelInterface::staticInterfaceName, sessionId)
+{
+}
+
+const TemperatureSensorChannelInterface* TemperatureSensorChannelInterface::listenInterface(const QString& id)
+{
+ return dynamic_cast<const TemperatureSensorChannelInterface*> (interface(id));
+}
+
+TemperatureSensorChannelInterface* TemperatureSensorChannelInterface::controlInterface(const QString& id)
+{
+ return interface(id);
+}
+
+
+TemperatureSensorChannelInterface* TemperatureSensorChannelInterface::interface(const QString& id)
+{
+ SensorManagerInterface& sm = SensorManagerInterface::instance();
+ if ( !sm.registeredAndCorrectClassName( id, TemperatureSensorChannelInterface::staticMetaObject.className())) {
+ return 0;
+ }
+
+ return dynamic_cast<TemperatureSensorChannelInterface*>(sm.interface(id));
+}
+
+bool TemperatureSensorChannelInterface::dataReceivedImpl()
+{
+ QVector<TimedUnsigned> values;
+ if(!read<TimedUnsigned>(values))
+ return false;
+ foreach(const TimedUnsigned& data, values)
+ emit temperatureChanged(data);
+ return true;
+}
+
+Unsigned TemperatureSensorChannelInterface::temperature()
+{
+ return getAccessor<Unsigned>("temperature");
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/qt-api/temperaturesensor_i.h
^
|
@@ -0,0 +1,118 @@
+/**
+ @file temperaturesensor_i.h
+ @brief Interface for TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef TEMPERATURESENSOR_I_H
+#define TEMPERATURESENSOR_I_H
+
+#include <QtDBus/QtDBus>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_i.h"
+
+/**
+ * Client interface for accessing temperature sensor.
+ * Provides signal on change of measured temperature level.
+ * Previous measured intensity level can be queried any time. Provided
+ * values are in \e celcius.
+ */
+class TemperatureSensorChannelInterface : public AbstractSensorChannelInterface
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(TemperatureSensorChannelInterface)
+ Q_PROPERTY(Unsigned temperature READ temperature NOTIFY temperatureChanged)
+
+public:
+ /**
+ * Name of the D-Bus interface for this class.
+ */
+ static const char* staticInterfaceName;
+
+ /**
+ * Create new instance of the class.
+ *
+ * @param id Sensor ID.
+ * @param sessionId Session ID.
+ * @return Pointer to new instance of the class.
+ */
+ static AbstractSensorChannelInterface* factoryMethod(const QString& id, int sessionId);
+
+ /**
+ * Get latest temperature reading from sensor daemon.
+ *
+ * @return temperature reading.
+ */
+ Unsigned temperature();
+
+ /**
+ * Constructor.
+ *
+ * @param path path.
+ * @param sessionId session ID.
+ */
+ TemperatureSensorChannelInterface(const QString& path, int sessionId);
+
+ /**
+ * Request a listening interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static const TemperatureSensorChannelInterface* listenInterface(const QString& id);
+
+ /**
+ * Request a control interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ * @deprecated use interface(const QString&) instead.
+ */
+ static TemperatureSensorChannelInterface* controlInterface(const QString& id);
+
+ /**
+ * Request an interface to the sensor.
+ *
+ * @param id sensor ID.
+ * @return Pointer to interface, or NULL on failure.
+ */
+ static TemperatureSensorChannelInterface* interface(const QString& id);
+
+protected:
+ virtual bool dataReceivedImpl();
+
+Q_SIGNALS:
+ /**
+ * Sent when measured temperature has changed.
+ *
+ * @param value ambient light reading.
+ */
+ void temperatureChanged(const Unsigned& value);
+};
+
+namespace local {
+ typedef ::TemperatureSensorChannelInterface TemperatureSensor;
+}
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensord/main.cpp
^
|
@@ -33,6 +33,8 @@
#include <QtCore/QCoreApplication>
#include <QtCore/QDebug>
+#include <systemd/sd-daemon.h>
+
#include <signal.h>
#include <iostream>
#include <errno.h>
@@ -137,6 +139,8 @@
if (parser.createDaemon())
{
+ fflush(0);
+
int pid = fork();
if(pid < 0)
@@ -144,8 +148,8 @@
sensordLogC() << "Failed to create a daemon: " << strerror(errno);
exit(EXIT_FAILURE);
} else if (pid > 0) {
- sensordLogW() << "Created a daemon";
- exit(EXIT_SUCCESS);
+ sensordLogD() << "Created a daemon";
+ _exit(EXIT_SUCCESS);
}
}
@@ -173,6 +177,11 @@
exit(EXIT_FAILURE);
}
+ if (parser.notifySystemd())
+ {
+ sd_notify(0, "READY=1");
+ }
+
int ret = app.exec();
sensordLogD() << "Exiting...";
Config::close();
@@ -183,6 +192,7 @@
{
qDebug() << "Usage: sensord [OPTIONS]";
qDebug() << " -d, --daemon Detach from terminal and run as daemon.\n";
+ qDebug() << " -s, --systemd Notify systemd when ready.\n";
qDebug() << " -l=N, --log-level=<level> Use given logging level. Messages are logged for";
qDebug() << " the given and higher priority levels. Level";
qDebug() << " can also be notched up by sending SIGUSR1 to";
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensord/parser.cpp
^
|
@@ -33,6 +33,7 @@
configFile_(false),
configDir_(false),
daemon_(false),
+ systemd_(false),
magnetometerCalibration_(true),
configFilePath_(""),
logLevel_(QtWarningMsg)
@@ -81,7 +82,9 @@
else if (opt.startsWith("--no-magnetometer-bg-calibration"))
magnetometerCalibration_ = false;
else if (opt.startsWith("-d") || opt.startsWith("--daemon"))
- daemon_ = true;
+ daemon_ = true, systemd_ = false;
+ else if (opt.startsWith("-s") || opt.startsWith("--systemd"))
+ systemd_ = true, daemon_ = false;
else if (opt.startsWith("-h") || opt.startsWith("--help"))
printHelp_ = true;
else if (opt.startsWith("-"))
@@ -134,3 +137,8 @@
return daemon_;
}
+bool Parser::notifySystemd() const
+{
+ return systemd_;
+}
+
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensord/parser.h
^
|
@@ -48,6 +48,7 @@
bool contextInfo() const;
bool magnetometerCalibration() const;
bool createDaemon() const;
+ bool notifySystemd() const;
private:
void parsingCommandLine(QStringList arguments);
@@ -57,6 +58,7 @@
bool configFile_;
bool configDir_;
bool daemon_;
+ bool systemd_;
bool magnetometerCalibration_;
QString configFilePath_;
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensord/sensord.pro
^
|
@@ -8,6 +8,8 @@
CONFIG += console \
link_pkgconfig
+PKGCONFIG += libsystemd
+
SENSORFW_INCLUDEPATHS = .. \
../include \
../filters \
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/humiditysensor/humidityplugin.cpp
^
|
@@ -0,0 +1,50 @@
+/**
+ @file HumidityPlugin.cpp
+ @brief Plugin for HumiditySensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "humidityplugin.h"
+#include "humiditysensor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void HumidityPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering humiditysensor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerSensor<HumiditySensorChannel>("humiditysensor");
+}
+
+void HumidityPlugin::Init(class Loader& l)
+{
+ Q_UNUSED(l);
+ SensorManager::instance().requestSensor("humiditysensor");
+}
+
+QStringList HumidityPlugin::Dependencies() {
+ return QString("humidityadaptor").split(":", QString::SkipEmptyParts);
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(humiditysensor, HumidityPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/humiditysensor/humidityplugin.h
^
|
@@ -0,0 +1,43 @@
+/**
+ @file humidityplugin.h
+ @brief Plugin for HumiditySensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef HUMIDITYPLUGIN_H
+#define HUMIDITYPLUGIN_H
+
+#include "plugin.h"
+
+class HumidityPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+private:
+ void Register(class Loader& l);
+ void Init(class Loader& l);
+ QStringList Dependencies();
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/humiditysensor/humiditysensor.cpp
^
|
@@ -0,0 +1,122 @@
+/**
+ @file humiditysensor.cpp
+ @brief humiditySensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "humiditysensor.h"
+
+#include "sensormanager.h"
+#include "bin.h"
+#include "bufferreader.h"
+#include "datatypes/orientation.h"
+
+HumiditySensorChannel::HumiditySensorChannel(const QString& id) :
+ AbstractSensorChannel(id),
+ DataEmitter<TimedUnsigned>(1),
+ previousRelativeValue_(0,0)
+{
+ SensorManager& sm = SensorManager::instance();
+
+ humidityAdaptor_ = sm.requestDeviceAdaptor("humidityadaptor");
+ if (!humidityAdaptor_) {
+ setValid(false);
+ return;
+ }
+
+ humidityReader_ = new BufferReader<TimedUnsigned>(1);
+
+ outputBuffer_ = new RingBuffer<TimedUnsigned>(1);
+
+ // Create buffers for filter chain
+ filterBin_ = new Bin;
+
+ filterBin_->add(humidityReader_, "humidity");
+ filterBin_->add(outputBuffer_, "buffer");
+
+ filterBin_->join("humidity", "source", "buffer", "sink");
+
+ // Join datasources to the chain
+ connectToSource(humidityAdaptor_, "humidity", humidityReader_);
+
+ marshallingBin_ = new Bin;
+ marshallingBin_->add(this, "sensorchannel");
+
+ outputBuffer_->join(this);
+
+
+ setDescription("relative humidity in percentage");
+ setRangeSource(humidityAdaptor_);
+ addStandbyOverrideSource(humidityAdaptor_);
+ setIntervalSource(humidityAdaptor_);
+
+ setValid(true);
+}
+
+HumiditySensorChannel::~HumiditySensorChannel()
+{
+ if (isValid()) {
+ SensorManager& sm = SensorManager::instance();
+
+ disconnectFromSource(humidityAdaptor_, "humidity", humidityReader_);
+
+ sm.releaseDeviceAdaptor("humidityadaptor");
+
+ delete humidityReader_;
+ delete outputBuffer_;
+ delete marshallingBin_;
+ delete filterBin_;
+ }
+}
+
+bool HumiditySensorChannel::start()
+{
+ sensordLogD() << "Starting HumiditySensorChannel";
+
+ if (AbstractSensorChannel::start()) {
+ marshallingBin_->start();
+ filterBin_->start();
+ humidityAdaptor_->startSensor();
+ }
+ return true;
+}
+
+bool HumiditySensorChannel::stop()
+{
+ sensordLogD() << "Stopping HumiditySensorChannel";
+
+ if (AbstractSensorChannel::stop()) {
+ humidityAdaptor_->stopSensor();
+ filterBin_->stop();
+ marshallingBin_->stop();
+ }
+ return true;
+}
+
+void HumiditySensorChannel::emitData(const TimedUnsigned& value)
+{
+ if (value.value_ != previousRelativeValue_.value_) {
+ previousRelativeValue_.value_ = value.value_;
+
+ writeToClients((const void*)(&value), sizeof(value));
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/humiditysensor/humiditysensor.h
^
|
@@ -0,0 +1,101 @@
+/**
+ @file humiditysensor.h
+ @brief humiditysensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef HUMIDITY_SENSOR_CHANNEL_H
+#define HUMIDITY_SENSOR_CHANNEL_H
+
+#include <QObject>
+
+#include "deviceadaptor.h"
+#include "abstractsensor.h"
+#include "humiditysensor_a.h"
+#include "dataemitter.h"
+#include "datatypes/timedunsigned.h"
+#include "datatypes/unsigned.h"
+
+class Bin;
+template <class TYPE> class BufferReader;
+class FilterBase;
+
+/**
+ * @brief Sensor for accessing the relative humidity sensor measurements.
+ *
+ * Signals listeners whenever observed relative humidity level has
+ * changed.
+ */
+class HumiditySensorChannel :
+ public AbstractSensorChannel,
+ public DataEmitter<TimedUnsigned>
+{
+ Q_OBJECT
+ Q_PROPERTY(Unsigned relativeHumidity READ relativeHumidity NOTIFY relativeHumidityChanged)
+
+public:
+ /**
+ * Factory method for HumiditySensorChannel.
+ * @return New HumiditySensorChannel as AbstractSensorChannel*
+ */
+ static AbstractSensorChannel* factoryMethod(const QString& id)
+ {
+ HumiditySensorChannel* sc = new HumiditySensorChannel(id);
+ new HumiditySensorChannelAdaptor(sc);
+
+ return sc;
+ }
+
+ /**
+ * Property for accessing the measured value.
+ * @return Last measured value.
+ */
+ Unsigned relativeHumidity() const { return previousRelativeValue_; }
+
+public Q_SLOTS:
+ bool start();
+ bool stop();
+
+signals:
+ /**
+ * Sent when a change in measured data is observed.
+ * @param value Measured value.
+ */
+ void relativeHumidityChanged(const Unsigned& value);
+
+protected:
+ HumiditySensorChannel(const QString& id);
+ virtual ~HumiditySensorChannel();
+
+private:
+ TimedUnsigned previousRelativeValue_;
+ TimedUnsigned previousAbsoluteValue_;
+ Bin* filterBin_;
+ Bin* marshallingBin_;
+ DeviceAdaptor* humidityAdaptor_;
+ BufferReader<TimedUnsigned>* humidityReader_;
+ RingBuffer<TimedUnsigned>* outputBuffer_;
+
+ void emitData(const TimedUnsigned& value);
+};
+
+#endif // HUMIDITY_SENSOR_CHANNEL_H
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/humiditysensor/humiditysensor.pro
^
|
@@ -0,0 +1,19 @@
+CONFIG += link_pkgconfig
+
+TARGET = humiditysensor
+
+HEADERS += humiditysensor.h \
+ humiditysensor_a.h \
+ humidityplugin.h
+
+SOURCES += humiditysensor.cpp \
+ humiditysensor_a.cpp \
+ humidityplugin.cpp
+
+include( ../sensor-config.pri )
+
+contextprovider {
+ DEFINES += PROVIDE_CONTEXT_INFO
+ PKGCONFIG += contextprovider-1.0
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/humiditysensor/humiditysensor_a.cpp
^
|
@@ -0,0 +1,36 @@
+/**
+ @file humiditysensor_a.cpp
+ @brief D-Bus adaptor for HumiditySensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "humiditysensor_a.h"
+
+HumiditySensorChannelAdaptor::HumiditySensorChannelAdaptor(QObject* parent) :
+ AbstractSensorChannelAdaptor(parent)
+{
+}
+
+Unsigned HumiditySensorChannelAdaptor::relativeHumidity() const
+{
+ return qvariant_cast<Unsigned>(parent()->property("relativeHumidity"));
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/humiditysensor/humiditysensor_a.h
^
|
@@ -0,0 +1,52 @@
+/**
+ @file humiditysensor_a.h
+ @brief D-Bus adaptor for HumiditySensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef HUMIDITY_SENSOR_H
+#define HUMIDITY_SENSOR_H
+
+#include <QtDBus/QtDBus>
+#include <QObject>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_a.h"
+
+class HumiditySensorChannelAdaptor : public AbstractSensorChannelAdaptor
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(HumiditySensorChannelAdaptor)
+ Q_CLASSINFO("D-Bus Interface", "local.HumiditySensor")
+ Q_PROPERTY(Unsigned relativeHumidity READ relativeHumidity NOTIFY relativeHumidityChanged)
+
+public:
+ HumiditySensorChannelAdaptor(QObject* parent);
+
+public Q_SLOTS:
+ Unsigned relativeHumidity() const;
+
+Q_SIGNALS:
+ void relativeHumidityChanged(const Unsigned& value);
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/lidsensor/lidplugin.cpp
^
|
@@ -0,0 +1,50 @@
+/**
+ @file LidPlugin.cpp
+ @brief Plugin for LidSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "lidplugin.h"
+#include "lidsensor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void LidPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering lidsensor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerSensor<LidSensorChannel>("lidsensor");
+}
+
+void LidPlugin::Init(class Loader& l)
+{
+ Q_UNUSED(l);
+ SensorManager::instance().requestSensor("lidsensor");
+}
+
+QStringList LidPlugin::Dependencies() {
+ return QString("lidsensoradaptor").split(":", QString::SkipEmptyParts);
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(lidsensor, LidPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/lidsensor/lidplugin.h
^
|
@@ -0,0 +1,42 @@
+/**
+ @file lidplugin.h
+ @brief Plugin for lidSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef LIDPLUGIN_H
+#define LIDPLUGIN_H
+
+#include "plugin.h"
+
+class LidPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+private:
+ void Register(class Loader& l);
+ void Init(class Loader& l);
+ QStringList Dependencies();
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/lidsensor/lidsensor.cpp
^
|
@@ -0,0 +1,122 @@
+/**
+ @file lidsensor.cpp
+ @brief LidSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "lidsensor.h"
+
+#include "sensormanager.h"
+#include "bin.h"
+#include "bufferreader.h"
+#include "datatypes/orientation.h"
+#include "datatypes/lid.h"
+
+LidSensorChannel::LidSensorChannel(const QString& id) :
+ AbstractSensorChannel(id),
+ DataEmitter<LidData>(1),
+ previousValue_(0, LidData::FrontLid, 0)
+{
+ SensorManager& sm = SensorManager::instance();
+
+ lidAdaptor_ = sm.requestDeviceAdaptor("lidsensoradaptor");
+ if (!lidAdaptor_) {
+ setValid(false);
+ return;
+ }
+
+ lidReader_ = new BufferReader<LidData>(1);
+
+ outputBuffer_ = new RingBuffer<LidData>(1);
+
+ // Create buffers for filter chain
+ filterBin_ = new Bin;
+
+ filterBin_->add(lidReader_, "lid");
+ filterBin_->add(outputBuffer_, "buffer");
+
+ filterBin_->join("lid", "source", "buffer", "sink");
+
+ // Join datasources to the chain
+ connectToSource(lidAdaptor_, "lid", lidReader_);
+
+ marshallingBin_ = new Bin;
+ marshallingBin_->add(this, "sensorchannel");
+
+ outputBuffer_->join(this);
+
+ setDescription("lid closed");
+ setRangeSource(lidAdaptor_);
+ addStandbyOverrideSource(lidAdaptor_);
+ setIntervalSource(lidAdaptor_);
+
+ setValid(true);
+}
+
+LidSensorChannel::~LidSensorChannel()
+{
+ if (isValid()) {
+ SensorManager& sm = SensorManager::instance();
+
+ disconnectFromSource(lidAdaptor_, "lid", lidReader_);
+
+ sm.releaseDeviceAdaptor("lidadaptor");
+
+ delete lidReader_;
+ delete outputBuffer_;
+ delete marshallingBin_;
+ delete filterBin_;
+ }
+}
+
+bool LidSensorChannel::start()
+{
+ sensordLogD() << "Starting LidSensorChannel";
+
+ if (AbstractSensorChannel::start()) {
+ marshallingBin_->start();
+ filterBin_->start();
+ lidAdaptor_->startSensor();
+ }
+ return true;
+}
+
+bool LidSensorChannel::stop()
+{
+ sensordLogD() << "Stopping LidSensorChannel";
+
+ if (AbstractSensorChannel::stop()) {
+ lidAdaptor_->stopSensor();
+ filterBin_->stop();
+ marshallingBin_->stop();
+ }
+ return true;
+}
+
+void LidSensorChannel::emitData(const LidData& value)
+{
+ if (value.value_ != previousValue_.value_) {
+ previousValue_.value_ = value.value_;
+
+ writeToClients((const void*)(&value), sizeof(value));
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/lidsensor/lidsensor.h
^
|
@@ -0,0 +1,101 @@
+/**
+ @file lidsensor.h
+ @brief LidSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef LID_SENSOR_CHANNEL_H
+#define LID_SENSOR_CHANNEL_H
+
+#include <QObject>
+
+#include "deviceadaptor.h"
+#include "abstractsensor.h"
+#include "lidsensor_a.h"
+#include "dataemitter.h"
+#include "datatypes/liddata.h"
+#include "datatypes/lid.h"
+class Bin;
+template <class TYPE> class BufferReader;
+class FilterBase;
+
+
+/**
+ * @brief Sensor for accessing the internal ambient light sensor measurements.
+ *
+ * Signals listeners whenever observed ambient light intensity level has
+ * changed.
+ */
+class LidSensorChannel :
+ public AbstractSensorChannel,
+ public DataEmitter<LidData>
+{
+ Q_OBJECT
+ Q_PROPERTY(LidData closed READ closed)
+
+public:
+ /**
+ * Factory method for LidSensorChannel.
+ * @return New LidSensorChannel as AbstractSensorChannel*
+ */
+ static AbstractSensorChannel* factoryMethod(const QString& id)
+ {
+ LidSensorChannel* sc = new LidSensorChannel(id);
+ new LidSensorChannelAdaptor(sc);
+
+ return sc;
+ }
+
+ /**
+ * Property for accessing the measured value.
+ * @return Last measured value.
+ */
+ LidData closed() const { return previousValue_; }
+
+public Q_SLOTS:
+ bool start();
+ bool stop();
+
+signals:
+ /**
+ * Sent when a change in measured data is observed.
+ * @param value Measured value.
+ */
+ void lidChanged(const Lid& value);
+
+protected:
+ LidSensorChannel(const QString& id);
+ virtual ~LidSensorChannel();
+
+private:
+ LidData previousValue_;
+ Bin* filterBin_;
+ Bin* marshallingBin_;
+ DeviceAdaptor* lidAdaptor_;
+ BufferReader<LidData>* lidReader_;
+ RingBuffer<LidData>* outputBuffer_;
+
+ void emitData(const LidData& value);
+
+};
+
+#endif // LID_SENSOR_CHANNEL_H
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/lidsensor/lidsensor.pro
^
|
@@ -0,0 +1,13 @@
+CONFIG += link_pkgconfig
+
+TARGET = lidsensor
+
+HEADERS += lidsensor.h \
+ lidsensor_a.h \
+ lidplugin.h
+
+SOURCES += lidsensor.cpp \
+ lidsensor_a.cpp \
+ lidplugin.cpp
+
+include( ../sensor-config.pri )
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/lidsensor/lidsensor_a.cpp
^
|
@@ -0,0 +1,36 @@
+/**
+ @file lidsensor_a.cpp
+ @brief D-Bus adaptor for LidSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "lidsensor_a.h"
+
+LidSensorChannelAdaptor::LidSensorChannelAdaptor(QObject* parent) :
+ AbstractSensorChannelAdaptor(parent)
+{
+}
+
+Unsigned LidSensorChannelAdaptor::closed() const
+{
+ return qvariant_cast<Unsigned>(parent()->property("closed"));
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/lidsensor/lidsensor_a.h
^
|
@@ -0,0 +1,52 @@
+/**
+ @file lidsensor_a.h
+ @brief D-Bus adaptor for LidSensor
+
+ <p>
+ Copyright (C) 2016 Canonical, Ltd.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef LID_SENSOR_H
+#define LID_SENSOR_H
+
+#include <QtDBus/QtDBus>
+#include <QObject>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_a.h"
+
+class LidSensorChannelAdaptor : public AbstractSensorChannelAdaptor
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(LidSensorChannelAdaptor)
+ Q_CLASSINFO("D-Bus Interface", "local.LidSensor")
+ Q_PROPERTY(Unsigned closed READ closed)
+
+public:
+ LidSensorChannelAdaptor(QObject* parent);
+
+public Q_SLOTS:
+ Unsigned closed() const;
+
+Q_SIGNALS:
+ void lidChanged(bool value);
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/pressuresensor/pressureplugin.cpp
^
|
@@ -0,0 +1,50 @@
+/**
+ @file PressurePlugin.cpp
+ @brief Plugin for PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "pressureplugin.h"
+#include "pressuresensor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void PressurePlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering pressuresensor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerSensor<PressureSensorChannel>("pressuresensor");
+}
+
+void PressurePlugin::Init(class Loader& l)
+{
+ Q_UNUSED(l);
+ SensorManager::instance().requestSensor("pressuresensor");
+}
+
+QStringList PressurePlugin::Dependencies() {
+ return QString("pressureadaptor").split(":", QString::SkipEmptyParts);
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(pressuresensor, PressurePlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/pressuresensor/pressureplugin.h
^
|
@@ -0,0 +1,43 @@
+/**
+ @file pressureplugin.h
+ @brief Plugin for PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef PRESSUREPLUGIN_H
+#define PRESSUREPLUGIN_H
+
+#include "plugin.h"
+
+class PressurePlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+private:
+ void Register(class Loader& l);
+ void Init(class Loader& l);
+ QStringList Dependencies();
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/pressuresensor/pressuresensor.cpp
^
|
@@ -0,0 +1,120 @@
+/**
+ @file pressuresensor.cpp
+ @brief PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "pressuresensor.h"
+
+#include "sensormanager.h"
+#include "bin.h"
+#include "bufferreader.h"
+
+PressureSensorChannel::PressureSensorChannel(const QString& id) :
+ AbstractSensorChannel(id),
+ DataEmitter<TimedUnsigned>(1),
+ previousValue_(0,0)
+{
+ SensorManager& sm = SensorManager::instance();
+
+ pressureAdaptor_ = sm.requestDeviceAdaptor("pressureadaptor");
+ if (!pressureAdaptor_) {
+ setValid(false);
+ return;
+ }
+
+ pressureReader_ = new BufferReader<TimedUnsigned>(1);
+
+ outputBuffer_ = new RingBuffer<TimedUnsigned>(1);
+
+ // Create buffers for filter chain
+ filterBin_ = new Bin;
+
+ filterBin_->add(pressureReader_, "pressure");
+ filterBin_->add(outputBuffer_, "buffer");
+
+ filterBin_->join("pressure", "source", "buffer", "sink");
+
+ // Join datasources to the chain
+ connectToSource(pressureAdaptor_, "pressure", pressureReader_);
+
+ marshallingBin_ = new Bin;
+ marshallingBin_->add(this, "sensorchannel");
+
+ outputBuffer_->join(this);
+
+ setDescription("ambient pressure in pascals");
+ setRangeSource(pressureAdaptor_);
+ addStandbyOverrideSource(pressureAdaptor_);
+ setIntervalSource(pressureAdaptor_);
+
+ setValid(true);
+}
+
+PressureSensorChannel::~PressureSensorChannel()
+{
+ if (isValid()) {
+ SensorManager& sm = SensorManager::instance();
+
+ disconnectFromSource(pressureAdaptor_, "pressure", pressureReader_);
+
+ sm.releaseDeviceAdaptor("pressureadaptor");
+
+ delete pressureReader_;
+ delete outputBuffer_;
+ delete marshallingBin_;
+ delete filterBin_;
+ }
+}
+
+bool PressureSensorChannel::start()
+{
+ sensordLogD() << "Starting PressureSensorChannel";
+
+ if (AbstractSensorChannel::start()) {
+ marshallingBin_->start();
+ filterBin_->start();
+ pressureAdaptor_->startSensor();
+ }
+ return true;
+}
+
+bool PressureSensorChannel::stop()
+{
+ sensordLogD() << "Stopping PressureSensorChannel";
+
+ if (AbstractSensorChannel::stop()) {
+ pressureAdaptor_->stopSensor();
+ filterBin_->stop();
+ marshallingBin_->stop();
+ }
+ return true;
+}
+
+void PressureSensorChannel::emitData(const TimedUnsigned& value)
+{
+ if (value.value_ != previousValue_.value_) {
+ previousValue_.value_ = value.value_;
+
+ writeToClients((const void*)(&value), sizeof(value));
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/pressuresensor/pressuresensor.h
^
|
@@ -0,0 +1,100 @@
+/**
+ @file pressuresensor.h
+ @brief PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef PRESSURE_SENSOR_CHANNEL_H
+#define PRESSURE_SENSOR_CHANNEL_H
+
+#include <QObject>
+
+#include "deviceadaptor.h"
+#include "abstractsensor.h"
+#include "pressuresensor_a.h"
+#include "dataemitter.h"
+#include "datatypes/timedunsigned.h"
+#include "datatypes/unsigned.h"
+
+class Bin;
+template <class TYPE> class BufferReader;
+class FilterBase;
+
+/**
+ * @brief Sensor for accessing the internal ambient light sensor measurements.
+ *
+ * Signals listeners whenever observed ambient light intensity level has
+ * changed.
+ */
+class PressureSensorChannel :
+ public AbstractSensorChannel,
+ public DataEmitter<TimedUnsigned>
+{
+ Q_OBJECT
+ Q_PROPERTY(Unsigned pressure READ pressure NOTIFY pressureChanged)
+
+public:
+ /**
+ * Factory method for PressureSensorChannel.
+ * @return New PressureSensorChannel as AbstractSensorChannel*
+ */
+ static AbstractSensorChannel* factoryMethod(const QString& id)
+ {
+ PressureSensorChannel* sc = new PressureSensorChannel(id);
+ new PressureSensorChannelAdaptor(sc);
+
+ return sc;
+ }
+
+ /**
+ * Property for accessing the measured value.
+ * @return Last measured value.
+ */
+ Unsigned pressure() const { return previousValue_; }
+
+public Q_SLOTS:
+ bool start();
+ bool stop();
+
+signals:
+ /**
+ * Sent when a change in measured data is observed.
+ * @param value Measured value.
+ */
+ void pressureChanged(const Unsigned& value);
+
+protected:
+ PressureSensorChannel(const QString& id);
+ virtual ~PressureSensorChannel();
+
+private:
+ TimedUnsigned previousValue_;
+ Bin* filterBin_;
+ Bin* marshallingBin_;
+ DeviceAdaptor* pressureAdaptor_;
+ BufferReader<TimedUnsigned>* pressureReader_;
+ RingBuffer<TimedUnsigned>* outputBuffer_;
+
+ void emitData(const TimedUnsigned& value);
+};
+
+#endif // PRESSURE_SENSOR_CHANNEL_H
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/pressuresensor/pressuresensor.pro
^
|
@@ -0,0 +1,19 @@
+CONFIG += link_pkgconfig
+
+TARGET = pressuresensor
+
+HEADERS += pressuresensor.h \
+ pressuresensor_a.h \
+ pressureplugin.h
+
+SOURCES += pressuresensor.cpp \
+ pressuresensor_a.cpp \
+ pressureplugin.cpp
+
+include( ../sensor-config.pri )
+
+contextprovider {
+ DEFINES += PROVIDE_CONTEXT_INFO
+ PKGCONFIG += contextprovider-1.0
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/pressuresensor/pressuresensor_a.cpp
^
|
@@ -0,0 +1,36 @@
+/**
+ @file pressuresensor_a.cpp
+ @brief D-Bus adaptor for PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "pressuresensor_a.h"
+
+PressureSensorChannelAdaptor::PressureSensorChannelAdaptor(QObject* parent) :
+ AbstractSensorChannelAdaptor(parent)
+{
+}
+
+Unsigned PressureSensorChannelAdaptor::pressure() const
+{
+ return qvariant_cast<Unsigned>(parent()->property("pressure"));
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/pressuresensor/pressuresensor_a.h
^
|
@@ -0,0 +1,52 @@
+/**
+ @file pressuresensor_a.h
+ @brief D-Bus adaptor for PressureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef PRESSURE_SENSOR_H
+#define PRESSURE_SENSOR_H
+
+#include <QtDBus/QtDBus>
+#include <QObject>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_a.h"
+
+class PressureSensorChannelAdaptor : public AbstractSensorChannelAdaptor
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(PressureSensorChannelAdaptor)
+ Q_CLASSINFO("D-Bus Interface", "local.PressureSensor")
+ Q_PROPERTY(Unsigned pressure READ pressure NOTIFY pressureChanged)
+
+public:
+ PressureSensorChannelAdaptor(QObject* parent);
+
+public Q_SLOTS:
+ Unsigned pressure() const;
+
+Q_SIGNALS:
+ void pressureChanged(const Unsigned& value);
+};
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/sensors.pro
^
|
@@ -11,6 +11,11 @@
compasssensor \
rotationsensor \
magnetometersensor \
- gyroscopesensor
+ gyroscopesensor \
+ lidsensor \
+ humiditysensor \
+ pressuresensor \
+ temperaturesensor \
+ stepcountersensor
contextprovider:SUBDIRS += contextplugin
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/stepcountersensor/stepcounterplugin.cpp
^
|
@@ -0,0 +1,53 @@
+/**
+ @file stepcounterplugin.cpp
+ @brief Plugin for stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Ustun Ergenoglu <ext-ustun.ergenoglu@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "stepcounterplugin.h"
+#include "stepcountersensor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void StepCounterPlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering stepcountersensor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerSensor<StepCounterSensorChannel>("stepcountersensor");
+}
+
+void StepCounterPlugin::Init(class Loader& l)
+{
+ Q_UNUSED(l);
+ SensorManager::instance().requestSensor("stepcountersensor");
+}
+
+QStringList StepCounterPlugin::Dependencies() {
+ return QString("stepcounteradaptor").split(":", QString::SkipEmptyParts);
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(stepcountersensor, StepCounterPlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/stepcountersensor/stepcounterplugin.h
^
|
@@ -0,0 +1,45 @@
+/**
+ @file stepcounterplugin.h
+ @brief Plugin for stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef STEPCOUNTERPLUGIN_H
+#define STEPCOUNTERPLUGIN_H
+
+#include "plugin.h"
+
+class StepCounterPlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+private:
+ void Register(class Loader& l);
+ void Init(class Loader& l);
+ QStringList Dependencies();
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/stepcountersensor/stepcountersensor.cpp
^
|
@@ -0,0 +1,123 @@
+/**
+ @file stepcountersensor.cpp
+ @brief stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "stepcountersensor.h"
+
+#include "sensormanager.h"
+#include "bin.h"
+#include "bufferreader.h"
+#include "datatypes/orientation.h"
+
+StepCounterSensorChannel::StepCounterSensorChannel(const QString& id) :
+ AbstractSensorChannel(id),
+ DataEmitter<TimedUnsigned>(1),
+ previousValue_(0,0)
+{
+ SensorManager& sm = SensorManager::instance();
+
+ stepcounterAdaptor_ = sm.requestDeviceAdaptor("stepcounteradaptor");
+ if (!stepcounterAdaptor_) {
+ setValid(false);
+ return;
+ }
+
+ stepcounterReader_ = new BufferReader<TimedUnsigned>(1);
+
+ outputBuffer_ = new RingBuffer<TimedUnsigned>(1);
+
+ // Create buffers for filter chain
+ filterBin_ = new Bin;
+
+ filterBin_->add(stepcounterReader_, "stepcounter");
+ filterBin_->add(outputBuffer_, "buffer");
+
+ filterBin_->join("stepcounter", "source", "buffer", "sink");
+
+ // Join datasources to the chain
+ connectToSource(stepcounterAdaptor_, "stepcounter", stepcounterReader_);
+
+ marshallingBin_ = new Bin;
+ marshallingBin_->add(this, "sensorchannel");
+
+ outputBuffer_->join(this);
+
+ setDescription("steps since boot");
+ setRangeSource(stepcounterAdaptor_);
+ addStandbyOverrideSource(stepcounterAdaptor_);
+ setIntervalSource(stepcounterAdaptor_);
+
+ setValid(true);
+}
+
+StepCounterSensorChannel::~StepCounterSensorChannel()
+{
+ if (isValid()) {
+ SensorManager& sm = SensorManager::instance();
+
+ disconnectFromSource(stepcounterAdaptor_, "stepcounter", stepcounterReader_);
+
+ sm.releaseDeviceAdaptor("stepcounteradaptor");
+
+ delete stepcounterReader_;
+ delete outputBuffer_;
+ delete marshallingBin_;
+ delete filterBin_;
+ }
+}
+
+bool StepCounterSensorChannel::start()
+{
+ sensordLogD() << "Starting StepCounterSensorChannel";
+
+ if (AbstractSensorChannel::start()) {
+ marshallingBin_->start();
+ filterBin_->start();
+ stepcounterAdaptor_->startSensor();
+ }
+ return true;
+}
+
+bool StepCounterSensorChannel::stop()
+{
+ sensordLogD() << "Stopping StepCounterSensorChannel";
+
+ if (AbstractSensorChannel::stop()) {
+ stepcounterAdaptor_->stopSensor();
+ filterBin_->stop();
+ marshallingBin_->stop();
+ }
+ return true;
+}
+
+void StepCounterSensorChannel::emitData(const TimedUnsigned& value)
+{
+ if (value.value_ != previousValue_.value_) {
+ previousValue_.value_ = value.value_;
+
+ writeToClients((const void*)(&value), sizeof(value));
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/stepcountersensor/stepcountersensor.h
^
|
@@ -0,0 +1,101 @@
+/**
+ @file stepcountersensor.h
+ @brief stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef STEPCOUNTER_SENSOR_CHANNEL_H
+#define STEPCOUNTER_SENSOR_CHANNEL_H
+
+#include <QObject>
+
+#include "deviceadaptor.h"
+#include "abstractsensor.h"
+#include "stepcountersensor_a.h"
+#include "dataemitter.h"
+#include "datatypes/timedunsigned.h"
+#include "datatypes/unsigned.h"
+
+class Bin;
+template <class TYPE> class BufferReader;
+class FilterBase;
+
+/**
+ * @brief Sensor for accessing the internal step counter sensor measurements.
+ *
+ * Signals listeners whenever observed steps count changed.
+ */
+class StepCounterSensorChannel :
+ public AbstractSensorChannel,
+ public DataEmitter<TimedUnsigned>
+{
+ Q_OBJECT;
+ Q_PROPERTY(Unsigned steps READ steps);
+
+public:
+ /**
+ * Factory method for StepCounterSensorChannel.
+ * @return New StepCounterSensorChannel as AbstractSensorChannel*
+ */
+ static AbstractSensorChannel* factoryMethod(const QString& id)
+ {
+ StepCounterSensorChannel* sc = new StepCounterSensorChannel(id);
+ new StepCounterSensorChannelAdaptor(sc);
+
+ return sc;
+ }
+
+ /**
+ * Property for accessing the measured value.
+ * @return Last measured value.
+ */
+ Unsigned steps() const { return previousValue_; }
+
+public Q_SLOTS:
+ bool start();
+ bool stop();
+
+signals:
+ /**
+ * Sent when a change in measured data is observed.
+ * @param value Measured value.
+ */
+ void StepCounterChanged(const Unsigned& value);
+
+protected:
+ StepCounterSensorChannel(const QString& id);
+ virtual ~StepCounterSensorChannel();
+
+private:
+ TimedUnsigned previousValue_;
+ Bin* filterBin_;
+ Bin* marshallingBin_;
+ DeviceAdaptor* stepcounterAdaptor_;
+ BufferReader<TimedUnsigned>* stepcounterReader_;
+ RingBuffer<TimedUnsigned>* outputBuffer_;
+
+ void emitData(const TimedUnsigned& value);
+};
+
+#endif // STEPCOUNTER_SENSOR_CHANNEL_H
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/stepcountersensor/stepcountersensor.pro
^
|
@@ -0,0 +1,19 @@
+CONFIG += link_pkgconfig
+
+TARGET = stepcountersensor
+
+HEADERS += stepcountersensor.h \
+ stepcountersensor_a.h \
+ stepcounterplugin.h
+
+SOURCES += stepcountersensor.cpp \
+ stepcountersensor_a.cpp \
+ stepcounterplugin.cpp
+
+include( ../sensor-config.pri )
+
+contextprovider {
+ DEFINES += PROVIDE_CONTEXT_INFO
+ PKGCONFIG += contextprovider-1.0
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/stepcountersensor/stepcountersensor_a.cpp
^
|
@@ -0,0 +1,38 @@
+/**
+ @file stepcountersensor_a.cpp
+ @brief D-Bus adaptor for stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "stepcountersensor_a.h"
+
+StepCounterSensorChannelAdaptor::StepCounterSensorChannelAdaptor(QObject* parent) :
+ AbstractSensorChannelAdaptor(parent)
+{
+}
+
+Unsigned StepCounterSensorChannelAdaptor::steps() const
+{
+ return qvariant_cast<Unsigned>(parent()->property("steps"));
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/stepcountersensor/stepcountersensor_a.h
^
|
@@ -0,0 +1,55 @@
+/**
+ @file stepcountersensor_a.h
+ @brief D-Bus adaptor for stepcounter sensor
+
+ <p>
+ Copyright (C) 2009-2010 Nokia Corporation
+ Copyright (C) 2016 kimmoli
+
+ @author Kimmo Lindholm <kimmo.lindholm@eke.fi>
+ @author Timo Rongas <ext-timo.2.rongas@nokia.com>
+ @author Antti Virtanen <antti.i.virtanen@nokia.com>
+
+ This file is part of Sensord.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef STEPCOUNTER_SENSOR_H
+#define STEPCOUNTER_SENSOR_H
+
+#include <QtDBus/QtDBus>
+#include <QObject>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_a.h"
+
+class StepCounterSensorChannelAdaptor : public AbstractSensorChannelAdaptor
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(StepCounterSensorChannelAdaptor)
+ Q_CLASSINFO("D-Bus Interface", "local.StepCounterSensor")
+ Q_PROPERTY(Unsigned steps READ steps)
+
+public:
+ StepCounterSensorChannelAdaptor(QObject* parent);
+
+public Q_SLOTS:
+ Unsigned steps() const;
+
+Q_SIGNALS:
+ void StepCounterChanged(const Unsigned& value);
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/temperaturesensor/temperatureplugin.cpp
^
|
@@ -0,0 +1,50 @@
+/**
+ @file temperatureplugin.cpp
+ @brief Plugin for TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "temperatureplugin.h"
+#include "temperaturesensor.h"
+#include "sensormanager.h"
+#include "logging.h"
+
+void TemperaturePlugin::Register(class Loader&)
+{
+ sensordLogD() << "registering temperaturesensor";
+ SensorManager& sm = SensorManager::instance();
+ sm.registerSensor<TemperatureSensorChannel>("temperaturesensor");
+}
+
+void TemperaturePlugin::Init(class Loader& l)
+{
+ Q_UNUSED(l);
+ SensorManager::instance().requestSensor("temperaturesensor");
+}
+
+QStringList TemperaturePlugin::Dependencies() {
+ return QString("temperatureadaptor").split(":", QString::SkipEmptyParts);
+}
+
+#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+Q_EXPORT_PLUGIN2(temperaturesensor, TemperaturePlugin)
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/temperaturesensor/temperatureplugin.h
^
|
@@ -0,0 +1,43 @@
+/**
+ @file temperatureplugin.h
+ @brief Plugin for TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef TEMPERATUREPLUGIN_H
+#define TEMPERATUREPLUGIN_H
+
+#include "plugin.h"
+
+class TemperaturePlugin : public Plugin
+{
+ Q_OBJECT
+#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
+ Q_PLUGIN_METADATA(IID "com.nokia.SensorService.Plugin/1.0")
+#endif
+private:
+ void Register(class Loader& l);
+ void Init(class Loader& l);
+ QStringList Dependencies();
+};
+
+#endif
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/temperaturesensor/temperaturesensor.cpp
^
|
@@ -0,0 +1,121 @@
+/**
+ @file temperaturesensor.cpp
+ @brief TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "temperaturesensor.h"
+
+#include "sensormanager.h"
+#include "bin.h"
+#include "bufferreader.h"
+#include "datatypes/orientation.h"
+
+TemperatureSensorChannel::TemperatureSensorChannel(const QString& id) :
+ AbstractSensorChannel(id),
+ DataEmitter<TimedUnsigned>(1),
+ previousValue_(0,0)
+{
+ SensorManager& sm = SensorManager::instance();
+
+ temperatureAdaptor_ = sm.requestDeviceAdaptor("temperatureadaptor");
+ if (!temperatureAdaptor_) {
+ setValid(false);
+ return;
+ }
+
+ temperatureReader_ = new BufferReader<TimedUnsigned>(1);
+
+ outputBuffer_ = new RingBuffer<TimedUnsigned>(1);
+
+ // Create buffers for filter chain
+ filterBin_ = new Bin;
+
+ filterBin_->add(temperatureReader_, "temperature");
+ filterBin_->add(outputBuffer_, "buffer");
+
+ filterBin_->join("temperature", "source", "buffer", "sink");
+
+ // Join datasources to the chain
+ connectToSource(temperatureAdaptor_, "temperature", temperatureReader_);
+
+ marshallingBin_ = new Bin;
+ marshallingBin_->add(this, "sensorchannel");
+
+ outputBuffer_->join(this);
+
+ setDescription("ambient temperature in celsius");
+ setRangeSource(temperatureAdaptor_);
+ addStandbyOverrideSource(temperatureAdaptor_);
+ setIntervalSource(temperatureAdaptor_);
+
+ setValid(true);
+}
+
+TemperatureSensorChannel::~TemperatureSensorChannel()
+{
+ if (isValid()) {
+ SensorManager& sm = SensorManager::instance();
+
+ disconnectFromSource(temperatureAdaptor_, "temperature", temperatureReader_);
+
+ sm.releaseDeviceAdaptor("temperatureadaptor");
+
+ delete temperatureReader_;
+ delete outputBuffer_;
+ delete marshallingBin_;
+ delete filterBin_;
+ }
+}
+
+bool TemperatureSensorChannel::start()
+{
+ sensordLogD() << "Starting TemperatureSensorChannel";
+
+ if (AbstractSensorChannel::start()) {
+ marshallingBin_->start();
+ filterBin_->start();
+ temperatureAdaptor_->startSensor();
+ }
+ return true;
+}
+
+bool TemperatureSensorChannel::stop()
+{
+ sensordLogD() << "Stopping TemperatureSensorChannel";
+
+ if (AbstractSensorChannel::stop()) {
+ temperatureAdaptor_->stopSensor();
+ filterBin_->stop();
+ marshallingBin_->stop();
+ }
+ return true;
+}
+
+void TemperatureSensorChannel::emitData(const TimedUnsigned& value)
+{
+ if (value.value_ != previousValue_.value_) {
+ previousValue_.value_ = value.value_;
+
+ writeToClients((const void*)(&value), sizeof(value));
+ }
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/temperaturesensor/temperaturesensor.h
^
|
@@ -0,0 +1,100 @@
+/**
+ @file temperaturesensor.h
+ @brief TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef TEMPERATURE_SENSOR_CHANNEL_H
+#define TEMPERATURE_SENSOR_CHANNEL_H
+
+#include <QObject>
+
+#include "deviceadaptor.h"
+#include "abstractsensor.h"
+#include "temperaturesensor_a.h"
+#include "dataemitter.h"
+#include "datatypes/timedunsigned.h"
+#include "datatypes/unsigned.h"
+
+class Bin;
+template <class TYPE> class BufferReader;
+class FilterBase;
+
+/**
+ * @brief Sensor for accessing the internal ambient light sensor measurements.
+ *
+ * Signals listeners whenever observed ambient light intensity level has
+ * changed.
+ */
+class TemperatureSensorChannel :
+ public AbstractSensorChannel,
+ public DataEmitter<TimedUnsigned>
+{
+ Q_OBJECT
+ Q_PROPERTY(Unsigned temperature READ temperature NOTIFY temperatureChanged)
+
+public:
+ /**
+ * Factory method for TemperatureSensorChannel.
+ * @return New TemperatureSensorChannel as AbstractSensorChannel*
+ */
+ static AbstractSensorChannel* factoryMethod(const QString& id)
+ {
+ TemperatureSensorChannel* sc = new TemperatureSensorChannel(id);
+ new TemperatureSensorChannelAdaptor(sc);
+
+ return sc;
+ }
+
+ /**
+ * Property for accessing the measured value.
+ * @return Last measured value.
+ */
+ Unsigned temperature() const { return previousValue_; }
+
+public Q_SLOTS:
+ bool start();
+ bool stop();
+
+signals:
+ /**
+ * Sent when a change in measured data is observed.
+ * @param value Measured value.
+ */
+ void temperatureChanged(const Unsigned& value);
+
+protected:
+ TemperatureSensorChannel(const QString& id);
+ virtual ~TemperatureSensorChannel();
+
+private:
+ TimedUnsigned previousValue_;
+ Bin* filterBin_;
+ Bin* marshallingBin_;
+ DeviceAdaptor* temperatureAdaptor_;
+ BufferReader<TimedUnsigned>* temperatureReader_;
+ RingBuffer<TimedUnsigned>* outputBuffer_;
+
+ void emitData(const TimedUnsigned& value);
+};
+
+#endif // TEMPERATURE_SENSOR_CHANNEL_H
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/temperaturesensor/temperaturesensor.pro
^
|
@@ -0,0 +1,19 @@
+CONFIG += link_pkgconfig
+
+TARGET = temperaturesensor
+
+HEADERS += temperaturesensor.h \
+ temperaturesensor_a.h \
+ temperatureplugin.h
+
+SOURCES += temperaturesensor.cpp \
+ temperaturesensor_a.cpp \
+ temperatureplugin.cpp
+
+include( ../sensor-config.pri )
+
+contextprovider {
+ DEFINES += PROVIDE_CONTEXT_INFO
+ PKGCONFIG += contextprovider-1.0
+}
+
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/temperaturesensor/temperaturesensor_a.cpp
^
|
@@ -0,0 +1,36 @@
+/**
+ @file temperaturesensor_a.cpp
+ @brief D-Bus adaptor for TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#include "temperaturesensor_a.h"
+
+TemperatureSensorChannelAdaptor::TemperatureSensorChannelAdaptor(QObject* parent) :
+ AbstractSensorChannelAdaptor(parent)
+{
+}
+
+Unsigned TemperatureSensorChannelAdaptor::temperature() const
+{
+ return qvariant_cast<Unsigned>(parent()->property("temperature"));
+}
|
[-]
[+]
|
Added |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/sensors/temperaturesensor/temperaturesensor_a.h
^
|
@@ -0,0 +1,52 @@
+/**
+ @file temperaturesensor_a.h
+ @brief D-Bus adaptor for TemperatureSensor
+
+ <p>
+ Copyright (C) 2016 Canonical LTD.
+
+ @author Lorn Potter <lorn.potter@canonical.com>
+
+ This file is part of Sensorfw.
+
+ Sensord is free software; you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License
+ version 2.1 as published by the Free Software Foundation.
+
+ Sensord is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with Sensord. If not, see <http://www.gnu.org/licenses/>.
+ </p>
+ */
+
+#ifndef TEMPERATURE_SENSOR_H
+#define TEMPERATURE_SENSOR_H
+
+#include <QtDBus/QtDBus>
+#include <QObject>
+
+#include "datatypes/unsigned.h"
+#include "abstractsensor_a.h"
+
+class TemperatureSensorChannelAdaptor : public AbstractSensorChannelAdaptor
+{
+ Q_OBJECT
+ Q_DISABLE_COPY(TemperatureSensorChannelAdaptor)
+ Q_CLASSINFO("D-Bus Interface", "local.TemperatureSensor")
+ Q_PROPERTY(Unsigned temperature READ temperature NOTIFY temperatureChanged)
+
+public:
+ TemperatureSensorChannelAdaptor(QObject* parent);
+
+public Q_SLOTS:
+ Unsigned temperature() const;
+
+Q_SIGNALS:
+ void temperatureChanged(const Unsigned& value);
+};
+
+#endif
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/tests/adaptors/adaptors.pro
^
|
@@ -16,7 +16,8 @@
../../adaptors/touchadaptor/touchadaptor.h \
../../adaptors/kbslideradaptor/kbslideradaptor.h \
../../adaptors/proximityadaptor/proximityadaptor.h \
- ../../adaptors/gyroscopeadaptor/gyroscopeadaptor.h
+ ../../adaptors/gyroscopeadaptor/gyroscopeadaptor.h \
+ ../../adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdev.h
SOURCES += adaptortest.cpp \
../../datatypes/utils.cpp \
@@ -27,7 +28,8 @@
../../adaptors/touchadaptor/touchadaptor.cpp \
../../adaptors/kbslideradaptor/kbslideradaptor.cpp \
../../adaptors/proximityadaptor/proximityadaptor.cpp \
- ../../adaptors/gyroscopeadaptor/gyroscopeadaptor.cpp
+ ../../adaptors/gyroscopeadaptor/gyroscopeadaptor.cpp \
+ ../../adaptors/lidsensoradaptor-evdev/lidsensoradaptor-evdev.cpp
INCLUDEPATH += ../.. \
@@ -43,7 +45,9 @@
../../adaptors/accelerometeradaptor \
../../adaptors/kbslideradaptor \
../../adaptors/proximityadaptor \
- ../../adaptors/gyroscopeadaptor
+ ../../adaptors/gyroscopeadaptor \
+ ../../adaptors/lidsensoradaptor-evdev
+
QMAKE_LIBDIR_FLAGS += -L../../builddir/core -L../../core/ -lrt
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/tests/adaptors/adaptortest.cpp
^
|
@@ -39,6 +39,7 @@
#include "kbslideradaptor.h"
#include "proximityadaptor.h"
#include "gyroscopeadaptor.h"
+#include "lidsensoradaptor-evdev.h"
#include "config.h"
@@ -156,5 +157,17 @@
adaptor->stopAdaptor();
}
+void AdaptorTest::testLidSensorAdaptor()
+{
+ LidSensorAdaptorEvdev* adaptor =
+ dynamic_cast<LidSensorAdaptorEvdev*>(LidSensorAdaptorEvdev::factoryMethod("lidsensoradaptor"));
+ QVERIFY( adaptor );
+
+ QVERIFY(adaptor->startAdaptor());
+ QVERIFY(adaptor->startSensor());
+
+ adaptor->stopSensor();
+ adaptor->stopAdaptor();
+}
QTEST_MAIN(AdaptorTest)
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/tests/adaptors/adaptortest.h
^
|
@@ -57,6 +57,7 @@
void testProximityAdaptor();
void testTouchAdaptor();
void testGyroscopeAdaptor();
+ void testLidSensorAdaptor();
};
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/tests/client/clientapitest.cpp
^
|
@@ -920,8 +920,9 @@
void TestClient::dataAvailable(const MagneticField&)
{
QTime now = QTime::currentTime();
+ ++dataCount;
qDebug() << "dataAvailable() "
- << ++dataCount << " in "
+ << dataCount << " in "
<< (dataCount > -1 ? m_exTimeData.msecsTo(now) : 0)
<< " ms" ;
m_exTimeData = now;
@@ -943,8 +944,9 @@
void TestClient::dataAvailable2(const XYZ&)
{
QTime now = QTime::currentTime();
+ ++dataCount;
qDebug() << "dataAvailable() "
- << ++dataCount
+ << dataCount
<< " in "
<< (dataCount > -1 ? m_exTimeData.msecsTo(now) : 0)
<< " ms";
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/tests/powermanagement/powermanagementtests/helpslot.h
^
|
@@ -52,7 +52,11 @@
{
while(!m_stop) {
msleep(250);
- system(QString("echo 0 0 0 | datafaker %1 & { sleep 0.1; eval 'kill $!' &> /dev/null; }").arg(m_inputFile).toLatin1().constData());
+ if (system(QString("echo 0 0 0 | datafaker %1 & { sleep 0.1; eval 'kill $!' &> /dev/null; }").arg(m_inputFile).toLatin1().constData()) != 0) {
+ /* Gcc will complain about completely ignoring
+ * system() return values. As we really do not
+ * care here, use dummy test to silence warnings. */
+ }
}
}
}
|
[-]
[+]
|
Changed |
_service:tar_git:hybris-libsensorfw-qt5-0.9.4.tar.bz2/tests/powermanagement/standbyoverridetests/helpslot.h
^
|
@@ -52,11 +52,15 @@
{
while(!m_stop) {
msleep(250);
- system(QString("echo 0 0 0 | datafaker %1 & { sleep 0.1; eval 'kill $!' &> /dev/null; }").arg(m_inputFile).toLatin1().constData());
+ if (system(QString("echo 0 0 0 | datafaker %1 & { sleep 0.1; eval 'kill $!' &> /dev/null; }").arg(m_inputFile).toLatin1().constData()) != 0) {
+ /* Gcc will complain about completely ignoring
+ * system() return values. As we really do not
+ * care here, use dummy test to silence warnings. */
+ }
}
-
}
}
+
QString m_inputFile;
int m_valueCount;
bool m_stop;
|
[-]
[+]
|
Changed |
_service:tar_git:sensorfwd.service
^
|
@@ -5,9 +5,8 @@
Conflicts=actdead.target
[Service]
-Type=forking
-BusName=com.nokia.SensorService
-ExecStart=/usr/sbin/sensorfwd -c=/etc/sensorfw/primaryuse.conf -d --log-level=warning --no-magnetometer-bg-calibration
+Type=notify
+ExecStart=/usr/sbin/sensorfwd -c=/etc/sensorfw/primaryuse.conf --systemd --log-level=warning --no-magnetometer-bg-calibration
ExecReload=/bin/kill -HUP $MAINPID
Restart=always
RestartSec=1
|