/* How to run Pass the Bluetooth address or name as the first param: go run examples/ble_battery.go BB-1234 NOTE: sudo is required to use BLE in Linux */ package main import ( "fmt" "os" "time" "gobot.io/x/gobot" "gobot.io/x/gobot/platforms/ble" ) func main() { bleAdaptor := ble.NewClientAdaptor(os.Args[1]) battery := ble.NewBatteryDriver(bleAdaptor) work := func() { gobot.Every(5*time.Second, func() { fmt.Println("Battery level:", battery.GetBatteryLevel()) }) } robot := gobot.NewRobot("bleBot", []gobot.Connection{bleAdaptor}, []gobot.Device{battery}, work, ) robot.Start() }