Add ability to set LED colors in DBus

phosphor-led-sysfs parses sysfs LED node names
in the form of "devicename:colour:function" as
described in

https://github.com/torvalds/linux/blob/master/Documentation/leds/leds-class.txt#L46

and then converts the "colour" part into the proper
value of the DBus 'Color' property using the
xyz.openbmc_project.Led.Physical.Palette interface.

In order for the led nodes to have their Color set,
the corresponding led nodes in devicetree must have
correct 'label' properties, e.g.:

leds {
    compatible = "gpio-leds";

    heartbeat {
        label = "bmc:green:hearbeat";
        gpios = <&gpio ASPEED_GPIO(R, 4) GPIO_ACTIVE_LOW>;
    };
    power_red {
        label = "system:red:power";
        gpios = <&gpio ASPEED_GPIO(N, 1) GPIO_ACTIVE_LOW>;
    };
}

Change-Id: I094f0e434bdd262995752576a3c792ccd5dbb3e2
Signed-off-by: Alexander Soldatov <a.soldatov@yadro.com>
Signed-off-by: Alexander Amelkin <a.amelkin@yadro.com>
diff --git a/physical.hpp b/physical.hpp
index 67a900b..3801c3a 100644
--- a/physical.hpp
+++ b/physical.hpp
@@ -37,9 +37,10 @@
      * @param[in] bus       - system dbus handler
      * @param[in] objPath   - The Dbus path that hosts physical LED
      * @param[in] ledPath   - sysfs path where this LED is exported
+     * @param[in] color     - led color name
      */
     Physical(sdbusplus::bus::bus& bus, const std::string& objPath,
-             SysfsLed& led) :
+             SysfsLed& led, const std::string& color = "") :
 
         sdbusplus::server::object::object<
             sdbusplus::xyz::openbmc_project::Led::server::Physical>(
@@ -50,6 +51,9 @@
         // need to save what the micro-controller currently has.
         setInitialState();
 
+        // Read led color from enviroment and set it in DBus.
+        setLedColor(color);
+
         // We are now ready.
         emit_object_added();
     }
@@ -102,6 +106,12 @@
      *  @return None
      */
     void blinkOperation();
+
+    /** @brief set led color property in DBus
+     *
+     *  @param[in] color - led color name
+     */
+    void setLedColor(const std::string& color);
 };
 
 } // namespace led