2014-12-09 22:33:02 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/spark"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
2014-12-09 22:58:52 +08:00
|
|
|
sparkCore := spark.NewSparkCoreAdaptor("spark", "DEVICE_ID", "ACCESS_TOKEN")
|
2014-12-09 22:33:02 +08:00
|
|
|
|
|
|
|
work := func() {
|
|
|
|
temp, err := sparkCore.Variable("temperature")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println(err.Error())
|
|
|
|
} else {
|
|
|
|
fmt.Printf("temp from variable is: %v", temp)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("spark",
|
|
|
|
[]gobot.Connection{sparkCore},
|
|
|
|
[]gobot.Device{},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|