From 8ec5b2ebfc1eef48f7a7d07cc86d2f6da14adb3b Mon Sep 17 00:00:00 2001 From: "Denis V. Dedkov" Date: Sat, 23 Jul 2016 16:23:18 +0500 Subject: [PATCH] Device init code was moved --- noolite.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/noolite.go b/noolite.go index b813569..723d001 100644 --- a/noolite.go +++ b/noolite.go @@ -89,6 +89,16 @@ func NewNooliteAdapter(mode, bitrate, repeats uint) (*NooliteAdapter, error) { m := (byte(repeats) << 5) | (byte(bitrate) << 3) | byte(mode) + d.Configuration(1) + if d.LastError() != "No error" { + return nil, errors.New(d.LastError()) + } + + d.Interface(0) + if d.LastError() != "No error" { + return nil, errors.New(d.LastError()) + } + return &NooliteAdapter{d, m}, nil } @@ -132,16 +142,6 @@ func (n *NooliteAdapter) composeCommand(cmd command, channel int, args ...int) [ } func (n *NooliteAdapter) sendCommand(command []byte) error { - n.Configuration(1) - if n.LastError() != "No error" { - return errors.New(n.LastError()) - } - - n.Interface(0) - if n.LastError() != "No error" { - return errors.New(n.LastError()) - } - n.ControlMsg(0x21, 0x09, 0x300, 0, command) if n.LastError() != "No error" { return errors.New(n.LastError())