prototooth/adapter_windows.go
Ron Evans 6dc1dff711
gap: add connection handler to be called on adapter connect/disconnect
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-09-10 17:17:45 +02:00

28 lines
687 B
Go

package bluetooth
import (
"github.com/go-ole/go-ole"
"tinygo.org/x/bluetooth/winbt"
)
type Adapter struct {
watcher *winbt.IBluetoothLEAdvertisementWatcher
connectHandler func(device Addresser, connected bool)
}
// DefaultAdapter is the default adapter on the system.
//
// Make sure to call Enable() before using it to initialize the adapter.
var DefaultAdapter = &Adapter{
connectHandler: func(device Addresser, connected bool) {
return
},
}
// 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
}