From 13b0f38693c635495a247da0d5c8501d5c61e529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 3 Apr 2019 15:11:43 +0200 Subject: [PATCH] Add reconfigure auto device mechanism --- libnymea/devicemanager.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libnymea/devicemanager.cpp b/libnymea/devicemanager.cpp index 78a3500a..70290368 100644 --- a/libnymea/devicemanager.cpp +++ b/libnymea/devicemanager.cpp @@ -1398,7 +1398,22 @@ void DeviceManager::onAutoDevicesAppeared(const DeviceClassId &deviceClassId, co qCWarning(dcDeviceManager()) << "Invalid parent device id. Not adding device to the system."; continue; } - Device *device = new Device(plugin->pluginId(), deviceClassId, this); + + Device *device = nullptr; + + // If the appreaed auto device holds a valid device id, do a reconfiguration for this device + if (!deviceDescriptor.deviceId().isNull()) { + device = findConfiguredDevice(deviceDescriptor.deviceId()); + if (!device) { + qCWarning(dcDeviceManager()) << "Could not find device for auto device descriptor" << deviceDescriptor.deviceId(); + continue; + } + qCDebug(dcDeviceManager()) << "Start reconfiguring auto device" << device; + reconfigureDevice(deviceDescriptor.deviceId(), deviceDescriptor.params()); + continue; + } + + device = new Device(plugin->pluginId(), deviceClassId, this); device->m_autoCreated = true; device->setName(deviceDescriptor.title()); device->setParams(deviceDescriptor.params());