aboutsummaryrefslogtreecommitdiff
path: root/advertisement.go
blob: 363b28f1eafb25cacfa8436939fe108c9f4ed56c (plain)
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
package anki

const (
	stateFullBattery = 1 << 4
	stateLowBattery  = 1 << 5
	stateOnCharger   = 1 << 6
)

type VehicleAdvInfo struct {
	VehicleAdvState uint8 // Battery
	Version         uint16
	Reserved        [5]uint8
	Name            [13]byte // UTF8: 12 bytes + NULL
}

func (v VehicleAdvInfo) FullBattery() bool {
	return v.VehicleAdvState&stateFullBattery != 0
}

func (v VehicleAdvInfo) LowBattery() bool {
	return v.VehicleAdvState&stateLowBattery != 0
}

func (v VehicleAdvInfo) OnCharger() bool {
	return v.VehicleAdvState&stateOnCharger != 0
}

type VehicleAdvMfg struct {
	Identifier uint32
	ModelID    uint8
	Reserved   uint8
	ProductID  uint16
}

type UUID [16]byte

type VehicleAdv struct {
	Flags     uint8
	TXPower   uint8
	MfgData   VehicleAdvMfg
	LocalName VehicleAdvInfo
	UUID      UUID
}