2020-05-30 18:55:20 +00:00
|
|
|
package bluetooth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/go-ole/go-ole"
|
2020-05-31 14:45:26 +00:00
|
|
|
"github.com/tinygo-org/bluetooth/winbt"
|
2020-05-30 18:55:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type Adapter struct {
|
|
|
|
watcher *winbt.IBluetoothLEAdvertisementWatcher
|
|
|
|
}
|
|
|
|
|
2020-06-01 11:26:45 +00:00
|
|
|
// DefaultAdapter is the default adapter on the system.
|
|
|
|
//
|
|
|
|
// Make sure to call Enable() before using it to initialize the adapter.
|
2020-06-02 23:13:46 +00:00
|
|
|
var DefaultAdapter = &Adapter{}
|
2020-05-30 18:55:20 +00:00
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|