/
devices.go
58 lines (50 loc) · 1.1 KB
/
devices.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
46
47
48
49
50
51
52
53
54
55
56
57
58
package linux
import "github.com/paypal/gatt/linux/gioctl"
const (
ioctlSize = uintptr(4)
hciMaxDevices = 16
typHCI = 72 // 'H'
)
var (
hciUpDevice = gioctl.IoW(typHCI, 201, ioctlSize) // HCIDEVUP
hciDownDevice = gioctl.IoW(typHCI, 202, ioctlSize) // HCIDEVDOWN
hciResetDevice = gioctl.IoW(typHCI, 203, ioctlSize) // HCIDEVRESET
hciGetDeviceList = gioctl.IoR(typHCI, 210, ioctlSize) // HCIGETDEVLIST
hciGetDeviceInfo = gioctl.IoR(typHCI, 211, ioctlSize) // HCIGETDEVINFO
)
type devRequest struct {
id uint16
opt uint32
}
type devListRequest struct {
devNum uint16
devRequest [hciMaxDevices]devRequest
}
type hciDevInfo struct {
id uint16
name [8]byte
bdaddr [6]byte
flags uint32
devType uint8
features [8]uint8
pktType uint32
linkPolicy uint32
linkMode uint32
aclMtu uint16
aclPkts uint16
scoMtu uint16
scoPkts uint16
stats hciDevStats
}
type hciDevStats struct {
errRx uint32
errTx uint32
cmdTx uint32
evtRx uint32
aclTx uint32
aclRx uint32
scoTx uint32
scoRx uint32
byteRx uint32
byteTx uint32
}