prototooth/adapter_windows.go
Ayke van Laethem 0474d7b750
all: change DefaultAdapter function to global
All initialization can be done in the Enable call. This makes the API a
bit simpler and a bit more consistent between Nordic chips and other BLE
interfaces.
2020-06-01 13:27:56 +02:00

23 lines
588 B
Go

package bluetooth
import (
"github.com/go-ole/go-ole"
"github.com/tinygo-org/bluetooth/winbt"
)
type Adapter struct {
handler func(Event)
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
}