2016-07-03 18:46:29 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"github.com/hybridgroup/gobot/platforms/ble"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-10-16 02:02:54 +08:00
|
|
|
gbot := gobot.NewMaster()
|
2016-07-03 18:46:29 +08:00
|
|
|
|
2016-10-03 22:58:43 +08:00
|
|
|
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
|
|
|
|
info := ble.NewDeviceInformationDriver(bleAdaptor)
|
2016-07-03 18:46:29 +08:00
|
|
|
|
|
|
|
work := func() {
|
|
|
|
fmt.Println("Model number:", info.GetModelNumber())
|
|
|
|
fmt.Println("Firmware rev:", info.GetFirmwareRevision())
|
|
|
|
fmt.Println("Hardware rev:", info.GetHardwareRevision())
|
|
|
|
fmt.Println("Manufacturer name:", info.GetManufacturerName())
|
|
|
|
fmt.Println("PnPId:", info.GetPnPId())
|
|
|
|
}
|
|
|
|
|
|
|
|
robot := gobot.NewRobot("bleBot",
|
|
|
|
[]gobot.Connection{bleAdaptor},
|
|
|
|
[]gobot.Device{info},
|
|
|
|
work,
|
|
|
|
)
|
|
|
|
|
|
|
|
gbot.AddRobot(robot)
|
|
|
|
|
|
|
|
gbot.Start()
|
|
|
|
}
|