blob: 5e46dd8c01562518ff171ce1f7b8b2adf409358b [file] [log] [blame]
Matthew Barthcd9ab082020-04-13 13:52:49 -05001#pragma once
2
3#include <sdbusplus/bus.hpp>
4
5namespace phosphor::power::regulators::control
6{
7
8constexpr auto busName = "xyz.openbmc_project.Power.Regulators";
9constexpr auto objPath = "/xyz/openbmc_project/power/regulators/manager";
10constexpr auto interface = "xyz.openbmc_project.Power.Regulators.Manager";
11
12/**
13 * @brief Call a dbus method
14 * @param[in] method - Method name to call
15 * @param[in] args - Any needed arguments to the method
16 *
17 * @return Response message from the method call
18 */
19template <typename... Args>
20auto callMethod(const std::string& method, Args&&... args)
21{
22 auto bus = sdbusplus::bus::new_default();
23 auto reqMsg =
24 bus.new_method_call(busName, objPath, interface, method.c_str());
25 reqMsg.append(std::forward<Args>(args)...);
26
27 return bus.call(reqMsg);
28}
29
30} // namespace phosphor::power::regulators::control