From 0c06d0bd975e1beba4620840c5d0634178550a65 Mon Sep 17 00:00:00 2001 From: deadprogram Date: Thu, 2 Feb 2017 16:10:09 +0100 Subject: [PATCH] firmata: use new improved default namer to avoid API conflicts Signed-off-by: deadprogram --- platforms/firmata/ble_firmata_adaptor.go | 3 ++- platforms/firmata/ble_firmata_adaptor_test.go | 3 ++- platforms/firmata/firmata_adaptor.go | 2 +- platforms/firmata/tcp_firmata_adaptor.go | 4 +++- platforms/firmata/tcp_firmata_adaptor_test.go | 3 ++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/platforms/firmata/ble_firmata_adaptor.go b/platforms/firmata/ble_firmata_adaptor.go index 43979d23..d30783c7 100644 --- a/platforms/firmata/ble_firmata_adaptor.go +++ b/platforms/firmata/ble_firmata_adaptor.go @@ -3,6 +3,7 @@ package firmata import ( "io" + "gobot.io/x/gobot" "gobot.io/x/gobot/platforms/ble" ) @@ -33,7 +34,7 @@ func NewBLEAdaptor(args ...interface{}) *BLEAdaptor { } a := NewAdaptor(address) - a.SetName("BLEFirmata") + a.SetName(gobot.DefaultName("BLEFirmata")) a.PortOpener = func(port string) (io.ReadWriteCloser, error) { sp := ble.NewSerialPort(address, rid, wid) sp.Open() diff --git a/platforms/firmata/ble_firmata_adaptor_test.go b/platforms/firmata/ble_firmata_adaptor_test.go index be7dd3fe..d3c11304 100644 --- a/platforms/firmata/ble_firmata_adaptor_test.go +++ b/platforms/firmata/ble_firmata_adaptor_test.go @@ -1,6 +1,7 @@ package firmata import ( + "strings" "testing" "gobot.io/x/gobot" @@ -16,5 +17,5 @@ func initTestBLEAdaptor() *BLEAdaptor { func TestFirmataBLEAdaptor(t *testing.T) { a := initTestBLEAdaptor() - gobottest.Assert(t, a.Name(), "BLEFirmata") + gobottest.Assert(t, strings.HasPrefix(a.Name(), "BLEFirmata"), true) } diff --git a/platforms/firmata/firmata_adaptor.go b/platforms/firmata/firmata_adaptor.go index 7bdbb8f7..0d7a48c8 100644 --- a/platforms/firmata/firmata_adaptor.go +++ b/platforms/firmata/firmata_adaptor.go @@ -47,7 +47,7 @@ type Adaptor struct { // string port as a label to be displayed in the log and api. func NewAdaptor(args ...interface{}) *Adaptor { f := &Adaptor{ - name: "Firmata", + name: gobot.DefaultName("Firmata"), port: "", conn: nil, board: client.New(), diff --git a/platforms/firmata/tcp_firmata_adaptor.go b/platforms/firmata/tcp_firmata_adaptor.go index fa6eeb2f..7dc7f53b 100644 --- a/platforms/firmata/tcp_firmata_adaptor.go +++ b/platforms/firmata/tcp_firmata_adaptor.go @@ -3,6 +3,8 @@ package firmata import ( "io" "net" + + "gobot.io/x/gobot" ) // TCPAdaptor represents a TCP based connection to a microcontroller running @@ -21,7 +23,7 @@ func NewTCPAdaptor(args ...interface{}) *TCPAdaptor { address := args[0].(string) a := NewAdaptor(address) - a.SetName("TCPFirmata") + a.SetName(gobot.DefaultName("TCPFirmata")) a.PortOpener = func(port string) (io.ReadWriteCloser, error) { return connect(port) } diff --git a/platforms/firmata/tcp_firmata_adaptor_test.go b/platforms/firmata/tcp_firmata_adaptor_test.go index 84cb5e4c..27a7a4a1 100644 --- a/platforms/firmata/tcp_firmata_adaptor_test.go +++ b/platforms/firmata/tcp_firmata_adaptor_test.go @@ -1,6 +1,7 @@ package firmata import ( + "strings" "testing" "gobot.io/x/gobot" @@ -16,5 +17,5 @@ func initTestTCPAdaptor() *TCPAdaptor { func TestFirmataTCPAdaptor(t *testing.T) { a := initTestTCPAdaptor() - gobottest.Assert(t, a.Name(), "TCPFirmata") + gobottest.Assert(t, strings.HasPrefix(a.Name(), "TCPFirmata"), true) }