From d38b95f41ff5e2352771978f2d61f482e4299bc3 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Fri, 21 Nov 2014 19:36:41 -0800 Subject: [PATCH] Refactor firmata to use new adaptor interface --- platforms/firmata/firmata_adaptor.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/platforms/firmata/firmata_adaptor.go b/platforms/firmata/firmata_adaptor.go index db14e3d0..8ba70714 100644 --- a/platforms/firmata/firmata_adaptor.go +++ b/platforms/firmata/firmata_adaptor.go @@ -11,10 +11,11 @@ import ( "github.com/tarm/goserial" ) -var _ gobot.AdaptorInterface = (*FirmataAdaptor)(nil) +var _ gobot.Adaptor = (*FirmataAdaptor)(nil) type FirmataAdaptor struct { - gobot.Adaptor + name string + port string board *board i2cAddress byte connect func(*FirmataAdaptor) (err error) @@ -43,11 +44,8 @@ func NewFirmataAdaptor(name string, args ...interface{}) *FirmataAdaptor { } return &FirmataAdaptor{ - Adaptor: *gobot.NewAdaptor( - name, - "FirmataAdaptor", - port, - ), + name: name, + port: port, connect: func(f *FirmataAdaptor) (err error) { if conn == nil { conn, err = serial.OpenPort(&serial.Config{Name: f.Port(), Baud: 57600}) @@ -67,7 +65,6 @@ func (f *FirmataAdaptor) Connect() (errs []error) { return []error{err} } f.board.connect() - f.SetConnected(true) return } @@ -88,6 +85,9 @@ func (f *FirmataAdaptor) Finalize() (errs []error) { return } +func (f *FirmataAdaptor) Port() string { return f.port } +func (f *FirmataAdaptor) Name() string { return f.name } + // InitServo (not yet implemented) func (f *FirmataAdaptor) InitServo() (err error) { return errors.New("InitServo is not yet implemented")