1cd9ab087SMatthew Barth #pragma once 2cd9ab087SMatthew Barth 3cd9ab087SMatthew Barth #include <sdbusplus/bus.hpp> 48acaf547SShawn McCarney #include <sdbusplus/sdbus.hpp> 58acaf547SShawn McCarney 68acaf547SShawn McCarney #include <chrono> 7cd9ab087SMatthew Barth 8cd9ab087SMatthew Barth namespace phosphor::power::regulators::control 9cd9ab087SMatthew Barth { 10cd9ab087SMatthew Barth 11cd9ab087SMatthew Barth constexpr auto busName = "xyz.openbmc_project.Power.Regulators"; 12cd9ab087SMatthew Barth constexpr auto objPath = "/xyz/openbmc_project/power/regulators/manager"; 13cd9ab087SMatthew Barth constexpr auto interface = "xyz.openbmc_project.Power.Regulators.Manager"; 14cd9ab087SMatthew Barth 15cd9ab087SMatthew Barth /** 16cd9ab087SMatthew Barth * @brief Call a dbus method 17cd9ab087SMatthew Barth * @param[in] method - Method name to call 18cd9ab087SMatthew Barth * @param[in] args - Any needed arguments to the method 19cd9ab087SMatthew Barth * 20cd9ab087SMatthew Barth * @return Response message from the method call 21cd9ab087SMatthew Barth */ 22cd9ab087SMatthew Barth template <typename... Args> callMethod(const std::string & method,Args &&...args)23cd9ab087SMatthew Barthauto callMethod(const std::string& method, Args&&... args) 24cd9ab087SMatthew Barth { 25cd9ab087SMatthew Barth auto bus = sdbusplus::bus::new_default(); 26*f5402197SPatrick Williams auto reqMsg = 27*f5402197SPatrick Williams bus.new_method_call(busName, objPath, interface, method.c_str()); 28cd9ab087SMatthew Barth reqMsg.append(std::forward<Args>(args)...); 29cd9ab087SMatthew Barth 308acaf547SShawn McCarney // Set timeout to 6 minutes; some regulator methods take over 5 minutes 318acaf547SShawn McCarney using namespace std::chrono_literals; 328acaf547SShawn McCarney sdbusplus::SdBusDuration timeout{6min}; 338acaf547SShawn McCarney return bus.call(reqMsg, timeout); 34cd9ab087SMatthew Barth } 35cd9ab087SMatthew Barth 36cd9ab087SMatthew Barth } // namespace phosphor::power::regulators::control 37