Fix robot command initialization
This commit is contained in:
parent
e1053fbdc5
commit
851b9bc48e
|
@ -14,7 +14,7 @@ func main() {
|
|||
nil,
|
||||
nil,
|
||||
func() {
|
||||
gobot.Every(0.5*time.Second, func() { fmt.Println("Greetings human") })
|
||||
gobot.Every(500*time.Millisecond, func() { fmt.Println("Greetings human") })
|
||||
},
|
||||
)
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ func Hello(params map[string]interface{}) string {
|
|||
}
|
||||
|
||||
func main() {
|
||||
master := gobot.GobotMaster()
|
||||
master := gobot.NewGobot()
|
||||
api.NewApi(master).Start()
|
||||
|
||||
hello := gobot.NewRobot("hello", nil, nil, nil)
|
||||
|
|
|
@ -12,7 +12,7 @@ func Hello(params map[string]interface{}) string {
|
|||
}
|
||||
|
||||
func main() {
|
||||
master := gobot.GobotMaster()
|
||||
master := gobot.NewGobot()
|
||||
|
||||
server := api.NewApi(master)
|
||||
server.Username = "gort"
|
||||
|
|
2
robot.go
2
robot.go
|
@ -44,7 +44,6 @@ func NewRobot(name string, c []Connection, d []Device, work func()) *Robot {
|
|||
}
|
||||
r.initName()
|
||||
log.Println("Initializing Robot", r.Name, "...")
|
||||
r.initCommands()
|
||||
r.initConnections(c)
|
||||
r.initDevices(d)
|
||||
return r
|
||||
|
@ -52,6 +51,7 @@ func NewRobot(name string, c []Connection, d []Device, work func()) *Robot {
|
|||
|
||||
func (r *Robot) Start() {
|
||||
log.Println("Starting Robot", r.Name, "...")
|
||||
r.initCommands()
|
||||
if err := r.Connections().Start(); err != nil {
|
||||
panic("Could not start connections")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue