Merge pull request #295 from alytvynov/dev

ble: populate descriptors after descovering characterisitcs
This commit is contained in:
Ron Evans 2016-07-13 12:16:38 -06:00 committed by GitHub
commit 0f4d861bab
1 changed files with 9 additions and 2 deletions

View File

@ -2,10 +2,11 @@ package ble
import ( import (
"fmt" "fmt"
"github.com/currantlabs/gatt"
"github.com/hybridgroup/gobot"
"log" "log"
"strings" "strings"
"github.com/currantlabs/gatt"
"github.com/hybridgroup/gobot"
) )
var _ gobot.Adaptor = (*BLEClientAdaptor)(nil) var _ gobot.Adaptor = (*BLEClientAdaptor)(nil)
@ -200,6 +201,7 @@ func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error) {
return return
} }
outer:
for _, s := range ss { for _, s := range ss {
b.services[s.UUID().String()] = NewBLEService(s.UUID().String(), s) 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 { for _, c := range cs {
_, 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 b.services[s.UUID().String()].characteristics[c.UUID().String()] = c
} }
} }