Hi,
I'm trying to access a service via dbus using your library. I am right now a bit stuck as the method which I am invoking is running into a "No reply within specified time" error. To narrow the issue down I first wanted to know whether my test code is correct.
My simple test code looks as follows:
`public class Main {
public static void main(String[] args) {
try (DBusConnection dbus = DBusConnection.getConnection(DBusConnection.DBusBusType.SYSTEM);) {
dbus.requestBusName("at.valli.mesh");
String busName = "org.bluez.mesh";
String objectPath = "/org/bluez/mesh";
Network1 mesh = dbus.getRemoteObject(busName, objectPath, Network1.class);
TestApplication application = new TestApplication();
dbus.exportObject(application.getObjectPath(), application);
TestElement element1 = new TestElement(application.getObjectPath(), (byte) 0);
TestElement element2 = new TestElement(application.getObjectPath(), (byte) 1);
dbus.exportObject(element1.getObjectPath(), element1);
dbus.exportObject(element2.getObjectPath(), element2);
UUID uuid = UUID.randomUUID();
mesh.Join(application, UUIDs.toBytes(uuid));
Thread.sleep(30000);
dbus.releaseBusName("at.valli.mesh");
} catch (NoReply | DBusException | IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}`
and the corresponding log output is as follows:
`13:18:05,277 DEBUG [main] o.f.d.c.Transport: Connecting to UNIX: {path=/var/run/dbus/system_bus_socket}
13:18:05,466 DEBUG [main] o.f.d.m.MethodCall: Creating message with serial 1
13:18:05,469 DEBUG [main] o.f.d.m.MethodCall: Appending sig: yyyy data: [66, 1, 0, 1]
13:18:05,470 DEBUG [main] o.f.d.m.MethodCall: Appending sig: ua(yv) data: [1, [[1, [o, /org/freedesktop/DBus]], [6, [s, org.freedesktop.DBus]], [2, [s, org.freedesktop.DBus]], [3, [s, Hello]]]]
13:18:05,471 DEBUG [main] o.f.d.m.MethodCall: Appended body, type: null start: 128 end: 128 size: 0
13:18:05,471 DEBUG [main] o.f.d.m.MethodCall: marshalled size ([0, 0, 0, 0]): 000000 00 00 00 00 ....
13:18:05,476 DEBUG [DBus Sender Thread-1] o.f.d.MessageWriter: <= MethodCall(0,1) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>Hello, Destination=>org.freedesktop.DBus } { }
13:18:05,484 DEBUG [DBusConnection] o.f.d.MessageReader: => MethodReturn(1,1) { Reply Serial=>1, Destination=>:1.73, Sender=>org.freedesktop.DBus, Signature=>s } { :1.73 }
13:18:05,485 DEBUG [DBusConnection] o.f.d.c.i.DBusConnection: Handling incoming method return: MethodReturn(1,1) { Reply Serial=>1, Destination=>:1.73, Sender=>org.freedesktop.DBus, Signature=>s } { :1.73 }
13:18:05,485 DEBUG [main] o.f.d.m.MethodCall: Creating message with serial 2
13:18:05,486 DEBUG [main] o.f.d.m.MethodCall: Appending sig: yyyy data: [66, 1, 0, 1]
13:18:05,486 DEBUG [main] o.f.d.m.MethodCall: Appending arguments with signature: su
13:18:05,487 DEBUG [main] o.f.d.m.MethodCall: Appending sig: ua(yv) data: [2, [[1, [o, /org/freedesktop/DBus]], [6, [s, org.freedesktop.DBus]], [2, [s, org.freedesktop.DBus]], [3, [s, RequestName]], [8, [g, su]]]]
13:18:05,487 DEBUG [main] o.f.d.m.MethodCall: Appending sig: su data: [at.valli.mesh, 6]
13:18:05,502 DEBUG [main] o.f.d.m.MethodCall: Appended body, type: su start: 144 end: 172 size: 28
13:18:05,502 DEBUG [main] o.f.d.m.MethodCall: marshalled size ([0, 0, 0, 28]): 000000 00 00 00 1c ...�
13:18:05,503 DEBUG [DBusConnection] o.f.d.MessageReader: => DBusSignal [clazz=null]
13:18:05,504 DEBUG [DBusConnection] o.f.d.c.i.DBusConnection: Handling incoming signal:
13:18:05,505 DEBUG [DBus Sender Thread-1] o.f.d.MessageWriter: <= MethodCall(0,2) { Path=>/org/freedesktop/DBus, Interface=>org.freedesktop.DBus, Member=>RequestName, Destination=>org.freedesktop.DBus, Signature=>su } { at.valli.mesh, 6 }
13:18:05,521 DEBUG [DBusConnection] o.f.d.MessageReader: => DBusSignal [clazz=null]
13:18:05,521 DEBUG [DBusConnection] o.f.d.c.i.DBusConnection: Handling incoming signal:
13:18:05,522 DEBUG [DBus Worker Thread-1] o.f.d.m.DBusSignal: Converting signal to type: class org.freedesktop.DBus$NameAcquired
13:18:05,522 DEBUG [DBus Worker Thread-1] o.f.d.m.DBusSignal: Creating signal of type class org.freedesktop.DBus$NameAcquired with parameters [/org/freedesktop/DBus, :1.73]
13:18:05,523 DEBUG [DBus Worker Thread-1] o.f.DBus$NameAcquired: Creating message with serial 3
13:18:05,523 DEBUG [DBus Worker Thread-1] o.f.DBus$NameAcquired: Appending sig: yyyy data: [66, 4, 0, 1]
13:18:05,533 DEBUG [DBus Worker Thread-1] o.f.DBus$NameAcquired: Appending sig: ua(yv) data: [4, [[1, [o, /org/freedesktop/DBus]], [2, [s, org.freedesktop.DBus]], [3, [s, NameAcquired]], [8, [g, s]]]]
13:18:05,532 DEBUG [DBus Worker Thread-2] o.f.d.m.DBusSignal: Converting signal to type: class org.freedesktop.DBus$NameAcquired
13:18:05,533 DEBUG [DBus Worker Thread-2] o.f.d.m.DBusSignal: Creating signal of type class org.freedesktop.DBus$NameAcquired with parameters [/org/freedesktop/DBus, at.valli.mesh]
13:18:05,534 DEBUG [DBus Worker Thread-2] o.f.DBus$NameAcquired: Creating message with serial 4
13:18:05,534 DEBUG [DBus Worker Thread-2] o.f.DBus$NameAcquired: Appending sig: yyyy data: [66, 4, 0, 1]
13:18:05,534 DEBUG [DBus Worker Thread-2] o.f.DBus$NameAcquired: Appending sig: ua(yv) data: [5, [[1, [o, /org/freedesktop/DBus]], [2, [s, org.freedesktop.DBus]], [3, [s, NameAcquired]], [8, [g, s]]]]
13:18:05,532 DEBUG [DBusConnection] o.f.d.MessageReader: => MethodReturn(1,4) { Reply Serial=>2, Destination=>:1.73, Sender=>org.freedesktop.DBus, Signature=>u } { 1 }
13:18:05,536 DEBUG [DBusConnection] o.f.d.c.i.DBusConnection: Handling incoming method return: MethodReturn(1,4) { Reply Serial=>2, Destination=>:1.73, Sender=>org.freedesktop.DBus, Signature=>u } { 1 }
13:18:05,544 DEBUG [main] o.f.d.m.ObjectTree: Adding /at/valli/mesh to object tree
13:18:05,568 DEBUG [main] o.f.d.m.ObjectTree: Adding /at/valli/mesh/element/0 to object tree
13:18:05,570 DEBUG [main] o.f.d.m.ObjectTree: Adding /at/valli/mesh/element/1 to object tree
13:18:05,603 DEBUG [main] o.f.d.m.MethodCall: Creating message with serial 5
13:18:05,604 DEBUG [main] o.f.d.m.MethodCall: Appending sig: yyyy data: [66, 1, 0, 1]
13:18:05,612 DEBUG [main] o.f.d.m.MethodCall: Appending arguments with signature: oay
13:18:05,612 DEBUG [main] o.f.d.m.MethodCall: Appending sig: ua(yv) data: [5, [[1, [o, /org/bluez/mesh]], [6, [s, org.bluez.mesh]], [2, [s, org.bluez.mesh.Network1]], [3, [s, Join]], [8, [g, oay]]]]
13:18:05,614 DEBUG [main] o.f.d.m.MethodCall: Appending sig: oay data: [/at/valli/mesh, [13, -20, -21, -22, -10, 34, 73, 5, -82, -109, -6, 38, 24, -42, -80, -121]]
13:18:05,614 DEBUG [main] o.f.d.m.MethodCall: Appended body, type: oay start: 128 end: 172 size: 44
13:18:05,620 DEBUG [main] o.f.d.m.MethodCall: marshalled size ([0, 0, 0, 44]): 000000 00 00 00 2c ...,
13:18:05,621 DEBUG [DBus Sender Thread-1] o.f.d.MessageWriter: <= MethodCall(0,5) { Path=>/org/bluez/mesh, Interface=>org.bluez.mesh.Network1, Member=>Join, Destination=>org.bluez.mesh, Signature=>oay } { /at/valli/mesh, [13, -20, -21, -22, -10, 34, 73, 5, -82, -109, -6, 38, 24, -42, -80, -121] }
13:18:25,624 DEBUG [main] o.f.d.c.i.DBusConnection: Disconnecting last remaining DBusConnection
13:18:25,625 DEBUG [main] o.f.d.e.Error: Creating message with serial 6
13:18:25,628 DEBUG [main] o.f.d.e.Error: Appending sig: yyyy data: [66, 3, 0, 1]
13:18:25,629 DEBUG [main] o.f.d.e.Error: Appending sig: ua(yv) data: [6, [[4, [s, org.freedesktop.DBus.Local.Disconnected]], [5, [u, 0]], [6, [s, org.freedesktop.DBus.Local]], [8, [g, s]]]]
13:18:25,635 DEBUG [main] o.f.d.e.Error: Appending sig: s data: [Disconnected]
13:18:25,636 DEBUG [main] o.f.d.c.i.DBusConnection: Sending disconnected signal
13:18:25,637 DEBUG [main] o.f.d.i.Local$Disconnected: Creating message with serial 7
13:18:25,641 DEBUG [main] o.f.d.i.Local$Disconnected: Appending sig: yyyy data: [66, 4, 0, 1]
13:18:25,642 DEBUG [main] o.f.d.i.Local$Disconnected: Appending sig: ua(yv) data: [8, [[1, [o, /]], [2, [s, org.freedesktop.DBus.Local]], [3, [s, Disconnected]]]]
13:18:25,643 DEBUG [main] o.f.d.c.i.DBusConnection: Handling incoming signal:
13:18:25,645 DEBUG [main] o.f.d.c.i.DBusConnection: Handling Disconnected signal from bus
13:18:25,646 DEBUG [main] o.f.d.e.Error: Creating message with serial 8
13:18:25,646 DEBUG [main] o.f.d.e.Error: Appending sig: yyyy data: [66, 3, 0, 1]
13:18:25,647 DEBUG [main] o.f.d.e.Error: Appending sig: ua(yv) data: [8, [[4, [s, org.freedesktop.DBus.Local.Disconnected]], [5, [u, 0]], [6, [s, org.freedesktop.DBus.Local]], [8, [g, s]]]]
13:18:25,650 DEBUG [main] o.f.d.e.Error: Appending sig: s data: [Disconnected]
13:18:25,652 DEBUG [main] o.f.d.c.i.DBusConnection: Handling Disconnected signal from bus
13:18:25,653 DEBUG [main] o.f.d.e.Error: Creating message with serial 9
13:18:25,653 DEBUG [main] o.f.d.e.Error: Appending sig: yyyy data: [66, 3, 0, 1]
13:18:25,658 DEBUG [main] o.f.d.e.Error: Appending sig: ua(yv) data: [9, [[4, [s, org.freedesktop.DBus.Local.Disconnected]], [5, [u, 0]], [6, [s, org.freedesktop.DBus.Local]], [8, [g, s]]]]
13:18:25,658 DEBUG [main] o.f.d.e.Error: Appending sig: s data: [Disconnected]
13:18:25,658 DEBUG [main] o.f.d.c.i.DBusConnection: Disconnecting Abstract Connection
13:18:25,659 DEBUG [main] o.f.d.c.Transport: Disconnecting Transport
13:18:25,659 DEBUG [main] c.a.m.u.UnixSocket: Closing socket
13:18:25,672 DEBUG [main] o.f.d.MessageWriter: Closing Message Writer
org.freedesktop.dbus.errors.NoReply: No reply within specified time
at org.freedesktop.dbus.RemoteInvocationHandler.executeRemoteMethod(RemoteInvocationHandler.java:160)
at org.freedesktop.dbus.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:228)
at com.sun.proxy.$Proxy19.Join(Unknown Source)
at at.valli.Main.main(Main.java:34)
13:18:25,672 DEBUG [main] c.a.m.u.UnixSocket: Closing socket`
The method I want to invoked is defined as follows:
void Join(object app_defined_root, array{byte}[16] uuid)
<method name="Join"> <arg name="app" type="o" direction="in"/> <arg name="uuid" type="ay" direction="in"/> </method>
I've mapped that with the help of the CodeGenerator to:
void Join(DBusInterface app_defined_root, List<Byte> uuid);
Best regards
valli