summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Crute <mike@crute.us>2018-06-06 04:01:37 +0000
committerMike Crute <mike@crute.us>2018-06-06 04:01:37 +0000
commit677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa (patch)
tree33284890e20331169d00bd0a0dea716fb7ea9806
parent451f69f66be6e0a9d9c9eba96974d8452ca5d134 (diff)
downloadmfi_homekit-677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa.tar.bz2
mfi_homekit-677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa.tar.xz
mfi_homekit-677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa.zip
Disable blinking LED when no controller
-rw-r--r--main.go15
1 files changed, 14 insertions, 1 deletions
diff --git a/main.go b/main.go
index 5a12a93..5545b65 100644
--- a/main.go
+++ b/main.go
@@ -13,7 +13,10 @@ import (
13 "time" 13 "time"
14) 14)
15 15
16const CMD_PATH = "/var/etc/persistent/power_control.sh" 16const (
17 CMD_PATH = "/var/etc/persistent/power_control.sh"
18 NO_BLINK_CMD = "/usr/bin/sh -c 'echo 0 > /proc/led/freq && echo 1 > /proc/led/status'"
19)
17 20
18type Device struct { 21type Device struct {
19 Root *Device 22 Root *Device
@@ -170,6 +173,15 @@ func (d *Device) Toggle(n string, on bool) ([]DeviceOutput, error) {
170 } 173 }
171} 174}
172 175
176func (d *Device) DisableBlink() error {
177 _, err := d.runCommand(NO_BLINK_CMD)
178 if err != nil {
179 return err
180 } else {
181 return nil
182 }
183}
184
173func (d *Device) GetReport() ([]DeviceOutput, error) { 185func (d *Device) GetReport() ([]DeviceOutput, error) {
174 out, err := d.runCommand(fmt.Sprintf("%s report", CMD_PATH)) 186 out, err := d.runCommand(fmt.Sprintf("%s report", CMD_PATH))
175 if err != nil { 187 if err != nil {
@@ -306,5 +318,6 @@ func main() {
306 318
307 // Gathering reports also keeps the SSH connections alive 319 // Gathering reports also keeps the SSH connections alive
308 go GatherReports(devs) 320 go GatherReports(devs)
321 go StopBlinking(devs)
309 t.Start() 322 t.Start()
310} 323}