/
ProfileManager.go
42 lines (34 loc) · 1019 Bytes
/
ProfileManager.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package toolz
import (
"github.com/godbus/dbus"
"github.com/mame82/mblue-toolz/dbusHelper"
)
const DBusNameProfileManager1Interface = "org.bluez.ProfileManager1"
type DBusBluezProfileOptions map[string]dbus.Variant
type ProfileManager1 struct {
c *dbusHelper.Client
}
func (pm *ProfileManager1) RegisterProfile(profilePath dbus.ObjectPath, UUID string, options DBusBluezProfileOptions) error {
call, err := pm.c.Call("RegisterProfile", profilePath, UUID, options)
if err != nil {
return err
}
return call.Err
}
func (pm *ProfileManager1) UnregisterProfile(profilePath dbus.ObjectPath) error {
call, err := pm.c.Call("UnregisterProfile", profilePath)
if err != nil {
return err
}
return call.Err
}
func (pm *ProfileManager1) Close() {
// closes CLients DBus connection
pm.c.Disconnect()
}
func ProfileManager() (res *ProfileManager1, err error) {
res = &ProfileManager1{
c: dbusHelper.NewClient(dbusHelper.SystemBus, "org.bluez", DBusNameProfileManager1Interface, "/org/bluez"),
}
return
}