1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-14 19:29:32 +08:00
hybridgroup.gobot/platforms/ardrone/ardrone_adaptor.go

51 lines
819 B
Go
Raw Normal View History

package ardrone
import (
2014-04-28 11:23:12 -07:00
client "github.com/hybridgroup/go-ardrone/client"
"github.com/hybridgroup/gobot"
)
type drone interface{}
type ArdroneAdaptor struct {
gobot.Adaptor
2014-04-28 11:23:12 -07:00
drone drone
connect func(*ArdroneAdaptor)
}
func NewArdroneAdaptor(name string) *ArdroneAdaptor {
2014-04-28 11:23:12 -07:00
return &ArdroneAdaptor{
Adaptor: gobot.Adaptor{
Name: name,
},
2014-04-28 11:23:12 -07:00
connect: func(a *ArdroneAdaptor) {
d, err := client.Connect(client.DefaultConfig())
if err != nil {
panic(err)
}
a.drone = d
},
}
}
2014-04-28 11:23:12 -07:00
func (a *ArdroneAdaptor) Connect() bool {
a.connect(a)
return true
}
2014-04-28 11:23:12 -07:00
func (a *ArdroneAdaptor) Reconnect() bool {
return true
}
2014-04-28 11:23:12 -07:00
func (a *ArdroneAdaptor) Disconnect() bool {
return true
}
2014-04-28 11:23:12 -07:00
func (a *ArdroneAdaptor) Finalize() bool {
return true
}
2014-06-10 15:16:11 -07:00
func (a *ArdroneAdaptor) Drone() drone {
return a.drone
}