Debian Codegraph @

examples/service/gap.go

raw symbols SCIP
1 package service
2
3 import "github.com/bettercap/gatt"
4
5 var (
6 attrGAPUUID = gatt.UUID16(0x1800)
7
8 attrDeviceNameUUID = gatt.UUID16(0x2A00)
9 attrAppearanceUUID = gatt.UUID16(0x2A01)
10 attrPeripheralPrivacyUUID = gatt.UUID16(0x2A02)
11 attrReconnectionAddrUUID = gatt.UUID16(0x2A03)
12 attrPeferredParamsUUID = gatt.UUID16(0x2A04)
13 )
14
15 // https://developer.bluetooth.org/gatt/characteristics/Pages/CharacteristicViewer.aspx?u=org.bluetooth.characteristic.gap.appearance.xml
16 var gapCharAppearanceGenericComputer = []byte{0x00, 0x80}
17
18 // NOTE: OS X provides GAP and GATT services, and they can't be customized.
19 // For Linux/Embedded, however, this is something we want to fully control.
20 func NewGapService(name string) *gatt.Service {
21 s := gatt.NewService(attrGAPUUID)
22 s.AddCharacteristic(attrDeviceNameUUID).SetValue([]byte(name))
23 s.AddCharacteristic(attrAppearanceUUID).SetValue(gapCharAppearanceGenericComputer)
24 s.AddCharacteristic(attrPeripheralPrivacyUUID).SetValue([]byte{0x00})
25 s.AddCharacteristic(attrReconnectionAddrUUID).SetValue([]byte{0x00, 0x00, 0x00, 0x00, 0x00, 0x00})
26 s.AddCharacteristic(attrPeferredParamsUUID).SetValue([]byte{0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xd0, 0x07})
27 return s
28 }