infinitime/btsetup.go

28 lines
490 B
Go

package infinitime
import (
"os/exec"
bt "github.com/muka/go-bluetooth/api"
"github.com/muka/go-bluetooth/bluez/profile/adapter"
)
var defaultAdapter *adapter.Adapter1
func init() {
// Get bluez default adapter
da, err := bt.GetDefaultAdapter()
if err != nil {
panic(err)
}
// Power on command (workaround as go-bluetooth does not have a power on function)
exec.Command("bluetoothctl", "power", "on").Start()
defaultAdapter = da
}
func Exit() error {
return bt.Exit()
}