bluetooth
bluetooth copied to clipboard
Add support for context handling
Currently the api does not allow passing context instead of timeouts. My suggestion is to refactor long running methods to their *WithContext alternative and change the existing methods to call those with background context. While this is a large request, I think it is really needed with many applications.
Example:
func (a *Adapter) Connect(address Address, params ConnectionParams) (d Device, e error) {
d, e = a.ConnectWithContext(context.Background(), address, params)
return
}
func (a *Adapter) ConnectWithContext(ctx context.Context, address Address, params ConnectionParams) (Device, error) {
// actual implementation
}
I was just about to open the same issue, I will try to open a simple pull request for Connect