Skip to content

Commit

Permalink
ble: scanresult channel needs to handle linux scan results
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Nov 27, 2020
1 parent b92f942 commit d0e5e83
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions platforms/ble/ble_client_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"sync"
"time"

"github.com/pkg/errors"
"gobot.io/x/gobot"
Expand Down Expand Up @@ -86,7 +87,7 @@ func (b *ClientAdaptor) Connect() (err error) {
b.addr.Set(b.Address())

// scan for the address
ch := make(chan bluetooth.ScanResult)
ch := make(chan bluetooth.ScanResult, 1)
err = b.adpt.Scan(func(adapter *bluetooth.Adapter, result bluetooth.ScanResult) {
if result.Address.String() == b.Address() {
b.adpt.StopScan()
Expand Down Expand Up @@ -137,7 +138,9 @@ func (b *ClientAdaptor) Reconnect() (err error) {

// Disconnect terminates the connection to the BLE peripheral. Returns true on successful disconnect.
func (b *ClientAdaptor) Disconnect() (err error) {
return b.device.Disconnect()
err = b.device.Disconnect()
time.Sleep(500 * time.Millisecond)
return
}

// Finalize finalizes the BLEAdaptor
Expand Down

0 comments on commit d0e5e83

Please sign in to comment.