2014-12-09 18:27:39 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
2016-10-03 16:58:43 +02:00
|
|
|
"github.com/hybridgroup/gobot/platforms/particle"
|
2014-12-09 18:27:39 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-15 20:02:54 +02:00
|
|
|
gbot := gobot.NewMaster()
|
2014-12-28 08:04:15 -08:00
|
|
|
|
2016-10-03 16:58:43 +02:00
|
|
|
core := particle.NewAdaptor("DEVICE_ID", "ACCESS_TOKEN")
|
2014-12-09 18:27:39 +01:00
|
|
|
|
|
|
|
work := func() {
|
2016-10-03 16:58:43 +02:00
|
|
|
if stream, err := core.EventStream("all", ""); err != nil {
|
2014-12-28 08:04:15 -08:00
|
|
|
fmt.Println(err)
|
2014-12-09 18:27:39 +01:00
|
|
|
} else {
|
2016-08-30 17:53:29 +02:00
|
|
|
// TODO: some other way to handle this
|
2016-10-03 16:58:43 +02:00
|
|
|
fmt.Println(stream)
|
2014-12-09 18:27:39 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("spark",
|
2016-10-03 16:58:43 +02:00
|
|
|
[]gobot.Connection{core},
|
2014-12-09 18:27:39 +01:00
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|