Add utility for D-Bus
Putting all D-Bus related operation to the utils file.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I934e519bca43b73da01ed09fc73f6c7cdc795e1f
diff --git a/manager.hpp b/manager.hpp
index 0cc5cf6..390c8fe 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -1,8 +1,7 @@
#pragma once
#include "ledlayout.hpp"
-
-#include <sdbusplus/bus.hpp>
+#include "utils.hpp"
#include <map>
#include <set>
@@ -12,11 +11,7 @@
{
namespace led
{
-
-/** @brief Physical LED dbus constructs */
-constexpr auto PHY_LED_PATH = "/xyz/openbmc_project/led/physical/";
-constexpr auto PHY_LED_IFACE = "xyz.openbmc_project.Led.Physical";
-constexpr auto DBUS_PROPERTY_IFACE = "org.freedesktop.DBus.Properties";
+using namespace phosphor::led::utils;
/** @class Manager
* @brief Manages group of LEDs and applies action on the elements of group
@@ -117,6 +112,9 @@
/** Map of physical LED path to service name */
std::map<std::string, std::string> phyLeds{};
+ /** DBusHandler class handles the D-Bus operations */
+ DBusHandler dBusHandler;
+
/** @brief Pointers to groups that are in asserted state */
std::set<const group*> assertedGroups;
@@ -146,36 +144,6 @@
*/
void drivePhysicalLED(const std::string& objPath, Layout::Action action,
uint8_t dutyOn, const uint16_t period);
-
- /** @brief Makes a dbus call to a passed in service name.
- * This is now the physical LED controller
- *
- * @param[in] service - dbus service name
- * @param[in] objPath - dbus object path
- * @param[in] property - property to be written to
- * @param[in] value - Value to write
- */
- template <typename T>
- void drivePhysicalLED(const std::string& service,
- const std::string& objPath,
- const std::string& property, const T& value)
- {
- std::variant<T> data = value;
-
- auto method = bus.new_method_call(service.c_str(), objPath.c_str(),
- DBUS_PROPERTY_IFACE, "Set");
- method.append(PHY_LED_IFACE);
- method.append(property);
- method.append(data);
-
- // There will be exceptions going forward and hence don't need a
- // response
- bus.call_noreply(method);
- return;
- }
-
- /** @brief Populates map of Physical LED paths to service name */
- void populateObjectMap();
};
} // namespace led