FlowerCare: Fix rediscovery
This commit is contained in:
parent
ac6dcf0765
commit
65bd08b547
@ -82,19 +82,17 @@ void IntegrationPluginFlowercare::discoverThings(ThingDiscoveryInfo *info)
|
||||
foreach (const QBluetoothDeviceInfo &deviceInfo, reply->discoveredDevices()) {
|
||||
qCDebug(dcFlowerCare()) << "Discovered device" << deviceInfo.name();
|
||||
if (deviceInfo.name().contains("Flower care")) {
|
||||
if (!verifyExistingDevices(deviceInfo)) {
|
||||
ThingDescriptor descriptor(flowerCareThingClassId, deviceInfo.name(), deviceInfo.address().toString());
|
||||
ParamList params;
|
||||
params << Param(flowerCareThingMacParamTypeId, deviceInfo.address().toString());
|
||||
descriptor.setParams(params);
|
||||
foreach (Thing *existingThing, myThings()) {
|
||||
if (existingThing->paramValue(flowerCareThingMacParamTypeId).toString() == deviceInfo.address().toString()) {
|
||||
descriptor.setThingId(existingThing->id());
|
||||
break;
|
||||
}
|
||||
ThingDescriptor descriptor(flowerCareThingClassId, deviceInfo.name(), deviceInfo.address().toString());
|
||||
ParamList params;
|
||||
params << Param(flowerCareThingMacParamTypeId, deviceInfo.address().toString());
|
||||
descriptor.setParams(params);
|
||||
foreach (Thing *existingThing, myThings()) {
|
||||
if (existingThing->paramValue(flowerCareThingMacParamTypeId).toString() == deviceInfo.address().toString()) {
|
||||
descriptor.setThingId(existingThing->id());
|
||||
break;
|
||||
}
|
||||
info->addThingDescriptor(descriptor);
|
||||
}
|
||||
info->addThingDescriptor(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
|
||||
@ -61,8 +61,6 @@ private:
|
||||
QHash<Thing*, FlowerCare*> m_list;
|
||||
QHash<FlowerCare*, int> m_refreshMinutes;
|
||||
|
||||
bool verifyExistingDevices(const QBluetoothDeviceInfo &deviceInfo);
|
||||
|
||||
private slots:
|
||||
void onPluginTimer();
|
||||
void onSensorDataReceived(quint8 batteryLevel, double degreeCelsius, double lux, double moisture, double fertility);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user