Add check for sensor with same name
Don't add a virtual sensor if one with the same name already exists.
Signed-off-by: Rashmica Gupta <rashmica.g@gmail.com>
Change-Id: I8efe6488dbae5f6c00e1540407fa8d8138a6bed1
diff --git a/virtualSensor.cpp b/virtualSensor.cpp
index 6dc4eb1..7ee3fae 100644
--- a/virtualSensor.cpp
+++ b/virtualSensor.cpp
@@ -378,6 +378,13 @@
}
else
{
+ if (virtualSensorsMap.find(name) != virtualSensorsMap.end())
+ {
+ log<level::ERR>(
+ "A virtual sensor with this name already exists",
+ entry("TYPE=%s", name.c_str()));
+ continue;
+ }
std::string objPath(sensorDbusPath);
objPath += sensorType + "/" + name;