added conrad shutter

This commit is contained in:
Simon Stürz 2015-02-20 14:54:29 +01:00 committed by Michael Zanetti
parent a7ca7621d4
commit 217e41ddad
3 changed files with 71 additions and 14 deletions

View File

@ -41,9 +41,9 @@
#include "devicepluginconrad.h"
#include "devicemanager.h"
#include "plugin/device.h"
#include "types/paramtype.h"
#include "devicemanager.h"
#include "plugininfo.h"
#include <QDebug>
#include <QStringList>
@ -58,24 +58,49 @@ DeviceManager::HardwareResources DevicePluginConrad::requiredHardware() const
return DeviceManager::HardwareResourceRadio433;
}
DeviceManager::DeviceSetupStatus DevicePluginConrad::setupDevice(Device *device)
{
if (device->deviceClassId() == conradRemoteDeviceClassId) {
device->setName(device->paramValue("name").toString() + " (Conrad Remote)");
return DeviceManager::DeviceSetupStatusSuccess;
}
if (device->deviceClassId() == conradShutterDeviceClassId) {
device->setName(device->paramValue("name").toString() + " (Conrad shutter RSM900R)");
return DeviceManager::DeviceSetupStatusSuccess;
}
return DeviceManager::DeviceSetupStatusFailure;
}
DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, const Action &action)
{
QList<int> rawData;
QByteArray binCode;
if(action.param("power").value().toBool()){
binCode = "10010011";
}else{
binCode = "10100011";
int repetitions = 10;
if (action.actionTypeId() == upActionTypeId) {
binCode = "10101000";
} else if (action.actionTypeId() == downActionTypeId) {
binCode = "10100000";
} else if (action.actionTypeId() == syncActionTypeId) {
binCode = "10100000";
repetitions = 20;
} else {
return DeviceManager::DeviceErrorActionTypeNotFound;
}
// append ID
QByteArray remoteId = "100101010110011000000001";
QByteArray motionDetectorId = "100100100101101101101010";
QByteArray wallSwitchId = "000001001101000010110110";
QByteArray randomID = "100010101010111010101010";
binCode.append("100101010110011000000001");
//QByteArray remoteId = "100101010110011000000001";
// QByteArray motionDetectorId = "100100100101101101101010";
//QByteArray wallSwitchId = "000001001101000010110110";
// QByteArray randomID = "100010101010111010101010";
binCode.append(wallSwitchId);
@ -101,11 +126,11 @@ DeviceManager::DeviceError DevicePluginConrad::executeAction(Device *device, con
// =======================================
// send data to driver
if(transmitData(delay, rawData)){
qDebug() << "action" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
if(transmitData(delay, rawData, repetitions)){
qDebug() << "action" << pluginName() << device->name() << action.actionTypeId();
return DeviceManager::DeviceErrorNoError;
}else{
qDebug() << "could not transmitt" << pluginName() << device->name() << "power: " << action.param("power").value().toBool();
qDebug() << "could not transmitt" << pluginName() << device->name() << action.actionTypeId();
return DeviceManager::DeviceErrorHardwareNotAvailable;
}
}

View File

@ -32,6 +32,7 @@ public:
explicit DevicePluginConrad();
DeviceManager::HardwareResources requiredHardware() const override;
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
void radioData(const QList<int> &rawData) override;
public slots:

View File

@ -9,6 +9,7 @@
{
"deviceClassId": "17cd2492-28ab-4827-ba6e-5ef35be23f1b",
"name": "Conrad Remote",
"idName": "conradRemote",
"createMethods": ["user"],
"paramTypes": [
{
@ -20,6 +21,7 @@
{
"id": "1f4050f5-4c90-4799-8d6d-e4069f3a2519",
"name": "Button pressed",
"idName": "remoteButtonPressed",
"paramTypes": [
{
"name": "button",
@ -36,6 +38,35 @@
]
}
]
},
{
"deviceClassId": "2bb14180-aa5d-4999-992d-e6d464cff486",
"name": "Conrad shutter RSM900R",
"idName": "conradShutter",
"createMethods": ["user"],
"paramTypes": [
{
"name": "name",
"type": "QString"
}
],
"actionTypes": [
{
"id": "e015419c-9df9-4bf5-a439-f1f32aedd1db",
"idName": "up",
"name": "Up"
},
{
"id": "c58a463a-f765-4a61-b2e2-883cc23878c0",
"idName": "down",
"name": "Down"
},
{
"id": "4125a18e-fa2d-4b25-acd1-e148d5d665f5",
"idName": "sync",
"name": "Send sync signal"
}
]
}
]
}