summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--physical.cpp5
-rw-r--r--physical.hpp8
-rw-r--r--test/physical.cpp11
3 files changed, 14 insertions, 10 deletions
diff --git a/physical.cpp b/physical.cpp
index ae9ff1c..e614b99 100644
--- a/physical.cpp
+++ b/physical.cpp
@@ -27,6 +27,7 @@ namespace led
/** @brief Populates key parameters */
void Physical::setInitialState()
{
+ assert = led.getMaxBrightness();
auto trigger = led.getTrigger();
if (trigger == "timer")
{
@@ -44,7 +45,7 @@ void Physical::setInitialState()
// Cache current LED state
auto brightness = led.getBrightness();
- if (brightness == ASSERT)
+ if (brightness == assert)
{
sdbusplus::xyz::openbmc_project::Led::server::Physical::state(
Action::On);
@@ -89,7 +90,7 @@ void Physical::driveLED(Action current, Action request)
void Physical::stableStateOperation(Action action)
{
- auto value = (action == Action::On) ? ASSERT : DEASSERT;
+ auto value = (action == Action::On) ? assert : DEASSERT;
led.setTrigger("none");
led.setBrightness(value);
diff --git a/physical.hpp b/physical.hpp
index e588de2..67a900b 100644
--- a/physical.hpp
+++ b/physical.hpp
@@ -12,10 +12,7 @@ namespace phosphor
{
namespace led
{
-/** @brief Assert LED by writing 255 */
-constexpr unsigned long ASSERT = 255;
-
-/** @brief De-assert by writing "0" */
+/** @brief De-assert value */
constexpr unsigned long DEASSERT = 0;
/** @class Physical
@@ -69,6 +66,9 @@ class Physical : public sdbusplus::server::object::object<
*/
SysfsLed& led;
+ /** @brief The value that will assert the LED */
+ unsigned long assert;
+
/** @brief The period that the LED will operate on, in milliseconds
* Will be removed when periodicity is put into interface
*/
diff --git a/test/physical.cpp b/test/physical.cpp
index f3c3187..f05d882 100644
--- a/test/physical.cpp
+++ b/test/physical.cpp
@@ -104,11 +104,14 @@ TEST(Physical, off)
TEST(Physical, on)
{
+ constexpr unsigned long asserted = 127;
+
sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
NiceMock<MockLed> led;
+ ON_CALL(led, getMaxBrightness()).WillByDefault(Return(asserted));
EXPECT_CALL(led, getTrigger()).WillOnce(Return("none"));
EXPECT_CALL(led, setTrigger("none"));
- EXPECT_CALL(led, setBrightness(phosphor::led::ASSERT));
+ EXPECT_CALL(led, setBrightness(asserted));
phosphor::led::Physical phy(bus, LED_OBJ, led);
phy.state(Action::On);
}
@@ -130,21 +133,21 @@ TEST(Physical, ctor_none_trigger_asserted_brightness)
sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
NiceMock<MockLed> led;
EXPECT_CALL(led, getTrigger()).WillRepeatedly(Return("none"));
- constexpr auto val = phosphor::led::ASSERT;
- EXPECT_CALL(led, getBrightness()).WillRepeatedly(Return(val));
+ EXPECT_CALL(led, getBrightness()).WillRepeatedly(Return(127));
phosphor::led::Physical phy(bus, LED_OBJ, led);
}
TEST(Physical, on_to_off)
{
InSequence s;
+ constexpr unsigned long asserted = 127;
auto bus = sdbusplus::bus::new_default();
NiceMock<MockLed> led;
+ ON_CALL(led, getMaxBrightness()).WillByDefault(Return(asserted));
EXPECT_CALL(led, getTrigger()).Times(1).WillOnce(Return("none"));
constexpr auto deasserted = phosphor::led::DEASSERT;
EXPECT_CALL(led, getBrightness()).WillOnce(Return(deasserted));
- constexpr auto asserted = phosphor::led::ASSERT;
EXPECT_CALL(led, setBrightness(asserted));
EXPECT_CALL(led, setBrightness(deasserted));
phosphor::led::Physical phy(bus, LED_OBJ, led);
OpenPOWER on IntegriCloud