hybridgroup.gobot/platforms/firmata/tcp_firmata_adaptor.go

27 lines
519 B
Go
Raw Normal View History

package firmata
import "net"
// TCPAdaptor represents a TCP based connection to a microcontroller running
// WiFiFirmata
type TCPAdaptor struct {
*Adaptor
}
// NewTCPAdaptor opens and uses a TCP connection to a microcontroller running
// WiFiFirmata
func NewTCPAdaptor(args ...interface{}) *TCPAdaptor {
address := args[0].(string)
conn, err := net.Dial("tcp", address)
if err != nil {
// TODO: handle error
}
a := NewAdaptor(conn, address)
a.SetName("TCPFirmata")
return &TCPAdaptor{
Adaptor: a,
}
}