parent
36533b61aa
commit
4a8db83c8b
@ -177,8 +177,7 @@
|
||||
|
||||
#include "hardware/radio433/radio433.h"
|
||||
|
||||
#include "plugin/device.h"
|
||||
#include "plugin/deviceclass.h"
|
||||
#include "plugin/devicepairinginfo.h"
|
||||
#include "plugin/deviceplugin.h"
|
||||
#include "guhsettings.h"
|
||||
|
||||
@ -465,13 +464,13 @@ DeviceManager::DeviceError DeviceManager::reconfigureDevice(const DeviceId &devi
|
||||
DeviceSetupStatus status = plugin->setupDevice(device);
|
||||
switch (status) {
|
||||
case DeviceSetupStatusFailure:
|
||||
qCWarning(dcDeviceManager) << "Device edit failed. Not saving changes of device paramters. Device setup incomplete.";
|
||||
qCWarning(dcDeviceManager) << "Device reconfiguration failed. Not saving changes of device paramters. Device setup incomplete.";
|
||||
return DeviceErrorSetupFailed;
|
||||
case DeviceSetupStatusAsync:
|
||||
m_asyncDeviceReconfiguration.append(device);
|
||||
return DeviceErrorAsync;
|
||||
case DeviceSetupStatusSuccess:
|
||||
qCDebug(dcDeviceManager) << "Device edit complete.";
|
||||
qCDebug(dcDeviceManager) << "Device reconfiguration succeeded.";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -528,16 +527,17 @@ DeviceManager::DeviceError DeviceManager::editDevice(const DeviceId &deviceId, c
|
||||
|
||||
/*! Initiates a pairing with a \l{DeviceClass}{Device} with the given \a pairingTransactionId, \a deviceClassId and \a params.
|
||||
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. */
|
||||
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms)
|
||||
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms)
|
||||
{
|
||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||
if (deviceClass.id().isNull()) {
|
||||
qCWarning(dcDeviceManager) << "cannot find a device class with id" << deviceClassId;
|
||||
qCWarning(dcDeviceManager) << "Cannot find a device class with id" << deviceClassId;
|
||||
return DeviceErrorDeviceClassNotFound;
|
||||
}
|
||||
|
||||
Q_UNUSED(pairingTransactionId)
|
||||
Q_UNUSED(params)
|
||||
Q_UNUSED(name)
|
||||
switch (deviceClass.setupMethod()) {
|
||||
case DeviceClass::SetupMethodJustAdd:
|
||||
qCWarning(dcDeviceManager) << "Cannot setup this device this way. No need to pair this device.";
|
||||
@ -558,7 +558,7 @@ DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId
|
||||
|
||||
/*! Initiates a pairing with a \l{DeviceClass}{Device} with the given \a pairingTransactionId, \a deviceClassId and \a deviceDescriptorId.
|
||||
* Returns \l{DeviceManager::DeviceError}{DeviceError} to inform about the result. */
|
||||
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId)
|
||||
DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId)
|
||||
{
|
||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||
if (deviceClass.id().isNull()) {
|
||||
@ -576,7 +576,7 @@ DeviceManager::DeviceError DeviceManager::pairDevice(const PairingTransactionId
|
||||
return DeviceErrorDeviceDescriptorNotFound;
|
||||
}
|
||||
|
||||
m_pairingsDiscovery.insert(pairingTransactionId, qMakePair<DeviceClassId, DeviceDescriptorId>(deviceClassId, deviceDescriptorId));
|
||||
m_pairingsDiscovery.insert(pairingTransactionId, DevicePairingInfo(deviceClassId, name, deviceDescriptorId));
|
||||
|
||||
if (deviceClass.setupMethod() == DeviceClass::SetupMethodDisplayPin) {
|
||||
DeviceDescriptor deviceDescriptor = m_discoveredDevices.value(deviceDescriptorId);
|
||||
@ -604,10 +604,9 @@ DeviceManager::DeviceError DeviceManager::confirmPairing(const PairingTransactio
|
||||
}
|
||||
|
||||
if (m_pairingsDiscovery.contains(pairingTransactionId)) {
|
||||
DeviceDescriptorId deviceDescriptorId = m_pairingsDiscovery.value(pairingTransactionId).second;
|
||||
DeviceClassId deviceClassId = m_pairingsDiscovery.value(pairingTransactionId).first;
|
||||
|
||||
DeviceDescriptor deviceDescriptor = m_discoveredDevices.value(deviceDescriptorId);
|
||||
DevicePairingInfo pairingInfo = m_pairingsDiscovery.value(pairingTransactionId);
|
||||
DeviceClassId deviceClassId = pairingInfo.deviceClassId();
|
||||
DeviceDescriptor deviceDescriptor = m_discoveredDevices.value(pairingInfo.deviceDescriptorId());
|
||||
|
||||
DevicePlugin *plugin = m_devicePlugins.value(m_supportedDevices.value(deviceClassId).pluginId());
|
||||
|
||||
@ -1101,7 +1100,7 @@ void DeviceManager::slotDeviceSetupFinished(Device *device, DeviceManager::Devic
|
||||
if (m_configuredDevices.contains(device)) {
|
||||
if (m_asyncDeviceReconfiguration.contains(device)) {
|
||||
m_asyncDeviceReconfiguration.removeAll(device);
|
||||
qCWarning(dcDeviceManager) << QString("Error in device setup after edit params. Device %1 (%2) would not be functional.").arg(device->name()).arg(device->id().toString());
|
||||
qCWarning(dcDeviceManager) << QString("Error in device setup after reconfiguration. Device %1 (%2) will not be functional.").arg(device->name()).arg(device->id().toString());
|
||||
|
||||
storeConfiguredDevices();
|
||||
|
||||
@ -1170,21 +1169,23 @@ void DeviceManager::slotPairingFinished(const PairingTransactionId &pairingTrans
|
||||
|
||||
DeviceClassId deviceClassId;
|
||||
ParamList params;
|
||||
QString deviceName;
|
||||
|
||||
// Do this before checking status to make sure we clean up our hashes properly
|
||||
if (m_pairingsJustAdd.contains(pairingTransactionId)) {
|
||||
QPair<DeviceClassId, ParamList> pair = m_pairingsJustAdd.take(pairingTransactionId);
|
||||
deviceClassId = pair.first;
|
||||
params = pair.second;
|
||||
DevicePairingInfo pairingInfo = m_pairingsJustAdd.take(pairingTransactionId);
|
||||
|
||||
deviceClassId = pairingInfo.deviceClassId();
|
||||
params = pairingInfo.params();
|
||||
deviceName = pairingInfo.deviceName();
|
||||
}
|
||||
|
||||
if (m_pairingsDiscovery.contains(pairingTransactionId)) {
|
||||
QPair<DeviceClassId, DeviceDescriptorId> pair = m_pairingsDiscovery.take(pairingTransactionId);
|
||||
DevicePairingInfo pairingInfo = m_pairingsDiscovery.take(pairingTransactionId);
|
||||
DeviceDescriptor descriptor = m_discoveredDevices.take(pairingInfo.deviceDescriptorId());
|
||||
|
||||
DeviceDescriptorId deviceDescriptorId = pair.second;
|
||||
DeviceDescriptor descriptor = m_discoveredDevices.take(deviceDescriptorId);
|
||||
|
||||
deviceClassId = pair.first;
|
||||
deviceClassId = pairingInfo.deviceClassId();
|
||||
deviceName = pairingInfo.deviceName();
|
||||
params = descriptor.params();
|
||||
}
|
||||
|
||||
@ -1207,7 +1208,11 @@ void DeviceManager::slotPairingFinished(const PairingTransactionId &pairingTrans
|
||||
|
||||
QList<DeviceId> newDevices;
|
||||
Device *device = new Device(plugin->pluginId(), id, deviceClassId, this);
|
||||
device->setName(deviceClass.name());
|
||||
if (deviceName.isEmpty()) {
|
||||
device->setName(deviceClass.name());
|
||||
} else {
|
||||
device->setName(deviceName);
|
||||
}
|
||||
device->setParams(params);
|
||||
|
||||
DeviceSetupStatus setupStatus = setupDevice(device);
|
||||
|
||||
@ -44,6 +44,7 @@
|
||||
|
||||
class Device;
|
||||
class DevicePlugin;
|
||||
class DevicePairingInfo;
|
||||
class Radio433;
|
||||
class UpnpDiscovery;
|
||||
|
||||
@ -52,6 +53,8 @@ class LIBGUH_EXPORT DeviceManager : public QObject
|
||||
Q_OBJECT
|
||||
Q_ENUMS(DeviceError)
|
||||
|
||||
friend class DevicePlugin;
|
||||
|
||||
public:
|
||||
enum HardwareResource {
|
||||
HardwareResourceNone = 0x00,
|
||||
@ -120,9 +123,10 @@ public:
|
||||
|
||||
DeviceError editDevice(const DeviceId &deviceId, const QString &name);
|
||||
|
||||
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms);
|
||||
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const DeviceDescriptorId &deviceDescriptorId);
|
||||
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const ParamList ¶ms);
|
||||
DeviceError pairDevice(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const QString &name, const DeviceDescriptorId &deviceDescriptorId);
|
||||
DeviceError confirmPairing(const PairingTransactionId &pairingTransactionId, const QString &secret = QString());
|
||||
|
||||
DeviceError removeConfiguredDevice(const DeviceId &deviceId);
|
||||
|
||||
Device* findConfiguredDevice(const DeviceId &id) const;
|
||||
@ -200,14 +204,11 @@ private:
|
||||
BluetoothScanner *m_bluetoothScanner;
|
||||
#endif
|
||||
|
||||
QHash<QUuid, QPair<DeviceClassId, ParamList> > m_pairingsJustAdd;
|
||||
QHash<QUuid, QPair<DeviceClassId, DeviceDescriptorId> > m_pairingsDiscovery;
|
||||
QHash<QUuid, DevicePairingInfo> m_pairingsJustAdd;
|
||||
QHash<QUuid, DevicePairingInfo> m_pairingsDiscovery;
|
||||
|
||||
QList<Device *> m_asyncDeviceReconfiguration;
|
||||
|
||||
QList<DevicePlugin *> m_discoveringPlugins;
|
||||
|
||||
friend class DevicePlugin;
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(DeviceManager::HardwareResources)
|
||||
|
||||
@ -26,6 +26,7 @@ SOURCES += devicemanager.cpp \
|
||||
plugin/deviceclass.cpp \
|
||||
plugin/deviceplugin.cpp \
|
||||
plugin/devicedescriptor.cpp \
|
||||
plugin/devicepairinginfo.cpp \
|
||||
hardware/gpio.cpp \
|
||||
hardware/gpiomonitor.cpp \
|
||||
hardware/radio433/radio433.cpp \
|
||||
@ -71,6 +72,7 @@ HEADERS += devicemanager.h \
|
||||
plugin/deviceclass.h \
|
||||
plugin/deviceplugin.h \
|
||||
plugin/devicedescriptor.h \
|
||||
plugin/devicepairinginfo.h \
|
||||
hardware/gpio.h \
|
||||
hardware/gpiomonitor.h \
|
||||
hardware/radio433/radio433.h \
|
||||
|
||||
@ -23,8 +23,8 @@
|
||||
#define DEVICEDESCRIPTION_H
|
||||
|
||||
#include "libguh.h"
|
||||
#include <typeutils.h>
|
||||
#include <types/param.h>
|
||||
#include "typeutils.h"
|
||||
#include "types/param.h"
|
||||
|
||||
#include <QVariantMap>
|
||||
|
||||
|
||||
63
libguh/plugin/devicepairinginfo.cpp
Normal file
63
libguh/plugin/devicepairinginfo.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stuerz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* 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/>. *
|
||||
* *
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
#include "devicepairinginfo.h"
|
||||
|
||||
DevicePairingInfo::DevicePairingInfo()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DevicePairingInfo::DevicePairingInfo(const DeviceClassId &deviceClassId, const QString &deviceName, const ParamList ¶ms) :
|
||||
m_deviceClassId(deviceClassId),
|
||||
m_deviceName(deviceName),
|
||||
m_params(params)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DevicePairingInfo::DevicePairingInfo(const DeviceClassId &deviceClassId, const QString &deviceName, const DeviceDescriptorId &deviceDescriptorId) :
|
||||
m_deviceClassId(deviceClassId),
|
||||
m_deviceName(deviceName),
|
||||
m_deviceDescriptorId(deviceDescriptorId)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DeviceClassId DevicePairingInfo::deviceClassId() const
|
||||
{
|
||||
return m_deviceClassId;
|
||||
}
|
||||
|
||||
QString DevicePairingInfo::deviceName() const
|
||||
{
|
||||
return m_deviceName;
|
||||
}
|
||||
|
||||
ParamList DevicePairingInfo::params() const
|
||||
{
|
||||
return m_params;
|
||||
}
|
||||
|
||||
DeviceDescriptorId DevicePairingInfo::deviceDescriptorId() const
|
||||
{
|
||||
return m_deviceDescriptorId;
|
||||
}
|
||||
|
||||
50
libguh/plugin/devicepairinginfo.h
Normal file
50
libguh/plugin/devicepairinginfo.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
* *
|
||||
* Copyright (C) 2016 Simon Stuerz <simon.stuerz@guh.guru> *
|
||||
* *
|
||||
* 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 DEVICEPAIRINGINFO_H
|
||||
#define DEVICEPAIRINGINFO_H
|
||||
|
||||
#include "libguh.h"
|
||||
#include "typeutils.h"
|
||||
#include "types/param.h"
|
||||
|
||||
class LIBGUH_EXPORT DevicePairingInfo
|
||||
{
|
||||
public:
|
||||
DevicePairingInfo();
|
||||
DevicePairingInfo(const DeviceClassId &deviceClassId, const QString &deviceName, const ParamList ¶ms);
|
||||
DevicePairingInfo(const DeviceClassId &deviceClassId, const QString &deviceName, const DeviceDescriptorId &deviceDescriptorId);
|
||||
|
||||
DeviceClassId deviceClassId() const;
|
||||
|
||||
QString deviceName() const;
|
||||
|
||||
ParamList params() const;
|
||||
|
||||
DeviceDescriptorId deviceDescriptorId() const;
|
||||
|
||||
private:
|
||||
DeviceClassId m_deviceClassId;
|
||||
QString m_deviceName;
|
||||
ParamList m_params;
|
||||
DeviceDescriptorId m_deviceDescriptorId;
|
||||
};
|
||||
|
||||
#endif // DEVICEPAIRINGINFO_H
|
||||
@ -96,7 +96,7 @@ DeviceManager::DeviceSetupStatus DevicePluginAwattar::setupDevice(Device *device
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
qCDebug(dcAwattar) << "Setup device" << device->params();
|
||||
qCDebug(dcAwattar) << "Setup device" << device->name() << device->params();
|
||||
|
||||
m_device = device;
|
||||
m_token = device->paramValue("token").toString();
|
||||
|
||||
@ -28,12 +28,6 @@
|
||||
"Heating"
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine",
|
||||
"defaultValue": "Heating system"
|
||||
},
|
||||
{
|
||||
"name": "user uuid",
|
||||
"type": "QString",
|
||||
@ -42,7 +36,7 @@
|
||||
{
|
||||
"name": "token",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
"inputType": "Password"
|
||||
}
|
||||
],
|
||||
"stateTypes": [
|
||||
|
||||
@ -115,10 +115,8 @@ DevicePluginCommandLauncher::DevicePluginCommandLauncher()
|
||||
DeviceManager::DeviceSetupStatus DevicePluginCommandLauncher::setupDevice(Device *device)
|
||||
{
|
||||
// Application
|
||||
if(device->deviceClassId() == applicationDeviceClassId){
|
||||
device->setName("Application launcher (" + device->paramValue("name").toString() + ")");
|
||||
if(device->deviceClassId() == applicationDeviceClassId)
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
// Script
|
||||
if(device->deviceClassId() == scriptDeviceClassId){
|
||||
@ -138,7 +136,6 @@ DeviceManager::DeviceSetupStatus DevicePluginCommandLauncher::setupDevice(Device
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
device->setName("Bashscript launcher (" + device->paramValue("name").toString() + ")");
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
|
||||
@ -17,11 +17,6 @@
|
||||
"Actuator"
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "command",
|
||||
"type": "QString",
|
||||
@ -60,11 +55,6 @@
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "script",
|
||||
"type": "QString",
|
||||
|
||||
@ -66,10 +66,8 @@ DeviceManager::HardwareResources DevicePluginConrad::requiredHardware() const
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginConrad::setupDevice(Device *device)
|
||||
{
|
||||
if (device->deviceClassId() == conradShutterDeviceClassId) {
|
||||
device->setName(device->paramValue("name").toString() + " (Conrad shutter RSM900R)");
|
||||
if (device->deviceClassId() == conradShutterDeviceClassId)
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
@ -19,13 +19,7 @@
|
||||
"Shading"
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
}
|
||||
],
|
||||
"paramTypes": [ ],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "e015419c-9df9-4bf5-a439-f1f32aedd1db",
|
||||
|
||||
@ -148,7 +148,7 @@ DeviceManager::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *devic
|
||||
// alarm
|
||||
if (device->deviceClassId() == alarmDeviceClassId) {
|
||||
Alarm *alarm = new Alarm(this);
|
||||
alarm->setName(device->paramValue("name").toString());
|
||||
alarm->setName(device->name());
|
||||
alarm->setMonday(device->paramValue("monday").toBool());
|
||||
alarm->setTuesday(device->paramValue("tuesday").toBool());
|
||||
alarm->setWednesday(device->paramValue("wednesday").toBool());
|
||||
@ -172,7 +172,7 @@ DeviceManager::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *devic
|
||||
}
|
||||
|
||||
if (device->deviceClassId() == countdownDeviceClassId) {
|
||||
Countdown *countdown = new Countdown(device->paramValue("name").toString(),
|
||||
Countdown *countdown = new Countdown(device->name(),
|
||||
QTime(device->paramValue("hours").toInt(),
|
||||
device->paramValue("minutes").toInt(),
|
||||
device->paramValue("seconds").toInt()),
|
||||
@ -278,10 +278,6 @@ void DevicePluginDateTime::startMonitoringAutoDevices()
|
||||
}
|
||||
|
||||
DeviceDescriptor dateDescriptor(todayDeviceClassId, "Date", "Time");
|
||||
ParamList params;
|
||||
params.append(Param("name", "Time"));
|
||||
dateDescriptor.setParams(params);
|
||||
|
||||
emit autoDevicesAppeared(todayDeviceClassId, QList<DeviceDescriptor>() << dateDescriptor);
|
||||
}
|
||||
|
||||
|
||||
@ -18,13 +18,7 @@
|
||||
"Time"
|
||||
],
|
||||
"createMethods": ["auto"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
}
|
||||
],
|
||||
"paramTypes": [ ],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "ab16997c-be29-438e-b588-2507d723d264",
|
||||
@ -183,11 +177,6 @@
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "monday",
|
||||
"type": "bool",
|
||||
@ -281,11 +270,6 @@
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "seconds",
|
||||
"type": "int",
|
||||
|
||||
@ -63,9 +63,8 @@ DeviceManager::HardwareResources DevicePluginElro::requiredHardware() const
|
||||
DeviceManager::DeviceError DevicePluginElro::executeAction(Device *device, const Action &action)
|
||||
{
|
||||
|
||||
if (action.actionTypeId() != powerActionTypeId) {
|
||||
if (action.actionTypeId() != powerActionTypeId)
|
||||
return DeviceManager::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
|
||||
QList<int> rawData;
|
||||
QByteArray binCode;
|
||||
|
||||
@ -19,11 +19,6 @@
|
||||
"idName": "elroSocket",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "channel 1",
|
||||
"type": "bool"
|
||||
|
||||
@ -75,17 +75,14 @@ DeviceManager::DeviceSetupStatus DevicePluginGenericElements::setupDevice(Device
|
||||
{
|
||||
// Toggle Button
|
||||
if (device->deviceClassId() == toggleButtonDeviceClassId) {
|
||||
device->setName(device->paramValue("name").toString() +" (Toggle Button)");
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
// Button
|
||||
if (device->deviceClassId() == buttonDeviceClassId) {
|
||||
device->setName(device->paramValue("name").toString() +" (Button)");
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
// ON/OFF Button
|
||||
if (device->deviceClassId() == onOffButtonDeviceClassId) {
|
||||
device->setName(device->paramValue("name").toString() +" (ON/OFF Button)");
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
|
||||
@ -18,13 +18,7 @@
|
||||
"Actuator"
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
}
|
||||
],
|
||||
"paramTypes": [ ],
|
||||
"stateTypes": [
|
||||
{
|
||||
"id": "b5e90567-54aa-49bd-a78a-3c19fb38aaf5",
|
||||
@ -46,13 +40,7 @@
|
||||
"Actuator"
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
}
|
||||
],
|
||||
"paramTypes": [ ],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "01f38af1-b2ab-4ec3-844e-ef52f0f229a9",
|
||||
@ -78,13 +66,7 @@
|
||||
"Actuator"
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
}
|
||||
],
|
||||
"paramTypes": [ ],
|
||||
"actionTypes": [
|
||||
{
|
||||
"id": "892596d2-0863-4807-97da-469b9f7003f2",
|
||||
|
||||
@ -18,11 +18,6 @@
|
||||
"Actuator"
|
||||
],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "family code",
|
||||
"type": "QString",
|
||||
|
||||
@ -117,7 +117,7 @@ void DevicePluginKodi::deviceRemoved(Device *device)
|
||||
{
|
||||
Kodi *kodi = m_kodis.key(device);
|
||||
m_kodis.remove(kodi);
|
||||
qCDebug(dcKodi) << "Delete " << device->paramValue("name");
|
||||
qCDebug(dcKodi) << "Delete " << device->name();
|
||||
kodi->deleteLater();
|
||||
}
|
||||
|
||||
|
||||
@ -20,11 +20,6 @@
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "id",
|
||||
"type": "QString",
|
||||
|
||||
@ -153,7 +153,7 @@ void DevicePluginLgSmartTv::deviceRemoved(Device *device)
|
||||
}
|
||||
|
||||
TvDevice *tvDevice= m_tvList.key(device);
|
||||
qCDebug(dcLgSmartTv) << "Remove device" << device->paramValue("name").toString();
|
||||
qCDebug(dcLgSmartTv) << "Remove device" << device->name();
|
||||
unpairTvDevice(device);
|
||||
m_tvList.remove(tvDevice);
|
||||
delete tvDevice;
|
||||
|
||||
@ -85,7 +85,6 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic
|
||||
{
|
||||
// Google mail
|
||||
if(device->deviceClassId() == googleMailDeviceClassId) {
|
||||
device->setName("Google Mail (" + device->paramValue("user").toString() + ")");
|
||||
SmtpClient *smtpClient = new SmtpClient(this);
|
||||
smtpClient->setHost("smtp.gmail.com");
|
||||
smtpClient->setPort(465);
|
||||
@ -107,7 +106,6 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic
|
||||
}
|
||||
// Yahoo mail
|
||||
if(device->deviceClassId() == yahooMailDeviceClassId) {
|
||||
device->setName("Yahoo Mail (" + device->paramValue("user").toString() + ")");
|
||||
SmtpClient *smtpClient = new SmtpClient(this);
|
||||
smtpClient->setHost("smtp.mail.yahoo.com");
|
||||
smtpClient->setPort(465);
|
||||
@ -129,7 +127,6 @@ DeviceManager::DeviceSetupStatus DevicePluginMailNotification::setupDevice(Devic
|
||||
}
|
||||
// Custom mail
|
||||
if(device->deviceClassId() == customMailDeviceClassId) {
|
||||
device->setName("Custom Mail (" + device->paramValue("sender mail").toString() + ")");
|
||||
SmtpClient *smtpClient = new SmtpClient(this);
|
||||
smtpClient->setHost(device->paramValue("SMTP server").toString());
|
||||
smtpClient->setPort(device->paramValue("port").toInt());
|
||||
|
||||
@ -82,14 +82,14 @@ DeviceManager::DeviceSetupStatus DevicePluginUdpCommander::setupDevice(Device *d
|
||||
bool portOk = false;
|
||||
int port = device->paramValue("port").toInt(&portOk);
|
||||
if (!portOk || port <= 0 || port > 65535) {
|
||||
qCWarning(dcUdpCommander) << device->paramValue("name") << ": invalid port:" << device->paramValue("port").toString() << ".";
|
||||
qCWarning(dcUdpCommander) << device->name() << ": invalid port:" << device->paramValue("port").toString() << ".";
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
QUdpSocket *udpSocket = new QUdpSocket(this);
|
||||
|
||||
if (!udpSocket->bind(QHostAddress::Any, port)) {
|
||||
qCWarning(dcUdpCommander) << device->paramValue("name") << "can't bind to port" << port << ".";
|
||||
qCWarning(dcUdpCommander) << device->name() << "can't bind to port" << port << ".";
|
||||
delete udpSocket;
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
@ -125,7 +125,7 @@ void DevicePluginUdpCommander::readPendingDatagrams()
|
||||
|
||||
if (datagram == device->paramValue("command").toByteArray() ||
|
||||
datagram == device->paramValue("command").toByteArray() + "\n") {
|
||||
qCDebug(dcUdpCommander) << device->paramValue("name").toString() << " got command from" << sender.toString() << senderPort;
|
||||
qCDebug(dcUdpCommander) << device->name() << " got command from" << sender.toString() << senderPort;
|
||||
emit emitEvent(Event(commandReceivedEventTypeId, device->id()));
|
||||
socket->writeDatagram("OK\n", sender, senderPort);
|
||||
}
|
||||
|
||||
@ -18,11 +18,6 @@
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "port",
|
||||
"type": "int"
|
||||
|
||||
@ -73,7 +73,6 @@ DeviceManager::DeviceSetupStatus DevicePluginUnitec::setupDevice(Device *device)
|
||||
}
|
||||
}
|
||||
|
||||
device->setName("Unitec switch 48111 (" + device->paramValue("Channel").toString() + ")");
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
|
||||
@ -19,11 +19,6 @@
|
||||
"idName": "switch",
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "channel",
|
||||
"type": "QString",
|
||||
|
||||
@ -18,11 +18,6 @@
|
||||
],
|
||||
"createMethods": ["user"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "mac",
|
||||
"type": "QString",
|
||||
|
||||
@ -88,8 +88,6 @@ DeviceManager::DeviceSetupStatus DevicePluginWemo::setupDevice(Device *device)
|
||||
return DeviceManager::DeviceSetupStatusFailure;
|
||||
}
|
||||
|
||||
device->setName("WeMo Switch (" + device->paramValue("serial number").toString() + ")");
|
||||
|
||||
refresh(device);
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ DevicePluginWifiDetector::DevicePluginWifiDetector()
|
||||
|
||||
DeviceManager::DeviceSetupStatus DevicePluginWifiDetector::setupDevice(Device *device)
|
||||
{
|
||||
qCDebug(dcWifiDetector) << "Setup" << device->params();
|
||||
qCDebug(dcWifiDetector) << "Setup" << device->name() << device->params();
|
||||
return DeviceManager::DeviceSetupStatusSuccess;
|
||||
}
|
||||
|
||||
@ -169,7 +169,6 @@ void DevicePluginWifiDetector::discoveryProcessFinished(int exitCode, QProcess::
|
||||
qCDebug(dcWifiDetector) << "Found" << name << macAddress.toLower();
|
||||
DeviceDescriptor descriptor(wifiDeviceClassId, name, macAddress);
|
||||
ParamList params;
|
||||
params.append(Param("name", name));
|
||||
params.append(Param("mac address", macAddress));
|
||||
descriptor.setParams(params);
|
||||
m_deviceDescriptors.append(descriptor);
|
||||
|
||||
@ -19,11 +19,6 @@
|
||||
],
|
||||
"createMethods": ["user", "discovery"],
|
||||
"paramTypes": [
|
||||
{
|
||||
"name": "name",
|
||||
"type": "QString",
|
||||
"inputType": "TextLine"
|
||||
},
|
||||
{
|
||||
"name": "mac address",
|
||||
"type": "QString",
|
||||
|
||||
@ -393,16 +393,17 @@ JsonReply* DeviceHandler::AddConfiguredDevice(const QVariantMap ¶ms)
|
||||
JsonReply *DeviceHandler::PairDevice(const QVariantMap ¶ms)
|
||||
{
|
||||
DeviceClassId deviceClassId(params.value("deviceClassId").toString());
|
||||
QString deviceName = params.value("name").toString();
|
||||
DeviceClass deviceClass = GuhCore::instance()->deviceManager()->findDeviceClass(deviceClassId);
|
||||
|
||||
DeviceManager::DeviceError status;
|
||||
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
|
||||
if (params.contains("deviceDescriptorId")) {
|
||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceDescriptorId);
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceDescriptorId);
|
||||
} else {
|
||||
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceParams);
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceParams);
|
||||
}
|
||||
|
||||
QVariantMap returns;
|
||||
|
||||
@ -370,10 +370,10 @@ HttpReply *DevicesResource::addConfiguredDevice(const QByteArray &payload) const
|
||||
|
||||
DeviceManager::DeviceError status;
|
||||
if (deviceDescriptorId.isNull()) {
|
||||
qCDebug(dcRest) << "Adding device with " << deviceParams;
|
||||
qCDebug(dcRest) << "Adding device" << deviceName << "with" << deviceParams;
|
||||
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceParams, newDeviceId);
|
||||
} else {
|
||||
qCDebug(dcRest) << "Adding discovered device with DeviceDescriptorId" << deviceDescriptorId.toString();
|
||||
qCDebug(dcRest) << "Adding discovered device" << deviceName << "with DeviceDescriptorId" << deviceDescriptorId.toString();
|
||||
status = GuhCore::instance()->deviceManager()->addConfiguredDevice(deviceClassId, deviceName, deviceDescriptorId, newDeviceId);
|
||||
}
|
||||
if (status == DeviceManager::DeviceErrorAsync) {
|
||||
@ -425,16 +425,18 @@ HttpReply *DevicesResource::pairDevice(const QByteArray &payload) const
|
||||
return createDeviceErrorReply(HttpReply::BadRequest, DeviceManager::DeviceErrorDeviceClassNotFound);
|
||||
}
|
||||
|
||||
qCDebug(dcRest) << "Pair device with deviceClassId" << deviceClassId.toString();
|
||||
QString deviceName = params.value("name").toString();
|
||||
|
||||
qCDebug(dcRest) << "Pair device" << deviceName << "with deviceClassId" << deviceClassId.toString();
|
||||
|
||||
DeviceManager::DeviceError status;
|
||||
PairingTransactionId pairingTransactionId = PairingTransactionId::createPairingTransactionId();
|
||||
if (params.contains("deviceDescriptorId")) {
|
||||
DeviceDescriptorId deviceDescriptorId(params.value("deviceDescriptorId").toString());
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceDescriptorId);
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceDescriptorId);
|
||||
} else {
|
||||
ParamList deviceParams = JsonTypes::unpackParams(params.value("deviceParams").toList());
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceParams);
|
||||
status = GuhCore::instance()->deviceManager()->pairDevice(pairingTransactionId, deviceClassId, deviceName, deviceParams);
|
||||
}
|
||||
|
||||
if (status != DeviceManager::DeviceErrorNoError)
|
||||
|
||||
Reference in New Issue
Block a user