diff options
-rw-r--r-- | bmc_state_manager.cpp | 40 | ||||
-rw-r--r-- | bmc_state_manager.hpp | 22 |
2 files changed, 61 insertions, 1 deletions
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp index 6eeec58..c739ae0 100644 --- a/bmc_state_manager.cpp +++ b/bmc_state_manager.cpp @@ -1,4 +1,5 @@ #include <iostream> +#include <log.hpp> #include "bmc_state_manager.hpp" namespace phosphor @@ -8,6 +9,45 @@ namespace state namespace manager { +// When you see server:: you know we're referencing our base class +namespace server = sdbusplus::xyz::openbmc_project::State::server; + +using namespace phosphor::logging; + +constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1"; +constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1"; +constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager"; + +void BMC::subscribeToSystemdSignals() +{ + auto method = this->bus.new_method_call(SYSTEMD_SERVICE, + SYSTEMD_OBJ_PATH, + SYSTEMD_INTERFACE, + "Subscribe"); + this->bus.call(method); + + return; +} + +BMC::Transition BMC::requestedBMCTransition(Transition value) +{ + log<level::INFO>( + "Setting the RequestedBMCTransition field", + entry("REQUESTED_BMC_TRANSITION=0x%s", + convertForMessage(value).c_str())); + return server::BMC::requestedBMCTransition(value); +} + +BMC::BMCState BMC::currentBMCState(BMCState value) +{ + log<level::INFO>( + "Setting the BMCState field", + entry("CURRENT_BMC_STATE=0x%s", + convertForMessage(value).c_str())); + return server::BMC::currentBMCState(value); +} + + } // namespace manager } // namespace state } // namepsace phosphor diff --git a/bmc_state_manager.hpp b/bmc_state_manager.hpp index 6b1f62d..be88ba8 100644 --- a/bmc_state_manager.hpp +++ b/bmc_state_manager.hpp @@ -29,7 +29,27 @@ class BMC : public sdbusplus::server::object::object< const char* objPath) : sdbusplus::server::object::object< sdbusplus::xyz::openbmc_project::State::server::BMC>( - bus, objPath) {}; + bus, objPath), + bus(bus) + { + subscribeToSystemdSignals(); + }; + + /** @brief Set value of BMCTransition **/ + Transition requestedBMCTransition(Transition value) override; + + /** @breif Set value of CurrentBMCState **/ + BMCState currentBMCState(BMCState value) override; + + private: + /** + * @brief subscribe to the systemd signals + **/ + void subscribeToSystemdSignals(); + + /** @brief Persistent sdbusplus DBus bus connection. **/ + sdbusplus::bus::bus& bus; + }; |