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 */
asserted(bool value)14 bool Group::asserted(bool value)
15 {
16     if (customCallBack != nullptr)
17     {
18         // Custom callback method tells if the lamptest request is handled
19         // successfully or not.
20         if (customCallBack(this, value))
21         {
22             // If the lamp test request is handled successfully, update the
23             // asserted property.
24             return sdbusplus::xyz::openbmc_project::Led::server::Group::
25                 asserted(value);
26         }
27 
28         // If the lamp test request is not handled successfully, return the
29         // existing asserted value without any change.
30         return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted();
31     }
32 
33     // If the value is already what is before, return right away
34     if (value ==
35         sdbusplus::xyz::openbmc_project::Led::server::Group::asserted())
36     {
37         return value;
38     }
39 
40     // Introducing these to enable gtest.
41     ActionSet ledsAssert{};
42     ActionSet ledsDeAssert{};
43 
44     // Group management is handled by Manager. The populated leds* sets are not
45     // really used by production code. They are there to enable gtest for
46     // validation.
47     auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
48 
49     // Store asserted state
50     if (serializePtr)
51     {
52         serializePtr->storeGroups(path, result);
53     }
54 
55     // If something does not go right here, then there should be an sdbusplus
56     // exception thrown.
57     manager.driveLEDs(ledsAssert, ledsDeAssert);
58 
59     // Set the base class's asserted to 'true' since the getter
60     // operation is handled there.
61     return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
62         result);
63 }
64 
65 } // namespace led
66 } // namespace phosphor
67