summaryrefslogtreecommitdiffstats
path: root/presence
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-06-08 12:12:53 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-07-08 16:52:38 -0400
commitec613db1206ffedc78971098a2567b88e532c5b6 (patch)
tree936b365bfff1c334b211dcb23950ee8b480c1117 /presence
parent6e9cfdb7cc15539bc7e7589c8284c4e2eebf08fe (diff)
downloadphosphor-fan-presence-ec613db1206ffedc78971098a2567b88e532c5b6.tar.gz
phosphor-fan-presence-ec613db1206ffedc78971098a2567b88e532c5b6.zip
presence: Use new sdbusplus wrapper
Use the sdbusplus wrapper methods introduced previously. Change-Id: Ifd431753e9513436a9b5ab98cc49d907a5929c20 Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'presence')
-rw-r--r--presence/fan_enclosure.cpp28
-rw-r--r--presence/fan_enclosure.hpp9
-rw-r--r--presence/tach_detect.cpp15
-rw-r--r--presence/tach_sensor.hpp9
4 files changed, 19 insertions, 42 deletions
diff --git a/presence/fan_enclosure.cpp b/presence/fan_enclosure.cpp
index 7b412bd..0d19e60 100644
--- a/presence/fan_enclosure.cpp
+++ b/presence/fan_enclosure.cpp
@@ -16,6 +16,7 @@
#include <algorithm>
#include <phosphor-logging/log.hpp>
#include "fan_enclosure.hpp"
+#include "sdbusplus.hpp"
#include "utility.hpp"
namespace phosphor
@@ -26,10 +27,11 @@ namespace presence
{
using namespace phosphor::logging;
+using namespace std::literals::string_literals;
//TODO Should get these from phosphor-inventory-manager config.h
-constexpr auto INVENTORY_PATH = "/xyz/openbmc_project/inventory";
-constexpr auto INVENTORY_INTF = "xyz.openbmc_project.Inventory.Manager";
+const auto INVENTORY_PATH = "/xyz/openbmc_project/inventory"s;
+const auto INVENTORY_INTF = "xyz.openbmc_project.Inventory.Manager"s;
presenceState FanEnclosure::getCurPresState()
{
@@ -63,24 +65,12 @@ void FanEnclosure::updInventory()
// Only update inventory when presence state changed
if (presState != curPresState)
{
- // Get inventory object for this fan
- ObjectMap invObj = getObjectMap(curPresState);
- // Get inventory manager service name from mapper
- std::string invService;
- invService = phosphor::fan::util::getInvService(bus);
// Update inventory for this fan
- auto invMsg = bus.new_method_call(invService.c_str(),
- INVENTORY_PATH,
- INVENTORY_INTF,
- "Notify");
- invMsg.append(std::move(invObj));
- auto invMgrResponseMsg = bus.call(invMsg);
- if (invMgrResponseMsg.is_method_error())
- {
- log<level::ERR>(
- "Error in inventory manager call to update inventory");
- return;
- }
+ util::SDBusPlus::lookupAndCallMethod(
+ INVENTORY_PATH,
+ INVENTORY_INTF,
+ "Notify"s,
+ getObjectMap(curPresState));
// Inventory updated, set presence state to current
presState = curPresState;
}
diff --git a/presence/fan_enclosure.hpp b/presence/fan_enclosure.hpp
index 8f5cfdf..8e6925a 100644
--- a/presence/fan_enclosure.hpp
+++ b/presence/fan_enclosure.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <sdbusplus/bus.hpp>
#include "fan_properties.hpp"
+#include "sdbusplus.hpp"
#include "sensor_base.hpp"
@@ -53,12 +53,9 @@ class FanEnclosure
/**
* @brief Constructs Fan Enclosure Object
*
- * @param[in] bus - Dbus bus object
* @param[in] fanProp - Fan enclosure properties
*/
- FanEnclosure(sdbusplus::bus::bus& bus,
- const phosphor::fan::Properties& fanProp) :
- bus(bus),
+ explicit FanEnclosure(const phosphor::fan::Properties& fanProp) :
invPath(std::get<0>(fanProp)),
fanDesc(std::get<1>(fanProp))
{
@@ -80,8 +77,6 @@ class FanEnclosure
std::unique_ptr<Sensor>&& sensor);
private:
- /** @brief Connection for sdbusplus bus */
- sdbusplus::bus::bus& bus;
/** @brief Inventory path for this fan enclosure */
const std::string invPath;
/** @brief Description used as 'PrettyName' on inventory object */
diff --git a/presence/tach_detect.cpp b/presence/tach_detect.cpp
index 2449f82..dc6356a 100644
--- a/presence/tach_detect.cpp
+++ b/presence/tach_detect.cpp
@@ -14,16 +14,14 @@
* limitations under the License.
*/
#include <vector>
-#include <sdbusplus/bus.hpp>
#include "fan_enclosure.hpp"
#include "fan_detect_defs.hpp"
+#include "sdbusplus.hpp"
#include "tach_sensor.hpp"
int main(void)
{
- auto bus = sdbusplus::bus::new_default();
-
std::vector<std::unique_ptr<phosphor::fan::presence::FanEnclosure>> fans;
for (auto const& detectMap: fanDetectMap)
@@ -33,13 +31,11 @@ int main(void)
for (auto const& fanProp: detectMap.second)
{
auto fan = std::make_unique<
- phosphor::fan::presence::FanEnclosure>(bus,
- fanProp);
+ phosphor::fan::presence::FanEnclosure>(fanProp);
for (auto const &fanSensor: std::get<2>(fanProp))
{
auto sensor = std::make_unique<
- phosphor::fan::presence::TachSensor>(bus,
- fanSensor,
+ phosphor::fan::presence::TachSensor>(fanSensor,
*fan);
fan->addSensor(std::move(sensor));
}
@@ -50,9 +46,10 @@ int main(void)
while (true)
{
+ using namespace phosphor::fan::util;
// Respond to dbus signals
- bus.process_discard();
- bus.wait();
+ SDBusPlus::getBus().process_discard();
+ SDBusPlus::getBus().wait();
}
return 0;
}
diff --git a/presence/tach_sensor.hpp b/presence/tach_sensor.hpp
index 3de5d69..47d2098 100644
--- a/presence/tach_sensor.hpp
+++ b/presence/tach_sensor.hpp
@@ -1,7 +1,7 @@
#pragma once
-#include <sdbusplus/bus.hpp>
#include <sdbusplus/server.hpp>
+#include "sdbusplus.hpp"
#include "sensor_base.hpp"
@@ -33,17 +33,14 @@ class TachSensor : public Sensor
/**
* @brief Constructs Tach Sensor Object
*
- * @param[in] bus - Dbus bus object
* @param[in] id - ID name of this sensor
* @param[in] fanEnc - Reference to the fan enclosure with this sensor
*/
TachSensor(
- sdbusplus::bus::bus& bus,
const std::string& id,
FanEnclosure& fanEnc) :
Sensor(id, fanEnc),
- bus(bus),
- tachSignal(bus,
+ tachSignal(util::SDBusPlus::getBus(),
match(id).c_str(),
std::bind(
std::mem_fn(&TachSensor::handleTachChange),
@@ -61,8 +58,6 @@ class TachSensor : public Sensor
bool isPresent();
private:
- /** @brief Connection for sdbusplus bus */
- sdbusplus::bus::bus& bus;
/** @brief Used to subscribe to dbus signals */
sdbusplus::server::match::match tachSignal;
/** @brief Tach speed value given from the signal */
OpenPOWER on IntegriCloud