2014-10-17 05:26:35 +08:00
|
|
|
/*
|
2014-10-29 05:52:59 +08:00
|
|
|
Package pebble contains the Gobot adaptor and driver for Pebble smart watch.
|
2014-10-17 05:26:35 +08:00
|
|
|
|
|
|
|
Installing:
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
It requires the 2.x iOS or Android app, and "watchbot" app (https://gobot.io/x/watchbot)
|
2014-10-17 05:26:35 +08:00
|
|
|
installed on Pebble watch. Then install running:
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
go get gobot.io/x/gobot/platforms/pebble
|
2014-10-17 05:26:35 +08:00
|
|
|
|
|
|
|
Example:
|
|
|
|
|
|
|
|
Before running the example, make sure configuration settings match with your program. In the example, api host is your computer IP, robot name is 'pebble' and robot api port is 8080
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2016-12-08 20:24:03 +08:00
|
|
|
"gobot.io/x/gobot"
|
|
|
|
"gobot.io/x/gobot/api"
|
|
|
|
"gobot.io/x/gobot/platforms/pebble"
|
2014-10-17 05:26:35 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-19 03:37:10 +08:00
|
|
|
master := gobot.NewMaster()
|
|
|
|
api.NewAPI(master).Start()
|
2014-10-17 05:26:35 +08:00
|
|
|
|
2016-10-02 00:01:30 +08:00
|
|
|
pebbleAdaptor := pebble.NewAdaptor()
|
|
|
|
watch := pebble.NewDriver(pebbleAdaptor)
|
2014-10-17 05:26:35 +08:00
|
|
|
|
|
|
|
work := func() {
|
2016-10-02 00:01:30 +08:00
|
|
|
watch.SendNotification("Hello Pebble!")
|
|
|
|
watch.On(watch.Event("button"), func(data interface{}) {
|
2014-10-17 05:26:35 +08:00
|
|
|
fmt.Println("Button pushed: " + data.(string))
|
|
|
|
})
|
|
|
|
|
2016-10-02 00:01:30 +08:00
|
|
|
watch.On(watch.Event("tap"), func(data interface{}) {
|
2014-10-17 05:26:35 +08:00
|
|
|
fmt.Println("Tap event detected")
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("pebble",
|
|
|
|
[]gobot.Connection{pebbleAdaptor},
|
2016-10-02 00:01:30 +08:00
|
|
|
[]gobot.Device{watch},
|
2014-10-17 05:26:35 +08:00
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
2016-10-19 03:37:10 +08:00
|
|
|
master.AddRobot(robot)
|
2014-10-17 05:26:35 +08:00
|
|
|
|
2016-10-19 03:37:10 +08:00
|
|
|
master.Start()
|
2014-10-17 05:26:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
For more information refer to the pebble README:
|
2016-12-21 17:55:15 +08:00
|
|
|
https://github.com/hybridgroup/gobot/blob/master/platforms/pebble/README.md
|
2014-10-17 05:26:35 +08:00
|
|
|
*/
|
2016-12-08 20:24:03 +08:00
|
|
|
package pebble // import "gobot.io/x/gobot/platforms/pebble"
|