Use generated bindings for Led Group manager
This extends generated sdbusplus interface and provides implementation for
handling LED group operations.
Change-Id: I9e6f83f2f801de24d33937bc651228b1c0ccdc37
Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index e146a74..1557aad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -3,7 +3,9 @@
phosphor_ledmanager_SOURCES = \
led-main.cpp \
- led-manager.cpp
+ manager.cpp \
+ group.cpp \
+ xyz.openbmc_project.Led.Group.cpp
BUILT_SOURCES = led-gen.hpp
CLEANFILES = led-gen.hpp
diff --git a/configure.ac b/configure.ac
index 600571e..612c3f4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -39,10 +39,6 @@
AS_IF([test "x$OBJPATH" == "x"], [OBJPATH="/xyz/openbmc_project/ledmanager/groups"])
AC_DEFINE_UNQUOTED([OBJPATH], ["$OBJPATH"], [The Ledmanager Dbus root])
-AC_ARG_VAR(INTERFACE, [The Ledmanager Dbus interface])
-AS_IF([test "x$INTERFACE" == "x"], [INTERFACE="xyz.openbmc_project.ledmanager"])
-AC_DEFINE_UNQUOTED([INTERFACE], ["$INTERFACE"], [The Ledmanager Dbus interface])
-
# Create configured output
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/group.cpp b/group.cpp
new file mode 100644
index 0000000..8ed2ab0
--- /dev/null
+++ b/group.cpp
@@ -0,0 +1,21 @@
+#include <sdbusplus/message.hpp>
+#include "group.hpp"
+namespace phosphor
+{
+namespace led
+{
+
+/** @brief Overloaded Property Setter function */
+bool Group::asserted(bool value)
+{
+ // Group management is handled by Manager
+ auto result = manager.setGroupState(path, value);
+
+ // Set the base class's asserted to 'true' since the getter
+ // operation is handled there.
+ return sdbusplus::xyz::openbmc_project::Led::server::
+ Group::asserted(result);
+}
+
+} // namespace led
+} // namespace phosphor
diff --git a/group.hpp b/group.hpp
new file mode 100644
index 0000000..3a14dc1
--- /dev/null
+++ b/group.hpp
@@ -0,0 +1,61 @@
+#pragma once
+
+#include <sdbusplus/bus.hpp>
+#include <sdbusplus/server/object.hpp>
+#include "xyz/openbmc_project/Led/Group/server.hpp"
+#include "manager.hpp"
+namespace phosphor
+{
+namespace led
+{
+
+/** @class Group
+ * @brief Manages group of LEDs and applies action on the elements of group
+ */
+class Group : sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Led::server::Group>
+{
+ public:
+ Group() = delete;
+ ~Group() = default;
+ Group(const Group&) = delete;
+ Group& operator=(const Group&) = delete;
+ Group(Group&&) = default;
+ Group& operator=(Group&&) = default;
+
+ /** @brief Constructs LED Group
+ *
+ * @param[in] bus - Handle to system dbus
+ * @param[in] objPath - The Dbus path that hosts LED group
+ * @param[in] manager - Reference to Manager
+ */
+ Group(sdbusplus::bus::bus& bus,
+ const std::string& objPath,
+ Manager& manager) :
+
+ sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::Led::server::Group>(
+ bus, objPath.c_str()),
+ path(objPath),
+ manager(manager)
+ {
+ // Nothing to do here
+ }
+
+ /** @brief Property SET Override function
+ *
+ * @param[in] value - True or False
+ * @return - Success or exception thrown
+ */
+ bool asserted(bool value) override;
+
+ private:
+ /** @brief Path of the group instance */
+ std::string path;
+
+ /** @brief Reference to Manager object */
+ Manager& manager;
+};
+
+} // namespace led
+} // namespace phosphor
diff --git a/led-main.cpp b/led-main.cpp
index 90bba1e..8a091eb 100644
--- a/led-main.cpp
+++ b/led-main.cpp
@@ -1,9 +1,38 @@
-#include "led-manager.hpp"
+#include <iostream>
+#include "manager.hpp"
+#include "group.hpp"
#include "config.h"
int main(void)
{
- phosphor::led::Group ledMgr(BUSNAME, OBJPATH, INTERFACE);
- ledMgr.run();
+ /** @brief Group manager object */
+ phosphor::led::Manager manager;
+
+ /** @brief Dbus constructs used by LED Group manager */
+ sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
+
+ /** @brief sd_bus object manager */
+ sdbusplus::server::manager::manager objManager(bus, OBJPATH);
+
+ /** @brief vector of led groups */
+ std::vector<std::unique_ptr<phosphor::led::Group>> groups;
+
+ /** Now create so many dbus objects as there are groups */
+ for (auto &grp: phosphor::led::Manager::ledMap)
+ {
+ groups.emplace_back(std::make_unique<phosphor::led::Group>(
+ bus, grp.first, manager));
+ }
+
+ /** @brief Claim the bus */
+ bus.request_name(BUSNAME);
+
+ /** @brief Wait for client requests */
+ while(true)
+ {
+ /** @brief process dbus calls / signals discarding unhandled */
+ bus.process_discard();
+ bus.wait();
+ }
return 0;
}
diff --git a/led-manager.cpp b/led-manager.cpp
deleted file mode 100644
index bfbf426..0000000
--- a/led-manager.cpp
+++ /dev/null
@@ -1,201 +0,0 @@
-#include <iostream>
-#include <cstring>
-#include <algorithm>
-#include <sdbusplus/vtable.hpp>
-#include <sdbusplus/message.hpp>
-#include <sdbusplus/bus.hpp>
-#include "led-manager.hpp"
-#include "led-gen.hpp"
-namespace phosphor
-{
-namespace led
-{
-
-std::set<const Group::group*> Group::assertedGroups;
-Group::group Group::currentState;
-
-/** @brief Called when the group's property is read
- * Signature as needed by sd_bus
- */
-int getGroupState(sd_bus *bus, const char *path, const char *interface,
- const char *property, sd_bus_message *reply,
- void *data, sd_bus_error* error)
-{
- auto ledMgr = static_cast<Group*>(data);
- auto state = ledMgr->getGroupState(path);
-
- sd_bus_message_append(reply, "b", state);
- return 0;
-}
-
-/** @brief Called when the group's asserted state is updated
- * Signature as needed by sd_bus
- */
-int setGroupState(sd_bus *bus, const char *path, const char *interface,
- const char *property, sd_bus_message *value,
- void *data, sd_bus_error* error)
-{
- bool state {};
- auto msg = sdbusplus::message::message(value);
- sd_bus_message_ref(value);
- msg.read(state);
-
- auto ledMgr = static_cast<Group*>(data);
- return ledMgr->setGroupState(path, state);
-}
-
-// Get the asserted state
-bool Group::getGroupState(const std::string& path)
-{
- return assertedGroups.find(&ledMap.at(path)) != assertedGroups.end();
-}
-
-// Assert -or- De-assert
-int Group::setGroupState(const std::string& path, bool assert)
-{
- if (assert)
- {
- assertedGroups.insert(&ledMap.at(path));
- }
- else
- {
- auto search = assertedGroups.find(&ledMap.at(path));
- if (search != assertedGroups.end())
- {
- assertedGroups.erase(&ledMap.at(path));
- }
- else
- {
- std::cout << "Group [ " << path << " ] Not present\n";
- }
- }
- return driveLEDs();
-}
-
-// Run through the map and apply action
-int Group::driveLEDs()
-{
- // This will contain the union of what's already in the asserted group
- group desiredState {};
- for(const auto& grp : assertedGroups)
- {
- desiredState.insert(grp->cbegin(), grp->cend());
- }
-
- // Always Do execute Turn Off and then Turn on since we have the Blink
- // taking priority over -on-
- group ledsToDeAssert {};
-
- std::set_difference(currentState.begin(), currentState.end(),
- desiredState.begin(), desiredState.end(),
- std::inserter(ledsToDeAssert, ledsToDeAssert.begin()));
- if(ledsToDeAssert.size())
- {
- // We really do not want the Group Manager to know how a particular LED
- // transitions from State-A --> State-B and all this must be handled by
- // the physical LED controller implementation.
- // So in this case, Group Manager really does not want to turn off the
- // LEDs and then turning it back on and let the physical LED controller
- // handle that.
-
- // If we previously had a FRU in ON state , and then if there was a
- // request to make it blink, the end state would now be blink.
- // If we either turn off blink / fault, then we need to go back to its
- // previous state.
- group ledsToReAssert {};
- std::set_intersection(desiredState.begin(), desiredState.end(),
- ledsToDeAssert.begin(), ledsToDeAssert.end(),
- std::inserter(ledsToReAssert, ledsToReAssert.begin()),
- ledComp);
-
- if (ledsToReAssert.size())
- {
- std::cout << "Asserting LEDs again" << std::endl;
- for (const auto& it: ledsToReAssert)
- {
- std::cout << "\t{" << it.name << "::" << it.action << "}"
- << std::endl;
- }
- }
- }
-
- // Turn on these
- group ledsToAssert {};
- std::set_difference(desiredState.begin(), desiredState.end(),
- currentState.begin(), currentState.end(),
- std::inserter(ledsToAssert, ledsToAssert.begin()));
-
- if(ledsToAssert.size())
- {
- std::cout << "Asserting LEDs" << std::endl;
- for (const auto& it: ledsToAssert)
- {
- std::cout << "\t{" << it.name << "::" << it.action << "}"
- << std::endl;
- }
- }
-
- // Done.. Save the latest and greatest.
- currentState = std::move(desiredState);
-
- return 0;
-}
-
-/** @brief Users having to assert a group will just turn this property to TRUE
- * similarly, setting this property to FALSE will deassert the group
- */
-constexpr sdbusplus::vtable::vtable_t led_vtable[] =
-{
- sdbusplus::vtable::start(),
- sdbusplus::vtable::property("Asserted", "b",
- getGroupState, setGroupState,
- sdbusplus::vtable::property_::emits_change),
- sdbusplus::vtable::end()
-};
-
-/** @brief Initialize the bus and announce services */
-Group::Group(const char* busName,
- const char* objPath,
- const char* intfName) :
- bus(sdbusplus::bus::new_system()),
- objManager(bus, objPath)
-{
- /** Now create so many dbus objects as there are groups */
- for (auto &grp: Group::ledMap)
- {
- intfContainer.emplace_back(bus, grp.first.c_str(),
- intfName, led_vtable, this);
-
- // These are now set of structs having LED name and the action. Do not
- // have anything to be done here at the moment but need to create a
- // mapping between led names to device strigs eventually
- //for (auto &set: grp.second)
- //{
-
- //}
- }
- // Once done, claim the bus and systemd will
- // consider this service started
- bus.request_name(busName);
-}
-
-/** @brief Wait for client requests */
-void Group::run()
-{
- while(true)
- {
- try
- {
- bus.process_discard();
- bus.wait();
- }
- catch (std::exception &e)
- {
- std::cerr << e.what() << std::endl;
- }
- }
-}
-
-} // namespace led
-
-} // namespace phosphor
diff --git a/led-manager.hpp b/led-manager.hpp
deleted file mode 100644
index 32306bd..0000000
--- a/led-manager.hpp
+++ /dev/null
@@ -1,119 +0,0 @@
-#pragma once
-
-#include <map>
-#include <set>
-#include <vector>
-#include <sdbusplus/bus.hpp>
-#include <sdbusplus/server/interface.hpp>
-#include <sdbusplus/server/manager.hpp>
-namespace phosphor
-{
-namespace led
-{
-
-/** @class Group
- * @brief Manages group of LEDs and applies action on the elements of group
- */
-
-class Group
-{
- public:
- /** @brief Define possible actions on a given LED.
- * For the BLINK operation, follow 50-50 duty cycle
- */
- enum Action
- {
- OFF,
- ON,
- BLINK,
- };
-
- Group() = delete;
- ~Group() = default;
- Group(const Group&) = delete;
- Group& operator=(const Group&) = delete;
- Group(Group&&) = delete;
- Group& operator=(Group&&) = delete;
-
- /** @brief Constructs LED manager
- *
- * @param[in] busName - The Dbus name to own
- * @param[in] objPath - The Dbus path that hosts LED manager
- * @param[in] intfName - The Dbus interface
- */
- Group(const char* busName, const char* objPath, const char* intfName);
-
- /** @brief Name of the LED and it's proposed action.
- * This structure is supplied as configuration at build time
- */
- struct LedAction
- {
- std::string name;
- Action action;
-
- // Needed for inserting elements into sets
- bool operator<(const LedAction& right) const
- {
- if (name == right.name)
- {
- return action < right.action;
- }
- return name < right.name;
- }
- };
-
- /** @brief For finding intersection */
- static bool ledComp(const LedAction& left, const LedAction& right)
- {
- return left.name < right.name;
- }
-
- using group = std::set<LedAction>;
-
- /** @brief static global map constructed at compile time */
- static const std::map<std::string, group> ledMap;
-
- /** @brief Dbus constructs used by LED manager */
- sdbusplus::bus::bus bus;
-
- /** @brief sd_bus object manager */
- sdbusplus::server::manager::manager objManager;
-
- /** @brief Individual objects */
- std::vector<sdbusplus::server::interface::interface> intfContainer;
-
- /** @brief Pointers to groups that are in asserted state */
- static std::set<const group*> assertedGroups;
-
- /** @brief Contains the LEDs that are in asserted state */
- static group currentState;
-
- /** @brief Waits on the client request and processes them */
- void run();
-
- /** @brief Given a group name, tells if its in asserted state or not.
- *
- * @param[in] name - Group name
- * @return - Whether in asserted state or not
- */
- bool getGroupState(const std::string& name);
-
- /** @brief Given a group name, applies the action on the group
- *
- * @param[in] name - Group name
- * @param[in] assert - Could be 0 or 1
- * @return - Success or exception thrown
- */
- int setGroupState(const std::string& name, bool assert);
-
- private:
- /** @brief Finds the set of LEDs to operate on and executes action
- *
- * @return: Returns '0' for now.
- */
- int driveLEDs();
-};
-
-} // namespace led
-
-} // namespace phosphor
diff --git a/led.yaml b/led.yaml
index 0d01c96..a4e1f89 100755
--- a/led.yaml
+++ b/led.yaml
@@ -1,119 +1,119 @@
EnclosureIdentify:
EnclosureIdentifyFront:
- action: blink
+ action: Blink
EnclosureIdentifyBack:
- action: blink
+ action: Blink
EnclosureFault:
EnclosureFaultFront:
- action: 'on'
+ action: 'On'
EnclosureFaultBack:
- action: 'on'
+ action: 'On'
PowerSupply1Identify:
PowerSupply_1:
- action: blink
+ action: Blink
EnclosureIdentifyFront:
- action: 'on'
+ action: 'On'
EnclosureIdentifyBack:
- action: 'on'
+ action: 'On'
PowerSupply1Fault:
PowerSupply_1:
- action: 'on'
+ action: 'On'
EnclosureFaultFront:
- action: 'on'
+ action: 'On'
EnclosureFaultBack:
- action: 'on'
+ action: 'On'
PowerSupply2Identify:
PowerSupply_2:
- action: blink
+ action: Blink
EnclosureIdentifyFront:
- action: 'on'
+ action: 'On'
EnclosureIdentifyBack:
- action: 'on'
+ action: 'On'
PowerSupply2Fault:
PowerSupply_2:
- action: 'on'
+ action: 'On'
EnclosureFaultFront:
- action: 'on'
+ action: 'On'
EnclosureFaultBack:
- action: 'on'
+ action: 'On'
FanA1Identify:
Fan_A1:
- action: blink
+ action: Blink
EnclosureIdentifyFront:
- action: 'on'
+ action: 'On'
EnclosureIdentifyBack:
- action: 'on'
+ action: 'On'
FanA1Fault:
Fan_A1:
- action: 'on'
+ action: 'On'
EnclosureFaultFront:
- action: 'on'
+ action: 'On'
EnclosureFaultBack:
- action: 'on'
+ action: 'On'
FanA2Identify:
Fan_A2:
- action: blink
+ action: Blink
EnclosureIdentifyFront:
- action: 'on'
+ action: 'On'
EnclosureIdentifyBack:
- action: 'on'
+ action: 'On'
FanA2Fault:
Fan_A2:
- action: 'on'
+ action: 'On'
EnclosureFaultFront:
- action: 'on'
+ action: 'On'
EnclosureFaultBack:
- action: 'on'
+ action: 'On'
FanA3Identify:
Fan_A3:
- action: blink
+ action: Blink
EnclosureIdentifyFront:
- action: 'on'
+ action: 'On'
EnclosureIdentifyBack:
- action: 'on'
+ action: 'On'
FanA3Fault:
Fan_A3:
- action: 'on'
+ action: 'On'
EnclosureFaultFront:
- action: 'on'
+ action: 'On'
EnclosureFaultBack:
- action: 'on'
+ action: 'On'
FanA4Identify:
Fan_A4:
- action: blink
+ action: Blink
EnclosureIdentifyFront:
- action: 'on'
+ action: 'On'
EnclosureIdentifyBack:
- action: 'on'
+ action: 'On'
FanA4Fault:
Fan_A4:
- action: 'on'
+ action: 'On'
EnclosureFaultFront:
- action: 'on'
+ action: 'On'
EnclosureFaultBack:
- action: 'on'
+ action: 'On'
PowerOn:
OpPanelFront:
- action: 'on'
- PanelPowerButtonNote1:
- action: 'on'
+ action: 'On'
+ PanelPowerButtOnNote1:
+ action: 'On'
PowerOff:
OpPanelFront:
- action: blink
- PanelPowerButtonNote1:
- action: blink
+ action: Blink
+ PanelPowerButtOnNote1:
+ action: Blink
diff --git a/manager.cpp b/manager.cpp
new file mode 100644
index 0000000..8ed9852
--- /dev/null
+++ b/manager.cpp
@@ -0,0 +1,112 @@
+#include <iostream>
+#include <string>
+#include <algorithm>
+#include "manager.hpp"
+#include "led-gen.hpp"
+namespace phosphor
+{
+namespace led
+{
+
+// Assert -or- De-assert
+bool Manager::setGroupState(const std::string& path, bool assert)
+{
+ if (assert)
+ {
+ assertedGroups.insert(&ledMap.at(path));
+ }
+ else
+ {
+ auto search = assertedGroups.find(&ledMap.at(path));
+ if (search != assertedGroups.end())
+ {
+ assertedGroups.erase(&ledMap.at(path));
+ }
+ }
+ // If something does not go right here, then there should be an sdbusplus
+ // exception thrown.
+ driveLEDs();
+
+ // If we survive, then set the state accordingly.
+ return assert;
+}
+
+/** @brief Run through the map and apply action on the LEDs */
+void Manager::driveLEDs()
+{
+ // This will contain the union of what's already in the asserted group
+ group desiredState {};
+ for(const auto& grp : assertedGroups)
+ {
+ desiredState.insert(grp->cbegin(), grp->cend());
+ }
+
+ // Always Do execute Turn Off and then Turn on since we have the Blink
+ // taking priority over -on-
+ group ledsToDeAssert {};
+
+ std::set_difference(currentState.begin(), currentState.end(),
+ desiredState.begin(), desiredState.end(),
+ std::inserter(ledsToDeAssert, ledsToDeAssert.begin()));
+
+ if(ledsToDeAssert.size())
+ {
+ // We really do not want the Manager to know how a particular LED
+ // transitions from State-A --> State-B and all this must be handled by
+ // the physical LED controller implementation.
+ // So in this case, Manager really does not want to turn off the
+ // LEDs and then turning it back on and let the physical LED controller
+ // handle that.
+
+ // I am still experimenting on the algo..
+ std::cout << "De asserting the LEDs" << std::endl;
+ for (const auto& it: ledsToDeAssert)
+ {
+ std::cout << "\t{" << it.name << "::" << it.action << "}"
+ << std::endl;
+ }
+
+ // If we previously had a FRU in ON state , and then if there was a
+ // request to make it blink, the end state would now be blink.
+ // If we either turn off blink / fault, then we need to go back to its
+ // previous state.
+ group ledsToReAssert {};
+ std::set_intersection(desiredState.begin(), desiredState.end(),
+ ledsToDeAssert.begin(), ledsToDeAssert.end(),
+ std::inserter(ledsToReAssert, ledsToReAssert.begin()),
+ ledComp);
+
+ if (ledsToReAssert.size())
+ {
+ std::cout << "Asserting LEDs again" << std::endl;
+ for (const auto& it: ledsToReAssert)
+ {
+ std::cout << "\t{" << it.name << "::" << it.action << "}"
+ << std::endl;
+ }
+ }
+ }
+
+ // Turn on these
+ group ledsToAssert {};
+ std::set_difference(desiredState.begin(), desiredState.end(),
+ currentState.begin(), currentState.end(),
+ std::inserter(ledsToAssert, ledsToAssert.begin()));
+
+ if(ledsToAssert.size())
+ {
+ std::cout << "Asserting LEDs" << std::endl;
+ for (const auto& it: ledsToAssert)
+ {
+ std::cout << "\t{" << it.name << "::" << it.action << "}"
+ << std::endl;
+ }
+ }
+
+ // Done.. Save the latest and greatest.
+ currentState = std::move(desiredState);
+ return;
+}
+
+} // namespace led
+} // namespace phosphor
diff --git a/manager.hpp b/manager.hpp
new file mode 100644
index 0000000..9e32216
--- /dev/null
+++ b/manager.hpp
@@ -0,0 +1,87 @@
+#pragma once
+
+#include <map>
+#include <set>
+namespace phosphor
+{
+namespace led
+{
+
+/** @class Manager
+ * @brief Manages group of LEDs and applies action on the elements of group
+ */
+class Manager
+{
+ public:
+ /** @brief Define possible actions on a given LED.
+ * For the BLINK operation, follow 50-50 duty cycle
+ */
+ enum Action
+ {
+ Off,
+ On,
+ Blink,
+ };
+
+ /** @brief Only need the default Manager */
+ Manager() = default;
+ ~Manager() = default;
+ Manager(const Manager&) = delete;
+ Manager& operator=(const Manager&) = delete;
+ Manager(Manager&&) = delete;
+ Manager& operator=(Manager&&) = delete;
+
+ /** @brief Name of the LED and it's proposed action.
+ * This structure is supplied as configuration at build time
+ */
+ struct LedAction
+ {
+ std::string name;
+ Action action;
+
+ // Needed for inserting elements into sets
+ bool operator<(const LedAction& right) const
+ {
+ if (name == right.name)
+ {
+ return action < right.action;
+ }
+ return name < right.name;
+ }
+ };
+
+ /** @brief For finding intersection */
+ static bool ledComp(const LedAction& left, const LedAction& right)
+ {
+ return left.name < right.name;
+ }
+
+ using group = std::set<LedAction>;
+
+ /** @brief static global map constructed at compile time */
+ static const std::map<std::string, group> ledMap;
+
+ /** @brief Given a group name, applies the action on the group
+ *
+ * @param[in] path - dbus path of group
+ * @param[in] assert - Could be true or false
+ * @return - Success or exception thrown
+ */
+ bool setGroupState(const std::string& path, bool assert);
+
+ private:
+ /** @brief Pointers to groups that are in asserted state */
+ std::set<const group*> assertedGroups;
+
+ /** @brief Contains the LEDs that are in asserted state */
+ group currentState;
+
+ /** @brief Finds the set of LEDs to operate on and executes action
+ *
+ * @return: None
+ */
+ void driveLEDs();
+};
+
+} // namespace led
+} // namespace phosphor
diff --git a/parse_led.py b/parse_led.py
index 7f212ea..ea58876 100755
--- a/parse_led.py
+++ b/parse_led.py
@@ -12,8 +12,8 @@
ofile.write('Please do NOT Edit !!! */\n\n')
ofile.write('const std::map<std::string,')
- ofile.write(' std::set<phosphor::led::Group::LedAction>>')
- ofile.write(' phosphor::led::Group::ledMap = {\n\n')
+ ofile.write(' std::set<phosphor::led::Manager::LedAction>>')
+ ofile.write(' phosphor::led::Manager::ledMap = {\n\n')
for group in ifile.iterkeys():
# Value of this group is a std::set<string, led structure>
ledset = ifile[group]
@@ -23,7 +23,7 @@
for name, value in list_dict.iteritems():
if group and led_dict and name and value:
ofile.write(' {\"' + led_dict + '\",')
- ofile.write(value.upper() + '},\n')
+ ofile.write(value + '},\n')
ofile.write(' }},\n')
ofile.write('};\n')
diff --git a/xyz.openbmc_project.Led.Group.cpp b/xyz.openbmc_project.Led.Group.cpp
new file mode 100644
index 0000000..cd32b4b
--- /dev/null
+++ b/xyz.openbmc_project.Led.Group.cpp
@@ -0,0 +1,117 @@
+#include <algorithm>
+#include <sdbusplus/server.hpp>
+#include <sdbusplus/exception.hpp>
+#include "xyz/openbmc_project/Led/Group/server.hpp"
+
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Led
+{
+namespace server
+{
+
+Group::Group(bus::bus& bus, const char* path)
+ : _xyz_openbmc_project_Led_Group_interface(
+ bus, path, _interface, _vtable, this)
+{
+}
+
+
+
+auto Group::asserted() const ->
+ bool
+{
+ return _asserted;
+}
+
+int Group::_callback_get_Asserted(
+ sd_bus* bus, const char* path, const char* interface,
+ const char* property, sd_bus_message* reply, void* context,
+ sd_bus_error* error)
+{
+ using sdbusplus::server::binding::details::convertForMessage;
+
+ try
+ {
+ auto m = message::message(sd_bus_message_ref(reply));
+
+ auto o = static_cast<Group*>(context);
+ m.append(convertForMessage(o->asserted()));
+ }
+ catch(sdbusplus::internal_exception_t& e)
+ {
+ sd_bus_error_set_const(error, e.name(), e.description());
+ return -EINVAL;
+ }
+
+ return true;
+}
+
+auto Group::asserted(bool value) ->
+ bool
+{
+ if (_asserted != value)
+ {
+ _asserted = value;
+ _xyz_openbmc_project_Led_Group_interface.property_changed("Asserted");
+ }
+
+ return _asserted;
+}
+
+int Group::_callback_set_Asserted(
+ sd_bus* bus, const char* path, const char* interface,
+ const char* property, sd_bus_message* value, void* context,
+ sd_bus_error* error)
+{
+ try
+ {
+ auto m = message::message(sd_bus_message_ref(value));
+
+ auto o = static_cast<Group*>(context);
+
+ bool v{};
+ m.read(v);
+ o->asserted(v);
+ }
+ catch(sdbusplus::internal_exception_t& e)
+ {
+ sd_bus_error_set_const(error, e.name(), e.description());
+ return -EINVAL;
+ }
+
+ return true;
+}
+
+namespace details
+{
+namespace Group
+{
+static const auto _property_Asserted =
+ utility::tuple_to_array(message::types::type_id<
+ bool>());
+}
+}
+
+
+const vtable::vtable_t Group::_vtable[] = {
+ vtable::start(),
+ vtable::property("Asserted",
+ details::Group::_property_Asserted
+ .data(),
+ _callback_get_Asserted,
+ _callback_set_Asserted,
+ vtable::property_::emits_change),
+ vtable::end()
+};
+
+} // namespace server
+} // namespace Led
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+
diff --git a/xyz/openbmc_project/Led/Group/server.hpp b/xyz/openbmc_project/Led/Group/server.hpp
new file mode 100644
index 0000000..9f5a796
--- /dev/null
+++ b/xyz/openbmc_project/Led/Group/server.hpp
@@ -0,0 +1,77 @@
+#pragma once
+#include <tuple>
+#include <systemd/sd-bus.h>
+#include <sdbusplus/server.hpp>
+
+namespace sdbusplus
+{
+namespace xyz
+{
+namespace openbmc_project
+{
+namespace Led
+{
+namespace server
+{
+
+class Group
+{
+ public:
+ /* Define all of the basic class operations:
+ * Not allowed:
+ * - Default constructor to avoid nullptrs.
+ * - Copy operations due to internal unique_ptr.
+ * Allowed:
+ * - Move operations.
+ * - Destructor.
+ */
+ Group() = delete;
+ Group(const Group&) = delete;
+ Group& operator=(const Group&) = delete;
+ Group(Group&&) = default;
+ Group& operator=(Group&&) = default;
+ virtual ~Group() = default;
+
+ /** @brief Constructor to put object onto bus at a dbus path.
+ * @param[in] bus - Bus to attach to.
+ * @param[in] path - Path to attach at.
+ */
+ Group(bus::bus& bus, const char* path);
+
+
+
+
+ /** Get value of Asserted */
+ virtual bool asserted() const;
+ /** Set value of Asserted */
+ virtual bool asserted(bool value);
+
+
+ private:
+
+ /** @brief sd-bus callback for get-property 'Asserted' */
+ static int _callback_get_Asserted(
+ sd_bus*, const char*, const char*, const char*,
+ sd_bus_message*, void*, sd_bus_error*);
+ /** @brief sd-bus callback for set-property 'Asserted' */
+ static int _callback_set_Asserted(
+ sd_bus*, const char*, const char*, const char*,
+ sd_bus_message*, void*, sd_bus_error*);
+
+
+ static constexpr auto _interface = "xyz.openbmc_project.Led.Group";
+ static const vtable::vtable_t _vtable[];
+ sdbusplus::server::interface::interface
+ _xyz_openbmc_project_Led_Group_interface;
+
+ bool _asserted{};
+
+};
+
+
+} // namespace server
+} // namespace Led
+} // namespace openbmc_project
+} // namespace xyz
+} // namespace sdbusplus
+