mirror of https://github.com/nymea/nymea.git
continue migrate to hardwaremanager
parent
039619ccfd
commit
ac436b0751
5
guh.pri
5
guh.pri
|
|
@ -84,9 +84,4 @@ coverage {
|
|||
QMAKE_CLEAN += *.gcda *.gcno coverage.info coverage.xml
|
||||
}
|
||||
|
||||
# Enable Radio 433 MHz for GPIO's
|
||||
enable433gpio {
|
||||
DEFINES += GPIO433
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
9
guh.pro
9
guh.pro
|
|
@ -13,7 +13,7 @@ doc.depends = libguh server
|
|||
# Note: some how extraimages in qdocconf did not the trick
|
||||
doc.commands += cd $$top_srcdir/libguh/interfaces; ./generatedoc.sh;
|
||||
doc.commands += cd $$top_srcdir/doc; qdoc config.qdocconf; cp -r images/* html/images/; \
|
||||
cp -r favicons/* html/; cp -r $$top_srcdir/doc/html $$top_builddir/
|
||||
cp -r favicons/* html/; cp -r $$top_srcdir/doc/html $$top_builddir/
|
||||
|
||||
licensecheck.commands = $$top_srcdir/tests/auto/checklicenseheaders.sh $$top_srcdir
|
||||
|
||||
|
|
@ -54,10 +54,3 @@ disabletesting {
|
|||
message("Building guh with tests")
|
||||
SUBDIRS += tests
|
||||
}
|
||||
|
||||
# GPIO RF 433 MHz support
|
||||
contains(DEFINES, GPIO433) {
|
||||
message("Radio 433 for GPIO's enabled")
|
||||
} else {
|
||||
message("Radio 433 for GPIO's disabled")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,17 +56,15 @@
|
|||
|
||||
/*! Construct the hardware resource Radio433 with the given \a parent. Each possible 433 MHz hardware will be initialized here. */
|
||||
Radio433::Radio433(QObject *parent) :
|
||||
QObject(parent)
|
||||
HardwareResource(HardwareResource::TypeRadio433, parent)
|
||||
{
|
||||
#ifdef GPIO433
|
||||
GuhSettings settings(GuhSettings::SettingsRoleGlobal);
|
||||
qCDebug(dcHardware) << "Loading GPIO settings from:" << settings.fileName();
|
||||
settings.beginGroup("GPIO");
|
||||
settings.beginGroup("RF433");
|
||||
int transmitterGpioNumber = settings.value("rf433tx",22).toInt();
|
||||
settings.endGroup();
|
||||
|
||||
m_transmitter = new Radio433Trasmitter(this, transmitterGpioNumber);
|
||||
#endif
|
||||
|
||||
m_brennenstuhlTransmitter = new Radio433BrennenstuhlGateway(this);
|
||||
connect(m_brennenstuhlTransmitter, &Radio433BrennenstuhlGateway::availableChanged, this, &Radio433::brennenstuhlAvailableChanged);
|
||||
|
|
@ -75,9 +73,7 @@ Radio433::Radio433(QObject *parent) :
|
|||
/*! Destroys the hardware resource Radio433 object. */
|
||||
Radio433::~Radio433()
|
||||
{
|
||||
#ifdef GPIO433
|
||||
m_transmitter->quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*! Enables GPIO transmitter and receiver and the Brennenstuhl Lan Gateway.
|
||||
|
|
@ -86,10 +82,8 @@ bool Radio433::enable()
|
|||
{
|
||||
m_brennenstuhlTransmitter->enable();
|
||||
|
||||
#ifdef GPIO433
|
||||
// check if GPIOs are available
|
||||
if (Gpio::isAvailable()) {
|
||||
|
||||
bool transmitterAvailable = m_transmitter->startTransmitter();
|
||||
if (!transmitterAvailable) {
|
||||
//qCWarning(dcHardware) << "ERROR: radio 433 MHz transmitter not available on GPIO's";
|
||||
|
|
@ -100,16 +94,17 @@ bool Radio433::enable()
|
|||
return false;
|
||||
}
|
||||
}
|
||||
qCDebug(dcDeviceManager()) << "--> Radio 433 MHz GPIO's enabled.";
|
||||
#endif
|
||||
|
||||
setEnabled(true);
|
||||
qCDebug(dcDeviceManager()) << "--> Radio 433 MHz GPIO's enabled.";
|
||||
return true;
|
||||
}
|
||||
|
||||
/*! Returns true, if the Radio433 hardware resources disabled correctly. */
|
||||
bool Radio433::disabel()
|
||||
bool Radio433::disable()
|
||||
{
|
||||
m_brennenstuhlTransmitter->disable();
|
||||
setEnabled(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -117,6 +112,7 @@ void Radio433::brennenstuhlAvailableChanged(const bool &available)
|
|||
{
|
||||
if (available) {
|
||||
qCDebug(dcHardware()) << "--> Radio 433 MHz Brennenstuhl LAN Gateway available.";
|
||||
setAvailable(true);
|
||||
} else {
|
||||
qCWarning(dcHardware()) << "--> Radio 433 MHz Brennenstuhl LAN Gateway NOT available.";
|
||||
}
|
||||
|
|
@ -132,12 +128,9 @@ bool Radio433::sendData(int delay, QList<int> rawData, int repetitions)
|
|||
sendBrennenstuhl = m_brennenstuhlTransmitter->sendData(delay, rawData, repetitions);
|
||||
}
|
||||
|
||||
#ifdef GPIO433
|
||||
if (m_transmitter->available()) {
|
||||
m_transmitter->sendData(delay, rawData, repetitions);
|
||||
sendGpio = true;
|
||||
}
|
||||
#endif
|
||||
|
||||
return (sendGpio || sendBrennenstuhl);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,28 +25,22 @@
|
|||
|
||||
#include <QObject>
|
||||
|
||||
#ifdef GPIO433
|
||||
#include "radio433transmitter.h"
|
||||
#endif
|
||||
|
||||
#include "libguh.h"
|
||||
#include "hardwareresource.h"
|
||||
#include "radio433brennenstuhlgateway.h"
|
||||
|
||||
class LIBGUH_EXPORT Radio433 : public QObject
|
||||
class LIBGUH_EXPORT Radio433 : public HardwareResource
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Radio433(QObject *parent = 0);
|
||||
~Radio433();
|
||||
|
||||
bool enable();
|
||||
bool disabel();
|
||||
|
||||
private:
|
||||
#ifdef GPIO433
|
||||
Radio433Trasmitter *m_transmitter;
|
||||
#endif
|
||||
|
||||
Radio433BrennenstuhlGateway *m_brennenstuhlTransmitter;
|
||||
|
||||
private slots:
|
||||
|
|
@ -55,6 +49,9 @@ private slots:
|
|||
public slots:
|
||||
bool sendData(int delay, QList<int> rawData, int repetitions);
|
||||
|
||||
bool enable();
|
||||
bool disable();
|
||||
|
||||
};
|
||||
|
||||
#endif // RADIO433_H
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ HardwareManager::HardwareManager(QObject *parent) : QObject(parent)
|
|||
// Init hardware resources
|
||||
m_pluginTimer = new PluginTimer(10000, this);
|
||||
|
||||
m_hardwareResources.append(m_pluginTimer);
|
||||
|
||||
m_radio433 = new Radio433(this);
|
||||
m_radio433->enable();
|
||||
|
||||
|
|
@ -24,7 +26,6 @@ HardwareManager::HardwareManager(QObject *parent) : QObject(parent)
|
|||
delete m_bluetoothScanner;
|
||||
m_bluetoothScanner = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Radio433 *HardwareManager::radio433()
|
||||
|
|
@ -57,3 +58,43 @@ BluetoothScanner *HardwareManager::bluetoothScanner()
|
|||
return m_bluetoothScanner;
|
||||
}
|
||||
|
||||
bool HardwareManager::isAvailable(const HardwareResource::Type &hardwareResourceType) const
|
||||
{
|
||||
foreach (HardwareResource *resource, m_hardwareResources) {
|
||||
if (resource->hardwareReourceType() == hardwareResourceType && resource->available()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HardwareManager::isEnabled(const HardwareResource::Type &hardwareResourceType) const
|
||||
{
|
||||
foreach (HardwareResource *resource, m_hardwareResources) {
|
||||
if (resource->hardwareReourceType() == hardwareResourceType && resource->enabled()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HardwareManager::enableHardwareReource(const HardwareResource::Type &hardwareResourceType)
|
||||
{
|
||||
foreach (HardwareResource *resource, m_hardwareResources) {
|
||||
if (resource->hardwareReourceType() == hardwareResourceType) {
|
||||
return resource->enabled();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool HardwareManager::disableHardwareReource(const HardwareResource::Type &hardwareResourceType)
|
||||
{
|
||||
foreach (HardwareResource *resource, m_hardwareResources) {
|
||||
if (resource->hardwareReourceType() == hardwareResourceType) {
|
||||
return resource->disable();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,12 @@ public:
|
|||
QtAvahiServiceBrowser *avahiBrowser();
|
||||
BluetoothScanner *bluetoothScanner();
|
||||
|
||||
bool isAvailable(const HardwareResource::Type &hardwareResourceType) const;
|
||||
bool isEnabled(const HardwareResource::Type &hardwareResourceType) const;
|
||||
|
||||
private:
|
||||
QList<HardwareResource *> m_hardwareResources;
|
||||
|
||||
// Hardware Resources
|
||||
Radio433 *m_radio433 = nullptr;
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
|
|
@ -37,8 +42,12 @@ private:
|
|||
BluetoothScanner *m_bluetoothScanner = nullptr;
|
||||
|
||||
signals:
|
||||
void hardwareResourceAvailableChanged(const HardwareResource::Type &hardwareResourceType, const bool &available);
|
||||
void hardwareResourceEnabledChanged(const HardwareResource::Type &hardwareResourceType, const bool &enabled);
|
||||
|
||||
public slots:
|
||||
bool enableHardwareReource(const HardwareResource::Type &hardwareResourceType);
|
||||
bool disableHardwareReource(const HardwareResource::Type &hardwareResourceType);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
This signal is emitted when the \l{State} with the given \a stateTypeId changed.
|
||||
The \a value parameter describes the new value of the State.
|
||||
*/
|
||||
|
||||
#include "device.h"
|
||||
#include "types/event.h"
|
||||
#include "loggingcategories.h"
|
||||
|
|
|
|||
Loading…
Reference in New Issue