FlowerCare: Fix rediscovery

This commit is contained in:
Michael Zanetti 2020-03-29 17:56:09 +02:00
parent ac6dcf0765
commit 65bd08b547
2 changed files with 9 additions and 23 deletions

View File

@ -82,7 +82,6 @@ void IntegrationPluginFlowercare::discoverThings(ThingDiscoveryInfo *info)
foreach (const QBluetoothDeviceInfo &deviceInfo, reply->discoveredDevices()) { foreach (const QBluetoothDeviceInfo &deviceInfo, reply->discoveredDevices()) {
qCDebug(dcFlowerCare()) << "Discovered device" << deviceInfo.name(); qCDebug(dcFlowerCare()) << "Discovered device" << deviceInfo.name();
if (deviceInfo.name().contains("Flower care")) { if (deviceInfo.name().contains("Flower care")) {
if (!verifyExistingDevices(deviceInfo)) {
ThingDescriptor descriptor(flowerCareThingClassId, deviceInfo.name(), deviceInfo.address().toString()); ThingDescriptor descriptor(flowerCareThingClassId, deviceInfo.name(), deviceInfo.address().toString());
ParamList params; ParamList params;
params << Param(flowerCareThingMacParamTypeId, deviceInfo.address().toString()); params << Param(flowerCareThingMacParamTypeId, deviceInfo.address().toString());
@ -96,7 +95,6 @@ void IntegrationPluginFlowercare::discoverThings(ThingDiscoveryInfo *info)
info->addThingDescriptor(descriptor); info->addThingDescriptor(descriptor);
} }
} }
}
info->finish(Thing::ThingErrorNoError); info->finish(Thing::ThingErrorNoError);
}); });
@ -158,16 +156,6 @@ void IntegrationPluginFlowercare::thingRemoved(Thing *thing)
} }
} }
bool IntegrationPluginFlowercare::verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo)
{
foreach (Thing *thing, m_list.keys()) {
if (thing->paramValue(flowerCareThingMacParamTypeId).toString() == deviceInfo.address().toString())
return true;
}
return false;
}
void IntegrationPluginFlowercare::onPluginTimer() void IntegrationPluginFlowercare::onPluginTimer()
{ {

View File

@ -61,8 +61,6 @@ private:
QHash<Thing*, FlowerCare*> m_list; QHash<Thing*, FlowerCare*> m_list;
QHash<FlowerCare*, int> m_refreshMinutes; QHash<FlowerCare*, int> m_refreshMinutes;
bool verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo);
private slots: private slots:
void onPluginTimer(); void onPluginTimer();
void onSensorDataReceived(quint8 batteryLevel, double degreeCelsius, double lux, double moisture, double fertility); void onSensorDataReceived(quint8 batteryLevel, double degreeCelsius, double lux, double moisture, double fertility);