blob: 873b4bee64e49609d3ed9a5bd538e5c5fd94b306 [file] [log] [blame]
George Liuee1c19e2021-04-01 15:02:57 +08001#pragma once
2
3#include "../utils.hpp"
4
5#include <sdbusplus/bus.hpp>
6#include <sdbusplus/server.hpp>
7
8namespace phosphor
9{
10namespace led
11{
12namespace Operational
13{
14namespace status
15{
16namespace monitor
17{
18using 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 */
28class 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 Williams32642442025-05-14 15:25:07 -040036 Monitor& operator=(Monitor&&) = delete;
George Liuee1c19e2021-04-01 15:02:57 +080037
38 /** @brief Add a watch for OperationalStatus.
39 *
40 * @param[in] bus - D-Bus object
41 */
Patrick Williams3e073ba2022-07-22 19:26:52 -050042 explicit Monitor(sdbusplus::bus_t& bus) :
George Liuee1c19e2021-04-01 15:02:57 +080043 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 Williams32642442025-05-14 15:25:07 -040049 [](sdbusplus::message_t& m) { matchHandler(m); })
George Liuee1c19e2021-04-01 15:02:57 +080050
51 {}
52
53 private:
George Liuee1c19e2021-04-01 15:02:57 +080054 /** @brief sdbusplus signal matches for Monitor */
55 sdbusplus::bus::match_t matchSignal;
56
George Liuee1c19e2021-04-01 15:02:57 +080057 /**
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 Aladyshevfecdd4d2025-02-07 12:28:19 +030065 static void matchHandler(sdbusplus::message_t& msg);
George Liuee1c19e2021-04-01 15:02:57 +080066
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 Williams275ad182025-03-03 11:19:17 -050075 static std::vector<std::string> getLedGroupPaths(
76 const std::string& inventoryPath);
George Liuee1c19e2021-04-01 15:02:57 +080077
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 Aladyshevfecdd4d2025-02-07 12:28:19 +030084 static void updateAssertedProperty(
85 const std::vector<std::string>& ledGroupPaths, bool value);
George Liuee1c19e2021-04-01 15:02:57 +080086};
87} // namespace monitor
88} // namespace status
89} // namespace Operational
90} // namespace led
91} // namespace phosphor