1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/examples/particle_events.go

33 lines
515 B
Go
Raw Normal View History

package main
import (
"fmt"
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/platforms/particle"
)
func main() {
gbot := gobot.NewMaster()
2014-12-28 08:04:15 -08:00
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN")
work := func() {
if stream, err := core.EventStream("all", ""); err != nil {
2014-12-28 08:04:15 -08:00
fmt.Println(err)
} else {
// TODO: some other way to handle this
fmt.Println(stream)
}
}
robot := gobot.NewRobot("spark",
[]gobot.Connection{core},
work,
)
gbot.AddRobot(robot)
gbot.Start()
}