George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "../utils.hpp" |
| 4 | |
| 5 | #include <sdbusplus/bus.hpp> |
| 6 | #include <sdbusplus/server.hpp> |
| 7 | |
| 8 | namespace phosphor |
| 9 | { |
| 10 | namespace led |
| 11 | { |
| 12 | namespace Operational |
| 13 | { |
| 14 | namespace status |
| 15 | { |
| 16 | namespace monitor |
| 17 | { |
| 18 | using namespace phosphor::led::utils; |
| 19 | |
| 20 | /** @class Monitor |
| 21 | * @brief Implementation of LED handling during the change of the Functional |
| 22 | * property of the OperationalStatus interface |
| 23 | * |
| 24 | * @details This implements methods for watching OperationalStatus interface of |
| 25 | * Inventory D-Bus object and then assert corresponding LED Group |
| 26 | * D-Bus objects. |
| 27 | */ |
| 28 | class Monitor |
| 29 | { |
| 30 | public: |
| 31 | Monitor() = delete; |
| 32 | ~Monitor() = default; |
| 33 | Monitor(const Monitor&) = delete; |
| 34 | Monitor& operator=(const Monitor&) = delete; |
| 35 | Monitor(Monitor&&) = default; |
Patrick Williams | 3264244 | 2025-05-14 15:25:07 -0400 | [diff] [blame] | 36 | Monitor& operator=(Monitor&&) = delete; |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 37 | |
| 38 | /** @brief Add a watch for OperationalStatus. |
| 39 | * |
| 40 | * @param[in] bus - D-Bus object |
| 41 | */ |
Patrick Williams | 3e073ba | 2022-07-22 19:26:52 -0500 | [diff] [blame] | 42 | explicit Monitor(sdbusplus::bus_t& bus) : |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 43 | matchSignal(bus, |
| 44 | "type='signal',member='PropertiesChanged', " |
| 45 | "interface='org.freedesktop.DBus.Properties', " |
| 46 | "sender='xyz.openbmc_project.Inventory.Manager', " |
| 47 | "arg0namespace='xyz.openbmc_project.State.Decorator." |
| 48 | "OperationalStatus'", |
Patrick Williams | 3264244 | 2025-05-14 15:25:07 -0400 | [diff] [blame] | 49 | [](sdbusplus::message_t& m) { matchHandler(m); }) |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 50 | |
| 51 | {} |
| 52 | |
| 53 | private: |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 54 | /** @brief sdbusplus signal matches for Monitor */ |
| 55 | sdbusplus::bus::match_t matchSignal; |
| 56 | |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 57 | /** |
| 58 | * @brief Callback handler that gets invoked when the PropertiesChanged |
| 59 | * signal is caught by this app. Message is scanned for Inventory |
| 60 | * D-Bus object path and if OperationalStatus::Functional is changed, |
| 61 | * then corresponding LED Group D-Bus object is called to assert. |
| 62 | * |
| 63 | * @param[in] msg - The D-Bus message contents |
| 64 | */ |
Konstantin Aladyshev | fecdd4d | 2025-02-07 12:28:19 +0300 | [diff] [blame] | 65 | static void matchHandler(sdbusplus::message_t& msg); |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 66 | |
| 67 | /** |
| 68 | * @brief From the Inventory D-Bus object, obtains the associated LED group |
| 69 | * D-Bus object, where the association name is "fault_led_group" |
| 70 | * |
| 71 | * @param[in] inventoryPath - Inventory D-Bus object path |
| 72 | * |
| 73 | * @return std::vector<std::string> - Vector of LED Group D-Bus object paths |
| 74 | */ |
Patrick Williams | 275ad18 | 2025-03-03 11:19:17 -0500 | [diff] [blame] | 75 | static std::vector<std::string> getLedGroupPaths( |
| 76 | const std::string& inventoryPath); |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 77 | |
| 78 | /** |
| 79 | * @brief Update the Asserted property of the LED Group Manager. |
| 80 | * |
| 81 | * @param[in] ledGroupPaths - LED Group D-Bus object Paths |
| 82 | * @param[in] value - The Asserted property value, True / False |
| 83 | */ |
Konstantin Aladyshev | fecdd4d | 2025-02-07 12:28:19 +0300 | [diff] [blame] | 84 | static void updateAssertedProperty( |
| 85 | const std::vector<std::string>& ledGroupPaths, bool value); |
George Liu | ee1c19e | 2021-04-01 15:02:57 +0800 | [diff] [blame] | 86 | }; |
| 87 | } // namespace monitor |
| 88 | } // namespace status |
| 89 | } // namespace Operational |
| 90 | } // namespace led |
| 91 | } // namespace phosphor |