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()) {
|
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());
|
descriptor.setParams(params);
|
||||||
descriptor.setParams(params);
|
foreach (Thing *existingThing, myThings()) {
|
||||||
foreach (Thing *existingThing, myThings()) {
|
if (existingThing->paramValue(flowerCareThingMacParamTypeId).toString() == deviceInfo.address().toString()) {
|
||||||
if (existingThing->paramValue(flowerCareThingMacParamTypeId).toString() == deviceInfo.address().toString()) {
|
descriptor.setThingId(existingThing->id());
|
||||||
descriptor.setThingId(existingThing->id());
|
break;
|
||||||
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()
|
void IntegrationPluginFlowercare::onPluginTimer()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user