blob: 33c64f67bccd538d8904dcc4c1abcbb0e99ac9af [file] [log] [blame]
George Liu2098aa62020-05-09 11:26:35 +08001#include "config.h"
2
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05303#include "group.hpp"
Patrick Venture91ac8d32018-11-01 17:03:22 -07004
5#include <sdbusplus/message.hpp>
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +05306namespace phosphor
7{
8namespace led
9{
10
11/** @brief Overloaded Property Setter function */
12bool Group::asserted(bool value)
13{
Vishwanatha Subbanna4846e922020-10-09 03:42:57 -050014 // If the value is already what is before, return right away
15 if (value ==
16 sdbusplus::xyz::openbmc_project::Led::server::Group::asserted())
17 {
18 return value;
19 }
20
George Liuc777bef2020-11-23 17:04:21 +080021 if (customCallBack != nullptr)
22 {
23 // Call the custom callback method
George Liu87fd11c2020-11-23 16:40:14 +080024 customCallBack(this, value);
George Liuc777bef2020-11-23 17:04:21 +080025
26 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
27 value);
28 }
29
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053030 // Introducing these to enable gtest.
Patrick Venture91ac8d32018-11-01 17:03:22 -070031 Manager::group ledsAssert{};
32 Manager::group ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053033
34 // Group management is handled by Manager. The populated leds* sets are not
35 // really used by production code. They are there to enable gtest for
36 // validation.
Patrick Venture91ac8d32018-11-01 17:03:22 -070037 auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053038
George Liu2098aa62020-05-09 11:26:35 +080039 // Store asserted state
40 serialize.storeGroups(path, result);
41
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053042 // If something does not go right here, then there should be an sdbusplus
43 // exception thrown.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +053044 manager.driveLEDs(ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053045
46 // Set the base class's asserted to 'true' since the getter
47 // operation is handled there.
Patrick Venture91ac8d32018-11-01 17:03:22 -070048 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
49 result);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053050}
51
52} // namespace led
53} // namespace phosphor