Add storeGroups/restoreGroups method to LED Manager
Use CEREAL to storeGroup/restoreGroups the current state of
asserted groups.
Call storeGroups() when the request comes to add to(remove from)
asserted group.
Call restoreGroups() as part of starting LED Manager daemon.
Tested: Manually set the Asserted property of each group to true,
after rebooting, all property values tested with the busctl command
are still true.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: Ibeb1de5f51e3d67e98eeea34764e9efc6d6d8b35
diff --git a/group.hpp b/group.hpp
index fdfcf55..7bf97c6 100644
--- a/group.hpp
+++ b/group.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "manager.hpp"
+#include "serialize.hpp"
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
@@ -31,18 +32,26 @@
/** @brief Constructs LED Group
*
* @param[in] bus - Handle to system dbus
- * @param[in] objPath - The Dbus path that hosts LED group
+ * @param[in] objPath - The D-Bus path that hosts LED group
* @param[in] manager - Reference to Manager
+ * @param[in] serialize - Serialize object
*/
Group(sdbusplus::bus::bus& bus, const std::string& objPath,
- Manager& manager) :
+ Manager& manager, Serialize& serialize) :
sdbusplus::server::object::object<
sdbusplus::xyz::openbmc_project::Led::server::Group>(
- bus, objPath.c_str()),
- path(objPath), manager(manager)
+ bus, objPath.c_str(), true),
+ path(objPath), manager(manager), serialize(serialize)
{
- // Nothing to do here
+ // Initialize Asserted property value
+ if (serialize.getGroupSavedState(objPath))
+ {
+ asserted(true);
+ }
+
+ // Emit deferred signal.
+ emit_object_added();
}
/** @brief Property SET Override function
@@ -58,6 +67,9 @@
/** @brief Reference to Manager object */
Manager& manager;
+
+ /** @brief The serialize class for storing and restoring groups of LEDs */
+ Serialize& serialize;
};
} // namespace led