func main() { gbot := gobot.NewGobot() a := api.NewAPI(gbot) a.Port = "8080" a.Start() pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble") work := func() { gobot.On(pebbleDriver.Event("accel"), func(data interface{}) { fmt.Println(data.(string)) }) } robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work, ) gbot.AddRobot(robot) gbot.Start() }
func main() { gbot := gobot.NewGobot() api := api.NewAPI(gbot) api.Port = "8080" api.Start() pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble") work := func() { pebbleDriver.SendNotification("Hello Pebble!") pebbleDriver.On(pebbleDriver.Event("button"), func(data interface{}) { fmt.Println("Button pushed: " + data.(string)) }) pebbleDriver.On(pebbleDriver.Event("tap"), func(data interface{}) { fmt.Println("Tap event detected") }) } robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work, ) gbot.AddRobot(robot) gbot.Start() }
func pebbleRobot() *gobot.Robot { p := pebble.NewPebbleAdaptor("pebble") m := mqtt.NewMqttAdaptor("mqtt", "tcp://192.168.0.90:1883", "pebble") watch := pebble.NewPebbleDriver(p, "pebble") work := func() { m.On("watch", func(data []byte) { watch.SendNotification(string(data)) }) } return gobot.NewRobot("pebble", []gobot.Connection{p, m}, []gobot.Device{watch}, work, ) }
func main() { master := gobot.NewGobot() api.NewAPI(master).Start() pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble") work := func() { gobot.On(pebbleDriver.Events["accel"], func(data interface{}) { fmt.Println(data.(string)) }) } robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work) master.Robots = append(master.Robots, robot) master.Start() }
func main() { master := gobot.NewGobot() api.NewAPI(master).Start() pebbleAdaptor := pebble.NewPebbleAdaptor("pebble") pebbleDriver := pebble.NewPebbleDriver(pebbleAdaptor, "pebble") work := func() { pebbleDriver.SendNotification("Hello Pebble!") gobot.On(pebbleDriver.Events["button"], func(data interface{}) { fmt.Println("Button pushed: " + data.(string)) }) gobot.On(pebbleDriver.Events["tap"], func(data interface{}) { fmt.Println("Tap event detected") }) } robot := gobot.NewRobot("pebble", []gobot.Connection{pebbleAdaptor}, []gobot.Device{pebbleDriver}, work) master.Robots = append(master.Robots, robot) master.Start() }