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) }