Skip to content

Commit c2aea60

Browse files
authored
feat: add linux led control in python (#621)
1 parent 5715a37 commit c2aea60

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

internal/orchestrator/orchestrator.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,28 @@ func getDevices() deviceResult {
979979
return res
980980
}
981981

982+
// addLedControl adds bindings for led control if the paths exist.
983+
func addLedControl(volumes []volume) []volume {
984+
ledsPath := paths.NewPathList(
985+
"/sys/class/leds/blue:user",
986+
"/sys/class/leds/green:user",
987+
"/sys/class/leds/red:user",
988+
"/sys/class/leds/blue:bt",
989+
"/sys/class/leds/green:wlan",
990+
"/sys/class/leds/red:panic",
991+
)
992+
for _, path := range ledsPath {
993+
if path.Exist() {
994+
volumes = append(volumes, volume{
995+
Type: "bind",
996+
Source: path.String(),
997+
Target: path.String(),
998+
})
999+
}
1000+
}
1001+
return volumes
1002+
}
1003+
9821004
func disconnectSerialFromRPCRouter(ctx context.Context, portAddress string, cfg config.Configuration) func() {
9831005
var msgPackRouterAddr = cfg.RouterSocketPath().String()
9841006
c, err := net.Dial("unix", msgPackRouterAddr)

internal/orchestrator/provision.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,8 @@ func generateMainComposeFile(
293293
}
294294
}
295295

296+
volumes = addLedControl(volumes)
297+
296298
groups := []string{"dialout", "video", "audio", "render"}
297299

298300
// Define depends_on conditions
@@ -320,7 +322,7 @@ func generateMainComposeFile(
320322
Entrypoint: "/run.sh",
321323
DependsOn: dependsOn,
322324
User: getCurrentUser(),
323-
GroupAdd: groups,
325+
GroupAdd: append(groups, "gpiod"),
324326
ExtraHosts: []string{"msgpack-rpc-router:host-gateway"},
325327
Labels: map[string]string{
326328
DockerAppLabel: "true",

0 commit comments

Comments
 (0)