summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishwanatha Subbanna <vishwa@linux.vnet.ibm.com>2017-03-10 14:39:20 +0530
committerPatrick Williams <patrick@stwcx.xyz>2017-03-24 20:25:35 +0000
commit4fa924801a0b751d4e59c1d2fd59a8f578590088 (patch)
tree9f561aa737f89cfb1503e7ad2ce2f56e340bf1d5
parent76f58348314324aa06aac8b0cfe13c756ed58730 (diff)
downloadphosphor-led-manager-4fa924801a0b751d4e59c1d2fd59a8f578590088.zip
phosphor-led-manager-4fa924801a0b751d4e59c1d2fd59a8f578590088.tar.gz
Use physical LED actions from generated code
Today's code returned a hardcoded string for physical LED action and this patch uses the generated string for the passed in action enum Fixes openbmc/phosphor-led-manager#2 Change-Id: I960e2d4346966caee526e1a0e8713e18d34b428a Signed-off-by: Vishwanatha Subbanna <vishwa@linux.vnet.ibm.com>
-rw-r--r--manager.cpp16
-rw-r--r--manager.hpp2
-rw-r--r--test/Makefile.am2
3 files changed, 12 insertions, 8 deletions
diff --git a/manager.cpp b/manager.cpp
index 0d25877..7b5791a 100644
--- a/manager.cpp
+++ b/manager.cpp
@@ -2,6 +2,7 @@
#include <string>
#include <algorithm>
#include <phosphor-logging/log.hpp>
+#include <xyz/openbmc_project/Led/Physical/server.hpp>
#include "manager.hpp"
namespace phosphor
{
@@ -141,21 +142,24 @@ void Manager::drivePhysicalLED(const std::string& objPath,
}
/** @brief Returns action string based on enum */
-const char* const Manager::getPhysicalAction(Layout::Action action)
+std::string Manager::getPhysicalAction(Layout::Action action)
{
- // TODO : When this is moved over to using libdus interfaces, this code will
- // away. https://github.com/openbmc/phosphor-led-manager/issues/2
+ namespace server = sdbusplus::xyz::openbmc_project::Led::server;
+
+ // TODO: openbmc/phosphor-led-manager#5
+ // Somehow need to use the generated Action enum than giving one
+ // in ledlayout.
if(action == Layout::Action::On)
{
- return "xyz.openbmc_project.Led.Physical.Action.On";
+ return server::convertForMessage(server::Physical::Action::On);
}
else if(action == Layout::Action::Blink)
{
- return "xyz.openbmc_project.Led.Physical.Action.Blink";
+ return server::convertForMessage(server::Physical::Action::Blink);
}
else
{
- return "xyz.openbmc_project.Led.Physical.Action.Off";
+ return server::convertForMessage(server::Physical::Action::Off);
}
}
diff --git a/manager.hpp b/manager.hpp
index 8dbbcd6..4adb229 100644
--- a/manager.hpp
+++ b/manager.hpp
@@ -97,7 +97,7 @@ class Manager
*
* @return string equivalent of the passed in enumeration
*/
- static const char* const getPhysicalAction(Layout::Action action);
+ static std::string getPhysicalAction(Layout::Action action);
/** @brief Chooses appropriate action to be triggered on physical LED
* and calls into function that applies the actual action.
diff --git a/test/Makefile.am b/test/Makefile.am
index 6efd2c7..0bf5215 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -7,6 +7,6 @@ TESTS = $(check_PROGRAMS)
check_PROGRAMS = utest
utest_CPPFLAGS = -Igtest $(GTEST_CPPFLAGS) $(AM_CPPFLAGS) $(PHOSPHOR_LOGGING_CFLAGS)
utest_CXXFLAGS = $(PTHREAD_CFLAGS)
-utest_LDFLAGS = -lgtest_main -lgtest $(PTHREAD_LIBS) $(OESDK_TESTCASE_FLAGS) $(SYSTEMD_LIBS) $(PHOSPHOR_LOGGING_LIBS)
+utest_LDFLAGS = -lgtest_main -lgtest $(PTHREAD_LIBS) $(OESDK_TESTCASE_FLAGS) $(SYSTEMD_LIBS) $(PHOSPHOR_LOGGING_LIBS) $(PHOSPHOR_DBUS_INTERFACES_LIBS)
utest_SOURCES = utest.cpp
utest_LDADD = $(top_builddir)/manager.o
OpenPOWER on IntegriCloud