xref: /openbmc/phosphor-led-manager/README.md (revision 4a435516)
1# phosphor-led-manager
2
3This project manages LED groups on dbus. Sometimes many LEDs must be driven
4together to indicate some system state.
5
6For example, there can be multiple identify LEDs. When the user wants to
7identify the system, they should all light up together.
8
9## Configuration
10
11The configuration can happen via json or yaml.
12
13### Configuration: LED Priority
14
15Each LED can have "Priority" as "Blink" or "On". If this property is defined, it
16should be defined on each instance of the LED in the config.
17
18When multiple LED groups are asserted and contain the same LED, "Priority"
19determines the state of the LED.
20
21For example, Group 1 says LED1 should be "Blink", and Group 2 says it should be
22"On". LED1 will then have the state declared in "Priority".
23
24### Configuration Example (JSON)
25
26This is our configuration file. It describes 2 LEDs for the
27'_enclosure_identify_' group, with their respective states and duty cycles.
28
29```json
30{
31  "leds": [
32    {
33      "group": "enclosure_identify",
34      "members": [
35        {
36          "Name": "pca955x_front_sys_id0",
37          "Action": "On",
38          "DutyOn": 50,
39          "Period": 0,
40          "Priority": "Blink"
41        },
42        {
43          "Name": "led_rear_enc_id0",
44          "Action": "On",
45          "DutyOn": 50,
46          "Period": 0,
47          "Priority": "Blink"
48        }
49      ]
50    }
51  ]
52}
53```
54
55Then start the program with
56
57```text
58~# ./phosphor-led-manager --config example.json
59```
60
61## Dbus interface
62
63When starting the program, our LED group shows up on dbus. Usually there will be
64many more groups.
65
66```text
67$ busctl tree xyz.openbmc_project.LED.GroupManager
68`- /xyz
69  `- /xyz/openbmc_project
70    `- /xyz/openbmc_project/led
71      `- /xyz/openbmc_project/led/groups
72        `- /xyz/openbmc_project/led/groups/enclosure_identify
73
74
75$ busctl introspect xyz.openbmc_project.LED.GroupManager /xyz/openbmc_project/led/groups/enclosure_identify
76NAME                                TYPE      SIGNATURE RESULT/VALUE FLAGS
77...
78xyz.openbmc_project.Led.Group       interface -         -            -
79.Asserted                           property  b         false        emits-change writable
80```
81
82In the above output, the usual org.freedesktop.\* interfaces have been removed
83to keep it readable.
84
85We can now drive the entire group by setting it's 'Asserted' property on dbus.
86
87```text
88$ busctl set-property \
89xyz.openbmc_project.LED.GroupManager \
90/xyz/openbmc_project/led/groups/enclosure_identify \
91xyz.openbmc_project.Led.Group Asserted b true
92```
93
94The program can then use the _xyz.openbmc_project.Led.Physical_ dbus interface
95exposed by _phosphor-led-sysfs_ to set each LED state.
96
97## How to Build
98
99```text
100meson setup build
101cd build
102ninja
103```
104