bluetooth/adapter_windows.go
Ayke van Laethem 22553053ff Add initial Windows support
Only scanning has been implemented so far. The most work was really just
understanding WinRT well enough to get to this point.
2020-05-30 21:51:27 +02:00

25 lines
594 B
Go

package bluetooth
import (
"github.com/aykevl/go-bluetooth/winbt"
"github.com/go-ole/go-ole"
)
type Adapter struct {
handler func(Event)
watcher *winbt.IBluetoothLEAdvertisementWatcher
}
var defaultAdapter Adapter
// DefaultAdapter returns the default adapter on the current system.
func DefaultAdapter() (*Adapter, error) {
return &defaultAdapter, nil
}
// 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
}