From 56d7c3a6a1e081dde58ebee6e318a164e9c588ef Mon Sep 17 00:00:00 2001 From: "kibak.yoon" Date: Wed, 12 Apr 2017 00:32:56 +0900 Subject: [PATCH] sensord: check URI to find the matched sensor Change-Id: Ib6d0364fd7036c295129872b7db79f0bd8f40685 Signed-off-by: kibak.yoon --- src/client/sensor_manager.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/client/sensor_manager.cpp b/src/client/sensor_manager.cpp index 9a93cb5..74ed6c7 100644 --- a/src/client/sensor_manager.cpp +++ b/src/client/sensor_manager.cpp @@ -272,8 +272,12 @@ sensor_info *sensor_manager::get_info(const char *uri) return &m_infos[0]; for (auto it = m_infos.begin(); it != m_infos.end(); ++it) { - if ((*it).get_uri() == uri) - return &*it; + std::size_t found = (*it).get_uri().rfind(uri); + + if (found == std::string::npos) + continue; + + return &*it; } return NULL; @@ -288,8 +292,12 @@ std::vector sensor_manager::get_infos(const char *uri) all = true; for (auto it = m_infos.begin(); it != m_infos.end(); ++it) { - if (all || (*it).get_type_uri() == uri) - infos.push_back(&*it); + std::size_t found = (*it).get_uri().rfind(uri); + + if (!all && found == std::string::npos) + continue; + + infos.push_back(&*it); } return infos; -- 2.7.4