George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 3 | #include "group.hpp" |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 4 | |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 5 | #include "ledlayout.hpp" |
| 6 | |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 7 | #include <sdbusplus/message.hpp> |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 8 | namespace phosphor |
| 9 | { |
| 10 | namespace led |
| 11 | { |
| 12 | |
| 13 | /** @brief Overloaded Property Setter function */ |
| 14 | bool Group::asserted(bool value) |
| 15 | { |
PriyangaRamasamy | 180090c | 2022-10-10 10:50:52 +0530 | [diff] [blame] | 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 | |
Vishwanatha Subbanna | 4846e92 | 2020-10-09 03:42:57 -0500 | [diff] [blame] | 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 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 40 | // Introducing these to enable gtest. |
Patrick Williams | 158b2c1 | 2022-03-17 05:57:44 -0500 | [diff] [blame] | 41 | ActionSet ledsAssert{}; |
| 42 | ActionSet ledsDeAssert{}; |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 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. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 47 | auto result = manager.setGroupState(path, value, ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 48 | |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 49 | // Store asserted state |
George Liu | 5467185 | 2023-10-30 09:09:39 +0800 | [diff] [blame] | 50 | if (serializePtr) |
| 51 | { |
| 52 | serializePtr->storeGroups(path, result); |
| 53 | } |
George Liu | 2098aa6 | 2020-05-09 11:26:35 +0800 | [diff] [blame] | 54 | |
Vishwanatha Subbanna | ed49073 | 2016-12-20 15:59:29 +0530 | [diff] [blame] | 55 | // If something does not go right here, then there should be an sdbusplus |
| 56 | // exception thrown. |
Vishwanatha Subbanna | 4b000d8 | 2017-05-03 18:44:16 +0530 | [diff] [blame] | 57 | manager.driveLEDs(ledsAssert, ledsDeAssert); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 58 | |
| 59 | // Set the base class's asserted to 'true' since the getter |
| 60 | // operation is handled there. |
Patrick Venture | 91ac8d3 | 2018-11-01 17:03:22 -0700 | [diff] [blame] | 61 | return sdbusplus::xyz::openbmc_project::Led::server::Group::asserted( |
| 62 | result); |
Vishwanatha Subbanna | 4c8c72b | 2016-11-29 23:02:06 +0530 | [diff] [blame] | 63 | } |
| 64 | |
| 65 | } // namespace led |
| 66 | } // namespace phosphor |