prototooth/adapter_windows.go
Ayke van Laethem f69df9d879
all: fix bug that caused a copied DefaultAdapter
The DefaultAdapter was a regular value, not a pointer-to-struct. This
meant that simply copying bluetooth.DefaultAdapter caused a copy of the
object itself (instead of a copy of the reference, as intended). This
meant that write events did not arrive.
2020-06-03 01:13:46 +02:00

22 lines
568 B
Go

package bluetooth
import (
"github.com/go-ole/go-ole"
"github.com/tinygo-org/bluetooth/winbt"
)
type Adapter struct {
watcher *winbt.IBluetoothLEAdvertisementWatcher
}
// DefaultAdapter is the default adapter on the system.
//
// Make sure to call Enable() before using it to initialize the adapter.
var DefaultAdapter = &Adapter{}
// Enable configures the BLE stack. It must be called before any
// Bluetooth-related calls (unless otherwise indicated).
func (a *Adapter) Enable() error {
return ole.RoInitialize(1) // initialize with multithreading enabled
}