m_loader.load_fusion_sensor(VIRTUAL_SENSOR_DIR_PATH, fusion_sensors);
m_loader.load_external_sensor(EXTERNAL_SENSOR_DIR_PATH, external_sensors);
- retvm_if(devices.empty(), false, "There is no sensors");
+ retvm_if(devices.empty() && external_sensors.empty(), false, "There is no sensors");
/* TODO: support dynamic sensor */
create_physical_sensors(devices, physical_sensors);
sensor_handler *sensor_manager::get_sensor_by_type(const std::string uri)
{
- auto it = m_sensors.begin();
- for (; it != m_sensors.end(); ++it) {
- std::size_t found = it->first.rfind(uri);
- if (found != std::string::npos)
+ for (auto it = m_sensors.begin(); it != m_sensors.end(); ++it) {
+ if (it->first == uri)
+ return it->second;
+
+ std::size_t found = it->first.find_last_of("/");
+ if (found == std::string::npos)
+ continue;
+
+ if (it->first.substr(0, found) == uri)
return it->second;
}
m_sensors[sinfo.get_uri()] = psensor;
}
}
-
}
void sensor_manager::create_fusion_sensors(fusion_sensor_registry_t &fsensors)