2014-12-09 22:58:52 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/spark"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
|
|
|
sparkCore := spark.NewSparkCoreAdaptor("spark", "DEVICE_ID", "ACCESS_TOKEN")
|
|
|
|
|
|
|
|
work := func() {
|
2014-12-28 20:46:27 +08:00
|
|
|
if result, err := sparkCore.Function("brew", "202,230"); err != nil {
|
|
|
|
fmt.Println(err)
|
2014-12-09 22:58:52 +08:00
|
|
|
} else {
|
2014-12-28 20:46:27 +08:00
|
|
|
fmt.Println("result from \"brew\":", result)
|
2014-12-09 22:58:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("spark",
|
|
|
|
[]gobot.Connection{sparkCore},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|