Skip to content

Commit 85e2305

Browse files
hoegaardendeadprogram
authored andcommitted
linux: Allow users to choose between different adapters
1 parent a798a48 commit 85e2305

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

adapter_linux.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,21 @@ type Adapter struct {
2626
connectHandler func(device Device, connected bool)
2727
}
2828

29+
// NewAdapter creates a new Adapter with the given ID.
30+
//
31+
// Make sure to call Enable() before using it to initialize the adapter.
32+
func NewAdapter(id string) *Adapter {
33+
return &Adapter{
34+
id: id,
35+
connectHandler: func(device Device, connected bool) {},
36+
}
37+
}
38+
2939
// DefaultAdapter is the default adapter on the system. On Linux, it is the
3040
// first adapter available.
3141
//
3242
// Make sure to call Enable() before using it to initialize the adapter.
33-
var DefaultAdapter = &Adapter{
34-
id: defaultAdapter,
35-
connectHandler: func(device Device, connected bool) {
36-
},
37-
}
43+
var DefaultAdapter = NewAdapter(defaultAdapter)
3844

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

0 commit comments

Comments
 (0)