-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.go
43 lines (37 loc) · 942 Bytes
/
utils.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
package main
import (
"fmt"
"github.com/muka/go-bluetooth/bluez/profile/device"
"strconv"
"strings"
)
func numberStringToUInt8Slice(str string) (out []uint8, err error) {
stringValues := strings.Split(str, ",")
out = make([]uint8, len(stringValues))
for i, val := range stringValues {
var converted uint64
converted, err = strconv.ParseUint(val, 10, 8)
if err != nil {
return
}
out[i] = uint8(converted)
}
return
}
func getColorString(v1 uint8, v2 uint8, v3 uint8) string {
return fmt.Sprintf("%d,%d,%d", v1, v2, v3)
}
func logCharacteristics(device *device.Device1) {
addr, _ := device.GetAddress()
chars, err := device.GetCharacteristics()
if err != nil {
log.Errorf("unable to retrieve characteristics for '%s': %v", addr, err)
return
}
for _, char := range chars {
uuid, _ := char.GetUUID()
flags, _ := char.GetFlags()
log.Debug("Device: ", addr)
log.Debugf("- char: %s %v", uuid, flags)
}
}