Merge PR #239: Add discovery mode to userandpassword mock device

This commit is contained in:
Jenkins nymea 2020-01-29 21:44:34 +01:00
commit 436b0aeffc
2 changed files with 12 additions and 1 deletions

View File

@ -124,6 +124,17 @@ void DevicePluginMock::discoverDevices(DeviceDiscoveryInfo *info)
return; return;
} }
if (info->deviceClassId() == mockUserAndPassDeviceClassId) {
QTimer::singleShot(1000, info, [this, info](){
if (myDevices().filterByDeviceClassId(mockUserAndPassDeviceClassId).isEmpty()) {
DeviceDescriptor descriptor(mockUserAndPassDeviceClassId, "Mock User & Password (Discovered)", QString());
info->addDeviceDescriptor(descriptor);
}
info->finish(Device::DeviceErrorNoError);
});
return;
}
qCWarning(dcMockDevice()) << "Cannot discover for deviceClassId" << info->deviceClassId(); qCWarning(dcMockDevice()) << "Cannot discover for deviceClassId" << info->deviceClassId();
info->finish(Device::DeviceErrorDeviceNotFound); info->finish(Device::DeviceErrorDeviceNotFound);
} }

View File

@ -866,7 +866,7 @@
"id": "6fe07a77-9c07-4736-81e2-d504314bbcb9", "id": "6fe07a77-9c07-4736-81e2-d504314bbcb9",
"name": "mockUserAndPass", "name": "mockUserAndPass",
"displayName": "Mock Device (User & Password)", "displayName": "Mock Device (User & Password)",
"createMethods": ["user"], "createMethods": ["discovery", "user"],
"setupMethod": "userandpassword" "setupMethod": "userandpassword"
} }
] ]