Skip to content

Commit

Permalink
linux: Allow users to choose between different adapters
Browse files Browse the repository at this point in the history
  • Loading branch information
hoegaarden authored and deadprogram committed Jan 2, 2025
1 parent a798a48 commit 85e2305
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions adapter_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ type Adapter struct {
connectHandler func(device Device, connected bool)
}

// NewAdapter creates a new Adapter with the given ID.
//
// Make sure to call Enable() before using it to initialize the adapter.
func NewAdapter(id string) *Adapter {
return &Adapter{
id: id,
connectHandler: func(device Device, connected bool) {},
}
}

// DefaultAdapter is the default adapter on the system. On Linux, it is the
// first adapter available.
//
// Make sure to call Enable() before using it to initialize the adapter.
var DefaultAdapter = &Adapter{
id: defaultAdapter,
connectHandler: func(device Device, connected bool) {
},
}
var DefaultAdapter = NewAdapter(defaultAdapter)

// Enable configures the BLE stack. It must be called before any
// Bluetooth-related calls (unless otherwise indicated).
Expand Down

0 comments on commit 85e2305

Please sign in to comment.