xref: /openbmc/phosphor-led-sysfs/README.md (revision 24d124f9)
1# phosphor-led-sysfs
2
3This project exposes physical LEDs on dbus.
4
5## Example
6
7Say we have 'identify' LED in our system, which may be declared in devicetree.
8
9```
10leds {
11    compatible = "gpio-leds";
12
13    identify {
14        gpios = <&gpio ASPEED_GPIO(S, 6) GPIO_ACTIVE_HIGH>;
15    };
16};
17```
18
19We can add an LED via the helper program. The main service is then started via
20dbus-activation.
21
22```
23./add-led-action --path /sys/class/leds/identify
24```
25
26which will expose following dbus objects:
27
28```
29busctl tree xyz.openbmc_project.LED.Controller
30`- /xyz
31  `- /xyz/openbmc_project
32    `- /xyz/openbmc_project/led
33      `- /xyz/openbmc_project/led/physical
34        `- /xyz/openbmc_project/led/physical/identify
35
36busctl introspect  xyz.openbmc_project.LED.Controller /xyz/openbmc_project/led/physical/identify
37NAME                                TYPE      SIGNATURE  RESULT/VALUE                             FLAGS
38...
39xyz.openbmc_project.Led.Physical    interface -          -                                        -
40.Color                              property  s          "xyz.openbmc_project.Led.Physical.Pal... emits-change writable
41.DutyOn                             property  y          50                                       emits-change writable
42.Period                             property  q          1000                                     emits-change writable
43.State                              property  s          "xyz.openbmc_project.Led.Physical.Act... emits-change writable
44```
45
46In the above output, the usual org.freedesktop.\* interfaces have been removed
47to keep it readable.
48
49## Example: using the dbus interface
50
51Query the LED State
52
53```
54busctl get-property  xyz.openbmc_project.LED.Controller \
55/xyz/openbmc_project/led/physical/identify \
56xyz.openbmc_project.Led.Physical State \
57s "xyz.openbmc_project.Led.Physical.Action.Off"
58```
59
60Set the LED State
61
62```
63busctl set-property  xyz.openbmc_project.LED.Controller \
64/xyz/openbmc_project/led/physical/identify \
65xyz.openbmc_project.Led.Physical State s \
66"xyz.openbmc_project.Led.Physical.Action.Off"
67```
68
69## How to Build
70
71```
72meson setup build
73cd build
74ninja
75```
76