examples: use standard service and characteristic UUIDs

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2021-01-30 22:42:17 +01:00 committed by Ron Evans
parent 549cb4a3f7
commit 27cc35a60b
4 changed files with 12 additions and 12 deletions

View file

@ -26,8 +26,8 @@ import (
var ( var (
adapter = bluetooth.DefaultAdapter adapter = bluetooth.DefaultAdapter
heartRateServiceUUID = bluetooth.New16BitUUID(0x180D) heartRateServiceUUID = bluetooth.ServiceUUIDHeartRate
heartRateCharacteristicUUID = bluetooth.New16BitUUID(0x2A37) heartRateCharacteristicUUID = bluetooth.CharacteristicUUIDHeartRateMeasurement
) )
func main() { func main() {

View file

@ -18,19 +18,19 @@ func main() {
adv := adapter.DefaultAdvertisement() adv := adapter.DefaultAdvertisement()
must("config adv", adv.Configure(bluetooth.AdvertisementOptions{ must("config adv", adv.Configure(bluetooth.AdvertisementOptions{
LocalName: "Go HRS", LocalName: "Go HRS",
ServiceUUIDs: []bluetooth.UUID{bluetooth.New16BitUUID(0x180D)}, ServiceUUIDs: []bluetooth.UUID{bluetooth.ServiceUUIDHeartRate},
})) }))
must("start adv", adv.Start()) must("start adv", adv.Start())
var heartRateMeasurement bluetooth.Characteristic var heartRateMeasurement bluetooth.Characteristic
must("add service", adapter.AddService(&bluetooth.Service{ must("add service", adapter.AddService(&bluetooth.Service{
UUID: bluetooth.New16BitUUID(0x180D), // Heart Rate UUID: bluetooth.ServiceUUIDHeartRate,
Characteristics: []bluetooth.CharacteristicConfig{ Characteristics: []bluetooth.CharacteristicConfig{
{ {
Handle: &heartRateMeasurement, Handle: &heartRateMeasurement,
UUID: bluetooth.New16BitUUID(0x2A37), // Heart Rate Measurement UUID: bluetooth.CharacteristicUUIDHeartRateMeasurement,
Value: []byte{0, heartRate}, Value: []byte{0, heartRate},
Flags: bluetooth.CharacteristicNotifyPermission, Flags: bluetooth.CharacteristicNotifyPermission,
}, },
}, },
})) }))

View file

@ -9,9 +9,9 @@ import (
) )
var ( var (
serviceUUID = bluetooth.NewUUID([16]byte{0x6E, 0x40, 0x00, 0x01, 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E}) serviceUUID = bluetooth.ServiceUUIDNordicUART
rxUUID = bluetooth.NewUUID([16]byte{0x6E, 0x40, 0x00, 0x02, 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E}) rxUUID = bluetooth.CharacteristicUUIDUARTRX
txUUID = bluetooth.NewUUID([16]byte{0x6E, 0x40, 0x00, 0x03, 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E}) txUUID = bluetooth.CharacteristicUUIDUARTTX
) )
var adapter = bluetooth.DefaultAdapter var adapter = bluetooth.DefaultAdapter

View file

@ -13,9 +13,9 @@ import (
) )
var ( var (
serviceUUID = bluetooth.NewUUID([16]byte{0x6E, 0x40, 0x00, 0x01, 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E}) serviceUUID = bluetooth.ServiceUUIDNordicUART
rxUUID = bluetooth.NewUUID([16]byte{0x6E, 0x40, 0x00, 0x02, 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E}) rxUUID = bluetooth.CharacteristicUUIDUARTRX
txUUID = bluetooth.NewUUID([16]byte{0x6E, 0x40, 0x00, 0x03, 0xB5, 0xA3, 0xF3, 0x93, 0xE0, 0xA9, 0xE5, 0x0E, 0x24, 0xDC, 0xCA, 0x9E}) txUUID = bluetooth.CharacteristicUUIDUARTTX
) )
func main() { func main() {