forked from muka/go-bluetooth
/
GattManager1.go
55 lines (47 loc) · 1.43 KB
/
GattManager1.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
43
44
45
46
47
48
49
50
51
52
53
54
55
package profile
import (
"github.com/phommel/go-bluetooth/bluez"
"github.com/godbus/dbus"
log "github.com/sirupsen/logrus"
)
// NewGattManager1 create a new GattManager1 client
func NewGattManager1(hostID string) *GattManager1 {
a := new(GattManager1)
a.client = bluez.NewClient(
&bluez.Config{
Name: "org.bluez",
Iface: "org.bluez.GattManager1",
Path: "/org/bluez/" + hostID,
Bus: bluez.SystemBus,
},
)
a.Properties = new(GattManager1Properties)
a.GetProperties()
return a
}
// GattManager1 client
type GattManager1 struct {
client *bluez.Client
Properties *GattManager1Properties
}
// GattManager1Properties exposed properties for GattManager1
type GattManager1Properties struct {
}
//GetProperties load all available properties
func (a *GattManager1) GetProperties() (*GattManager1Properties, error) {
err := a.client.GetProperties(a.Properties)
return a.Properties, err
}
// Close the connection
func (a *GattManager1) Close() {
a.client.Disconnect()
}
//RegisterApplication add a new bluetooth Application
func (a *GattManager1) RegisterApplication(app dbus.ObjectPath, options map[string]interface{}) error {
log.Debugf("Registering app %s", app)
return a.client.Call("RegisterApplication", 0, app, options).Store()
}
//UnregisterApplication remove a bluetooth Application
func (a *GattManager1) UnregisterApplication(app dbus.ObjectPath) error {
return a.client.Call("UnregisterApplication", 0, app).Store()
}