hink / go-blink1

Thingm Blink(1) interface library for Go
20 stars 9 forks source link

SetState does not return an error for a failed write #1

Closed kazrakcom closed 8 years ago

kazrakcom commented 8 years ago

The SetState method discards the return code from fadeToRgbBlink1. If the app cannot write (because, say, the blink(1) got unplugged) then this will fail silently.

Fix: change SetState to:

func (b *Device) SetState(state State) (err error) { b.CurrentState = state bytes := fadeToRgbBlink1(b, state.FadeTime, state.Red, state.Green, state.Blue, state.Normal) if bytes <= 0 { err = errors.New("Unable to write to blink(1).") } return }

hink commented 8 years ago

Must have overlooked that. Thanks.