This repository has been archived on 2024-04-14. You can view files and clone it, but cannot push or open issues or pull requests.
infinitime/btsetup.go

28 lines
418 B
Go

package infinitime
import (
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)
}
da.SetPowered(true)
defaultAdapter = da
}
func Exit() error {
if defaultAdapter != nil {
defaultAdapter.Close()
}
return bt.Exit()
}