Fix bug where Connect blocked forever after 10 seconds

This commit is contained in:
Elara 2021-08-22 13:09:56 -07:00
parent 8f4bb3e226
commit 613a7cb044

View File

@ -168,12 +168,11 @@ func pair(timeout time.Duration) (*Device, error) {
// Create new device
out := &Device{}
// Start bluetooth discovery
discovery, cancelDiscover, err := bt.Discover(defaultAdapter, &adapter.DiscoveryFilter{Transport: "le"})
// Ignore the cancel function as it blocks forever
discovery, _, err := bt.Discover(defaultAdapter, &adapter.DiscoveryFilter{Transport: "le"})
if err != nil {
return nil, err
}
// Cancel discovery at end of function
defer cancelDiscover()
discoveryLoop:
for {
select {