dbus: transition to interface for testing
To make testing easier, the dbus objects now receive a
helper interface to use instead of calling into a helper module.
Tested: Ran on quanta-q71l board and it behaved as expected.
Change-Id: I2521d9c75aec76e92d2e26dc044d01011e44d552
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/dbus/util.cpp b/dbus/util.cpp
index 7e1f9a5..f0ffffb 100644
--- a/dbus/util.cpp
+++ b/dbus/util.cpp
@@ -9,9 +9,9 @@
/* TODO(venture): Basically all phosphor apps need this, maybe it should be a
* part of sdbusplus. There is an old version in libmapper.
*/
-std::string GetService(sdbusplus::bus::bus& bus,
- const std::string& intf,
- const std::string& path)
+std::string DbusHelper::GetService(sdbusplus::bus::bus& bus,
+ const std::string& intf,
+ const std::string& path)
{
auto mapper = bus.new_method_call(
"xyz.openbmc_project.ObjectMapper",
@@ -39,12 +39,11 @@
return response.begin()->first;
}
-void GetProperties(sdbusplus::bus::bus& bus,
- const std::string& service,
- const std::string& path,
- struct SensorProperties* prop)
+void DbusHelper::GetProperties(sdbusplus::bus::bus& bus,
+ const std::string& service,
+ const std::string& path,
+ struct SensorProperties* prop)
{
-
auto pimMsg = bus.new_method_call(service.c_str(),
path.c_str(),
propertiesintf.c_str(),
@@ -69,9 +68,12 @@
valueResponseMsg.read(propMap);
// If no error was set, the values should all be there.
- prop->unit = sdbusplus::message::variant_ns::get<std::string>(propMap["Unit"]);
- prop->scale = sdbusplus::message::variant_ns::get<int64_t>(propMap["Scale"]);
- prop->value = sdbusplus::message::variant_ns::get<int64_t>(propMap["Value"]);
+ prop->unit = sdbusplus::message::variant_ns::get<std::string>(
+ propMap["Unit"]);
+ prop->scale = sdbusplus::message::variant_ns::get<int64_t>(
+ propMap["Scale"]);
+ prop->value = sdbusplus::message::variant_ns::get<int64_t>(
+ propMap["Value"]);
return;
}