Fix power supply present delay
The member variable indicating a power supply is present should be
updated after the timer expires. If the message is not indicating
present, the variable should be set to false and the timer stopped.
Change-Id: Id5b78e42858cc2dd96b8a3fc9ecb21ec4eec6b10
Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
diff --git a/power-supply/power_supply.cpp b/power-supply/power_supply.cpp
index 8a00d59..7eb4569 100644
--- a/power-supply/power_supply.cpp
+++ b/power-supply/power_supply.cpp
@@ -166,15 +166,14 @@
auto valPropMap = msgData.find(PRESENT_PROP);
if (valPropMap != msgData.end())
{
- present = sdbusplus::message::variant_ns::get<bool>(valPropMap->second);
-
- if (present)
+ if (sdbusplus::message::variant_ns::get<bool>(valPropMap->second))
{
clearFaults();
presentTimer.start(presentInterval, Timer::TimerType::oneshot);
}
else
{
+ present = false;
presentTimer.stop();
}
}