first version, rf code not working yet
This commit is contained in:
parent
4db0fc715e
commit
6f72d39ec0
3
debian/guh-plugins.install
vendored
3
debian/guh-plugins.install
vendored
@ -13,5 +13,4 @@ usr/lib/guh/plugins/libguh_devicepluginwifidetector.so
|
||||
usr/lib/guh/plugins/libguh_deviceplugindatetime.so
|
||||
usr/lib/guh/plugins/libguh_deviceplugingenericelements.so
|
||||
usr/lib/guh/plugins/libguh_deviceplugincommandlauncher.so
|
||||
usr/lib/guh/plugins/libguh_devicepluginleynew.so
|
||||
|
||||
usr/lib/guh/plugins/libguh_devicepluginunitec.so
|
||||
|
||||
@ -13,7 +13,7 @@ SUBDIRS += elro \
|
||||
datetime \
|
||||
genericelements \
|
||||
commandlauncher \
|
||||
leynew \
|
||||
unitec \
|
||||
|
||||
|
||||
|
||||
|
||||
115
plugins/deviceplugins/unitec/devicepluginunitec.cpp
Normal file
115
plugins/deviceplugins/unitec/devicepluginunitec.cpp
Normal file
@ -0,0 +1,115 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh 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 General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/*!
|
||||
\page unitec.html
|
||||
\title Unitec
|
||||
|
||||
\ingroup plugins
|
||||
\ingroup rf433
|
||||
|
||||
This plugin allows to controll RF 433 MHz actors an receive remote signals from \l{www.unitec-elektro.de}{Unitec}
|
||||
devices.
|
||||
|
||||
\chapter Plugin properties
|
||||
Following JSON file contains the definition and the description of all available \l{DeviceClass}{DeviceClasses}
|
||||
and \l{Vendor}{Vendors} of this \l{DevicePlugin}.
|
||||
|
||||
Each \l{DeviceClass} has a list of \l{ParamType}{paramTypes}, \l{ActionType}{actionTypes}, \l{StateType}{stateTypes}
|
||||
and \l{EventType}{eventTypes}. The \l{DeviceClass::CreateMethod}{createMethods} parameter describes how the \l{Device}
|
||||
will be created in the system. A device can have more than one \l{DeviceClass::CreateMethod}{CreateMethod}.
|
||||
The \l{DeviceClass::SetupMethod}{setupMethod} describes the setup method of the \l{Device}.
|
||||
The detailed implementation of each \l{DeviceClass} can be found in the source code.
|
||||
|
||||
\quotefile plugins/deviceplugins/elro/devicepluginelro.json
|
||||
*/
|
||||
|
||||
#include "devicepluginunitec.h"
|
||||
#include "devicemanager.h"
|
||||
#include "plugininfo.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QStringList>
|
||||
|
||||
DevicePluginUnitec::DevicePluginUnitec()
|
||||
{
|
||||
}
|
||||
|
||||
DeviceManager::HardwareResources DevicePluginUnitec::requiredHardware() const
|
||||
{
|
||||
return DeviceManager::HardwareResourceRadio433;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginUnitec::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
QList<int> rawData;
|
||||
QByteArray binCode;
|
||||
|
||||
|
||||
// sync signal (20 * 1)
|
||||
binCode.append("11111111111111111111");
|
||||
|
||||
// Button ID
|
||||
if (device->paramValue("Channel").toString() == "A") {
|
||||
binCode.append("000");
|
||||
} else if (device->paramValue("Channel").toString() == "B") {
|
||||
binCode.append("100");
|
||||
} else if (device->paramValue("Channel").toString() == "C") {
|
||||
binCode.append("010");
|
||||
} else if (device->paramValue("Channel").toString() == "D") {
|
||||
binCode.append("110");
|
||||
} else if (device->paramValue("Channel").toString() == "ALL") {
|
||||
binCode.append("001");
|
||||
}
|
||||
|
||||
// power state
|
||||
if (action.param("power").value().toBool() == true) {
|
||||
binCode.append("11");
|
||||
} else {
|
||||
binCode.append("01");
|
||||
}
|
||||
|
||||
|
||||
// =======================================
|
||||
//create rawData timings list
|
||||
int delay = 250;
|
||||
|
||||
// add the code
|
||||
foreach (QChar c, binCode) {
|
||||
if(c == '0'){
|
||||
rawData.append(3);
|
||||
rawData.append(1);
|
||||
}else{
|
||||
rawData.append(1);
|
||||
rawData.append(3);
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << binCode;
|
||||
qDebug() << rawData;
|
||||
|
||||
// =======================================
|
||||
// send data to hardware resource
|
||||
if(transmitData(delay, rawData)){
|
||||
qDebug() << "transmitted" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
|
||||
return DeviceManager::DeviceErrorNoError;
|
||||
}else{
|
||||
qDebug() << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
|
||||
return DeviceManager::DeviceErrorHardwareNotAvailable;
|
||||
}
|
||||
}
|
||||
41
plugins/deviceplugins/unitec/devicepluginunitec.h
Normal file
41
plugins/deviceplugins/unitec/devicepluginunitec.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* This file is part of guh. *
|
||||
* *
|
||||
* Guh is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, version 2 of the License. *
|
||||
* *
|
||||
* Guh 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 General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#ifndef DEVICEPLUGINUNITEC_H
|
||||
#define DEVICEPLUGINUNITEC_H
|
||||
|
||||
#include "plugin/deviceplugin.h"
|
||||
|
||||
class DevicePluginUnitec : public DevicePlugin
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginunitec.json")
|
||||
Q_INTERFACES(DevicePlugin)
|
||||
|
||||
public:
|
||||
explicit DevicePluginUnitec();
|
||||
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
|
||||
public slots:
|
||||
DeviceManager::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
|
||||
};
|
||||
|
||||
#endif // DEVICEPLUGINUNITEC_H
|
||||
36
plugins/deviceplugins/unitec/devicepluginunitec.json
Normal file
36
plugins/deviceplugins/unitec/devicepluginunitec.json
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "Unitec",
|
||||
"id": "aefca391-f8bf-4f6c-a205-6764de3c2c3c",
|
||||
"vendors": [
|
||||
{
|
||||
"name": "Unitec",
|
||||
"id": "f2cd9a76-5a7f-4c01-bf8c-5eae8b12e95c",
|
||||
"deviceClasses": [
|
||||
{
|
||||
"deviceClassId": "8468a15d-ecc0-43b6-98ca-e1e4ac9e2df3",
|
||||
"name": "Unitec switch (48111)",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "Channel",
|
||||
"type": "QString",
|
||||
"allowedValues": ["A", "B", "C", "D"]
|
||||
}
|
||||
],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "a85b5443-e91f-4814-a813-c75b04d7a823",
|
||||
"name": "Set power",
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "power",
|
||||
"type": "bool"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
11
plugins/deviceplugins/unitec/unitec.pro
Normal file
11
plugins/deviceplugins/unitec/unitec.pro
Normal file
@ -0,0 +1,11 @@
|
||||
include(../../plugins.pri)
|
||||
|
||||
TARGET = $$qtLibraryTarget(guh_devicepluginunitec)
|
||||
|
||||
SOURCES += \
|
||||
devicepluginunitec.cpp
|
||||
|
||||
HEADERS += \
|
||||
devicepluginunitec.h
|
||||
|
||||
|
||||
Reference in New Issue
Block a user