Ask for adapter ID in Init()

This commit is contained in:
Elara 2022-05-02 20:14:46 -07:00
parent 6c3f1b14c9
commit 5e5eef15dc

View File

@ -11,7 +11,7 @@ import (
var defaultAdapter *adapter.Adapter1 var defaultAdapter *adapter.Adapter1
var itdAgent *Agent var itdAgent *Agent
func Init() { func Init(adapterID string) {
conn, err := dbus.SystemBus() conn, err := dbus.SystemBus()
if err != nil { if err != nil {
panic(err) panic(err)
@ -23,8 +23,12 @@ func Init() {
panic(err) panic(err)
} }
if adapterID == "" {
adapterID = bt.GetDefaultAdapterID()
}
// Get bluez default adapter // Get bluez default adapter
da, err := bt.GetDefaultAdapter() da, err := bt.GetAdapter(adapterID)
if err != nil { if err != nil {
panic(err) panic(err)
} }