Merge pull request #295 from alytvynov/dev
ble: populate descriptors after descovering characterisitcs
This commit is contained in:
commit
0f4d861bab
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue