From f20424feadbb00b89f62147dc44ddde9602cb6f2 Mon Sep 17 00:00:00 2001 From: Andrew Lytvynov Date: Wed, 13 Jul 2016 10:16:58 -0700 Subject: [PATCH 1/2] ble: populate descriptors after descovering characterisitcs On Linux, characteristic discovery requires setting the descriptor field explicitly. --- platforms/ble/ble_client_adaptor.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/platforms/ble/ble_client_adaptor.go b/platforms/ble/ble_client_adaptor.go index 2a864f0a..673cda05 100644 --- a/platforms/ble/ble_client_adaptor.go +++ b/platforms/ble/ble_client_adaptor.go @@ -2,10 +2,11 @@ package ble import ( "fmt" - "github.com/currantlabs/gatt" - "github.com/hybridgroup/gobot" "log" "strings" + + "github.com/currantlabs/gatt" + "github.com/hybridgroup/gobot" ) var _ gobot.Adaptor = (*BLEClientAdaptor)(nil) @@ -200,6 +201,7 @@ func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error) { return } +outer: for _, s := range ss { b.services[s.UUID().String()] = NewBLEService(s.UUID().String(), s) @@ -210,6 +212,11 @@ func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error) { } for _, c := range cs { + desc, err := p.DiscoverDescriptors(nil, c) + if err != nil { + fmt.Printf("Failed to discover descriptors: %v\n", err) + continue outer + } b.services[s.UUID().String()].characteristics[c.UUID().String()] = c } } From f6920ab65c48f88befc651fa16a35826d628742d Mon Sep 17 00:00:00 2001 From: Andrew Lytvynov Date: Wed, 13 Jul 2016 10:25:30 -0700 Subject: [PATCH 2/2] ble: fix unused var Shame on me --- platforms/ble/ble_client_adaptor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/ble/ble_client_adaptor.go b/platforms/ble/ble_client_adaptor.go index 673cda05..3846e2de 100644 --- a/platforms/ble/ble_client_adaptor.go +++ b/platforms/ble/ble_client_adaptor.go @@ -212,7 +212,7 @@ outer: } for _, c := range cs { - desc, err := p.DiscoverDescriptors(nil, c) + _, err := p.DiscoverDescriptors(nil, c) if err != nil { fmt.Printf("Failed to discover descriptors: %v\n", err) continue outer