xref: /openbmc/phosphor-led-manager/manager/group.cpp (revision 5467185344a5a8c327d0c860ded34b51d939b6d6)
1 #include "config.h"
2 
3 #include "group.hpp"
4 
5 #include "ledlayout.hpp"
6 
7 #include <sdbusplus/message.hpp>
8 namespace phosphor
9 {
10 namespace led
11 {
12 
13 /** @brief Overloaded Property Setter function */
14 bool Group::asserted(bool value)
15 {
16     // If the value is already what is before, return right away
17     if (value ==
18         sdbusplus::xyz::openbmc_project::Led::server::Group::asserted())
19     {
20         return value;
21     }
22 
23     if (customCallBack != nullptr)
24     {
25         // Call the custom callback method
26         customCallBack(this, value);
27 
28         return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
29             value);
30     }
31 
32     // Introducing these to enable gtest.
33     ActionSet ledsAssert{};
34     ActionSet ledsDeAssert{};
35 
36     // Group management is handled by Manager. The populated leds* sets are not
37     // really used by production code. They are there to enable gtest for
38     // validation.
39     auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
40 
41     // Store asserted state
42     if (serializePtr)
43     {
44         serializePtr->storeGroups(path, result);
45     }
46 
47     // If something does not go right here, then there should be an sdbusplus
48     // exception thrown.
49     manager.driveLEDs(ledsAssert, ledsDeAssert);
50 
51     // Set the base class's asserted to 'true' since the getter
52     // operation is handled there.
53     return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
54         result);
55 }
56 
57 } // namespace led
58 } // namespace phosphor
59