blob: 92927700bffcc93596cec7abeda41bd2009d0a9c [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
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053021 // Introducing these to enable gtest.
Patrick Venture91ac8d32018-11-01 17:03:22 -070022 Manager::group ledsAssert{};
23 Manager::group ledsDeAssert{};
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053024
25 // Group management is handled by Manager. The populated leds* sets are not
26 // really used by production code. They are there to enable gtest for
27 // validation.
Patrick Venture91ac8d32018-11-01 17:03:22 -070028 auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert);
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053029
George Liu2098aa62020-05-09 11:26:35 +080030 // Store asserted state
31 serialize.storeGroups(path, result);
32
Vishwanatha Subbannaed490732016-12-20 15:59:29 +053033 // If something does not go right here, then there should be an sdbusplus
34 // exception thrown.
Vishwanatha Subbanna4b000d82017-05-03 18:44:16 +053035 manager.driveLEDs(ledsAssert, ledsDeAssert);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053036
37 // Set the base class's asserted to 'true' since the getter
38 // operation is handled there.
Patrick Venture91ac8d32018-11-01 17:03:22 -070039 return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted(
40 result);
Vishwanatha Subbanna4c8c72b2016-11-29 23:02:06 +053041}
42
43} // namespace led
44} // namespace phosphor