LampTest: Notify PHYP to start the lamp test

- As part of the lamp test, when the lamp test is started / stoped,
  the BMC needs to notify PHYP, so that PHYP can do lamp test on
  externally connected drawers.
  For example: MEX IO drawers.

- Since the command to notify PHYP needs to be completed in the PLDM
  daemon, ledManager only needs to update the corresponding D-Bus
  interface property value.

Tested:
- Notify PHYP by the host-lamp-test path
  busctl set-property xyz.openbmc_project.LED.GroupManager
  /xyz/openbmc_project/led/groups/host_lamp_test
  xyz.openbmc_project.Led.Group Asserted b true

Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I0a0aad91c512183e457903bddb392ee56118f21c
diff --git a/lamptest.cpp b/lamptest.cpp
index 572ef68..aaf73de 100644
--- a/lamptest.cpp
+++ b/lamptest.cpp
@@ -35,6 +35,9 @@
 
     timer.setEnabled(false);
 
+    // Stop host lamp test
+    doHostLampTest(false);
+
     // Set all the Physical action to Off
     for (const auto& path : physicalLEDPaths)
     {
@@ -128,6 +131,9 @@
     timer.restart(std::chrono::seconds(LAMP_TEST_TIMEOUT_IN_SECS));
     isLampTestRunning = true;
 
+    // Notify PHYP to start the lamp test
+    doHostLampTest(true);
+
     // Set all the Physical action to On for lamp test
     for (const auto& path : physicalLEDPaths)
     {
@@ -180,5 +186,22 @@
     }
 }
 
+void LampTest::doHostLampTest(bool value)
+{
+    try
+    {
+        PropertyValue assertedValue{value};
+        dBusHandler.setProperty(HOST_LAMP_TEST_OBJECT,
+                                "xyz.openbmc_project.Led.Group", "Asserted",
+                                assertedValue);
+    }
+    catch (const sdbusplus::exception::SdBusError& e)
+    {
+        log<level::ERR>("Failed to set Asserted property",
+                        entry("ERROR=%s", e.what()),
+                        entry("PATH=%s", HOST_LAMP_TEST_OBJECT));
+    }
+}
+
 } // namespace led
 } // namespace phosphor