Create Init() rather than using init()

gatt_localtime
Arsen Musayelyan 1 year ago
parent 75942bdb0c
commit 7fb1fcce68

@ -1,27 +1,27 @@
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() {
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()
da.SetPowered(true)
defaultAdapter = da
}
func Exit() error {
if defaultAdapter != nil {
defaultAdapter.Close()
}
return bt.Exit()
}

Loading…
Cancel
Save