public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* Problems with returning Default Adapter in C-Glib-DBus code
@ 2008-05-22 22:20 David Stockwell
  2008-05-22 23:17 ` [Bluez-devel] " Marcel Holtmann
  0 siblings, 1 reply; 4+ messages in thread
From: David Stockwell @ 2008-05-22 22:20 UTC (permalink / raw)
  To: BlueZ development; +Cc: Marcel Holtmann, Johan Hedberg


[-- Attachment #1.1: Type: text/plain, Size: 1835 bytes --]

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



[-- Attachment #1.2: Type: text/html, Size: 2678 bytes --]

[-- Attachment #2: DefaultAdapter.cpp --]
[-- Type: application/octet-stream, Size: 2002 bytes --]

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <string>
#include <iostream>
#include <cstdlib>
#include <vector>

// #define DBUS_API_SUBJECT_TO_CHANGE

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

using namespace std;

static	GMainLoop *mainLoop=NULL;
static	DBusGConnection	*dBusG = NULL;
static	GError		*dError=NULL;
static	DBusGProxy	*dMgrObj=NULL;

static void run_mainLoop() {
	GMainContext *ctx;
	ctx=g_main_loop_get_context(mainLoop);
	while (g_main_context_pending(ctx))
		g_main_context_iteration(ctx, FALSE);
}

int main(int argc, char *argv[])
{
	char	*servicePath = (char *) malloc(32);

	g_type_init();
	g_log_set_always_fatal(G_LOG_LEVEL_WARNING);
	mainLoop=g_main_loop_new(NULL, FALSE);

	dBusG=dbus_g_bus_get(DBUS_BUS_SYSTEM, &dError);
	if (dError!=NULL) {
		cout << "Connection to System Bus failed: " << dError->message << endl;
		g_error_free(dError);
		return	EXIT_FAILURE;
	}

	run_mainLoop();

	dbus_g_connection_flush(dBusG);

//	registerMarshallers();

	dMgrObj=dbus_g_proxy_new_for_name(dBusG, "org.bluez", "/", "org.bluez.Manager");
	cout << "after dbus_g_proxy_new_for_name (dMgrObj)" << endl;
	cout << " bus:       " << dbus_g_proxy_get_bus_name(dMgrObj) << endl;
	cout << " path:      " << dbus_g_proxy_get_path(dMgrObj) << endl;
	cout << " interface: " << dbus_g_proxy_get_interface(dMgrObj) << endl;
	initManagerSignals(dBusG, dMgrObj);

/*
	Now, identify the Default Adapter path and establish a proxy to the org.bluez.Adapter interface for that Adapter
*/

	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;
		}
	}
}

[-- Attachment #3: DefaultAdapterOut.txt --]
[-- Type: text/plain, Size: 174 bytes --]

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'

[-- Attachment #4: DefaultAdapter.txt --]
[-- Type: text/plain, Size: 412 bytes --]

[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"

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-22 23:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-22 22:20 Problems with returning Default Adapter in C-Glib-DBus code David Stockwell
2008-05-22 23:17 ` [Bluez-devel] " Marcel Holtmann
2008-05-22 23:46   ` David Stockwell
2008-05-22 23:53     ` [Bluez-devel] " Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox