Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions gatt.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,17 @@ func Connect(ctx context.Context, f AdvFilter) (Client, error) {
}
}

cln, err := Dial(ctx, (<-ch).Addr())
return cln, errors.Wrap(err, "can't dial")
select {
case a, ok := <-ch:
if ok {
cln, err := Dial(ctx, a.Addr())
return cln, errors.Wrap(err, "can't dial")
} else {
return nil, errors.New("channel closed")
}
default:
return nil, errors.New("not found")
}
}

// A NotificationHandler handles notification or indication from a server.
Expand Down