Added asynchronous callDbusMethod
This path added two callDbusMethod methods, one without method return
value (default return ec), and the other with method return value.
Change-Id: I16503fe24adc0f3896a861972751d532b6361ef9
Signed-off-by: George Liu <liuxiwei@ieisystem.com>
diff --git a/include/ipmid/utils.hpp b/include/ipmid/utils.hpp
index c099da0..4547dc0 100644
--- a/include/ipmid/utils.hpp
+++ b/include/ipmid/utils.hpp
@@ -4,6 +4,7 @@
#include <ipmid/api-types.hpp>
#include <ipmid/message.hpp>
#include <ipmid/types.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/server.hpp>
#include <chrono>
@@ -468,6 +469,31 @@
} // namespace method_no_args
+template <typename... InputArgs>
+boost::system::error_code callDbusMethod(
+ ipmi::Context::ptr ctx, const std::string& service,
+ const std::string& objPath, const std::string& interface,
+ const std::string& method, const InputArgs&... args)
+{
+ boost::system::error_code ec;
+ ctx->bus->yield_method_call(ctx->yield, ec, service, objPath, interface,
+ method, args...);
+
+ return ec;
+}
+
+template <typename RetType, typename... InputArgs>
+RetType callDbusMethod(ipmi::Context::ptr ctx, boost::system::error_code& ec,
+ const std::string& service, const std::string& objPath,
+ const std::string& interface, const std::string& method,
+ const InputArgs&... args)
+{
+ auto rc = ctx->bus->yield_method_call<RetType>(
+ ctx->yield, ec, service, objPath, interface, method, args...);
+
+ return rc;
+}
+
/** @brief Perform the low-level i2c bus write-read.
* @param[in] i2cBus - i2c bus device node name, such as /dev/i2c-2.
* @param[in] targetAddr - i2c device target address.