2015-06-07 19:31:00 -07:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2015-06-29 15:25:59 -07:00
|
|
|
"time"
|
2015-06-07 19:31:00 -07:00
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/ble"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
gbot := gobot.NewGobot()
|
|
|
|
|
2015-06-29 15:25:59 -07:00
|
|
|
bleAdaptor := ble.NewBLEAdaptor("ble", "20:73:77:65:43:21")
|
2015-06-07 19:31:00 -07:00
|
|
|
battery := ble.NewBLEBatteryDriver(bleAdaptor, "battery")
|
|
|
|
|
|
|
|
work := func() {
|
|
|
|
fmt.Println("Working...")
|
2015-06-29 15:25:59 -07:00
|
|
|
|
|
|
|
gobot.After(3*time.Second, func() {
|
|
|
|
fmt.Println(battery.GetBatteryLevel())
|
|
|
|
})
|
2015-06-07 19:31:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("bleBot",
|
|
|
|
[]gobot.Connection{bleAdaptor},
|
|
|
|
[]gobot.Device{battery},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|