Connection closed err in code. Dbus-send works fine though

PookieMonster pookie at mailinator.com
Tue Jul 26 09:02:48 PDT 2011


I'm trying to get the basic PIN agent (agent.c) that ships with Bluez to run
on my system.  Right now it's returning after the DBus call to get the
default bluetooth adapter in this chunk of code:

[code]
	msg = dbus_message_new_method_call("org.bluez", "/",
					"org.bluez.Manager", "DefaultAdapter");

	if (!msg) {
		printf("\n[Bluetooth] Can't allocate new method call\n");
		return NULL;
	}

	dbus_error_init(&err);

	reply = dbus_connection_send_with_reply_and_block(conn, msg, -1, &err);

	dbus_message_unref(msg);

	if (!reply) {
		fprintf(stderr,
			"[Bluetooth] Can't get default adapter\n");
		if (dbus_error_is_set(&err)) {
			fprintf(stderr, "[Bluetooth] %s\n", err.message);
			dbus_error_free(&err);
		}
		return NULL;
	} 
[/code]

reply is coming back NULL and err is set so I get this output:

[Bluetooth] Can't get default adapter
[Bluetooth] Connection is closed

However, if I run dbus-send on the same machine, I get back the information
I expect
# dbus-send --print-reply --system --dest=org.bluez --type=method_call /
org.bluez.Manager.DefaultAdapter
method return sender=:1.0 -> dest=:1.9 reply_serial=2
   object path "/org/bluez/146/hci0"

Any ideas what would cause it to work in one place and not the other.  I am
trying to integrate this code into a larger application, but this would be
the only code that is concerned with DBus so I was assuming I'd be fine
(perhaps mistakenly assuming)

Thanks.

-- 
View this message in context: http://old.nabble.com/Connection-closed-err-in-code.-Dbus-send-works-fine-though-tp32140675p32140675.html
Sent from the Free Desktop - dbus mailing list archive at Nabble.com.



More information about the dbus mailing list