diff options
author | Patrick Williams <patrick@stwcx.xyz> | 2017-05-05 15:55:24 -0500 |
---|---|---|
committer | Patrick Williams <patrick@stwcx.xyz> | 2017-05-11 03:28:41 +0000 |
commit | d32f81814d25cdcd00b46c45b13042267b0c413d (patch) | |
tree | 461588e3076e3e18bad2cd4f380d6365bbaf4237 | |
parent | 8f8ba39f4e8aac93b18d5893b4da696c7d4c76d3 (diff) | |
download | phosphor-state-manager-d32f81814d25cdcd00b46c45b13042267b0c413d.tar.gz phosphor-state-manager-d32f81814d25cdcd00b46c45b13042267b0c413d.zip |
bmc: use latest sdbusplus match APIs
Change-Id: I02aca5f8c7e633c6de7608194a0bdb0874ef2090
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
-rw-r--r-- | bmc_state_manager.cpp | 12 | ||||
-rw-r--r-- | bmc_state_manager.hpp | 50 |
2 files changed, 22 insertions, 40 deletions
diff --git a/bmc_state_manager.cpp b/bmc_state_manager.cpp index 4559c80..9929059 100644 --- a/bmc_state_manager.cpp +++ b/bmc_state_manager.cpp @@ -130,23 +130,15 @@ void BMC::executeTransition(const Transition tranReq) return; } -int BMC::bmcStateChangeSignal(sd_bus_message *msg, void *userData, - sd_bus_error *retError) -{ - return static_cast<BMC*>(userData)->bmcStateChange(msg, retError); -} - -int BMC::bmcStateChange(sd_bus_message *msg, - sd_bus_error *retError) +int BMC::bmcStateChange(sdbusplus::message::message& msg) { uint32_t newStateID {}; sdbusplus::message::object_path newStateObjPath; std::string newStateUnit{}; std::string newStateResult{}; - auto sdPlusMsg = sdbusplus::message::message(msg); //Read the msg and populate each variable - sdPlusMsg.read(newStateID, newStateObjPath, newStateUnit, newStateResult); + msg.read(newStateID, newStateObjPath, newStateUnit, newStateResult); //Caught the signal that indicates the BMC is now BMC_READY if((newStateUnit == obmcStandbyTarget) && diff --git a/bmc_state_manager.hpp b/bmc_state_manager.hpp index 0e52a25..f6f7540 100644 --- a/bmc_state_manager.hpp +++ b/bmc_state_manager.hpp @@ -1,5 +1,6 @@ #pragma once +#include <functional> #include <sdbusplus/bus.hpp> #include "xyz/openbmc_project/State/BMC/server.hpp" @@ -10,13 +11,17 @@ namespace state namespace manager { +using BMCInherit = sdbusplus::server::object::object< + sdbusplus::xyz::openbmc_project::State::server::BMC>; +namespace sdbusRule = sdbusplus::bus::match::rules; + + /** @class BMC * @brief OpenBMC BMC state management implementation. * @details A concrete implementation for xyz.openbmc_project.State.BMC * DBus API. */ -class BMC : public sdbusplus::server::object::object< - sdbusplus::xyz::openbmc_project::State::server::BMC> +class BMC : public BMCInherit { public: /** @brief Constructs BMC State Manager @@ -27,20 +32,18 @@ class BMC : public sdbusplus::server::object::object< */ BMC(sdbusplus::bus::bus& bus, const char* objPath) : - sdbusplus::server::object::object< - sdbusplus::xyz::openbmc_project::State::server::BMC>( - bus, objPath, true), - bus(bus), - stateSignal( - std::make_unique< - decltype(stateSignal)::element_type>( + BMCInherit(bus, objPath, true), + bus(bus), + stateSignal( + std::make_unique<decltype(stateSignal)::element_type>( bus, - "type='signal'," - "member='JobRemoved'," - "path='/org/freedesktop/systemd1'," - "interface='org.freedesktop.systemd1.Manager'", - bmcStateChangeSignal, - this)) + sdbusRule::type::signal() + + sdbusRule::member("JobRemoved") + + sdbusRule::path("/org/freedesktop/systemd1") + + sdbusRule::interface( + "org.freedesktop.systemd1.Manager"), + std::bind(std::mem_fn(&BMC::bmcStateChange), + this, std::placeholders::_1))) { subscribeToSystemdSignals(); discoverInitialState(); @@ -70,34 +73,21 @@ class BMC : public sdbusplus::server::object::object< */ void executeTransition(Transition tranReq); - /** @brief Callback used to direct you into the class - * - * @param[in] msg - Data associated with subscribed signal - * @param[in] userData - Pointer to this object instance - * @param[out] retError - return error data if any - * - */ - static int bmcStateChangeSignal(sd_bus_message* msg, - void* userData, - sd_bus_error* retError); - /** @brief Callback function on bmc state change * * Check if the state is relevant to the BMC and if so, update * corresponding BMC object's state * * @param[in] msg - Data associated with subscribed signal - * @param[out] retError - return error data if any * */ - int bmcStateChange(sd_bus_message* msg, - sd_bus_error* retError); + int bmcStateChange(sdbusplus::message::message& msg); /** @brief Persistent sdbusplus DBus bus connection. **/ sdbusplus::bus::bus& bus; /** @brief Used to subscribe to dbus system state changes **/ - std::unique_ptr<sdbusplus::server::match::match> stateSignal; + std::unique_ptr<sdbusplus::bus::match_t> stateSignal; }; } // namespace manager |