update discoveryParams from QVariantMap to QList<Param> too
This commit is contained in:
parent
a1353da833
commit
da9c937f94
@ -173,7 +173,7 @@ QList<DeviceClass> DeviceManager::supportedDevices(const VendorId &vendorId) con
|
||||
return ret;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DeviceManager::discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const
|
||||
DeviceManager::DeviceError DeviceManager::discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const
|
||||
{
|
||||
DeviceClass deviceClass = findDeviceClass(deviceClassId);
|
||||
if (!deviceClass.isValid()) {
|
||||
|
||||
@ -78,7 +78,7 @@ public:
|
||||
|
||||
QList<Vendor> supportedVendors() const;
|
||||
QList<DeviceClass> supportedDevices(const VendorId &vendorId = VendorId()) const;
|
||||
DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const;
|
||||
DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const;
|
||||
|
||||
QList<Device*> configuredDevices() const;
|
||||
QPair<DeviceError, QString> addConfiguredDevice(const DeviceClassId &deviceClassId, const QList<Param> ¶ms, const DeviceId id = DeviceId::createDeviceId());
|
||||
|
||||
@ -152,7 +152,7 @@ bool DevicePlugin::configureAutoDevice(QList<Device*> loadedDevices, Device *dev
|
||||
be an async operation. Return DeviceErrorAsync or DeviceErrorNoError if the discovery
|
||||
has been started successfully. Return an appropriate error otherwise.
|
||||
Once devices are discovered, emit devicesDiscovered() once. */
|
||||
DeviceManager::DeviceError DevicePlugin::discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const
|
||||
DeviceManager::DeviceError DevicePlugin::discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const
|
||||
{
|
||||
Q_UNUSED(deviceClassId)
|
||||
Q_UNUSED(params)
|
||||
|
||||
@ -50,7 +50,7 @@ public:
|
||||
virtual DeviceManager::HardwareResources requiredHardware() const = 0;
|
||||
|
||||
virtual bool configureAutoDevice(QList<Device *> loadedDevices, Device *device) const;
|
||||
virtual DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const;
|
||||
virtual DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const;
|
||||
|
||||
virtual QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device);
|
||||
virtual void deviceRemoved(Device *device);
|
||||
|
||||
@ -423,14 +423,20 @@ QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const
|
||||
DeviceManager::DeviceError DevicePluginOpenweathermap::discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const
|
||||
{
|
||||
qDebug() << "should discover divces for" << deviceClassId << params.value("location").toString();
|
||||
if(params.value("location").toString() == ""){
|
||||
QString location;
|
||||
foreach (const Param ¶m, params) {
|
||||
if (param.name() == "location") {
|
||||
location = param.value().toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (location.isEmpty()){
|
||||
m_openweaher->searchAutodetect();
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
}
|
||||
m_openweaher->search(params.value("location").toString());
|
||||
m_openweaher->search(location);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ public:
|
||||
QList<Vendor> supportedVendors() const override;
|
||||
QList<DeviceClass> supportedDevices() const override;
|
||||
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const override;
|
||||
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||
DeviceManager::HardwareResources requiredHardware() const override;
|
||||
QPair<DeviceManager::DeviceError, QString> executeAction(Device *device, const Action &action) override;
|
||||
|
||||
@ -157,7 +157,7 @@ QList<ParamType> DevicePluginPhilipsHue::configurationDescription() const
|
||||
return params;
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError DevicePluginPhilipsHue::discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const
|
||||
DeviceManager::DeviceError DevicePluginPhilipsHue::discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const
|
||||
{
|
||||
m_discovery->findBridges(4000);
|
||||
return DeviceManager::DeviceErrorAsync;
|
||||
|
||||
@ -46,7 +46,7 @@ public:
|
||||
PluginId pluginId() const override;
|
||||
|
||||
QList<ParamType> configurationDescription() const override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QVariantMap ¶ms) const override;
|
||||
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const QList<Param> ¶ms) const override;
|
||||
|
||||
QPair<DeviceManager::DeviceSetupStatus, QString> setupDevice(Device *device) override;
|
||||
|
||||
|
||||
@ -243,7 +243,13 @@ JsonReply *DeviceHandler::GetDiscoveredDevices(const QVariantMap ¶ms) const
|
||||
|
||||
DeviceClassId deviceClassId = DeviceClassId(params.value("deviceClassId").toString());
|
||||
|
||||
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(deviceClassId, params.value("discoveryParams").toMap());
|
||||
QList<Param> discoveryParams;
|
||||
foreach (const QVariant &discoveryParam, params.value("discoveryParams").toList()) {
|
||||
Param dp(discoveryParam.toMap().keys().first(), discoveryParam.toMap().values().first());
|
||||
discoveryParams.append(dp);
|
||||
}
|
||||
|
||||
DeviceManager::DeviceError status = GuhCore::instance()->deviceManager()->discoverDevices(deviceClassId, discoveryParams);
|
||||
switch (status) {
|
||||
case DeviceManager::DeviceErrorAsync:
|
||||
case DeviceManager::DeviceErrorNoError: {
|
||||
@ -621,5 +627,14 @@ void DeviceHandler::pairingFinished(const QUuid &pairingTransactionId, DeviceMan
|
||||
return;
|
||||
}
|
||||
|
||||
if (status != DeviceManager::DeviceErrorNoError) {
|
||||
QVariantMap returns;
|
||||
returns.insert("success", false);
|
||||
returns.insert("errorMessage", errorMessage);
|
||||
reply->setData(returns);
|
||||
reply->finished();
|
||||
return;
|
||||
}
|
||||
|
||||
m_asynDeviceAdditions.insert(deviceId, reply);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user