1 #pragma once 2 3 #include <string> 4 #include <sdbusplus/bus.hpp> 5 #include <sdbusplus/server/object.hpp> 6 #include "xyz/openbmc_project/Led/Physical/server.hpp" 7 namespace phosphor 8 { 9 namespace led 10 { 11 12 /** @class Physical 13 * @brief Responsible for applying actions on a particular physical LED 14 */ 15 class Physical : public sdbusplus::server::object::object< 16 sdbusplus::xyz::openbmc_project::Led::server::Physical> 17 { 18 public: 19 Physical() = delete; 20 ~Physical() = default; 21 Physical(const Physical&) = delete; 22 Physical& operator=(const Physical&) = delete; 23 Physical(Physical&&) = default; 24 Physical& operator=(Physical&&) = default; 25 26 /** @brief Constructs LED object. Argument 'true' says that we hold off 27 * from sending the signals since we need to do some house keeping and 28 * only when we finish that, we are considered active and can then 29 * broadcast the signal. 30 * 31 * @param[in] bus - system dbus handler 32 * @param[in] objPath - The Dbus path that hosts physical LED 33 * @param[in] ledPath - sysfs path where this LED is exported 34 */ 35 Physical(sdbusplus::bus::bus& bus, 36 const std::string& objPath, 37 const std::string& ledPath) : 38 39 sdbusplus::server::object::object< 40 sdbusplus::xyz::openbmc_project::Led::server::Physical>( 41 bus, objPath.c_str(), true), 42 path(ledPath) 43 { 44 // Suppose this is getting launched as part of BMC reboot, then we 45 // need to save what the micro-controller currently has. 46 setInitialState(); 47 48 // We are now ready. 49 emit_object_added(); 50 } 51 52 /** @brief Overloaded State Property Setter function 53 * 54 * @param[in] value - One of OFF / ON / BLINK 55 * @return - Success or exception thrown 56 */ 57 Action state(Action value) override; 58 59 private: 60 /** @brief File system location where this LED is exposed 61 * Typically /sys/class/leds/<Led-Name> 62 */ 63 std::string path; 64 65 /** @brief Applies the user triggered action on the LED 66 * by writing to sysfs 67 * 68 * @return None 69 */ 70 void driveLED(void); 71 72 /** @brief reads sysfs and then setsup the parameteres accordingly 73 * 74 * @return Status or exception thrown 75 */ 76 void setInitialState(void); 77 }; 78 79 } // namespace led 80 } 81