diff options
author | Mike Crute <mike@crute.us> | 2018-06-06 04:01:37 +0000 |
---|---|---|
committer | Mike Crute <mike@crute.us> | 2018-06-06 04:01:37 +0000 |
commit | 677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa (patch) | |
tree | 33284890e20331169d00bd0a0dea716fb7ea9806 | |
parent | 451f69f66be6e0a9d9c9eba96974d8452ca5d134 (diff) | |
download | mfi_homekit-677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa.tar.bz2 mfi_homekit-677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa.tar.xz mfi_homekit-677b2d0b9c347fdc99e1ae1143b3edfa73eb21fa.zip |
Disable blinking LED when no controller
-rw-r--r-- | main.go | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -13,7 +13,10 @@ import ( | |||
13 | "time" | 13 | "time" |
14 | ) | 14 | ) |
15 | 15 | ||
16 | const CMD_PATH = "/var/etc/persistent/power_control.sh" | 16 | const ( |
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 | ||
18 | type Device struct { | 21 | type 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 | ||
176 | func (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 | |||
173 | func (d *Device) GetReport() ([]DeviceOutput, error) { | 185 | func (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 | } |