bluetooth icon indicating copy to clipboard operation
bluetooth copied to clipboard

Add support for context handling

Open Lenart12 opened this issue 11 months ago • 1 comments

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
}

Lenart12 avatar Feb 11 '25 21:02 Lenart12

I was just about to open the same issue, I will try to open a simple pull request for Connect

acouvreur avatar Oct 04 '25 16:10 acouvreur