2021-08-20 00:41:09 +00:00
|
|
|
package infinitime
|
|
|
|
|
|
|
|
import (
|
2021-09-09 15:34:56 +00:00
|
|
|
"os/exec"
|
|
|
|
|
2021-08-20 00:41:09 +00:00
|
|
|
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)
|
|
|
|
}
|
2021-09-09 15:34:56 +00:00
|
|
|
|
|
|
|
// Power on command (workaround as go-bluetooth does not have a power on function)
|
|
|
|
exec.Command("bluetoothctl", "power", "on").Start()
|
|
|
|
|
2021-08-20 00:41:09 +00:00
|
|
|
defaultAdapter = da
|
|
|
|
}
|
|
|
|
|
|
|
|
func Exit() error {
|
|
|
|
return bt.Exit()
|
2021-09-09 15:34:56 +00:00
|
|
|
}
|