Closed
Description
Running on Ubuntu 18.04, although the same issue appears on Ubuntu 16 Core
I've found an issue in an app I'm writing, where I scan the Bluetooth devices in range, filter out any devices that are not the sensors I'm interested in, then connect to each in turn in order to obtain information from them. After 4 successful connections connections lock up in Scan it seems.
I've modified the main function in examples/basic/explorer to distill the issue into something that I hope makes sense. This will connect to the first few devices, then it will never come out of dev.NewDevice(...)
func main() {
flag.Parse()
d, err := dev.NewDevice(*device)
if err != nil {
log.Fatalf("can't new device : %s", err)
}
ble.SetDefaultDevice(d)
addresses := []string{"c1:85:1f:60:83:f8", "c7:7f:04:8d:ee:59", "c9:35:97:07:94:e1", "e6:2d:89:8c:49:6c", "e6:bd:57:4e:20:df", "e9:1e:0e:18:d0:92", "eb:d6:c9:6c:ef:87", "ed:24:62:72:24:9b", "f4:64:fb:60:22:cb"}
for _, a := range addresses {
filter := filter(a)
ctx := ble.WithSigHandler(context.WithTimeout(context.Background(), *sd))
cln, err := ble.Connect(ctx, filter)
if err != nil {
log.Fatalf("can't connect : %s", err)
}
done := make(chan struct{})
go func() {
<-cln.Disconnected()
fmt.Printf("[ %s ] is disconnected \n", cln.Addr())
close(done)
}()
fmt.Printf("Discovering profile...\n")
_, err = cln.DiscoverProfile(true)
if err != nil {
log.Fatalf("can't discover profile: %s", err)
}
// Disconnect the connection. (On OS X, this might take a while.)
fmt.Printf("Disconnecting [ %s ]... (this might take up to few seconds on OS X)\n", cln.Addr())
cln.CancelConnection()
<-done
}
}
Metadata
Metadata
Assignees
Labels
No labels