Debian Codegraph @

examples/service/battery.go

raw symbols SCIP
1 package service
2
3 import "github.com/paypal/gatt"
4
5 func NewBatteryService() *gatt.Service {
6 lv := byte(100)
7 s := gatt.NewService(gatt.UUID16(0x180F))
8 c := s.AddCharacteristic(gatt.UUID16(0x2A19))
9 c.HandleReadFunc(
10 func(rsp gatt.ResponseWriter, req *gatt.ReadRequest) {
11 rsp.Write([]byte{lv})
12 lv--
13 })
14
15 // FIXME: this cause connection interrupted on Mac.
16 // Characteristic User Description
17 // c.AddDescriptor(gatt.UUID16(0x2901)).SetValue([]byte("Battery level between 0 and 100 percent"))
18
19 // Characteristic Presentation Format
20 c.AddDescriptor(gatt.UUID16(0x2904)).SetValue([]byte{4, 1, 39, 173, 1, 0, 0})
21
22 return s
23 }