Skip to contentSkip to conversation

Problems with returning Default Adapter in C-Glib-DBus code

DISCUSSION David Stockwell 2 participants 4 messages May 22, 2008 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

Since upgrading to 3.32 (and possibly before), I have been having a problem with calling the new, experimental DefaultAdapter method against the "/". When I do so, it properly returns the Adapter path "/hci0", but fails with the following error: Unregistered object at path '/hci0'.

Prior to this, I used to call what was effectively the old DefaultAdapter using the "/org/bluez" path and returning the old string version of the Adapter path, receiving "/org/bluez/hci0".

Output of my failing program is as follows (also, in DefaultAdapterOut.txt):

after dbus_g_proxy_new_for_name (dMgrObj)
bus: org.bluez
path: /
interface: org.bluez.Manager
Failed to get DefaultAdapter: Unregistered object at path '/hci0'

At the same time, I called dbus-send to see if this was some more fundamental failure, but calls against both paths are successful, as shown in the following (DefaultAdapter.txt):

[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.DefaultAdapter method return sender=:1.12 -> dest=:1.22
string "/org/bluez/hci0"
[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter method return sender=:1.12 -> dest=:1.23
object path "/hci0"

I have attached a cut-down version of the source, which I am compiling against KDE and MandrivaLinux.

MY SUSPICION is that the real problem is that I did not adjust my source application to use libgdbus, introduced in 3.32. Specifically, given the following set of includes, which of these are replaced by gdbus.h?

#include <dbus/dbus.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
#include <glib-object.h>

Any hints will be appreciated...

David Stockwell

after dbus_g_proxy_new_for_name (dMgrObj)
bus: org.bluez
path: /
interface: org.bluez.Manager
Failed to get DefaultAdapter: Unregistered object at path '/hci0'

[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez org.bluez.Manager.DefaultAdapter method return sender=:1.12 -> dest=:1.22
string "/org/bluez/hci0"
[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call --print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter method return sender=:1.12 -> dest=:1.23
object path "/hci0"

maintainer
#1 lore raw

Hi David,

Quoted 22 lines

Since upgrading to 3.32 (and possibly before), I have been having a problem with calling the new, experimental DefaultAdapter method against the "/". When I do so, it properly returns the Adapter path "/hci0", but fails with the following error: Unregistered object at path '/hci0'.

Prior to this, I used to call what was effectively the old DefaultAdapter using the "/org/bluez" path and returning the old string version of the Adapter path, receiving "/org/bluez/hci0".

Output of my failing program is as follows (also, in DefaultAdapterOut.txt):

after dbus_g_proxy_new_for_name (dMgrObj)
bus: org.bluez
path: /
interface: org.bluez.Manager
Failed to get DefaultAdapter: Unregistered object at path '/hci0' At the same time, I called dbus-send to see if this was some more fundamental failure, but calls against both paths are successful, as shown in the following (DefaultAdapter.txt):

Quoted 9 lines

[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call -- print-reply --dest=org.bluez /org/bluez org.bluez.Manager.DefaultAdapter
method return sender=:1.12 -> dest=:1.22
string "/org/bluez/hci0"
[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call -- print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter method return sender=:1.12 -> dest=:1.23
object path "/hci0"

you have to give an object path instead of a string when using "/ hci0". That is the big change :)

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel

#2 lore raw

Actually, I did that...I think.

Please review the following call:

if (dbus_g_proxy_call(dMgrObj, "DefaultAdapter", &dError, G_TYPE_INVALID, G_TYPE_OBJECT, &servicePath, G_TYPE_INVALID)) {
cout << "DefaultAdapter is " << servicePath << endl;
} else {
if (dError!=NULL) {
cout << "Failed to get DefaultAdapter: " << dError->message << endl;
g_error_free(dError);
return EXIT_FAILURE;
}
}

The G_TYPE_OBJECT should mark the return value (stuffed into a char * servicePath) as an Object Path. Or am I mistaken?

DS

----- Original Message -----
From: "Marcel Holtmann" <[email protected]>
To: "David Stockwell" <[email protected]>
Cc: "BlueZ development" <[email protected]>; "Johan Hedberg" <[email protected]>
Sent: Thursday, May 22, 2008 6:17 PM
Subject: Re: Problems with returning Default Adapter in C-Glib-DBus code

Hi David,

Quoted 22 lines

Since upgrading to 3.32 (and possibly before), I have been having a problem with calling the new, experimental DefaultAdapter method against the "/". When I do so, it properly returns the Adapter path "/hci0", but fails with the following error: Unregistered object at path '/hci0'.

Prior to this, I used to call what was effectively the old DefaultAdapter using the "/org/bluez" path and returning the old string version of the Adapter path, receiving "/org/bluez/hci0".

Output of my failing program is as follows (also, in DefaultAdapterOut.txt):

after dbus_g_proxy_new_for_name (dMgrObj)
bus: org.bluez
path: /
interface: org.bluez.Manager
Failed to get DefaultAdapter: Unregistered object at path '/hci0' At the same time, I called dbus-send to see if this was some more fundamental failure, but calls against both paths are successful, as shown in the following (DefaultAdapter.txt):

Quoted 9 lines

[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call -- print-reply --dest=org.bluez /org/bluez org.bluez.Manager.DefaultAdapter
method return sender=:1.12 -> dest=:1.22
string "/org/bluez/hci0"
[dstockwell@freqonec001 ~]$ dbus-send --system --type=method_call -- print-reply --dest=org.bluez / org.bluez.Manager.DefaultAdapter method return sender=:1.12 -> dest=:1.23
object path "/hci0"

you have to give an object path instead of a string when using "/ hci0". That is the big change :)

Regards

Marcel

maintainer
#3 lore raw

Hi David,

Quoted 15 lines

Actually, I did that...I think.

Please review the following call:

if (dbus_g_proxy_call(dMgrObj, "DefaultAdapter", &dError, G_TYPE_INVALID, G_TYPE_OBJECT, &servicePath, G_TYPE_INVALID)) {
cout << "DefaultAdapter is " << servicePath << endl;
} else {
if (dError!=NULL) {
cout << "Failed to get DefaultAdapter: " << dError->message << endl; g_error_free(dError);
return EXIT_FAILURE;
}
}

Quoted 2 lines

The G_TYPE_OBJECT should mark the return value (stuffed into a char
* servicePath) as an Object Path. Or am I mistaken?

the type is an DBUS_G_OBJECT_PATH or similar.

Regards

Marcel

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Bluez-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-devel