-
Notifications
You must be signed in to change notification settings - Fork 0
/
register_profile.vala
66 lines (59 loc) · 2.36 KB
/
register_profile.vala
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
56
57
58
59
60
61
62
63
64
65
66
/**********************************************************************
owon-tools - Copyright (C) 2017 - Andreas Kemnade
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied
warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
[DBus (name = "org.bluez.GattProfile1")]
class GattProfile : Object {
public void release() {
stderr.printf("profile release\n");
}
string [] u_u_i_ds;
[DBus (visible = false)]
public GattProfile(string [] uuids) {
u_u_i_ds = uuids;
}
[DBus (visible = false)]
public HashTable<string,Variant> get_all_prop() {
var ht = new HashTable<string,Variant>(str_hash, str_equal);
ht["UUIDs"] = new Variant.strv(u_u_i_ds);
return ht;
}
}
[DBus (name = "org.freedesktop.DBus.ObjectManager")]
class FDObjectManager : Object {
public HashTable<GLib.ObjectPath,HashTable<string,HashTable<string,Variant>>> get_managed_objects() {
var ht = new HashTable<string,HashTable<string,Variant>>(str_hash, str_equal);
ht["org.bluez.GattProfile1"] = profile.get_all_prop();
var res = new HashTable<GLib.ObjectPath,HashTable<string,HashTable<string,Variant>>>(str_hash, str_equal);
res[new ObjectPath("/org/ak/owonmulti/bleprofile")] = ht;
return res;
}
[DBus (visible = false)]
GattProfile profile;
[DBus (visible = false)]
public FDObjectManager(GattProfile profile) {
this.profile = profile;
}
}
public void register_profile(DBusConnection conn, string uuid)
{
string [] uuids = {uuid};
GattProfile gattprof = new GattProfile(uuids);
org.bluez.GattManager1 manager = conn.get_proxy_sync("org.bluez", "/org/bluez/hci0");
conn.register_object("/org/ak/owonmulti/bleprofile",
gattprof);
conn.register_object("/org/ak/owonmulti",
new FDObjectManager(gattprof));
/* conn.register_object("/",
new FDObjectManager(gattprof));
*/
manager.register_application.begin(new ObjectPath("/org/ak/owonmulti"),
new GLib.HashTable<string, GLib.Value?>(GLib.str_hash, GLib.str_equal));
}