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; 36 Monitor& operator=(Monitor&&) = delete; 37 38 /** @brief Add a watch for OperationalStatus. 39 * 40 * @param[in] bus - D-Bus object 41 */ Monitor(sdbusplus::bus_t & bus)42 explicit Monitor(sdbusplus::bus_t& bus) : 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'", 49 [](sdbusplus::message_t& m) { matchHandler(m); }) 50 51 {} 52 53 private: 54 /** @brief sdbusplus signal matches for Monitor */ 55 sdbusplus::bus::match_t matchSignal; 56 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 */ 65 static void matchHandler(sdbusplus::message_t& msg); 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 */ 75 static std::vector<std::string> getLedGroupPaths( 76 const std::string& inventoryPath); 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 */ 84 static void updateAssertedProperty( 85 const std::vector<std::string>& ledGroupPaths, bool value); 86 }; 87 } // namespace monitor 88 } // namespace status 89 } // namespace Operational 90 } // namespace led 91 } // namespace phosphor 92