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