forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathble_device_info.go
45 lines (34 loc) · 871 Bytes
/
ble_device_info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
//go:build example
// +build example
//
// Do not build by default.
/*
How to run
Pass the Bluetooth address or name as the first param:
go run examples/ble_device_info.go BB-1234
NOTE: sudo is required to use BLE in Linux
*/
package main
import (
"fmt"
"os"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/platforms/ble"
)
func main() {
bleAdaptor := ble.NewClientAdaptor(os.Args[1])
info := ble.NewDeviceInformationDriver(bleAdaptor)
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,
)
robot.Start()
}