firmata: use new improved default namer to avoid API conflicts
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
5d90090d57
commit
0c06d0bd97
|
@ -3,6 +3,7 @@ package firmata
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
|
|
||||||
|
"gobot.io/x/gobot"
|
||||||
"gobot.io/x/gobot/platforms/ble"
|
"gobot.io/x/gobot/platforms/ble"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -33,7 +34,7 @@ func NewBLEAdaptor(args ...interface{}) *BLEAdaptor {
|
||||||
}
|
}
|
||||||
|
|
||||||
a := NewAdaptor(address)
|
a := NewAdaptor(address)
|
||||||
a.SetName("BLEFirmata")
|
a.SetName(gobot.DefaultName("BLEFirmata"))
|
||||||
a.PortOpener = func(port string) (io.ReadWriteCloser, error) {
|
a.PortOpener = func(port string) (io.ReadWriteCloser, error) {
|
||||||
sp := ble.NewSerialPort(address, rid, wid)
|
sp := ble.NewSerialPort(address, rid, wid)
|
||||||
sp.Open()
|
sp.Open()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package firmata
|
package firmata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
|
@ -16,5 +17,5 @@ func initTestBLEAdaptor() *BLEAdaptor {
|
||||||
|
|
||||||
func TestFirmataBLEAdaptor(t *testing.T) {
|
func TestFirmataBLEAdaptor(t *testing.T) {
|
||||||
a := initTestBLEAdaptor()
|
a := initTestBLEAdaptor()
|
||||||
gobottest.Assert(t, a.Name(), "BLEFirmata")
|
gobottest.Assert(t, strings.HasPrefix(a.Name(), "BLEFirmata"), true)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ type Adaptor struct {
|
||||||
// string port as a label to be displayed in the log and api.
|
// string port as a label to be displayed in the log and api.
|
||||||
func NewAdaptor(args ...interface{}) *Adaptor {
|
func NewAdaptor(args ...interface{}) *Adaptor {
|
||||||
f := &Adaptor{
|
f := &Adaptor{
|
||||||
name: "Firmata",
|
name: gobot.DefaultName("Firmata"),
|
||||||
port: "",
|
port: "",
|
||||||
conn: nil,
|
conn: nil,
|
||||||
board: client.New(),
|
board: client.New(),
|
||||||
|
|
|
@ -3,6 +3,8 @@ package firmata
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
|
"gobot.io/x/gobot"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TCPAdaptor represents a TCP based connection to a microcontroller running
|
// TCPAdaptor represents a TCP based connection to a microcontroller running
|
||||||
|
@ -21,7 +23,7 @@ func NewTCPAdaptor(args ...interface{}) *TCPAdaptor {
|
||||||
address := args[0].(string)
|
address := args[0].(string)
|
||||||
|
|
||||||
a := NewAdaptor(address)
|
a := NewAdaptor(address)
|
||||||
a.SetName("TCPFirmata")
|
a.SetName(gobot.DefaultName("TCPFirmata"))
|
||||||
a.PortOpener = func(port string) (io.ReadWriteCloser, error) {
|
a.PortOpener = func(port string) (io.ReadWriteCloser, error) {
|
||||||
return connect(port)
|
return connect(port)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package firmata
|
package firmata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"gobot.io/x/gobot"
|
"gobot.io/x/gobot"
|
||||||
|
@ -16,5 +17,5 @@ func initTestTCPAdaptor() *TCPAdaptor {
|
||||||
|
|
||||||
func TestFirmataTCPAdaptor(t *testing.T) {
|
func TestFirmataTCPAdaptor(t *testing.T) {
|
||||||
a := initTestTCPAdaptor()
|
a := initTestTCPAdaptor()
|
||||||
gobottest.Assert(t, a.Name(), "TCPFirmata")
|
gobottest.Assert(t, strings.HasPrefix(a.Name(), "TCPFirmata"), true)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue