OneWire: Fix manual discovering of connected devices
This commit is contained in:
parent
ac6dcf0765
commit
37081a51bd
@ -59,15 +59,16 @@ void IntegrationPluginOneWire::discoverThings(ThingDiscoveryInfo *info)
|
||||
//devices cannot be discovered since auto mode is enabled
|
||||
return info->finish(Thing::ThingErrorNoError);
|
||||
} else {
|
||||
m_runningDiscoveries.insert(parentDevice, info);
|
||||
connect(info, &ThingDiscoveryInfo::destroyed, this, [this, parentDevice](){
|
||||
m_runningDiscoveries.remove(parentDevice);
|
||||
});
|
||||
|
||||
if (m_oneWireInterface)
|
||||
m_oneWireInterface->discoverDevices();
|
||||
}
|
||||
}
|
||||
|
||||
m_runningDiscoveries.append(info);
|
||||
connect(info, &ThingDiscoveryInfo::destroyed, this, [this, info](){
|
||||
m_runningDiscoveries.removeAll(info);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@ -370,9 +371,8 @@ void IntegrationPluginOneWire::onOneWireDevicesDiscovered(QList<OneWire::OneWire
|
||||
if (autoDiscoverEnabled) {
|
||||
emit autoThingsAppeared(descriptors);
|
||||
} else {
|
||||
|
||||
while (!m_runningDiscoveries.isEmpty()) {
|
||||
ThingDiscoveryInfo *info = m_runningDiscoveries.takeFirst();
|
||||
ThingDiscoveryInfo *info = m_runningDiscoveries.take(parentDevice);
|
||||
if (info && m_runningDiscoveries.isEmpty()) {
|
||||
info->addThingDescriptors(descriptors);
|
||||
info->finish(Thing::ThingErrorNoError);
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ private:
|
||||
PluginTimer *m_pluginTimer = nullptr;
|
||||
OneWire *m_oneWireInterface = nullptr;
|
||||
|
||||
QList<ThingDiscoveryInfo*> m_runningDiscoveries;
|
||||
QHash<Thing*, ThingDiscoveryInfo*> m_runningDiscoveries;
|
||||
|
||||
private slots:
|
||||
void onPluginTimer();
|
||||
|
||||
@ -101,9 +101,7 @@ bool OneWire::discoverDevices()
|
||||
oneWireDevices.append(thing);
|
||||
}
|
||||
}
|
||||
if(!oneWireDevices.isEmpty()) {
|
||||
emit devicesDiscovered(oneWireDevices);
|
||||
}
|
||||
emit devicesDiscovered(oneWireDevices);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user